Index: trunk/MagicSoft/Cosy/main/MCosy.cc
===================================================================
--- trunk/MagicSoft/Cosy/main/MCosy.cc	(revision 1699)
+++ 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 1699)
+++ 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
