Index: trunk/MagicSoft/Cosy/Changelog
===================================================================
--- trunk/MagicSoft/Cosy/Changelog	(revision 6840)
+++ trunk/MagicSoft/Cosy/Changelog	(revision 6841)
@@ -1,3 +1,28 @@
                                                                   -*-*- END -*-*-
+
+ 2005/03/17 - Thomas Bretz
+
+   * main/MCosy.[h,cc]:
+     - implemented WM_GRB and TrackPositionGRB for GRB mode
+
+   * main/MStarguider.cc:
+     - added 'status' to FINDSTAR-REPORT
+     - send STARG-REPORT only if Starguider is switched on
+     - enhanced output in starguider report
+
+   * tcpip/MCeCoCom.cc:
+     - tried to backengineer the CC-REPORT because it is not documented
+       in the CC TDAS
+     - changed critical values for windspeed from 10/20/30 to 30/40/50
+
+   * tcpip/MDriveCom.[h,cc]:
+     - implemented handling of GRB command
+     - enhanced SendStargReport. Starguider Report now:
+       misszd[%05.3f] missaz[%05.3f] 
+       nomzd[%c %03d %02d %03d] nomaz[%c %03d %02d %03d]
+       centerx[%05.1f] centery[%05.1f] n[%04d]
+       bright[%03.1f] mjd[%12.6f]
+
+
 
  2004/09/05 - Robert Wagner (La Palma)
Index: trunk/MagicSoft/Cosy/main/MCosy.cc
===================================================================
--- trunk/MagicSoft/Cosy/main/MCosy.cc	(revision 6840)
+++ trunk/MagicSoft/Cosy/main/MCosy.cc	(revision 6841)
@@ -415,4 +415,20 @@
 
 void MCosy::TrackPosition(const RaDec &dst) // ra, dec [rad]
+{
+    MTracking track(this, lout);
+    track.SetOut(fOutRep);
+//#ifdef EXPERT
+//    track.SetPointAccDec(0.4, 0.4);
+//    track.SetPointVelocity(0.2); // fast: 0.6, slow: 0.2
+//#else
+    track.SetPointAccDec(0.2, 0.1);
+    track.SetPointVelocity(0.1);
+//#endif
+    track.SetTrackAccDec(0.1, 0.1);
+
+    track.TrackPosition(dst);
+}
+
+void MCosy::TrackPositionGRB(const RaDec &dst) // ra, dec [rad]
 {
     MTracking track(this, lout);
@@ -701,4 +717,17 @@
         return (void*)0x8888;
 
+    case WM_GRB:
+        //cout << "WM_Track: START" << endl;
+        {
+            RaDec dest = ((RaDec*)mp)[0];
+            if (fStarguider)
+                fStarguider->SetPointingPosition(((RaDec*)mp)[1]);
+            if (!CheckNetwork())
+                return (void*)0xebb0;
+            TrackPositionGRB(dest*kDeg2Rad);
+        }
+        //cout << "WM_Track: done. (return 0x8888)" << endl;
+        return (void*)0x8888;
+
     case WM_NEWTRACK:
         //cout << "WM_NewTrack: START" << endl;
Index: trunk/MagicSoft/Cosy/main/MCosy.h
===================================================================
--- trunk/MagicSoft/Cosy/main/MCosy.h	(revision 6840)
+++ trunk/MagicSoft/Cosy/main/MCosy.h	(revision 6841)
@@ -37,4 +37,5 @@
 #define WM_POSITION1    0x100f
 #define WM_ENDSWITCH    0x1010
+#define WM_GRB          0x1011
 
 class ShaftEncoder;
@@ -153,4 +154,5 @@
     int  SetPosition(const ZdAz &dst, Bool_t track=kFALSE);
     void TrackPosition(const RaDec &dst); // ra, dec [rad]
+    void TrackPositionGRB(const RaDec &dst); // ra, dec [rad]
 
     void TerminateApp();
Index: trunk/MagicSoft/Cosy/main/MStarguider.cc
===================================================================
--- trunk/MagicSoft/Cosy/main/MStarguider.cc	(revision 6840)
+++ trunk/MagicSoft/Cosy/main/MStarguider.cc	(revision 6841)
@@ -1219,5 +1219,5 @@
     if (outrep.Lock("MStarguider::FindStar"))
     {
-        outrep << "FINDSTAR-REPORT " << MTime(-1) << " " << setprecision(7);
+        outrep << "FINDSTAR-REPORT 00 " << MTime(-1) << " " << setprecision(7);
         outrep << 90-za0.Alt() << " " << za0.Az() << " ";
         outrep << za1.Zd() << " " << za1.Az() << " ";
@@ -1367,5 +1367,11 @@
 	    fStargCaos->Run(img, kFALSE, kFALSE, pos, t, 30, 3.0); // [px]
 	const Float_t pixsize = atof(fPixSize->GetText()); // [arcsec/px]
-	sgcenterzdaz.Zd((sgcenter.GetY()-293.6) * pixsize /3600 );
+
+        // BE CAREFULL: This transformation is WRONG. It is just
+        // a transformation of units, but this implies, that the
+        // coordiante axis in both units look the same. This is
+        // wrong exspecially near the zenith were az-lines are highly
+        // curved around the zenith!
+        sgcenterzdaz.Zd((sgcenter.GetY()-293.6) * pixsize /3600 );
 	sgcenterzdaz.Az((sgcenter.GetX()-53.2) * pixsize /3600 ); 
 #ifdef EXPERT
@@ -1487,10 +1493,9 @@
         f2.DrawCircle(skycenter, 3.84*.5*74.0, 0x0a);
 
+        if (fCosy) {
+            MDriveCom &com = *fCosy->GetDriveCom();
+            com.SendStargReport(fStatus, fD, fSao->GetZdAz(), sgcenter, spots.GetEntries(), bright, time.GetMjd());    // Report
+        }
     } //CalcStars
-
-    if (fCosy) {
-        MDriveCom &com = *fCosy->GetDriveCom();
-        com.SendStargReport(fStatus, fD);    // Report
-    }
 
     // Draw Circles around center of Camera
Index: trunk/MagicSoft/Cosy/tcpip/MCeCoCom.cc
===================================================================
--- trunk/MagicSoft/Cosy/tcpip/MCeCoCom.cc	(revision 6840)
+++ trunk/MagicSoft/Cosy/tcpip/MCeCoCom.cc	(revision 6841)
@@ -32,5 +32,5 @@
     // Remove the 30 tokens of the subsystem status
     //  table 12.1 p59
-    for (int i=0; i<30; i++)
+    for (int i=0; i<31; i++)
         str.Remove(0, str.First(' ')+1);
 
@@ -38,5 +38,5 @@
     float zd, az, dec, ra, temp, solar, wind, hum;
     n=sscanf(str.Data(),
-             "%f %f %f %f %f %f %f %f %*f %*f %n",
+             "%f %f %f %f %f %f %f %f %*f %*f %*s %*s %*s %*s %n",
              &zd, &az, &dec, &ra, &temp, &solar, &wind, &hum, &len);
     if (n!=8)
@@ -60,5 +60,5 @@
     fWindSpeed = wind;
 
-    if (fWindSpeed>30)
+    if (fWindSpeed>50)
         fAlarmCounter++;
     else
@@ -136,9 +136,9 @@
     if (fHumidity>80)
         rc++;
-    if (fWindSpeed>10)
+    if (fWindSpeed>30)
         rc++;
-    if (fWindSpeed>20)
+    if (fWindSpeed>40)
         rc++;
-    if (fWindSpeed>30)
+    if (fWindSpeed>50)
         rc++;
 
Index: trunk/MagicSoft/Cosy/tcpip/MDriveCom.cc
===================================================================
--- trunk/MagicSoft/Cosy/tcpip/MDriveCom.cc	(revision 6840)
+++ trunk/MagicSoft/Cosy/tcpip/MDriveCom.cc	(revision 6841)
@@ -7,4 +7,5 @@
 #include "MCosy.h"
 #include "MString.h"
+#include "Ring.h"
 
 using namespace std;
@@ -62,4 +63,30 @@
     //cout << "MDriveCom - TRACK... start." << endl;
     fQueue->PostMsg(WM_TRACK, &rd, sizeof(rd));
+    //cout << "MDriveCom - TRACK... done." << endl;
+    return true;
+}
+
+bool MDriveCom::CommandGRB(TString &str)
+{
+    Double_t ra, dec;
+    if (!ReadPosition(str, ra, dec))
+    {
+        cout << "ERROR - Reading position from GRB" << endl;
+        return false;
+    }
+    if (!str.IsNull())
+    {
+        cout << "ERROR - Too many bytes in command GRB" << endl;
+        return false;
+    }
+
+    cout << "CC-COMMAND " << MTime(-1) << " GRB " << ra << "h " << dec << "d '" << str << "'" << endl;
+
+    ra *= 15; // h -> deg
+
+    RaDec rd[2] = { RaDec(ra, dec), RaDec(ra, dec) };
+
+    //cout << "MDriveCom - TRACK... start." << endl;
+    fQueue->PostMsg(WM_GRB, &rd, sizeof(rd));
     //cout << "MDriveCom - TRACK... done." << endl;
     return true;
@@ -113,4 +140,7 @@
     if (cmd==(TString)"RADEC")
         return CommandRADEC(str);
+
+    if (cmd==(TString)"GRB")
+        return CommandGRB(str);
 
     if (cmd==(TString)"ZDAZ")
@@ -190,11 +220,12 @@
 }
 
-bool MDriveCom::SendStargReport(UInt_t stat, ZdAz miss)
-{
-   
-    // miss [rad]
+bool MDriveCom::SendStargReport(UInt_t stat, ZdAz miss, ZdAz nompos, Ring center, Int_t n, Double_t bright, Double_t mjd)
+{
+    // miss   [deg]
+    // nompos [rad]
     const MTime t(-1);
 
-    miss *= kRad2Deg;
+    miss   *= 60;        // [arcmin]
+    nompos *= kRad2Deg;  // [deg]
 
     // Set status flag
@@ -211,6 +242,13 @@
 
     TString str;
-    str += txt.Print("%05.3f ", miss.Zd());
-    str += txt.Print("%05.3f", miss.Az());
+    str += txt.Print("%05.3f ", miss.Zd());       //[arcmin]
+    str += txt.Print("%05.3f ", miss.Az());       //[arcmin]
+    Print(str, nompos.Zd());                      //[deg]
+    Print(str, nompos.Az());                      //[deg]
+    str += txt.Print("%05.1f ",   center.GetX()); //number
+    str += txt.Print("%05.1f ",   center.GetY()); //number
+    str += txt.Print("%04d ",   n);               //number
+    str += txt.Print("%03.1f",  bright);
+    str += txt.Print("%12.6f ", t.GetMjd());      // mjd
     
     return Send("STARG-REPORT", str, kTRUE);
Index: trunk/MagicSoft/Cosy/tcpip/MDriveCom.h
===================================================================
--- trunk/MagicSoft/Cosy/tcpip/MDriveCom.h	(revision 6840)
+++ trunk/MagicSoft/Cosy/tcpip/MDriveCom.h	(revision 6841)
@@ -9,4 +9,5 @@
 class ZdAz;
 class MsgQueue;
+class Ring;
 
 class MDriveCom : public MCeCoCom
@@ -22,4 +23,5 @@
 
     bool CommandRADEC(TString &str);
+    bool CommandGRB(TString &str);
     bool CommandZDAZ(TString &str);
 
@@ -39,5 +41,5 @@
 
     bool SendReport(UInt_t stat, RaDec rd, ZdAz so, ZdAz is, ZdAz er);
-    bool SendStargReport(UInt_t stat, ZdAz miss);
+    bool SendStargReport(UInt_t stat, ZdAz miss, ZdAz nompos, Ring center, Int_t n, Double_t bright, Double_t mjd);
     bool SendStatus(const char *stat);
 };
