Index: trunk/MagicSoft/Cosy/Changelog
===================================================================
--- trunk/MagicSoft/Cosy/Changelog	(revision 1700)
+++ trunk/MagicSoft/Cosy/Changelog	(revision 1701)
@@ -23,4 +23,7 @@
      - implemented WM_HOME
      - fixed workaround for the encoder resolutions of the MACS
+
+   * base/MGLIst.h
+     - removed (use the one from Mars)
 
 
Index: trunk/MagicSoft/Cosy/base/MGList.h
===================================================================
--- trunk/MagicSoft/Cosy/base/MGList.h	(revision 1700)
+++ 	(revision )
@@ -1,34 +1,0 @@
-#ifndef MARS_MGList
-#define MARS_MGList
-
-#ifndef ROOT_TList
-#include <TList.h>
-#endif
-
-class TGWidget;
-class TGPicture;
-
-class MGList : public TList
-{
-private:
-    TGWidget *GetWidget(TObject *obj) const;
-    Bool_t    IsExisting(TObject *obj) const;
-
-    void      AddPicture(const TGPicture *pic, const char *name);
-
-public:
-    MGList() : TList() {}
-    virtual ~MGList();
-
-    void Add(TObject *obj);
-    void Add(TObject *obj, Option_t *opt);
-
-    const TGPicture *GetPicture(const char *name);
-    const TGPicture *GetPicture(const char *name, Int_t width, Int_t height);
-
-    TObject *FindWidget(Int_t id) const;
-
-    ClassDef(MGList, 0)
-};
-
-#endif
Index: trunk/MagicSoft/Cosy/candrv/network.cc
===================================================================
--- trunk/MagicSoft/Cosy/candrv/network.cc	(revision 1700)
+++ trunk/MagicSoft/Cosy/candrv/network.cc	(revision 1701)
@@ -235,5 +235,6 @@
         if (fNodes[i])
         {
-            lout << "- Setting up Node #" << dec << i << endl;
+            lout << "- Setting up Node #" << dec << i << " (";
+            lout << fNodes[i]->GetNodeName() << ")" << endl;
             fNodes[i]->InitDevice(this);
             if (!fNodes[i]->IsZombieNode())
Index: trunk/MagicSoft/Cosy/devdrv/macs.cc
===================================================================
--- trunk/MagicSoft/Cosy/devdrv/macs.cc	(revision 1700)
+++ trunk/MagicSoft/Cosy/devdrv/macs.cc	(revision 1701)
@@ -110,10 +110,10 @@
 
     case 0x6002:
-        lout << "- Velocity resolution " << GetNodeName() << ": " << dec << val << " ticks/min" << endl;
+        lout << "- " << GetNodeName() << ": Velocity resolution = " << dec << val << " ticks/min" << endl;
         fVelRes = val;
         return;
 
     case 0x6501:
-        lout << "- Encoder resolution " << GetNodeName() << ": " << dec << val << " ticks/min" << endl;
+        lout << "- " << GetNodeName() << ": Encoder resolution = " << dec << val << " ticks/min" << endl;
         fRes = val;
         return;
@@ -132,5 +132,5 @@
         case 0:
             lout << ddev(MLog::eGui);
-            lout << "- Velocity set (" << GetNodeName() << ")" << endl;
+            lout << "- " << GetNodeName() << ": Velocity set." << endl;
             lout << edev(MLog::eGui);
             return;
@@ -142,10 +142,10 @@
         case 0:
             lout << ddev(MLog::eGui);
-            lout << "- Acceleration set (" << GetNodeName() << ")" << endl;
+            lout << "- " << GetNodeName() << ": Acceleration set." << endl;
             lout << edev(MLog::eGui);
             return;
         case 1:
             lout << ddev(MLog::eGui);
-            lout << "- Deceleration set (" << GetNodeName() << ")" << endl;
+            lout << "- " << GetNodeName() << ": Decceleration set." << endl;
             lout << edev(MLog::eGui);
             return;
@@ -157,5 +157,5 @@
         case 0:
             lout << ddev(MLog::eGui);
-            lout << "- RPM mode switched (" << GetNodeName() << ")" << endl;
+            lout << "- " << GetNodeName() << ": RPM mode switched." << endl;
             lout << edev(MLog::eGui);
             return;
@@ -182,5 +182,5 @@
         case 0:
             lout << ddev(MLog::eGui);
-            lout << "- Absolute positioning started (" << GetNodeName() << ")" << endl;
+            lout << "- " << GetNodeName() << ": Absolute positioning started." << endl;
             lout << edev(MLog::eGui);
             return;
@@ -188,5 +188,5 @@
         case 1:
             lout << ddev(MLog::eGui);
-            lout << "- Relative positioning started (" << GetNodeName() << ")" << endl;
+            lout << "- " << GetNodeName() << ": Relative positioning started." << endl;
             lout << edev(MLog::eGui);
             return;
@@ -202,12 +202,19 @@
 void Macs::ReqVelRes()
 {
-    lout << "- Requesting velocity resolution (velres, 0x6002) of " << GetNodeName() << endl;
+    lout << "- " << GetNodeName() << ": Requesting velocity resolution (velres, 0x6002)." << endl;
     RequestSDO(0x6002);
     WaitForSdo(0x6002);
 }
 
+void Macs::ReqRes()
+{
+    lout << "- " << GetNodeName() << ": Requesting encoder resolution (res, 0x6501)." << endl;
+    RequestSDO(0x6501);
+    WaitForSdo(0x6501);
+}
+
 void Macs::SetPDO1On(BYTE_t flag)
 {
-    lout << "- " << (flag?"Enable":"Disable") << " PDO1 of " << GetNodeName() << endl;
+    lout << "- " << GetNodeName() << ": " << (flag?"Enable":"Disable") << " PDO1." << endl;
     SendSDO(0x1800, 1, (LWORD_t)(flag?0:1)<<31); 
     WaitForSdo(0x1800, 1);           
@@ -216,7 +223,7 @@
 void Macs::InitDevice(Network *net)
 {
-    lout << "- MAC Init device." << endl;
+    lout << "- " << GetNodeName() << ": MAC Init device." << endl;
     NodeDrv::InitDevice(net);
-    lout << "- MAC Init device...done." << endl;
+    lout << "- " << GetNodeName() << ": MAC Init device...done." << endl;
 
 //    SendSDO(0x4003, (LWORD_t)('E'<<24 | 'X'<<16 | 'I'<<8 'T'));
@@ -238,5 +245,5 @@
     EnableTimeout(kFALSE);
 
-    lout << "- Requesting Mac Software Version of " << GetNodeName() << endl;
+    lout << "- " << GetNodeName() << ": Requesting Mac Software Version." << endl;
     RequestSDO(0x100a);
     WaitForSdo(0x100a);
@@ -244,7 +251,8 @@
     SetRpmMode(FALSE);
 
+    ReqRes();    // Init fRes
     ReqVelRes(); // Init fVelRes
 
-    lout << "- Motor on of " << GetNodeName() << endl;
+    lout << "- " << GetNodeName() << ": Motor on." << endl;
     SendSDO(0x3000, string('o', 'n'));
     WaitForSdo(0x3000);
@@ -286,5 +294,5 @@
     SetPDO1On(FALSE);
 
-    lout << "- Motor off of " << GetNodeName() << endl;
+    lout << "- " << GetNodeName() << ": Motor off." << endl;
     SendSDO(0x3000, string('o', 'f', 'f'));
     WaitForSdo(0x3000);
@@ -299,19 +307,12 @@
 void Macs::ReqPos()
 {
-    lout << "- Requesting Position of " << GetNodeName() << endl;
+    lout << "- " << GetNodeName() << ": Requesting Position." << endl;
     RequestSDO(0x6004);
     WaitForSdo(0x6004);
 }
 
-void Macs::ReqRes()
-{
-    lout << "- Requesting Encoder Resolution of " << GetNodeName() << endl;
-    RequestSDO(0x6501);
-    WaitForSdo(0x6501);
-}
-
 void Macs::ReqVel()
 {
-    lout << "- Requesting Velocity of " << GetNodeName() << endl;
+    lout << "- " << GetNodeName() << ": Requesting Velocity." << endl;
     RequestSDO(0x2002);
     WaitForSdo(0x2002);
@@ -320,5 +321,11 @@
 void Macs::SetHome(LWORDS_t pos, WORD_t maxtime)
 {
-    lout << "- Driving " << GetNodeName() << " to home position, Offset=" << dec << pos << endl;
+    /*
+    Bool_t to = fTimerOn;
+
+    if (to)
+        EnableTimeout(kFALSE);
+    */
+    lout << "- " << GetNodeName() << ": Driving to home position, Offset=" << dec << pos << endl;
     SendSDO(0x6003, 2, (LWORD_t)pos);       // home
     WaitForSdo(0x6003, 2);
@@ -328,8 +335,11 @@
     SendSDO(0x3001, string('h','o','m','e'));       // home
     WaitForSdo(0x3001, 0, maxtime*1000);
-    lout << "- Home position of " << GetNodeName() << " reached. " << endl;
+    lout << "- " << GetNodeName() << ": Home position reached. " << endl;
 
     SendSDO(0x6003, 0, string('s','e','t'));       // home
     WaitForSdo(0x6003, 0);
+
+    //if (to)
+    //    EnableTimeout(kTRUE);
 }
 
@@ -379,5 +389,5 @@
 void Macs::SetNoWait(BYTE_t flag)
 {
-    lout << "- Setting NOWAIT " << (flag?"ON ":"OFF ") << GetNodeName() << endl;
+    lout << "- " << GetNodeName() << ": Setting NOWAIT " << (flag?"ON":"OFF") << "." << endl;
     SendSDO(0x3008, flag ? string('o', 'n') : string('o', 'f', 'f'));
     WaitForSdo(0x3008);
@@ -390,5 +400,5 @@
     // or by a positioning command (POSA, ...)
     //
-    lout << "- Setting Vel Sync Mode of " << GetNodeName() << endl;
+    lout << "- " << GetNodeName() << ": Starting RPM Sync Mode." << endl;
     SendSDO(0x3007, 0, string('s', 'y', 'n', 'c'));
     WaitForSdo(0x3007, 0);
@@ -401,5 +411,5 @@
     // or by a positioning command (POSA, ...)
     //
-    lout << "- Setting Pos Sync Mode of " << GetNodeName() << endl;
+    lout << "- " << GetNodeName() << ": Starting Posistion Sync Mode." << endl;
     SendSDO(0x3007, 1, string('s', 'y', 'n', 'c'));
     WaitForSdo(0x3007, 1);
@@ -446,5 +456,5 @@
     if (!errnum)
     {
-        lout << "Mac " << GetNodeName() << " reports Error occursion." << endl;
+        lout << "- " << GetNodeName() << ": reports Error occursion." << endl;
         SetError(-1);
         return;
@@ -456,5 +466,13 @@
     //
     if (GetError()>0)
-        lout << GetNodeName() << " WARNING! Error #" << GetError() << " unhandled by software." << endl;
+    {
+        lout << GetNodeName() << ": WARNING! Error #" << GetError() << " unhandled (not cleared) by software." << endl;
+
+        //
+        // If the error is unhadled and/or not cleared, don't try it again.
+        //
+        if (GetError()==errnum)
+            return;
+    }
 
     SetError(errnum);
@@ -464,5 +482,11 @@
     {
     case 6:
+        //
+        // Report the error to the user. All possible movements should have
+        // been stopped anyhow. Now delete the error to prevent the system
+        // from reporting this error a thousands of times.
+        //
         lout << "Home position not the first positioning command." << endl;
+        SetError(0);
         return;
 
@@ -607,5 +631,5 @@
 void Macs::EnableTimeout(bool enable, LWORDS_t ms)
 {
-    lout << "- MAC " << (enable?"En":"Dis") << "able timeout, " << dec << ms << "ms." << endl;
+    lout << "- " << GetNodeName() << ": " << (enable?"En":"Dis") << "able timeout, " << dec << ms << "ms." << endl;
     if (!enable)
     {
@@ -613,5 +637,5 @@
         WaitForSdo(0x4000, 1);
 
-        lout << "- Stopping handshake (PC)." << endl;
+        lout << "- " << GetNodeName() << ": Stopping handshake (PC)." << endl;
 
         fTimeout->Stop(); //kTRUE);
@@ -634,9 +658,9 @@
         // any reason
         //
-        lout << "- MAC starting handshake." << endl;
+        lout << "- " << GetNodeName() << ": starting handshake." << endl;
         SendSDO(0x4000, 1, string('o', 'n'));
         WaitForSdo(0x4000, 1);
     }
-    lout << "- Timeout timer of " << GetNodeName() << " turned "
+    lout << "- " << GetNodeName() << ": Timeout timer turned "
         << (enable?"on.":"off.") << endl;
 }
Index: trunk/MagicSoft/Cosy/devdrv/macs.h
===================================================================
--- trunk/MagicSoft/Cosy/devdrv/macs.h	(revision 1700)
+++ trunk/MagicSoft/Cosy/devdrv/macs.h	(revision 1701)
@@ -39,6 +39,4 @@
     Bool_t HandleTimer(TTimer *t);
 
-    void ReqRes();
-
 public:
     Macs(const BYTE_t nodeid, const char *name=NULL, MLog &out=gLog);
@@ -65,4 +63,5 @@
     //void ReqAxEnd();
     void ReqVelRes();
+    void ReqRes();
     void SetHome(LWORDS_t pos=0, WORD_t maxtime=25);
     void SetAcceleration(LWORD_t acc);
Index: trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc
===================================================================
--- trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc	(revision 1700)
+++ trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc	(revision 1701)
@@ -60,4 +60,5 @@
         lout << "Scaling: " <<  (val&4   ?"on":"off") << "  ";
         lout << "Modulo: " <<   (val&4096?"on":"off") << endl;
+        return;
 
     case 0x6001:
@@ -78,6 +79,8 @@
 
     case 0x6502:
+        if (val==0)
+            val = 1;  // Single Turn = Multiturn with one turn
         lout << "- Possible Turns: " << dec << val << endl;
-        fTurns = val ? val : 1; // Single Turn = Multiturn with one turn
+        fTurns = val; 
         return;
 
@@ -198,5 +201,5 @@
     // Requesting and checking (FIXME) type of encoder
     //
-    lout << "- Requesting Hardware Type (SDO 0x1000) of " << GetNodeName() << endl;
+    lout << "- " << GetNodeName() << ": Requesting Hardware Type (0x1000)." << endl;
     RequestSDO(0x1000);
     if (!WaitForSdo(0x1000))
@@ -210,5 +213,5 @@
     // Read physical ticks per revolution
     //
-    lout << "- Requesting physical ticks/revolution (SDO 0x6501) of " << GetNodeName() << endl;
+    lout << "- " << GetNodeName() << ": Requesting physical ticks/revolution (SDO 0x6501)." << endl;
     RequestSDO(0x6501);
     WaitForSdo(0x6501);
@@ -217,5 +220,5 @@
     // Read number of possible ticks per revolution
     //
-    lout << "- Requesting possible ticks/revolution (SDO 0x6502) of " << GetNodeName() << endl;
+    lout << "- " << GetNodeName() << ": Requesting possible ticks/revolution (SDO 0x6502)." << endl;
     RequestSDO(0x6502);
     WaitForSdo(0x6502);
@@ -224,5 +227,5 @@
     // Set logic ticks/revolution = physical ticks/revolution => scale factor = 1
     //
-    lout << "- Configuring SDO 0x6001 of " << GetNodeName() << endl;
+    lout << "- " << GetNodeName() << ": Configuring log. tick/rev (0x6001)." << endl;
     SendSDO(0x6001, fTicks);
     WaitForSdo(0x6001);
@@ -231,26 +234,26 @@
     // Set maximum number of ticks (ticks * turns)
     //
-    lout << "- Configuring SDO 0x6002 of " << GetNodeName() << endl;
+    lout << "- " << GetNodeName() << ": Configuring max number of ticks (0x6002)." << endl;
     SendSDO(0x6002, (LWORD_t)(fTicks*fTurns));
     WaitForSdo(0x6002);
 
     //
+    // Delete preset Value
+    //
+    lout << "- " << GetNodeName() << ": Delete preset value (0x6003)." << endl;
+    SendSDO(0x6003, (LWORD_t)0xffffffff);
+    WaitForSdo(0x6003);
+
+    //
     // Configure PDOs
     //
-    lout << "- Configuring SDO 0x1802 of " << GetNodeName() << endl;
+    lout << "- " << GetNodeName() << ": Configuring PDOs (0x1802)." << endl;
     SendSDO(0x1802, 1, (LWORD_t)0x281);
     WaitForSdo(0x1802, 1);
 
     //
-    // Delete preset Value
-    //
-    lout << "- Configuring SDO 0x6003 of " << GetNodeName() << endl;
-    SendSDO(0x6003, (LWORD_t)0xffffffff);
-    WaitForSdo(0x6003);
-
-    //
     // Request Parameter
     //
-    lout << "- Requesting SDO 0x6000 of " << GetNodeName() << endl;
+    lout << "- " << GetNodeName() << ": Requesting SDO 0x6000." << endl;
     RequestSDO(0x6000);
     WaitForSdo(0x6000);
@@ -258,5 +261,5 @@
     ReqPos();
 
-    lout << "- Start Node " << GetNodeName() << endl;
+    lout << "- " << GetNodeName() << ": Start Node (NMT)." << endl;
     SendNMT(kNMT_START);
 }
@@ -267,5 +270,5 @@
     // Request Position
     //
-    lout << "- Requesting Position of " << GetNodeName() << endl;
+    lout << "- " << GetNodeName() << ": Requesting Position." << endl;
     RequestSDO(0x6004);
     WaitForSdo(0x6004);
@@ -277,5 +280,5 @@
     fTurn = pre/16384;
 
-    lout << " - Setting Preset " << GetNodeName() << endl;
+    lout << "- " << GetNodeName() << ": Setting Preset." << endl;
     SendSDO(0x6003, (LWORD_t)fPos);
     WaitForSdo(0x6003);
@@ -284,5 +287,5 @@
 void ShaftEncoder::StopDevice()
 {
-    lout << "- Stop Node " << GetNodeName() << endl;
+    lout << "- " << GetNodeName() << ": Stop Node (NMT)." << endl;
     SendNMT(kNMT_STOP);
 }
Index: trunk/MagicSoft/Cosy/gui/MGAccuracy.cc
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGAccuracy.cc	(revision 1700)
+++ trunk/MagicSoft/Cosy/gui/MGAccuracy.cc	(revision 1701)
@@ -72,4 +72,5 @@
     axe = new TGaxis(  0, -60*4,  0, 60*4,  -4, 4,   304, "+-N");
     axe->SetTitle("Zd"); // \xb0
+    axe->SetLabelOffset(-0.02);
     axe->SetBit(kCanDelete);
     axe->Draw();
Index: trunk/MagicSoft/Cosy/gui/MGCosy.cc
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGCosy.cc	(revision 1700)
+++ trunk/MagicSoft/Cosy/gui/MGCosy.cc	(revision 1701)
@@ -43,4 +43,5 @@
     kPB_TRACK,
     kPB_STOP,
+    kPB_HOME,
     kPB_CALCALTAZ,
     kPB_TPOINT,
@@ -98,5 +99,5 @@
 
     l = new TGLabel(f, "Mjd:");
-    l->Move(x-60, y+20);
+    l->Move(x-60, y+17);
     fList->Add(l);
 
@@ -104,18 +105,18 @@
     fMjd = new TGLabel(f, "00000.000000");
     fUtc->Move(x-25, y);
-    fMjd->Move(x-25, y+20);
+    fMjd->Move(x-25, y+17);
     fList->Add(fUtc);
     fList->Add(fMjd);
 
     l = new TGLabel(f, "SE-Az:");
-    l->Move(x-60, y+60);
+    l->Move(x-60, y+40);
     fList->Add(l);
 
     l = new TGLabel(f, "SE-Zd1:");
-    l->Move(x-60, y+80);
+    l->Move(x-60, y+57);
     fList->Add(l);
 
     l = new TGLabel(f, "SE-Zd2:");
-    l->Move(x-60, y+100);
+    l->Move(x-60, y+74);
     fList->Add(l);
 
@@ -127,7 +128,7 @@
     fLabel1[1]->SetTextJustify(kTextRight);
     fLabel1[2]->SetTextJustify(kTextRight);
-    fLabel1[0]->Move(x,    y+60);
-    fLabel1[1]->Move(x+43, y+60);
-    fLabel1[2]->Move(x+70, y+60);
+    fLabel1[0]->Move(x,    y+40);
+    fLabel1[1]->Move(x+43, y+40);
+    fLabel1[2]->Move(x+70, y+40);
     fList->Add(fLabel1[0]);
     fList->Add(fLabel1[1]);
@@ -144,7 +145,7 @@
     fLabel2[1]->SetTextJustify(kTextRight);
     fLabel2[2]->SetTextJustify(kTextRight);
-    fLabel2[0]->Move(x,    y+80);
-    fLabel2[1]->Move(x+43, y+80);
-    fLabel2[2]->Move(x+70, y+80);
+    fLabel2[0]->Move(x,    y+57);
+    fLabel2[1]->Move(x+43, y+57);
+    fLabel2[2]->Move(x+70, y+57);
     fList->Add(fLabel2[0]);
     fList->Add(fLabel2[1]);
@@ -161,7 +162,7 @@
     fLabel3[1]->SetTextJustify(kTextRight);
     fLabel3[2]->SetTextJustify(kTextRight);
-    fLabel3[0]->Move(x,    y+100);
-    fLabel3[1]->Move(x+43, y+100);
-    fLabel3[2]->Move(x+70, y+100);
+    fLabel3[0]->Move(x,    y+74);
+    fLabel3[1]->Move(x+43, y+74);
+    fLabel3[2]->Move(x+70, y+74);
     fList->Add(fLabel3[0]);
     fList->Add(fLabel3[1]);
@@ -172,9 +173,9 @@
 
     l = new TGLabel(f, "Offset-Zd:");
-    l->Move(x-60, y+140);
+    l->Move(x-60, y+102);
     fList->Add(l);
 
     l = new TGLabel(f, "Offset-Az:");
-    l->Move(x-60, y+160);
+    l->Move(x-60, y+119);
     fList->Add(l);
 
@@ -183,8 +184,57 @@
     fOffsetZd->SetTextJustify(kTextRight);
     fOffsetAz->SetTextJustify(kTextRight);
-    fOffsetZd->Move(x, y+140);
-    fOffsetAz->Move(x, y+160);
+    fOffsetZd->Move(x, y+102);
+    fOffsetAz->Move(x, y+119);
     fList->Add(fOffsetZd);
     fList->Add(fOffsetAz);
+
+    l = new TGLabel(f, "Ra (estimated):");
+    l->Move(x-60, y+142);
+    fList->Add(l);
+
+    l = new TGLabel(f, "Ra (soll):");
+    l->Move(x-60, y+159);
+    fList->Add(l);
+
+    l = new TGLabel(f, "Dec (estimated):");
+    l->Move(x-60, y+182);
+    fList->Add(l);
+
+    l = new TGLabel(f, "Dec (soll):");
+    l->Move(x-60, y+199);
+    fList->Add(l);
+
+    l = new TGLabel(f, "Zd (soll):");
+    l->Move(x-60, y+222);
+    fList->Add(l);
+
+    l = new TGLabel(f, "Az (soll):");
+    l->Move(x-60, y+239);
+    fList->Add(l);
+
+    fRaEst  = new TGLabel(f, "+000h 00.0m");
+    fDecEst = new TGLabel(f, "+000h 00.0m");
+    fRaSoll = new TGLabel(f, "+000h 00.0m");
+    fDecSoll = new TGLabel(f, "+000h 00.0m");
+    fZdSoll = new TGLabel(f, "+000h 00.0m");
+    fAzSoll = new TGLabel(f, "+000h 00.0m");
+    fRaEst->SetTextJustify(kTextRight);
+    fDecEst->SetTextJustify(kTextRight);
+    fRaSoll->SetTextJustify(kTextRight);
+    fDecSoll->SetTextJustify(kTextRight);
+    fZdSoll->SetTextJustify(kTextRight);
+    fAzSoll->SetTextJustify(kTextRight);
+    fRaEst->Move(x+30, y+142);
+    fRaSoll->Move(x+30, y+159);
+    fDecEst->Move(x+30, y+182);
+    fDecSoll->Move(x+30, y+199);
+    fZdSoll->Move(x+30, y+222);
+    fAzSoll->Move(x+30, y+239);
+    fList->Add(fRaEst);
+    fList->Add(fDecEst);
+    fList->Add(fRaSoll);
+    fList->Add(fDecSoll);
+    fList->Add(fZdSoll);
+    fList->Add(fAzSoll);
 
 
@@ -329,4 +379,11 @@
     fList->Add(but);
 
+    but = new TGTextButton(tf1, "Home", kPB_HOME);
+    but->Resize(80, 25);
+    but->Move(160, 197);
+    but->SetToolTipText("Initiate Home Drive.");
+    but->Associate(this);
+    fList->Add(but);
+
     but= new TGTextButton(tf2, "Calc Zd/Az",  kPB_CALCALTAZ);
     but->Resize(80, 25);
@@ -637,4 +694,62 @@
 }
 
+void MGCosy::UpdateRaDec(ZdAz &pos, double mjd, RaDec &radec)
+{
+    static Int_t rai=~0;
+    static Int_t deci=~0;
+    static Int_t ras=~0;
+    static Int_t decs=~0;
+
+    static SlaStars sla;
+    sla.SetMjd(mjd);
+
+    RaDec rd = sla.CalcRaDec(pos*2*TMath::Pi()/360);
+
+    char text[64];
+
+    rd.Ra(rd.Ra()  * 24/2/TMath::Pi());
+    rd.Dec(rd.Dec()*360/2/TMath::Pi());
+
+    radec.Ra(radec.Ra()  * 24/2/TMath::Pi());
+    radec.Dec(radec.Dec()*360/2/TMath::Pi());
+
+    RaDec test = rd*600;
+
+    if (rai!=(int)test.Ra())
+    {
+        rai = (int)test.Ra();
+        sprintf(text, "%c%dh %.1fm", rd.Ra()<0?'-':'+', abs((int)rd.Ra()), 0.1*(abs((int)test.Ra())%600));
+        fRaEst->SetText(new TGString(text));
+    }
+    if (deci!=(int)test.Dec())
+    {
+        deci = (int)test.Dec();
+        sprintf(text, "%c%dd %.1fm", rd.Dec()<0?'-':'+' , abs((int)rd.Dec()), 0.1*(abs((int)test.Dec())%600));
+        fDecEst->SetText(new TGString(text));
+    }
+
+    if (radec.Dec()>90|| radec.Dec()<-90)
+    {
+        radec.Ra(radec.Ra()+12);
+        radec.Dec(180-radec.Dec());
+    }
+    radec.Ra(fmod((radec.Ra()+48), 24));
+
+    test = radec*600;
+
+    if (ras!=(int)test.Ra())
+    {
+        ras = (int)test.Ra();
+        sprintf(text, "%c%dh %.1fm", radec.Ra()<0?'-':'+', abs((int)radec.Ra()), 0.1*(abs((int)test.Ra())%600));
+        fRaSoll->SetText(new TGString(text));
+    }
+    if (decs!=(int)test.Dec())
+    {
+        decs = (int)test.Dec();
+        sprintf(text, "%c%dd %.1fm", radec.Dec()<0?'-':'+' , abs((int)radec.Dec()), 0.1*(abs((int)test.Dec())%600));
+        fDecSoll->SetText(new TGString(text));
+    }
+}
+
 void MGCosy::UpdateOffset(ZdAz &off)
 {
@@ -647,5 +762,5 @@
     {
         zd = (Int_t)off.Zd();
-        sprintf(text, "%d", zd);
+        sprintf(text, "%dre", zd);
         fOffsetZd->SetText(new TGString(text));
     }
@@ -653,9 +768,34 @@
     {
         az = (Int_t)off.Az();
-        sprintf(text, "%d", az);
+        sprintf(text, "%dre", az);
         fOffsetAz->SetText(new TGString(text));
     }
 }
 
+void MGCosy::UpdateZdAz(ZdAz &soll)
+{
+    soll *= 360/2/TMath::Pi();
+
+    static Int_t zd=~0;
+    static Int_t az=~0;
+
+    char text[21];
+
+    ZdAz test = soll*600;
+
+    if (zd!=(int)test.Zd())
+    {
+        zd = (int)test.Zd();
+        sprintf(text, "%c%dh %.1fm", soll.Zd()<0?'-':'+', abs((int)soll.Zd()), 0.1*(abs((int)test.Zd())%600));
+        fZdSoll->SetText(new TGString(text));
+    }
+    if (az!=(int)test.Az())
+    {
+        az = (int)test.Az();
+        sprintf(text, "%c%dd %.1fm", soll.Az()<0?'-':'+' , abs((int)soll.Az()), 0.1*(abs((int)test.Az())%600));
+        fAzSoll->SetText(new TGString(text));
+    }
+}
+
 double MGCosy::UpdateTime()
 {
@@ -682,5 +822,6 @@
 }
 
-void MGCosy::Update(ZdAz pos, ZdAz acc, ZdAz vel, ZdAz off, UInt_t stat)
+void MGCosy::Update(ZdAz pos, ZdAz acc, ZdAz vel, ZdAz off, RaDec radec,
+                    ZdAz soll, UInt_t stat)
 {
     double mjd = UpdateTime();
@@ -689,4 +830,6 @@
     fVelocity->Update(vel);
     UpdateOffset(off);
+    UpdateRaDec(pos, mjd, radec);
+    UpdateZdAz(soll);
 
 #define kError     0x01
@@ -701,4 +844,8 @@
     EnableLabel(fStopping, stat&kStopping);
     EnableLabel(fStopped,  stat&kStopped);
+    EnableLabel(fRaSoll,   stat&kTracking);
+    EnableLabel(fDecSoll,  stat&kTracking);
+    EnableLabel(fZdSoll,   stat&kMoving);
+    EnableLabel(fAzSoll,   stat&kMoving);
 
     stat&kTracking ? fAccuracy->MapWindow() : fAccuracy->UnmapWindow();
@@ -706,10 +853,10 @@
     //    stat&kTracking ? fOffset->MapWindow()   : fOffset->UnmapWindow();
 
-    if (!fLog->TestBit(kHasChanged))
-        return;
-
-    fLog->MapSubwindows();
-    fLog->Layout();
-    fLog->ResetBit(kHasChanged);
+    if (fLog->TestBit(kHasChanged))
+    {
+        fLog->MapSubwindows();
+        fLog->Layout();
+        fLog->ResetBit(kHasChanged);
+    }
 }
 // ======================================================================
@@ -919,5 +1066,4 @@
                 StopDemo();
                 fQueue->PostMsg(WM_STOP, 0, 0);
-
                 cout << "PostMsg (WM_Stop) returned." << endl;
                 return kTRUE;
@@ -972,4 +1118,7 @@
                 fQueue->Proc(WM_RESETBENDING, NULL);
                 return kTRUE;
+            case kPB_HOME:
+                fQueue->PostMsg(WM_HOME, 0, 0);
+                return kTRUE;
 
             default:
Index: trunk/MagicSoft/Cosy/gui/MGCosy.h
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGCosy.h	(revision 1700)
+++ trunk/MagicSoft/Cosy/gui/MGCosy.h	(revision 1701)
@@ -47,4 +47,13 @@
     TGLabel       *fOffsetAz;
 
+    TGLabel       *fRaEst;
+    TGLabel       *fDecEst;
+
+    TGLabel       *fRaSoll;
+    TGLabel       *fDecSoll;
+
+    TGLabel       *fZdSoll;
+    TGLabel       *fAzSoll;
+
     TGLabel       *fUtc;
     TGLabel       *fMjd;
@@ -83,4 +92,6 @@
     void EnableLabel(TGLabel *label, Bool_t stat);
     void UpdateOffset(ZdAz &off);
+    void UpdateZdAz(ZdAz &off);
+    void UpdateRaDec(ZdAz &pos, double mjd, RaDec &radec);
     double UpdateTime();
 
@@ -97,5 +108,5 @@
     TGListBox *GetLog() const { return fLog; }
 
-    void Update(ZdAz pos, ZdAz acc, ZdAz vel, ZdAz off, UInt_t stat);
+    void Update(ZdAz pos, ZdAz acc, ZdAz vel, ZdAz off, RaDec radec, ZdAz soll, UInt_t stat);
 
     Bool_t ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2);
Index: trunk/MagicSoft/Cosy/gui/MGVelocity.cc
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGVelocity.cc	(revision 1700)
+++ trunk/MagicSoft/Cosy/gui/MGVelocity.cc	(revision 1701)
@@ -123,4 +123,5 @@
     axe = new TGaxis(0, -60*2, 0, 60*2,  -2, 2,  304, "+-N");
     axe->SetTitle("Zd"); // \xb0
+    axe->SetLabelOffset(-0.02);
     axe->SetBit(kCanDelete);
     axe->Draw();
Index: trunk/MagicSoft/Cosy/main/MCosy.cc
===================================================================
--- trunk/MagicSoft/Cosy/main/MCosy.cc	(revision 1700)
+++ trunk/MagicSoft/Cosy/main/MCosy.cc	(revision 1701)
@@ -395,11 +395,11 @@
     // const ZdAz dest = CorrectTarget(src, dst);
     //
-    const ZdAz bend = fBending(dst);
-    const ZdAz dest = bend*16384/2/TMath::Pi();
+    fZdAzSoll = fBending(dst);
+    const ZdAz dest = fZdAzSoll*16384/2/TMath::Pi();
 
     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;
-    cout << "Bend'd Dest   Zd: " << Rad2SE(bend.Zd()) << "se  Az:" << Rad2SE(bend.Az())  << "se" << endl;
+    cout << "Bend'd Dest   Zd: " << Rad2SE(fZdAzSoll.Zd()) << "se  Az:" << Rad2SE(fZdAzSoll.Az())  << "se" << endl;
     cout << "Shortest Dest Zd: " << dest.Zd() << "se  Az:" << dest.Az() << "se" << endl;
 
@@ -674,11 +674,4 @@
     {
         //
-        // The loop should not be executed faster than the ramp of
-        // a change in the velocity can be followed.
-        // (This is important on fast machines >500MHz)
-        //
-        //usleep(100000000);
-
-        //
         // Request Target position for this moment
         //
@@ -759,4 +752,9 @@
         // update time
         //
+        //
+        // The loop should not be executed faster than the ramp of
+        // a change in the velocity can be followed.
+        // (This is important on fast machines >500MHz)
+        //
         usleep(50000); // 0.05s
     }
@@ -779,5 +777,5 @@
         return;
     //
-    // Set status to stopped
+    // Set status to Stopping
     //
     SetStatus(MCosy::kStopping);
@@ -812,5 +810,4 @@
 void *MCosy::Proc(int msg, void *mp)
 {
-    cout << "MCosy::Proc: 0x" << msg << endl;
     switch (msg)
     {
@@ -820,4 +817,5 @@
 
     case WM_STOP:
+        cout << "MCosy::Proc: Stop." << endl;
         StopMovement();
         return NULL;
@@ -923,4 +921,22 @@
         cout << "WM_ResetBending: done. (return 0xbe0e)" << endl;
         return (void*)0xbe0e;
+
+    case WM_HOME:
+        cout << "WM_Home: START" << endl;
+        if (fMac1 && fMac2)
+        {
+            cout << "Going Home..." << endl;
+            fMac1->SetHome(250000, 100);
+            fMac2->SetHome(250000, 100);
+
+            fAz->SetPreset();
+            fZd1->SetPreset();
+            fZd2->SetPreset();
+
+            fMac1->ReqPos();
+            fMac2->ReqPos();
+        }
+        cout << "WM_Home: done. (return 0x403e)" << endl;
+        return (void*)0x403e;
 
     case WM_CALCALTAZ:
@@ -954,5 +970,5 @@
         return (void*)0xaaaa;
     }
-    cout << "Unknown Msg" << endl;
+    cout << "MCosy::Proc: Unknown message 0x" << msg << endl;
     return (void*)0xffffffff;
 }
@@ -988,5 +1004,5 @@
     else
         resrezd = env.GetValue("Zd_ResRE[re/U_mot]", 1500);
-
+ 
     Double_t ressezd = 0;
     if (fZd1)
@@ -1004,8 +1020,4 @@
         resseaz = env.GetValue("Az_ResSE[se/U_mot]", 16384);
 
-    /* WORKAROUND !!!!!!!!!!!!! FIXME !!!!!!!!!!! */
-    resrezd = 500;
-    resreaz = 500;
-
     kGearRatio.Set (gzd*resrezd/ressezd, gaz*resreaz/resseaz);  //[re/se]
     kGearRatio2.Set(gzd*resrezd/360.0,   gaz*resreaz/360.0);    //[re/deg]
@@ -1036,11 +1048,11 @@
     }
 
-    fMac1->EnableTimeout(kTRUE, 500);
-    fMac2->EnableTimeout(kTRUE, 500);
+    //fMac1->EnableTimeout(kTRUE, 500);
+    //fMac2->EnableTimeout(kTRUE, 500);
 
     if (!(fZd1 && fZd2 && fAz))
         return;
 
-    /*
+
     //
     // Start the Network
@@ -1049,5 +1061,5 @@
     TEnv env(".cosyrc");
     cout << "done." << endl;
-
+/*
     const int res = fMac3->GetVelRes();
 
@@ -1222,4 +1234,7 @@
             }
 
+            fZdAzSoll.Set(sollzd.Zd(), sollaz.Az());
+            fZdAzSoll *= 2*TMath::Pi()/16384;
+
             fTrackingError.Set((ist.Zd()-sollzd.Zd())*kGearRatio.X(),
                                (ist.Az()-sollaz.Az())*kGearRatio.Y());
@@ -1248,5 +1263,5 @@
 
     fWin->Update(bendist*(360.0/2/TMath::Pi()), fTrackingError/kGearRatio2,
-                 fVelocity, fOffset/*/kGearRatio2*/,
+                 fVelocity, fOffset/*/kGearRatio2*/, fRaDec, fZdAzSoll,
                  fStatus);
 
@@ -1291,8 +1306,8 @@
     lout << "- Starting TX Thread." << endl;
     fTTalk = new MTTalk(this);
+    //    fTGui = new MTGui(this);
 
     lout << "- Starting GUI update." << endl;
     fUpdateGui->TurnOn();
-    //    fTGui = new MTGui(this);
 }
 
Index: trunk/MagicSoft/Cosy/main/MCosy.h
===================================================================
--- trunk/MagicSoft/Cosy/main/MCosy.h	(revision 1700)
+++ trunk/MagicSoft/Cosy/main/MCosy.h	(revision 1701)
@@ -21,4 +21,6 @@
 #define WM_RESETBENDING 0x1008
 #define WM_CALCALTAZ    0x1009
+#define WM_HOME         0x100a
+
 
 class ShaftEncoder;
@@ -76,4 +78,5 @@
     ZdAz  fTrackingError; // Tracking Offset between SE and calc-pos [re]
     ZdAz  fOffset;        // Offset between se and re coordinate system [re]
+    ZdAz  fZdAzSoll;      // Soll position when moving
     RaDec fRaDec;         // Position to track
     int   fTracking;      // Flag for present tracking action
