Index: /trunk/MagicSoft/Cosy/Changelog
===================================================================
--- /trunk/MagicSoft/Cosy/Changelog	(revision 7786)
+++ /trunk/MagicSoft/Cosy/Changelog	(revision 7787)
@@ -1,3 +1,43 @@
                                                                   -*-*- END -*-*-
+ 2006/07/11 Thomas Bretz (La Palma)
+
+   * Makefile:
+     - changed to support linking with the libmars.so instead
+       of compiling a lot of stuff itself
+
+   * Makefile.conf.general:  
+     - added -DMARSVER
+
+   * base/BaseLinkDef.h:
+     - removed the now obsolete pragma
+
+   * base/Makefile
+     - removed the now obsolete files
+
+   * candrv/Makefile, caos/Makefile, catalog/Makefile, 
+     videodev/Makefile, devdrv/Makefile, gui/Makefile, 
+     main/Makefile, tcpip/Makefile:
+     - added the new mars include directory
+
+   * caos/Leds.h, caos/Rings.h:
+     - added an overwrite for Print to make the compiler happy
+
+   * catalog/StarCatalog.cc:
+     - small improvements to determination of image border 
+       by using min- and max-functions
+
+   * gui/MGCoordinate.cc:
+     - small improvement to layout
+
+   * gui/MGImage.cc:
+     - fixed 16bit-color mode. The encoding was just wrong
+
+   * videodev/Camera.cc:
+     - unlock the tread after the broadcast. The reason why it
+       is neccessary in root 4.04/02g to make cosy work is
+       unknown. Anyhow it makes switching the cameras more robust
+
+
+
  2006/07/11 Daniela Dorner
 
Index: /trunk/MagicSoft/Cosy/Makefile
===================================================================
--- /trunk/MagicSoft/Cosy/Makefile	(revision 7786)
+++ /trunk/MagicSoft/Cosy/Makefile	(revision 7787)
@@ -23,6 +23,6 @@
 SOLIB    = cosy.so
 CINT     = M
-INCLUDES = -I. -Imain  -Ibase -Icandrv -Iincl -Igui -Ivideodev -Icatalog -Idevdrv
-LIBS     = -lpng -lz -L/usr/X11R6/lib -lpthread
+INCLUDES = -I. -Imain  -Ibase -Icandrv -Iincl -Igui -Ivideodev -Icatalog -Idevdrv -Imars
+LIBS     = -lpng -lz -L/usr/X11R6/lib -lpthread libmars.so
 
 #
@@ -126,55 +126,6 @@
 
 links:
-	@ln -sf ../../Mars/mbase/MAGIC.h base/MAGIC.h
-	@ln -sf ../../Mars/mbase/MLog.h  base/MLog.h
-	@ln -sf ../../Mars/mbase/MLog.cc base/MLog.cc
-	@ln -sf ../../Mars/mbase/MLogPlugin.h  base/MLogPlugin.h
-	@ln -sf ../../Mars/mbase/MLogPlugin.cc base/MLogPlugin.cc
-	@ln -sf ../../Mars/mbase/MLogManip.h  base/MLogManip.h
-	@ln -sf ../../Mars/mbase/MLogManip.cc base/MLogManip.cc
-	@ln -sf ../../Mars/mbase/MGList.h  base/MGList.h
-	@ln -sf ../../Mars/mbase/MGList.cc base/MGList.cc
-	@ln -sf ../../Mars/mbase/MTime.h  base/MTime.h
-	@ln -sf ../../Mars/mbase/MTime.cc base/MTime.cc
-	@ln -sf ../../Mars/mbase/MParContainer.h  base/MParContainer.h
-	@ln -sf ../../Mars/mbase/MParContainer.cc base/MParContainer.cc
-	@ln -sf ../../Mars/mbase/MString.h  base/MString.h
-	@ln -sf ../../Mars/mbase/MString.cc base/MString.cc
-	@ln -sf ../../Mars/mbase/MGMap.h  base/MGMap.h
-	@ln -sf ../../Mars/mbase/MGMap.cc base/MGMap.cc
-	@ln -sf ../../Mars/mbase/MGMenu.h  base/MGMenu.h
-	@ln -sf ../../Mars/mbase/MGMenu.cc base/MGMenu.cc
-	@ln -sf ../../Mars/mbase/MString.h  base/MString.h
-	@ln -sf ../../Mars/mbase/MString.cc base/MString.cc
-	@ln -sf ../../Mars/mgeom/MGeomMirror.h  base/MGeomMirror.h
-	@ln -sf ../../Mars/mgeom/MGeomMirror.cc  base/MGeomMirror.cc
-	@ln -sf ../../Mars/mgeom/MGeomCam.h  base/MGeomCam.h
-	@ln -sf ../../Mars/mgeom/MGeomCam.cc base/MGeomCam.cc
-	@ln -sf ../../Mars/mgeom/MGeomPix.h  base/MGeomPix.h
-	@ln -sf ../../Mars/mgeom/MGeomPix.cc base/MGeomPix.cc
-	@ln -sf ../../Mars/mgeom/MGeomCamMagic.h  base/MGeomCamMagic.h
-	@ln -sf ../../Mars/mgeom/MGeomCamMagic.cc base/MGeomCamMagic.cc
-	@ln -sf ../../Mars/mastro/MAstro.h  base/MAstro.h
-	@ln -sf ../../Mars/mastro/MAstro.cc base/MAstro.cc
-	@ln -sf ../../Mars/mastro/MAstroCatalog.h  base/MAstroCatalog.h
-	@ln -sf ../../Mars/mastro/MAstroCatalog.cc base/MAstroCatalog.cc
-	@ln -sf ../../Mars/mastro/MAstroCamera.h  base/MAstroCamera.h
-	@ln -sf ../../Mars/mastro/MAstroCamera.cc base/MAstroCamera.cc
-	@ln -sf ../../Mars/mastro/MAstroSky2Local.h  base/MAstroSky2Local.h
-	@ln -sf ../../Mars/mastro/MAstroSky2Local.cc base/MAstroSky2Local.cc
-	@ln -sf ../../Mars/mastro/MObservatory.h  base/MObservatory.h
-	@ln -sf ../../Mars/mastro/MObservatory.cc base/MObservatory.cc
-	@ln -sf ../../Mars/mhist/MHCamera.h base/MHCamera.h
-	@ln -sf ../../Mars/mhist/MHCamera.cc base/MHCamera.cc
-	@ln -sf ../../Mars/mhbase/MH.h base/MH.h
-	@ln -sf ../../Mars/mhbase/MH.cc base/MH.cc
-	@ln -sf ../../Mars/mhbase/MBinning.h base/MBinning.h
-	@ln -sf ../../Mars/mhbase/MBinning.cc base/MBinning.cc
-	@ln -sf ../../Mars/mbase/MParList.h base/MParList.h
-	@ln -sf ../../Mars/mbase/MParList.cc base/MParList.cc
-	@ln -sf ../../Mars/mgui/MHexagon.h base/MHexagon.h
-	@ln -sf ../../Mars/mgui/MHexagon.cc base/MHexagon.cc
-	@ln -sf ../../Mars/mgui/MCamEvent.h base/MCamEvent.h
-	@ln -sf ../../Mars/mgui/MCamEvent.cc base/MCamEvent.cc
+	@ln -sf /home/caos/March06/Mars/*/*.h mars
+	@ln -sf /home/caos/March06/Mars/libmars.so
 
 magic:
Index: /trunk/MagicSoft/Cosy/Makefile.conf.general
===================================================================
--- /trunk/MagicSoft/Cosy/Makefile.conf.general	(revision 7786)
+++ /trunk/MagicSoft/Cosy/Makefile.conf.general	(revision 7787)
@@ -13,5 +13,5 @@
 
 CANDEFS	  = -DCPU=486 -DBUS_LITTLE_ENDIAN -DDEBUG=0 -DLINUX -D__LINUX__ -DSHOW 
-DEFINES	  = -D__COSY__ -DROOTVER=\"$(ROOTVER)\" $(CANDEFS)
+DEFINES	  = -D__COSY__ -DMARSVER=\"Cosy\" -DROOTVER=\"$(ROOTVER)\" $(CANDEFS)
 
 CXXFLAGS  = $(ROOTCFLAGS) $(INCLUDES) $(OPTIM) $(DEBUG) $(DEFINES)
Index: /trunk/MagicSoft/Cosy/base/BaseLinkDef.h
===================================================================
--- /trunk/MagicSoft/Cosy/base/BaseLinkDef.h	(revision 7786)
+++ /trunk/MagicSoft/Cosy/base/BaseLinkDef.h	(revision 7787)
@@ -6,32 +6,34 @@
 
 //#pragma link C++ global gLog;
-#pragma link C++ class MLog;
+//#pragma link C++ class MLog;
+//#pragma link C++ class MLogHtml;
+//#pragma link C++ class MArgs;
 #pragma link C++ class MStar+;
-#pragma link C++ class MGMap+;
-#pragma link C++ class MGList+;
-#pragma link C++ class MParContainer+;
+//#pragma link C++ class MGMap+;
+//#pragma link C++ class MGList+;
+//#pragma link C++ class MParContainer+;
 
-#pragma link C++ class MObservatory+;
-#pragma link C++ class MVector3+;
+//#pragma link C++ class MObservatory+;
+//#pragma link C++ class MVector3+;
 
-#pragma link C++ class MString+;
-#pragma link C++ class MAstro+;
-#pragma link C++ class MAstroSky2Local+;
-#pragma link C++ class MAstroCatalog+;
-#pragma link C++ class MAstroCamera+;
+//#pragma link C++ class MString+;
+//#pragma link C++ class MAstro+;
+//#pragma link C++ class MAstroSky2Local+;
+//#pragma link C++ class MAstroCatalog+;
+//#pragma link C++ class MAstroCamera+;
 
-#pragma link C++ class MGeomPix+;
-#pragma link C++ class MGeomCam+;
-#pragma link C++ class MGeomCamMagic+;
-#pragma link C++ class MGeomMirror+;
+//#pragma link C++ class MGeomPix+;
+//#pragma link C++ class MGeomCam+;
+//#pragma link C++ class MGeomCamMagic+;
+//#pragma link C++ class MGeomMirror+;
 
-#pragma link C++ class MHCamera+;
-#pragma link C++ class MH+;
-#pragma link C++ class MBinning+;
-#pragma link C++ class MCamEvent+;
-#pragma link C++ class MHexagon+;
+//#pragma link C++ class MHCamera+;
+//#pragma link C++ class MH+;
+//#pragma link C++ class MBinning+;
+//#pragma link C++ class MCamEvent+;
+//#pragma link C++ class MHexagon+;
 
-#pragma link C++ class MTime+;
-#pragma link C++ function operator<<(ostream&, MTime&);
+//#pragma link C++ class MTime+;
+//#pragma link C++ function operator<<(ostream&, MTime&);
 
 #endif
Index: /trunk/MagicSoft/Cosy/base/Makefile
===================================================================
--- /trunk/MagicSoft/Cosy/base/Makefile	(revision 7786)
+++ /trunk/MagicSoft/Cosy/base/Makefile	(revision 7787)
@@ -32,56 +32,12 @@
 
 SRCFILES = MStopwatch.cc \
-           MParContainer.cc \
            MThread.cc \
 	   MTimeout.cc \
-           MTime.cc \
-           MString.cc \
-	   MStar.cc \
+           MStar.cc \
 	   MStarList.cc \
-           MAstro.cc \
-           MAstroCatalog.cc \
-           MAstroCamera.cc \
-           MAstroSky2Local.cc \
-           MGeomMirror.cc \
-           MGeomPix.cc \
-           MGeomCam.cc \
-           MGeomCamMagic.cc \
-           MGMap.cc \
-           MGMenu.cc \
-           MH.cc \
-           MBinning.cc \
-           MHexagon.cc \
-           MCamEvent.cc \
-           MHCamera.cc \
-           msgqueue.cc \
-           MLog.cc \
-           MLogManip.cc \
-           MObservatory.cc \
-           MGList.cc
-
-CINTHEADERS = MStar.h \
-	      MGList.h \
-              MTime.h \
-              MString.h \
-              MAstro.h \
-              MAstroSky2Local.h \
-              MAstroCatalog.h \
-              MAstroCamera.h \
-	      MGeomMirror.h \
-	      MGeomPix.h \
-	      MGeomCam.h \
-              MGeomCamMagic.h \
- 	      MHCamera.h \
-              MBinning.h \
-              MH.h \
-              MGMap.h \
-              MGMenu.h \
-              MHexagon.h \
-              MCamEvent.h \
-	      MLog.h \
-	      MLogManip.h \
-              MObservatory.h \
-              MParContainer.h
-
+           msgqueue.cc
+           
+CINTHEADERS = MStar.h
+	      
 SRCS    = $(SRCFILES)
 HEADERS = $(SRCFILES:.cc=.h)
Index: /trunk/MagicSoft/Cosy/candrv/Makefile
===================================================================
--- /trunk/MagicSoft/Cosy/candrv/Makefile	(revision 7786)
+++ /trunk/MagicSoft/Cosy/candrv/Makefile	(revision 7787)
@@ -20,5 +20,5 @@
 # @endcode 
 
-INCLUDES = -I. -I.. -I../incl -I../base
+INCLUDES = -I. -I.. -I../incl -I../base -I../mars
 
 # @code 
Index: /trunk/MagicSoft/Cosy/caos/Leds.h
===================================================================
--- /trunk/MagicSoft/Cosy/caos/Leds.h	(revision 7786)
+++ /trunk/MagicSoft/Cosy/caos/Leds.h	(revision 7787)
@@ -29,4 +29,5 @@
 
     void Print(Option_t *o=NULL) const;
+    void Print(Option_t *o1, Option_t *o2) const { TClonesArray::Print(o1, o2); }
 
     ClassDef(Leds, 1)
Index: /trunk/MagicSoft/Cosy/caos/Makefile
===================================================================
--- /trunk/MagicSoft/Cosy/caos/Makefile	(revision 7786)
+++ /trunk/MagicSoft/Cosy/caos/Makefile	(revision 7787)
@@ -20,5 +20,5 @@
 # @endcode 
 
-INCLUDES = -I. -I.. -I../base
+INCLUDES = -I. -I.. -I../base -I../mars
 #base: MString
 
Index: /trunk/MagicSoft/Cosy/caos/Rings.h
===================================================================
--- /trunk/MagicSoft/Cosy/caos/Rings.h	(revision 7786)
+++ /trunk/MagicSoft/Cosy/caos/Rings.h	(revision 7787)
@@ -28,4 +28,5 @@
 
     void Print(Option_t *o=NULL) const;
+    void Print(Option_t *o1, Option_t *o2) const { TClonesArray::Print(o1, o2); }
 
     const Ring &operator()(int i) const { return *(Ring*)At(i); }
Index: /trunk/MagicSoft/Cosy/catalog/Makefile
===================================================================
--- /trunk/MagicSoft/Cosy/catalog/Makefile	(revision 7786)
+++ /trunk/MagicSoft/Cosy/catalog/Makefile	(revision 7787)
@@ -20,5 +20,5 @@
 # @endcode 
 
-INCLUDES = -I. -I.. -I../base -I../slalib
+INCLUDES = -I. -I.. -I../base -I../slalib -I../mars
 
 # @code 
Index: /trunk/MagicSoft/Cosy/catalog/StarCatalog.cc
===================================================================
--- /trunk/MagicSoft/Cosy/catalog/StarCatalog.cc	(revision 7786)
+++ /trunk/MagicSoft/Cosy/catalog/StarCatalog.cc	(revision 7787)
@@ -169,13 +169,8 @@
     // CalcStars flips the picture in X defaultwise now
     // This defined the box in which stars are really returned
-    int x0 = (768-xc)-box;
-    int x1 = (768-xc)+box;
-    int y0 = yc-box;
-    int y1 = yc+box;
-
-    if (x0<  -offset) x0=  -offset;
-    if (y0<  -offset) y0=  -offset;
-    if (x1>fW+offset) x1=fW+offset;
-    if (y1>fH+offset) y1=fH+offset;
+    const int x0 = TMath::Max((768-xc)-box,   -offset);
+    const int y0 = TMath::Max(yc-box,         -offset);
+    const int x1 = TMath::Min((768-xc)+box, fW+offset);
+    const int y1 = TMath::Min(yc+box,       fH+offset);
 
     // Align stars into telescope system
Index: /trunk/MagicSoft/Cosy/devdrv/Makefile
===================================================================
--- /trunk/MagicSoft/Cosy/devdrv/Makefile	(revision 7786)
+++ /trunk/MagicSoft/Cosy/devdrv/Makefile	(revision 7787)
@@ -21,5 +21,5 @@
 
 DEFINES	 = -DCPU=486 -DBUS_LITTLE_ENDIAN -DDEBUG=0 -DLINUX -DSHOW 
-INCLUDES = -I. -I.. -I../base -I../candrv -I../incl
+INCLUDES = -I. -I.. -I../base -I../candrv -I../incl -I../mars
 
 # @code 
Index: /trunk/MagicSoft/Cosy/gui/MGCoordinate.cc
===================================================================
--- /trunk/MagicSoft/Cosy/gui/MGCoordinate.cc	(revision 7786)
+++ /trunk/MagicSoft/Cosy/gui/MGCoordinate.cc	(revision 7787)
@@ -94,5 +94,5 @@
         label = new TGLabel(this, deg);
         label->SetTextJustify(kTextLeft);
-        label->Move(39, 26);
+        label->Move(37, 29);
         label->MapWindow();
         fList->Add(label);
@@ -100,5 +100,5 @@
         label = new TGLabel(this, min);
         label->SetTextJustify(kTextLeft);
-        label->Move(73, 26);
+        label->Move(71, 29);
         label->MapWindow();
         fList->Add(label);
@@ -106,5 +106,5 @@
         label = new TGLabel(this, sec);
         label->SetTextJustify(kTextLeft);
-        label->Move(107, 26);
+        label->Move(107, 29);
         label->MapWindow();
         fList->Add(label);
Index: /trunk/MagicSoft/Cosy/gui/MGImage.cc
===================================================================
--- /trunk/MagicSoft/Cosy/gui/MGImage.cc	(revision 7786)
+++ /trunk/MagicSoft/Cosy/gui/MGImage.cc	(revision 7787)
@@ -97,6 +97,9 @@
     while (s<e)
     {
-        //      11111100    11111000      11111000
-        *d++ = (*s&0xfc) | (*s&0xf8)<<5 | (*s&0xf8)<<11;
+        //         11111100    11111000      11111000
+        // *d++ = (*s&0xfc) | (*s&0xf8)<<5 | (*s&0xf8)<<11;
+
+        //      11111000       11111100       11111000
+        *d++ = (*s&0xf8)<<8 | (*s&0xfc)<<3 | (*s>>3);
         s++;
     }
Index: /trunk/MagicSoft/Cosy/gui/Makefile
===================================================================
--- /trunk/MagicSoft/Cosy/gui/Makefile	(revision 7786)
+++ /trunk/MagicSoft/Cosy/gui/Makefile	(revision 7787)
@@ -21,5 +21,6 @@
 
 INCLUDES = -I. -I.. -I../base -I../slalib -I../candrv -I../incl \
-	   -I../catalog -I../videodev -I../main -I../caos -I../tcpip
+	   -I../catalog -I../videodev -I../main -I../caos -I../tcpip \
+           -I../mars
 
 # @code 
Index: /trunk/MagicSoft/Cosy/main/Makefile
===================================================================
--- /trunk/MagicSoft/Cosy/main/Makefile	(revision 7786)
+++ /trunk/MagicSoft/Cosy/main/Makefile	(revision 7787)
@@ -21,5 +21,6 @@
 
 INCLUDES = -I. -I../base -I.. -I../gui -I../catalog -I../devdrv \
-	   -I../candrv -I../incl -I../videodev -I../caos -I../tcpip
+	   -I../candrv -I../incl -I../videodev -I../caos -I../tcpip \
+           -I../mars
 
 # @code 
Index: /trunk/MagicSoft/Cosy/tcpip/Makefile
===================================================================
--- /trunk/MagicSoft/Cosy/tcpip/Makefile	(revision 7786)
+++ /trunk/MagicSoft/Cosy/tcpip/Makefile	(revision 7787)
@@ -20,5 +20,5 @@
 # @endcode 
 
-INCLUDES = -I. -I../base -I../catalog -I../main -I../candrv -I../incl -I../caos
+INCLUDES = -I. -I../base -I../catalog -I../main -I../candrv -I../incl -I../caos -I../mars
 
 # @code 
Index: /trunk/MagicSoft/Cosy/videodev/Camera.cc
===================================================================
--- /trunk/MagicSoft/Cosy/videodev/Camera.cc	(revision 7786)
+++ /trunk/MagicSoft/Cosy/videodev/Camera.cc	(revision 7787)
@@ -17,4 +17,10 @@
 inline int Camera::Ioctl(int req, void *opt, const char *str)
 {
+    if (fd<0)
+    {
+        cout << "Error! Called Ioctl with invalid filedescriptor." << endl;
+        return -1;
+    }
+
     while (1)
     {
@@ -181,5 +187,5 @@
 //        cout << "Camera::Camera - mutex is already locked by this thread" << endl;
     pthread_create(&fThread, NULL, MapThread, this);
-    cout << "done." << endl;
+    cout << "CameraInitialized..." << endl;
 
 }
@@ -216,9 +222,7 @@
 void Camera::ExitLoop()
 {
-    //    cout << "ExitLoop..." << endl;
     fStop = 1;
     while (IsRunning())
         usleep(1);
-    //    cout << "Loop exited." << endl;
 }
 
@@ -261,7 +265,5 @@
     while (1)
     {
-        //cout << "Wait..." << flush;
-        fCond.Wait();
-        //cout << "done." << endl;
+        fCond.Wait();;
         if (fd==-1)
             break;
@@ -319,5 +321,4 @@
     }
 
-    cout << "Loop..." << endl;
     ExitLoop();
 
@@ -329,4 +330,10 @@
     //
     fCond.Broadcast();
+
+    // I don't know what the reason for this line is, but it
+    // seems to solve some starnge crashes when switching
+    // between the two cameras and it ensures that cosy works
+    // with root 4.04/02g
+    fMutex->UnLock();
 }
 
Index: /trunk/MagicSoft/Cosy/videodev/Makefile
===================================================================
--- /trunk/MagicSoft/Cosy/videodev/Makefile	(revision 7786)
+++ /trunk/MagicSoft/Cosy/videodev/Makefile	(revision 7787)
@@ -20,5 +20,5 @@
 # @endcode 
 
-INCLUDES = -I. -I.. -I../incl -I../base -I../caos -I/usr/X11R6/include
+INCLUDES = -I. -I.. -I../incl -I../base -I../caos -I/usr/X11R6/include -I../mars
 
 # @code 
