Index: trunk/MagicSoft/Cosy/Changelog
===================================================================
--- trunk/MagicSoft/Cosy/Changelog	(revision 919)
+++ trunk/MagicSoft/Cosy/Changelog	(revision 920)
@@ -1,4 +1,61 @@
                                                                   -*-*- END -*-*-
  2001/08/29 - Thomas Bretz:
+
+   * base/BaseLinkDef.h, base/BaseIncl.h, 
+     candrv/CandrvIncl.h, candrv/CandrvLinkDef.h,
+     catalog/CatalogLinkDef.h, catalog/CatalogIncl.h,
+     devdrv/DevdrvIncl.h, devdrv/DevdrvLinkDef.h,
+     gui/GuiLinkDef.h, gui/GuiIncl.h,
+     slalib/SlalibIncl.h, slalib/SlalibLinkDef.h,
+     videodev/VideodevLinkDef.h, videodev/VideodevIncl.h:
+     - added
+     
+   * Makefile.rules:
+     - added CINTHEADERS
+     
+   * cosy.cc:
+     - changed logging to MLog
+     
+   * base/Makefile:
+     - added MLog and MLogManip
+     
+   * base/log.h, candrv/canopen.[h,cc], candrv/network.[h,cc],
+     candrv/nodedrv.[h,cc], candrv/vmodican.[h,cc],
+     devdrv/macs.[h,cc]
+     - changed from ostream to MLog
+     
+   * devdrv/shaftencoder.[h,cc]
+     - changed from ostream to MLog
+     - changed buffering of values 
+     - removed old updating thread stuff
+     
+   * catalog/SlaStars.[h,cc]:
+     - added GetApproxVel
+     
+   * gui/MGAccuracy.cc:
+     - fixed the wrong deg2rad value
+     - added more accurate calculation of one dimensional
+       tracking error value
+     
+   * MGCosy.[h,cc]:
+     - added a TGListBox
+     - added some Labels to display offset as value
+     - removed offset display
+     - changed layout of dialog
+     - added layout manager
+     - added status frame
+     - added tabs
+     - added status display and update
+     
+   * gui/MGEmbeddedCanvas.cc:
+     - removed raised frame around embedded canvas
+     - enhanced size by 1
+     
+   * gui/MGSkyPosition.cc:
+     - a new position checks now for a new angle, too
+     - removed debugging output
+     
+   * slalib/Makefile:
+     - added altaz.c
  
    * MCosy.[cc,h]:
@@ -8,30 +65,15 @@
      - TerminateApp now sends WM_QUIT
      - removed comments with old GUI thread
+     - added a missing bracket, which prevents us from stopping
+       a positioning command
+     - changed some output from cout to lout
+     - added empty prototype to Limit speed in tracking mode
+     - changed constructor to use of MLog
 
    * base/MGList.h:
      - added DBG_MGLIST for debugging
      
-   * devdrv/shaftencoder.[h,cc]:
-     - removed old updating thread stuff
-     
-   * gui/MGAccuracy.[h,cc]:
-     - added more accurate calculation of one dimensional
-       tracking error value
-
    * gui/MGCoordinate.cc:
      - removed logging statement from destructor
-     
-   * gui/MGCosy.cc:
-     - changed layout of dialog
-     - added layout manager
-     - added status frame
-     - added tabs
-     - added status display and update
-     
-   * gui/MGEmbeddedCanvas.cc:
-     - enhanced size by 1
-     
-   * gui/MGSkyPosition.cc:
-     - removed debugging output
      
    * gui/MGVelocity.cc:
Index: trunk/MagicSoft/Cosy/MCosy.cc
===================================================================
--- trunk/MagicSoft/Cosy/MCosy.cc	(revision 919)
+++ trunk/MagicSoft/Cosy/MCosy.cc	(revision 920)
@@ -13,4 +13,6 @@
 #include "MGCosy.h"
 #include "SlaStars.h"
+
+#include "slalib/slalib.h"  // FIXME: REMOVE
 
 #include "macs.h"
@@ -202,5 +204,5 @@
     cout << "SDO..." << flush;
 
-    while (fMac1->IsPositioning() || fMac2->IsPositioning() && !StopWaitingForSDO())
+    while ((fMac1->IsPositioning() || fMac2->IsPositioning()) && !StopWaitingForSDO())
         usleep(1);
 
@@ -234,5 +236,5 @@
     const ZdAz dest = CorrectTarget(src, dst);
 
-    cout << "Positioning to Target..." << endl;
+    lout << "Positioning to Target..." << endl;
     //cout << "Source        Zd: " << src.Zd()  << "se  Az:" << src.Az()  << "se" << endl;
     //cout << "Destination   Zd: " << Rad2SE(dst.Zd()) << "se  Az:" << Rad2SE(dst.Az())  << "se" << endl;
@@ -265,5 +267,5 @@
         if (!cdzd && !cdaz)
         {
-            cout << "Positioning done with " << i << "manuvers." << endl;
+            lout << "Positioning done with " << i << "manuvers." << endl;
             return TRUE;
         }
@@ -300,5 +302,5 @@
     CheckForError();
 
-    cout << "Positioning ERROR!" << endl;
+    lout << "Warning: Requested position not reached." << endl;
     return FALSE;
 }
@@ -313,5 +315,7 @@
         return kTRUE;
 
-    lout << "Error #6004 (requesting re pos from Macs) happened." << endl;
+    if (HasError())
+        lout << "Error #6004 (requesting re pos from Macs) happened." << endl;
+
     return kFALSE;
 }
@@ -325,5 +329,7 @@
         return kTRUE;
 
-    lout << "Error #3006 (setting velocity of Macs) happened." << endl;
+    if (HasError())
+        lout << "Error #3006 (setting velocity of Macs) happened." << endl;
+
     return kFALSE;
 }
@@ -346,4 +352,32 @@
 }
 
+void MCosy::LimitSpeed(ZdAz *vt, const ZdAz &vcalc) const
+{
+    return;
+
+    //
+    // How to limit the speed. If the wind comes and blowes
+    // we cannot forbid changing of the sign. But on the other hand
+    // we don't want fast changes!
+    //
+
+    ULong_t vrzd = fMac1->GetVelRes();
+    ULong_t vraz = fMac2->GetVelRes();
+
+#define sgn(x) (x<0?-1:1)
+
+    if (sgn(vt->Az()) != sgn(vcalc.Az()))
+        vt->Az(0.1*vcalc.Az());
+    else
+        if (fabs(vt->Az()) > 0.9*vraz)
+            vt->Az(0.9*vraz*sgn(vt->Az()));
+
+    if (sgn(vt->Zd()) != sgn(vcalc.Zd()))
+        vt->Zd(0.1*vcalc.Zd());
+    else
+        if (fabs(vt->Zd()) > 0.9*vrzd)
+            vt->Zd(0.9*vrzd*sgn(vt->Zd()));
+}
+
 void MCosy::TrackPosition(const RaDec &dst) // ra, dec [rad]
 {
@@ -358,5 +392,5 @@
     if (!SetPosition(dest))
     {
-        cout << "ERROR: Cannot start tracking, unable to reach requested position." << endl;
+        lout << "ERROR: Cannot start tracking, unable to reach requested position." << endl;
         return;
     }
@@ -386,7 +420,7 @@
     InitTracking();
 
-    cout << "Start tracking:";
-    cout << " Ra: " << Rad2Deg(dst.Ra())  << "deg  ";
-    cout << "Dec: " << Rad2Deg(dst.Dec()) << "deg" << endl;
+    lout << "Start tracking:";
+    lout << " Ra: " << Rad2Deg(dst.Ra())  << "deg  ";
+    lout << "Dec: " << Rad2Deg(dst.Dec()) << "deg" << endl;
 
     //
@@ -414,5 +448,7 @@
         //
         sla.SetMjd(sla.CalcMjd()+dt/(60*60*24));
-        dest = CorrectTarget(GetSePos(), sla.CalcZdAz(dst));
+        dest = CorrectTarget(GetSePos(), sla.CalcZdAz(dst)); // [se]
+
+        //ZdAz vcalc = sla.GetApproxVel(dst) * kGearRatio2*4./60.;  // [re/min]
 
         //
@@ -428,5 +464,5 @@
         // Shaft- and the rotary encoders
         //
-        dest *= kGearRatio;
+        dest *= kGearRatio;  // [re]
         dest -= GetRePos() + fOffset;
 
@@ -442,4 +478,5 @@
         //
         ZdAz vt = v/4;
+        //LimitSpeed(&vt, vcalc);
         vt.Round();
 
@@ -449,5 +486,5 @@
         if (v.Zd()>.9*fMac1->GetVelRes() || v.Az()>.9*fMac2->GetVelRes())
         {
-            cout << "Error: Tracking speed faster than possible maximum velocity." << endl;
+            lout << "Error: Tracking speed faster than possible maximum velocity." << endl;
             break;
         }
@@ -490,5 +527,5 @@
     SetStatus(kStopped);
 
-    cout << "Tracking stopped." << endl;
+    lout << "Tracking stopped." << endl;
 
     CheckForError();
@@ -750,5 +787,5 @@
 
     fWin->Update(ist, fTrackingError/kGearRatio2,
-                 fVelocity, fOffset/kGearRatio2,
+                 fVelocity, fOffset/*/kGearRatio2*/,
                  fStatus);
 
@@ -788,5 +825,5 @@
 }
 
-MCosy::MCosy(const char *dev, const int baud, ostream &out)
+MCosy::MCosy(const char *dev, const int baud, MLog &out)
 : Network(dev, baud, out), fTracking(kFALSE)
 {
@@ -822,4 +859,5 @@
     fAlt2->SetDisplay(fWin->GetLabel3());
 
+    lout.SetOutputGui(fWin->GetLog(), kTRUE);
 }
 
@@ -857,4 +895,6 @@
     cout << "Deleting MGCosy." << endl;
 
+    lout.DisableOutputDevice(MLog::eGui);
+
     delete fWin;
 
Index: trunk/MagicSoft/Cosy/MCosy.h
===================================================================
--- trunk/MagicSoft/Cosy/MCosy.h	(revision 919)
+++ trunk/MagicSoft/Cosy/MCosy.h	(revision 920)
@@ -88,4 +88,5 @@
 
     void InitTracking();
+    void LimitSpeed(ZdAz *vt, const ZdAz &vcalc) const;
 
     void TalkThread();
@@ -102,5 +103,5 @@
 
 public:
-    MCosy(const char *dev, const int baud, ostream &out=cout);
+    MCosy(const char *dev, const int baud, MLog &out=gLog);
     ~MCosy();
 
Index: trunk/MagicSoft/Cosy/Makefile.rules
===================================================================
--- trunk/MagicSoft/Cosy/Makefile.rules	(revision 919)
+++ trunk/MagicSoft/Cosy/Makefile.rules	(revision 920)
@@ -4,14 +4,14 @@
         -f Makefile.depend 2> kk.kk ; cat kk.kk
 
-$(LIB): $(OBJS) $(HEADERS)
+$(LIB): $(OBJS) $(HEADERS) $(CINT)Cint.o
 	@echo " - Building Library lib$(LIB) ... "
 	$(AR) $(LIB) *.o
 
-$(CINT)Cint.cc: $(HEADERS) 
+$(CINT)Cint.cc: $(CINTHEADERS) 
 	@echo 
 	@echo " - Generating dictionary $(CINT)Cint.cc ..."
 
 	$(ROOTSYS)/bin/rootcint -f $(CINT)Cint.cc \
-	-c $(INCLUDES) $(DEFINES) $(HEADERS) $(CINT)Incl.h $(CINT)LinkDef.h 
+	-c $(INCLUDES) $(DEFINES) $(CINTHEADERS) $(CINT)Incl.h $(CINT)LinkDef.h 
 
 .cxx.o:	
Index: trunk/MagicSoft/Cosy/ToDo
===================================================================
--- trunk/MagicSoft/Cosy/ToDo	(revision 919)
+++ trunk/MagicSoft/Cosy/ToDo	(revision 920)
@@ -10,3 +10,6 @@
    
  - Check why it crashes if you exit the program while 'going home'
+ 
+ - If one axis stops because of an error the other axis isn't stopped
+   ( SetPosition, software endswitch activated)
 
Index: trunk/MagicSoft/Cosy/base/BaseIncl.h
===================================================================
--- trunk/MagicSoft/Cosy/base/BaseIncl.h	(revision 920)
+++ trunk/MagicSoft/Cosy/base/BaseIncl.h	(revision 920)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: trunk/MagicSoft/Cosy/base/BaseLinkDef.h
===================================================================
--- trunk/MagicSoft/Cosy/base/BaseLinkDef.h	(revision 920)
+++ trunk/MagicSoft/Cosy/base/BaseLinkDef.h	(revision 920)
@@ -0,0 +1,10 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+//#pragma link C++ global gLog;
+#pragma link C++ class MLog;
+
+#endif
Index: trunk/MagicSoft/Cosy/base/Makefile
===================================================================
--- trunk/MagicSoft/Cosy/base/Makefile	(revision 919)
+++ trunk/MagicSoft/Cosy/base/Makefile	(revision 920)
@@ -36,5 +36,10 @@
 	   MTimeout.cc \
            msgqueue.cc \
+           MLog.cc \
+           MLogManip.cc \
            timer.cc 
+
+CINTHEADERS = MLog.h \
+	      MLogManip.h
 
 SRCS    = $(SRCFILES)
Index: trunk/MagicSoft/Cosy/base/log.h
===================================================================
--- trunk/MagicSoft/Cosy/base/log.h	(revision 919)
+++ trunk/MagicSoft/Cosy/base/log.h	(revision 920)
@@ -4,11 +4,17 @@
 #include <ostream.h>
 
+#include "MLog.h"
+
+//#ifndef __CINT__
+extern MLog gLog;
+//#endif
+
 class Log
 {
 protected:
-    ostream &lout;
+    MLog &lout;
 
 public:
-    Log(ostream &out=cout) : lout(out) {}
+    Log(MLog &out=gLog) : lout(out) {}
 };
 
Index: trunk/MagicSoft/Cosy/candrv/CandrvIncl.h
===================================================================
--- trunk/MagicSoft/Cosy/candrv/CandrvIncl.h	(revision 920)
+++ trunk/MagicSoft/Cosy/candrv/CandrvIncl.h	(revision 920)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: trunk/MagicSoft/Cosy/candrv/CandrvLinkDef.h
===================================================================
--- trunk/MagicSoft/Cosy/candrv/CandrvLinkDef.h	(revision 920)
+++ trunk/MagicSoft/Cosy/candrv/CandrvLinkDef.h	(revision 920)
@@ -0,0 +1,7 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#endif
Index: trunk/MagicSoft/Cosy/candrv/canopen.cc
===================================================================
--- trunk/MagicSoft/Cosy/candrv/canopen.cc	(revision 919)
+++ trunk/MagicSoft/Cosy/candrv/canopen.cc	(revision 920)
@@ -4,5 +4,5 @@
 #include <iomanip.h>  // setw, setfill
 
-CanOpen::CanOpen(const char *dev, const int baud, ostream &out=cout) : VmodIcan(dev, baud, out)
+CanOpen::CanOpen(const char *dev, const int baud, MLog &out) : VmodIcan(dev, baud, out)
 {
     for (int i=0; i<32; i++)
Index: trunk/MagicSoft/Cosy/candrv/network.cc
===================================================================
--- trunk/MagicSoft/Cosy/candrv/network.cc	(revision 919)
+++ trunk/MagicSoft/Cosy/candrv/network.cc	(revision 920)
@@ -24,5 +24,5 @@
 }
 
-Network::Network(const char *dev, const int baud, ostream &out) : CanOpen(dev, baud, out)
+Network::Network(const char *dev, const int baud, MLog &out) : CanOpen(dev, baud, out)
 {
     for (int i=0; i<32; i++)
Index: trunk/MagicSoft/Cosy/candrv/network.h
===================================================================
--- trunk/MagicSoft/Cosy/candrv/network.h	(revision 919)
+++ trunk/MagicSoft/Cosy/candrv/network.h	(revision 920)
@@ -21,5 +21,5 @@
 
 public:
-    Network(const char *dev, const int baud, ostream &out=cout);
+    Network(const char *dev, const int baud, MLog &out=gLog);
 
     void SetNode(NodeDrv *drv);
Index: trunk/MagicSoft/Cosy/candrv/nodedrv.cc
===================================================================
--- trunk/MagicSoft/Cosy/candrv/nodedrv.cc	(revision 919)
+++ trunk/MagicSoft/Cosy/candrv/nodedrv.cc	(revision 920)
@@ -5,6 +5,7 @@
 
 #include "network.h"
+#include "MLogManip.h"
 
-NodeDrv::NodeDrv(BYTE_t nodeid, ostream &out) : Log(out), fNetwork(NULL), fId(32), fError(0)
+NodeDrv::NodeDrv(BYTE_t nodeid, MLog &out) : Log(out), fNetwork(NULL), fId(32), fError(0)
 {
     if (nodeid>31)
@@ -31,7 +32,15 @@
 void NodeDrv::HandleSDOOK(WORD_t idx, BYTE_t subidx)
 {
+    const Bool_t gui = lout.IsOutputDeviceEnabled(MLog::eGui);
+
+    if (gui)
+        lout << ddev(MLog::eGui);
+
     lout << hex << setfill('0');
     lout << "Sdo=" << idx  << "/" << (int)subidx << " set.";
     lout << endl;
+
+    if (gui)
+        lout << edev(MLog::eGui);
 }
 
Index: trunk/MagicSoft/Cosy/candrv/nodedrv.h
===================================================================
--- trunk/MagicSoft/Cosy/candrv/nodedrv.h	(revision 919)
+++ trunk/MagicSoft/Cosy/candrv/nodedrv.h	(revision 920)
@@ -21,5 +21,5 @@
 
 public:
-    NodeDrv(BYTE_t nodeid, ostream &out=cout);
+    NodeDrv(BYTE_t nodeid, MLog &out=gLog);
 
     BYTE_t   GetId()      { return fId; }
Index: trunk/MagicSoft/Cosy/candrv/vmodican.cc
===================================================================
--- trunk/MagicSoft/Cosy/candrv/vmodican.cc	(revision 919)
+++ trunk/MagicSoft/Cosy/candrv/vmodican.cc	(revision 920)
@@ -758,5 +758,5 @@
 }
 
-VmodIcan::VmodIcan(const char *dev, const int baud, ostream &out) : Log(out), MThread(false)//: CanDriver(dev, baud)
+VmodIcan::VmodIcan(const char *dev, const int baud, MLog &out) : Log(out), MThread(false)//: CanDriver(dev, baud)
 {
     //
Index: trunk/MagicSoft/Cosy/candrv/vmodican.h
===================================================================
--- trunk/MagicSoft/Cosy/candrv/vmodican.h	(revision 919)
+++ trunk/MagicSoft/Cosy/candrv/vmodican.h	(revision 920)
@@ -56,5 +56,5 @@
 
 public:
-    VmodIcan(const char *dev, const int baud, ostream &out=cout);
+    VmodIcan(const char *dev, const int baud, MLog &out=gLog);
     virtual ~VmodIcan();
 
Index: trunk/MagicSoft/Cosy/catalog/CatalogIncl.h
===================================================================
--- trunk/MagicSoft/Cosy/catalog/CatalogIncl.h	(revision 920)
+++ trunk/MagicSoft/Cosy/catalog/CatalogIncl.h	(revision 920)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: trunk/MagicSoft/Cosy/catalog/CatalogLinkDef.h
===================================================================
--- trunk/MagicSoft/Cosy/catalog/CatalogLinkDef.h	(revision 920)
+++ trunk/MagicSoft/Cosy/catalog/CatalogLinkDef.h	(revision 920)
@@ -0,0 +1,7 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#endif
Index: trunk/MagicSoft/Cosy/catalog/SlaStars.cc
===================================================================
--- trunk/MagicSoft/Cosy/catalog/SlaStars.cc	(revision 919)
+++ trunk/MagicSoft/Cosy/catalog/SlaStars.cc	(revision 920)
@@ -107,2 +107,15 @@
     return AltAz(DPI/2-zdaz.Zd(), zdaz.Az());
 }
+
+ZdAz SlaStars::GetApproxVel(const RaDec &radec) const // [rad/rad]
+{
+    double az, vaz, aaz;
+    double el, vel, ael;
+    double pa, vpa, apa;
+    slaAltaz(GetAlpha()-radec.Ra(), radec.Dec(), GetPhi(),
+             &az, &vaz, &aaz,
+             &el, &vel, &ael,
+             &pa, &vpa, &apa);
+
+    return ZdAz(-vel, vaz);
+}
Index: trunk/MagicSoft/Cosy/catalog/SlaStars.h
===================================================================
--- trunk/MagicSoft/Cosy/catalog/SlaStars.h	(revision 919)
+++ trunk/MagicSoft/Cosy/catalog/SlaStars.h	(revision 920)
@@ -27,4 +27,6 @@
     void   Set(const RaDec &radec);
 
+    ZdAz   GetApproxVel(const RaDec &radec) const; // [rad/rad];
+
     RaDec  CalcRaDec(const AltAz &altaz) const;
     RaDec  CalcRaDec(const ZdAz  &altaz) const;
Index: trunk/MagicSoft/Cosy/cosy.cc
===================================================================
--- trunk/MagicSoft/Cosy/cosy.cc	(revision 919)
+++ trunk/MagicSoft/Cosy/cosy.cc	(revision 920)
@@ -9,20 +9,27 @@
 #include <TApplication.h>
 
+#include "MLogManip.h"
+#include "base/timer.h"
+
+#define clog(txt) \
+    lout << edev(MLog::eStdout) << txt << endl << ddev(MLog::eStdout)
+
 int main(int argc, char **argv)
 {
-    cout << endl;
-    cout << "Starting..." << endl;
-    cout << endl;
+    Timer time;
+    time.Now();
 
     //
     // this must move to MGCosy !!!! (or MApplication)
     //
-    ofstream lout("cosy.log");
-    lout << "Starting Cosy" << endl;
+    MLog lout("cosy.log", kTRUE);
+
+    clog("Starting Cosy at " << time.GetTimeStr() << " ...");
 
     //
     // start the main window
     //
-    lout << "- Initialising Root environment." << endl;
+    clog("- Initialising Root environment.");
+
     TROOT root("Cosy", "Magic Control System");
     TApplication app("App", &argc, argv);
@@ -34,14 +41,14 @@
     cosy->Start();
 
-    lout << "- Starting mainloop." << endl;
+    clog("- Starting mainloop.");
     app.Run(kTRUE);
 
-    lout << "- Stopping cosy." << endl;
+    clog("- Stopping cosy.");
     cosy->Stop();
-    lout << "- cosy stopped." << endl;
+    clog("- cosy stopped."); 
 
     delete cosy;
 
-    lout << "- Terminating Program." << endl;
+    clog("- Terminating Program.");
     cout << "The End." << endl;
 }
Index: trunk/MagicSoft/Cosy/devdrv/DevdrvIncl.h
===================================================================
--- trunk/MagicSoft/Cosy/devdrv/DevdrvIncl.h	(revision 920)
+++ trunk/MagicSoft/Cosy/devdrv/DevdrvIncl.h	(revision 920)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: trunk/MagicSoft/Cosy/devdrv/DevdrvLinkDef.h
===================================================================
--- trunk/MagicSoft/Cosy/devdrv/DevdrvLinkDef.h	(revision 920)
+++ trunk/MagicSoft/Cosy/devdrv/DevdrvLinkDef.h	(revision 920)
@@ -0,0 +1,7 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#endif
Index: trunk/MagicSoft/Cosy/devdrv/macs.cc
===================================================================
--- trunk/MagicSoft/Cosy/devdrv/macs.cc	(revision 919)
+++ trunk/MagicSoft/Cosy/devdrv/macs.cc	(revision 920)
@@ -7,5 +7,5 @@
 #include "network.h"
 
-Macs::Macs(BYTE_t nodeid, ostream &out=cout)
+Macs::Macs(BYTE_t nodeid, MLog &out)
     : NodeDrv(nodeid, out), fMacId(2*nodeid+1),
     fPos(0), fPosTime(0.0), fPdoPos(0), fPdoTime(0.0),
Index: trunk/MagicSoft/Cosy/devdrv/macs.h
===================================================================
--- trunk/MagicSoft/Cosy/devdrv/macs.h	(revision 919)
+++ trunk/MagicSoft/Cosy/devdrv/macs.h	(revision 920)
@@ -28,5 +28,5 @@
 
 public:
-    Macs(BYTE_t nodeid, ostream &out=cout);
+    Macs(BYTE_t nodeid, MLog &out=gLog);
     virtual ~Macs();
 
Index: trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc
===================================================================
--- trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc	(revision 919)
+++ trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc	(revision 920)
@@ -13,5 +13,5 @@
 #include <sys/resource.h>  // PRIO_PROCESS
 
-ShaftEncoder::ShaftEncoder(BYTE_t nodeid, ostream &out=cout) : NodeDrv(nodeid, out), fLabel(NULL)
+ShaftEncoder::ShaftEncoder(BYTE_t nodeid, MLog &out) : NodeDrv(nodeid, out), fLabel(NULL)
 {
 }
@@ -88,26 +88,25 @@
 void ShaftEncoder::DisplayVal()
 {
-    static LWORDS_t pos;   // ticks
-    static WORDS_t  vel;   // ticks per 5ms
-    static WORDS_t  acc;   // ticks per 25ms^2
-
     char text[21];
 
-    if (fPos!=pos)
+    if (fPos!=fUpdPos)
     {
         sprintf(text, "%ld", fPos);
         fLabel[0]->SetText(new TGString(text));
-    }
-
-    if (fVel!=vel)
+        fUpdPos = fPos;
+    }
+
+    if (fVel!=fUpdVel)
     {
         sprintf(text, "%d", fVel);
         fLabel[1]->SetText(new TGString(text));
-    }
-
-    if (fAcc!=acc)
+        fUpdVel = fVel;
+    }
+
+    if (fAcc!=fUpdAcc)
     {
         sprintf(text, "%d", fAcc);
         fLabel[2]->SetText(new TGString(text));
+        fUpdAcc = fAcc;
     }
 }
Index: trunk/MagicSoft/Cosy/devdrv/shaftencoder.h
===================================================================
--- trunk/MagicSoft/Cosy/devdrv/shaftencoder.h	(revision 919)
+++ trunk/MagicSoft/Cosy/devdrv/shaftencoder.h	(revision 920)
@@ -18,4 +18,7 @@
 
     TGLabel **fLabel;
+    LWORDS_t  fUpdPos;   // ticks
+    WORDS_t   fUpdVel;   // ticks per 5ms
+    WORDS_t   fUpdAcc;   // ticks per 25ms^2
 
     Timer fTime;
@@ -28,5 +31,5 @@
 
 public:
-    ShaftEncoder(BYTE_t nodeid, ostream &out=cout);
+    ShaftEncoder(BYTE_t nodeid, MLog &out=gLog);
     virtual ~ShaftEncoder();
 
Index: trunk/MagicSoft/Cosy/gui/GuiIncl.h
===================================================================
--- trunk/MagicSoft/Cosy/gui/GuiIncl.h	(revision 920)
+++ trunk/MagicSoft/Cosy/gui/GuiIncl.h	(revision 920)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: trunk/MagicSoft/Cosy/gui/GuiLinkDef.h
===================================================================
--- trunk/MagicSoft/Cosy/gui/GuiLinkDef.h	(revision 920)
+++ trunk/MagicSoft/Cosy/gui/GuiLinkDef.h	(revision 920)
@@ -0,0 +1,7 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#endif
Index: trunk/MagicSoft/Cosy/gui/MGAccuracy.cc
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGAccuracy.cc	(revision 919)
+++ trunk/MagicSoft/Cosy/gui/MGAccuracy.cc	(revision 920)
@@ -184,5 +184,5 @@
 void MGAccuracy::UpdateText(Float_t pzd, Float_t azd, Float_t aaz)
 {
-    const Float_t d2r = TMath::Pi()/360.;
+    const Float_t d2r = TMath::Pi()/180.;
 
     pzd *= d2r;
Index: trunk/MagicSoft/Cosy/gui/MGCosy.cc
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGCosy.cc	(revision 919)
+++ trunk/MagicSoft/Cosy/gui/MGCosy.cc	(revision 920)
@@ -12,4 +12,5 @@
 #include <TSystem.h>       // gSystem
 #include <TGLabel.h>       // TGLabel
+#include <TGListBox.h>     // TGListBox
 #include <TG3DLine.h>      // TGHorizontal3DLine (TGSplitter)
 #include <TGFrame.h>       // TGGroupFrame
@@ -72,6 +73,21 @@
 void MGCosy::CreateLabel(TGCompositeFrame *f)
 {
+    const int x = 180;
     const int y = 25;
-    const int x = 180;
+
+    TGLabel *l;
+
+    l = new TGLabel(f, "SE-Az:");
+    l->Move(x-60, y);
+    fList->Add(l);
+
+    l = new TGLabel(f, "SE-Zd1:");
+    l->Move(x-60, y+20);
+    fList->Add(l);
+
+    l = new TGLabel(f, "SE-Zd2:");
+    l->Move(x-60, y+40);
+    fList->Add(l);
+
 
     fLabel1 = new TGLabel*[3];
@@ -126,4 +142,21 @@
     //f->AddFrame(fLabel3[2]);
 
+    l = new TGLabel(f, "Offset-Zd:");
+    l->Move(x-60, y+80);
+    fList->Add(l);
+
+    l = new TGLabel(f, "Offset-Az:");
+    l->Move(x-60, y+100);
+    fList->Add(l);
+
+    fOffsetZd = new TGLabel(f, "0000000");
+    fOffsetAz = new TGLabel(f, "0000000");
+    fOffsetZd->SetTextJustify(kTextRight);
+    fOffsetAz->SetTextJustify(kTextRight);
+    fOffsetZd->Move(x, y+80);
+    fOffsetAz->Move(x, y+100);
+    fList->Add(fOffsetZd);
+    fList->Add(fOffsetAz);
+
 
     fError    = new TGLabel(f, "Error");
@@ -258,14 +291,18 @@
     fAccuracy    = new MGAccuracy   (f, 300);
     fVelocity    = new MGVelocity   (f, "Velocity ['/min]", 300);
-    fOffset      = new MGVelocity   (f, "Offset se-re [']", 300);
+//    fOffset      = new MGVelocity   (f, "Offset se-re [']", 300);
 
     fList->Add(fSkyPosition);
     fList->Add(fAccuracy);
     fList->Add(fVelocity);
-    fList->Add(fOffset);
+//    fList->Add(fOffset);
 
     TGGroupFrame *frame = new TGGroupFrame(f, "Status");
     frame->Resize(300, 300);
     fList->Add(frame);
+
+    fLog = new TGListBox(f, -1, kSunkenFrame);  //kSunkenFrame|kDoubleBorder,
+    fLog->Resize(300, 300);
+    fList->Add(fLog);
 
     //
@@ -277,5 +314,5 @@
     f->AddFrame(frame);
     f->AddFrame(fVelocity);
-    f->AddFrame(fOffset);
+    f->AddFrame(fLog);
 
     AddFrame(f, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 1, 0));
@@ -337,4 +374,25 @@
 }
 
+void MGCosy::UpdateOffset(ZdAz &off)
+{
+    static Int_t zd=~0;
+    static Int_t az=~0;
+
+    char text[21];
+
+    if (zd!=(Int_t)off.Zd())
+    {
+        zd = (Int_t)off.Zd();
+        sprintf(text, "%ld", zd);
+        fOffsetZd->SetText(new TGString(text));
+    }
+    if (az!=(Int_t)off.Az())
+    {
+        az = (Int_t)off.Az();
+        sprintf(text, "%ld", az);
+        fOffsetAz->SetText(new TGString(text));
+    }
+}
+
 void MGCosy::Update(ZdAz pos, ZdAz acc, ZdAz vel, ZdAz off, UInt_t stat)
 {
@@ -342,5 +400,5 @@
     fAccuracy->Update(pos, acc);
     fVelocity->Update(vel);
-    fOffset->Update(off);
+    UpdateOffset(off);
 
 #define kError     0x01
@@ -358,5 +416,12 @@
     stat&kTracking ? fAccuracy->MapWindow() : fAccuracy->UnmapWindow();
     stat&kTracking ? fVelocity->MapWindow() : fVelocity->UnmapWindow();
-    stat&kTracking ? fOffset->MapWindow()   : fOffset->UnmapWindow();
+    //    stat&kTracking ? fOffset->MapWindow()   : fOffset->UnmapWindow();
+
+    if (!fLog->TestBit(kHasChanged))
+        return;
+
+    fLog->MapSubwindows();
+    fLog->Layout();
+    fLog->ResetBit(kHasChanged);
 }
 // ======================================================================
Index: trunk/MagicSoft/Cosy/gui/MGCosy.h
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGCosy.h	(revision 919)
+++ trunk/MagicSoft/Cosy/gui/MGCosy.h	(revision 920)
@@ -33,4 +33,5 @@
 class TGCompositeFrame;
 class TGTab;
+class TGListBox;
 
 class MGCosy : public TGMainFrame
@@ -50,4 +51,7 @@
     TGLabel      **fLabel3;
 
+    TGLabel       *fOffsetZd;
+    TGLabel       *fOffsetAz;
+
     MGCoordinates *fCoord;
     MGSkyPosition *fSkyPosition;
@@ -66,4 +70,6 @@
     TGLabel *fStopped;
 
+    TGListBox *fLog;
+
     void CreateMenu();
     void CreateLabel(TGCompositeFrame *f);
@@ -73,4 +79,5 @@
 
     void EnableLabel(TGLabel *label, Bool_t stat);
+    void UpdateOffset(ZdAz &off);
 
 public:
@@ -80,7 +87,9 @@
     void CloseWindow();
 
-    TGLabel **GetLabel1() { return fLabel1; }
-    TGLabel **GetLabel2() { return fLabel2; }
-    TGLabel **GetLabel3() { return fLabel3; }
+    TGLabel **GetLabel1() const { return fLabel1; }
+    TGLabel **GetLabel2() const { return fLabel2; }
+    TGLabel **GetLabel3() const { return fLabel3; }
+
+    TGListBox *GetLog() const { return fLog; }
 
     void Update(ZdAz pos, ZdAz acc, ZdAz vel, ZdAz off, UInt_t stat);
Index: trunk/MagicSoft/Cosy/gui/MGEmbeddedCanvas.cc
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGEmbeddedCanvas.cc	(revision 919)
+++ trunk/MagicSoft/Cosy/gui/MGEmbeddedCanvas.cc	(revision 920)
@@ -12,5 +12,5 @@
 MGEmbeddedCanvas::MGEmbeddedCanvas(const char *name, const TGWindow* p,
                                    const UInt_t width, Float_t range)
-    : TRootEmbeddedCanvas(name, p, width+1, width+1, kRaisedFrame),//, 0) //234, 76, kFixedSize)
+    : TRootEmbeddedCanvas(name, p, width+1, width+1, 0/*kRaisedFrame*/),
       fModified(kFALSE), fWidth(width), fRange(range), fPix(2.*range/width)
 {
Index: trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc	(revision 919)
+++ trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc	(revision 920)
@@ -203,6 +203,8 @@
 void MGSkyPosition::UpdatePosition(Float_t zd, Float_t az)
 {
-    static int X=~0;
-    static int Y=~0;
+    static int X =~0;
+    static int Y =~0;
+    static int Rx=~0;
+    static int Ry=~0;
 
     const float rad = D2PI*az/360.0;
@@ -217,9 +219,15 @@
     const int pixy = (int)(y/fPix);
 
-    if (X==pixx && Y==pixy)
+    const int rx = (int)(s*fWidth/2.);
+    const int ry = (int)(c*fWidth/2.);
+
+    if (X==pixx && Y==pixy && Rx==rx && Ry==ry)
         return;
 
     X = pixx;
     Y = pixy;
+
+    Rx = rx;
+    Ry = ry;
 
     const float dx = s*4.;
Index: trunk/MagicSoft/Cosy/videodev/VideodevIncl.h
===================================================================
--- trunk/MagicSoft/Cosy/videodev/VideodevIncl.h	(revision 920)
+++ trunk/MagicSoft/Cosy/videodev/VideodevIncl.h	(revision 920)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: trunk/MagicSoft/Cosy/videodev/VideodevLinkDef.h
===================================================================
--- trunk/MagicSoft/Cosy/videodev/VideodevLinkDef.h	(revision 920)
+++ trunk/MagicSoft/Cosy/videodev/VideodevLinkDef.h	(revision 920)
@@ -0,0 +1,7 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#endif
Index: trunk/MagicSoft/slalib/Makefile
===================================================================
--- trunk/MagicSoft/slalib/Makefile	(revision 919)
+++ trunk/MagicSoft/slalib/Makefile	(revision 920)
@@ -37,5 +37,6 @@
         nutc.c   dmxv.c   refro.c  prec.c   nut.c   dmxm.c  evp.c    \
         drange.c deuler.c cldj.c   aopqk.c  refz.c  dh2e.c  de2h.c   \
-        dt.c     dmoon.c  planet.c planel.c el2ue.c ue2pv.c pv2ue.c
+        dt.c     dmoon.c  planet.c planel.c el2ue.c ue2pv.c pv2ue.c  \
+        altaz.c
 #	addet.c
 #        afin.c airmas.c altaz.c amp.c \
Index: trunk/MagicSoft/slalib/SlalibIncl.h
===================================================================
--- trunk/MagicSoft/slalib/SlalibIncl.h	(revision 920)
+++ trunk/MagicSoft/slalib/SlalibIncl.h	(revision 920)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: trunk/MagicSoft/slalib/SlalibLinkDef.h
===================================================================
--- trunk/MagicSoft/slalib/SlalibLinkDef.h	(revision 920)
+++ trunk/MagicSoft/slalib/SlalibLinkDef.h	(revision 920)
@@ -0,0 +1,7 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#endif
