Index: /trunk/MagicSoft/Cosy/Changelog
===================================================================
--- /trunk/MagicSoft/Cosy/Changelog	(revision 9521)
+++ /trunk/MagicSoft/Cosy/Changelog	(revision 9522)
@@ -1,8 +1,29 @@
                                                                   -*-*- END -*-*-
+ 2009/12/01 Thomas Bretz
+
+   * catalog/SlaStars.h:
+     - fixed unit of GetZdAz
+     - added GetZdAzRad and GetRaDecRad
+
+   * main/MTracking.cc:
+     - fixed unit of fTrackPos calling sla.Set
+     - don't distribute ra/dec to starguider it seems to be responsible
+       for crashes
+     - fixed units of getting coordinates from slalib
+     - keep calculating a future position in the tracking loop
+     - for the moment set the observatory key explicitly
+       (Mars doesn't store it)
+
+   * tcpip/MDriveCom.cc:
+     - fixed the number of expected arguments in CELEST command
+
+
+
  2009/10/21 Thomas Bretz
 
    * catalog/SlaPlanets.[h,cc]:
      - Now derives from SlaStars
-     - new function to get the current sky position of a celestial object
+     - new function to get the current sky position of a celestial
+       object
 
    * catalog/SlaStars.[h,cc]:
Index: /trunk/MagicSoft/Cosy/catalog/SlaStars.h
===================================================================
--- /trunk/MagicSoft/Cosy/catalog/SlaStars.h	(revision 9521)
+++ /trunk/MagicSoft/Cosy/catalog/SlaStars.h	(revision 9522)
@@ -26,6 +26,8 @@
 
     //    const AltAz GetAltAz() const { return fAltAz*360/D2PI; }
-    const ZdAz   GetZdAz()  const     { return ZdAz(TMath::Pi()/2-fAltAz.Alt(), fAltAz.Az())*TMath::DegToRad(); }
+    const ZdAz   GetZdAz()  const     { return ZdAz(TMath::Pi()/2-fAltAz.Alt(), fAltAz.Az())/TMath::DegToRad(); }
+    const ZdAz   GetZdAzRad() const   { return ZdAz(TMath::Pi()/2-fAltAz.Alt(), fAltAz.Az()); }
     const RaDec  GetRaDec() const     { return fRaDec/TMath::DegToRad(); }
+    const RaDec  GetRaDecRad() const  { return fRaDec; }
     const double GetHourAngle() const { return fHourAngle; }
 
Index: /trunk/MagicSoft/Cosy/main/MTracking.cc
===================================================================
--- /trunk/MagicSoft/Cosy/main/MTracking.cc	(revision 9521)
+++ /trunk/MagicSoft/Cosy/main/MTracking.cc	(revision 9522)
@@ -219,10 +219,12 @@
 {
     if (fTrackType<0)
-        sla.Set(fTrackPos);
+        sla.Set(fTrackPos/TMath::DegToRad());
     else
         sla.SetPlanet((ePlanets_t)fTrackType);
 
-    if (fCosy->fStarguider)
-        fCosy->fStarguider->SetPointingPosition(sla.GetRaDec());
+//    if (fCosy->fStarguider)
+//        fCosy->fStarguider->SetPointingPosition(sla.GetRaDec());
+
+//    gLog << all << "=====> " << (int)(&sla==&fSlalib) << " " << fTrackType << " MJD=" << Form("%.13f", sla.GetMjd()) << " HA=" << sla.GetHourAngle() << " Alpha=" << sla.GetAlpha() << " fTrackPos.Ra()=" << fTrackPos.Ra() << " fTrackPos.Dec()=" << fTrackPos.Dec() << " Alt=" << sla.GetZdAzRad().Zd() << " Az=" << sla.GetZdAzRad().Az() << endl;
 }
 
@@ -232,5 +234,5 @@
     UpdateSlalib(fSlalib);
 
-    fCosy->fRaDec     = fSlalib.GetRaDec();
+    fCosy->fRaDec     = fSlalib.GetRaDecRad();
     fCosy->fHourAngle = fSlalib.GetHourAngle();
 }
@@ -244,8 +246,10 @@
 bool MTracking::Move()
 {
-    const RaDec &dst = fSlalib.GetRaDec();
-
-    ZdAz dest = fSlalib.GetZdAz();//fSlalib.CalcZdAz(dst);
-
+    const RaDec &dst = fSlalib.GetRaDecRad();
+
+    ZdAz dest = fSlalib.GetZdAzRad();//fSlalib.CalcZdAz(dst);
+
+    if (fTrackType<0)
+       gLog << all << fSlalib.GetTime() << ": Tracking Planet" << endl;
     gLog << all << fSlalib.GetTime() << ": Track Position " << dst.Ra()*kRad2Deg/15 << "h, " << dst.Dec()*kRad2Deg <<"deg" << endl;
 
@@ -275,4 +279,7 @@
 void MTracking::TrackPosition(const RaDec &dst)
 {
+
+//    gLog << all << "=====> dst.Ra()=" << dst.Ra() << " dst.Dec()=" << dst.Dec() << "   (deg?)" << endl;
+
     fTrackPos  = dst;
     fTrackType = -1;
@@ -317,5 +324,5 @@
     //fCosy->fRaDec = fSlalib.GetRaDec();
 
-    ZdAz pos = fSlalib.GetZdAz();//fSlalib.CalcZdAz(fSlalib.GetRaDec());
+    ZdAz pos = fSlalib.GetZdAzRad();//fSlalib.CalcZdAz(fSlalib.GetRaDec());
 
     // Some output
@@ -355,5 +362,5 @@
         // Request Target position for Now+dt
         //
-        UpdateSlalib();
+        UpdateSlalib(dt);
         //fCosy->fRaDec = fSlalib.GetRaDec();
 
@@ -361,5 +368,5 @@
         // Request nominal position for this time in the future (To+dt)
         //
-        const ZdAz pointing = fSlalib.GetZdAz(); //fSlalib.CalcZdAz(fSlalib.GetRaDec()); // [rad]
+        const ZdAz pointing = fSlalib.GetZdAzRad(); //fSlalib.CalcZdAz(fSlalib.GetRaDec()); // [rad]
         ZdAz dest = fCosy->AlignTrackingPos(pointing);     // fix ambiguity
 
@@ -452,5 +459,7 @@
     gLog << inf2 << "- Tracking Thread started (" << MTime(-1) << ")" << endl;
 
-    SlaPlanets sla(fSlalib.GetObservatoryKey());
+    //SlaPlanets sla(fSlalib.GetObservatoryKey());
+    SlaPlanets sla(MObservatory::kMagic1);
+//    gLog << all << "====> KEYS " << (int)fSlalib.GetObservatoryKey() << " " << (int)sla.GetObservatoryKey() << " " << (int)fCosy->fObservatory << endl;
 
     UpdateSlalib(sla);
@@ -498,5 +507,5 @@
             UpdateSlalib(sla, mjdzd);
 
-            ZdAz dummy = sla.GetZdAz();//sla.CalcZdAz(radec, mjdzd);
+            ZdAz dummy = sla.GetZdAzRad();//sla.CalcZdAz(radec, mjdzd);
             dummy = fCosy->AlignTrackingPos(dummy);
             fCosy->fZdAzSoll.Zd(dummy.Zd());
@@ -509,5 +518,5 @@
             UpdateSlalib(sla, mjdaz);
 
-            ZdAz dummy = sla.GetZdAz();//sla.CalcZdAz(radec, mjdaz);
+            ZdAz dummy = sla.GetZdAzRad();//sla.CalcZdAz(radec, mjdaz);
             dummy = fCosy->AlignTrackingPos(dummy);
             fCosy->fZdAzSoll.Az(dummy.Az());
Index: /trunk/MagicSoft/Cosy/tcpip/MDriveCom.cc
===================================================================
--- /trunk/MagicSoft/Cosy/tcpip/MDriveCom.cc	(revision 9521)
+++ /trunk/MagicSoft/Cosy/tcpip/MDriveCom.cc	(revision 9522)
@@ -138,5 +138,5 @@
     Float_t dra, ddec;
     Int_t n=sscanf(str.Data(), "%d %f %f %n", &id, &dra, &ddec, &len);
-    if (n!=1)
+    if (n!=3)
     {
         gLog << warn << "WARNING - Not enough argmuents (CELEST)." << endl;
