Index: trunk/MagicSoft/Cosy/gui/MGAccuracy.cc
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGAccuracy.cc	(revision 1819)
+++ trunk/MagicSoft/Cosy/gui/MGAccuracy.cc	(revision 1953)
@@ -246,4 +246,5 @@
     //
     // calculate actual time for planet positions
+    // acc [deg]
     //
     static int X = ~0;
Index: trunk/MagicSoft/Cosy/gui/MGCosy.cc
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGCosy.cc	(revision 1819)
+++ trunk/MagicSoft/Cosy/gui/MGCosy.cc	(revision 1953)
@@ -32,4 +32,5 @@
 
 #undef DEBUG
+#define EXPERT
 
 ClassImp(MGCosy);
@@ -44,5 +45,5 @@
     kPB_TRACK,
     kPB_STOP,
-    kPB_HOME,
+    kPB_TRACKPOS,
     kPB_CALCALTAZ,
     kPB_TPOINT,
@@ -126,54 +127,16 @@
     fList->Add(l);
 
-    fLabel1 = new TGLabel*[3];
-    fLabel1[0] = new TGLabel(f, "00000"); // Max: 16384
-    fLabel1[1] = new TGLabel(f, "000");   // Max: 256
-    fLabel1[2] = new TGLabel(f, "000");   // Max: 256
-    fLabel1[0]->SetTextJustify(kTextRight);
-    fLabel1[1]->SetTextJustify(kTextRight);
-    fLabel1[2]->SetTextJustify(kTextRight);
-    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]);
-    fList->Add(fLabel1[2]);
-    //f->AddFrame(fLabel1[0]);
-    //f->AddFrame(fLabel1[1]);
-    //f->AddFrame(fLabel1[2]);
-
-    fLabel2 = new TGLabel*[3];
-    fLabel2[0] = new TGLabel(f, "00000");
-    fLabel2[1] = new TGLabel(f, "000");
-    fLabel2[2] = new TGLabel(f, "000");
-    fLabel2[0]->SetTextJustify(kTextRight);
-    fLabel2[1]->SetTextJustify(kTextRight);
-    fLabel2[2]->SetTextJustify(kTextRight);
-    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]);
-    fList->Add(fLabel2[2]);
-    //f->AddFrame(fLabel2[0]);
-    //f->AddFrame(fLabel2[1]);
-    //f->AddFrame(fLabel2[2]);
-
-    fLabel3 = new TGLabel*[3];
-    fLabel3[0] = new TGLabel(f, "00000");
-    fLabel3[1] = new TGLabel(f, "000");
-    fLabel3[2] = new TGLabel(f, "000");
-    fLabel3[0]->SetTextJustify(kTextRight);
-    fLabel3[1]->SetTextJustify(kTextRight);
-    fLabel3[2]->SetTextJustify(kTextRight);
-    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]);
-    fList->Add(fLabel3[2]);
-    //f->AddFrame(fLabel3[0]);
-    //f->AddFrame(fLabel3[1]);
-    //f->AddFrame(fLabel3[2]);
+    fLabel1 = new TGLabel(f, "00000"); // Max: 16384
+    fLabel2 = new TGLabel(f, "00000");
+    fLabel3 = new TGLabel(f, "00000");
+    fLabel1->SetTextJustify(kTextRight);
+    fLabel2->SetTextJustify(kTextRight);
+    fLabel3->SetTextJustify(kTextRight);
+    fLabel1->Move(x, y+40);
+    fLabel2->Move(x, y+57);
+    fLabel3->Move(x, y+74);
+    fList->Add(fLabel1);
+    fList->Add(fLabel2);
+    fList->Add(fLabel3);
 
     l = new TGLabel(f, "Offset-Zd:");
@@ -250,5 +213,5 @@
     fAvailMac1 = new TGLabel(f, "- MAC1 -");
     fAvailMac2 = new TGLabel(f, "- MAC2 -");
-    fAvailMac3 = new TGLabel(f, "- MAC3 -");
+    //fAvailMac3 = new TGLabel(f, "- MAC3 -");
     fAvailSe1  = new TGLabel(f, "-SE/Zd1-");
     fAvailSe2  = new TGLabel(f, "-SE/Zd2-");
@@ -261,5 +224,5 @@
     fAvailMac1->SetBackgroundColor(color);
     fAvailMac2->SetBackgroundColor(color);
-    fAvailMac3->SetBackgroundColor(color);
+    //fAvailMac3->SetBackgroundColor(color);
     fAvailSe1->SetBackgroundColor(color);
     fAvailSe2->SetBackgroundColor(color);
@@ -281,5 +244,5 @@
     fAvailMac1->Move(10, 25+120);
     fAvailMac2->Move(10, 25+140);
-    fAvailMac3->Move(10, 25+160);
+    //fAvailMac3->Move(10, 25+160);
     fAvailSe1->Move(10, 25+180);
     fAvailSe2->Move(10, 25+200);
@@ -293,5 +256,5 @@
     fAvailMac1->Resize(60, 20);
     fAvailMac2->Resize(60, 20);
-    fAvailMac3->Resize(60, 20);
+    //fAvailMac3->Resize(60, 20);
     fAvailSe1->Resize(60, 20);
     fAvailSe2->Resize(60, 20);
@@ -305,5 +268,5 @@
     fList->Add(fAvailMac1);
     fList->Add(fAvailMac2);
-    fList->Add(fAvailMac3);
+    //fList->Add(fAvailMac3);
     fList->Add(fAvailSe1);
     fList->Add(fAvailSe2);
@@ -332,9 +295,11 @@
 
     int i=0;
-    while (!fin.eof())
+    while (1)
     {
         TString str;
         Double_t zd, az;
         fin >> str >> zd >> az;
+        if (!fin)
+            break;
         box->AddEntry(str, i++);
 
@@ -347,8 +312,10 @@
     TGCompositeFrame *tf1 = fTab->AddTab("Position");
     TGCompositeFrame *tf2 = fTab->AddTab("Track");
+#ifdef EXPERT
     TGCompositeFrame *tf4 = fTab->AddTab("Calib");
     TGCompositeFrame *tf5 = fTab->AddTab("Test SE");
     TGCompositeFrame *tf6 = fTab->AddTab("Gear");
-    /*TGCompositeFrame *tf3 =*/ fTab->AddTab("Demo");
+#endif
+    /*TGCompositeFrame *tf3 =*/// fTab->AddTab("Demo");
 
     fCZdAz = new MGCoordinates(tf1, kETypeZdAz);
@@ -362,7 +329,9 @@
     fList->Add(fCRaDec);
 
+#ifdef EXPERT
     fCCalib = new MGCoordinates(tf4, kETypeRaDec);
     fCCalib->Move(27, 105);
     fList->Add(fCCalib);
+#endif
 
     const int x=15;
@@ -372,7 +341,7 @@
     TGLabel *l1 = new TGLabel(tf1, "Move the telescope to a position given in");
     TGLabel *l2 = new TGLabel(tf1, "local coordinates. The given coordinates");
-    TGLabel *l3 = new TGLabel(tf1, "are pointing coordinates, which means that the");
-    TGLabel *l4 = new TGLabel(tf1, "coordinates are corrected for the bending of");
-    TGLabel *l5 = new TGLabel(tf1, "the telescope."); 
+    TGLabel *l3 = new TGLabel(tf1, "are pointing coordinates. Enter the coordinates");
+    TGLabel *l4 = new TGLabel(tf1, "manually or choose a predefined position");
+    TGLabel *l5 = new TGLabel(tf1, "from the combobox below.");
     l1->Move(x, y);
     l2->Move(x, y+h);
@@ -396,8 +365,10 @@
     fList->Add(l3);
 
+#ifdef EXPERT
     l1 = new TGLabel(tf4, "Start the calibration using the Start button.");
     l2 = new TGLabel(tf4, "Write a coordinate pair to a TPoint file using");
-    l3 = new TGLabel(tf4, "the TPoint button. To set the Shaftencoder offset");
-    l4 = new TGLabel(tf4, "use the Calib SE button.");
+    l3 = new TGLabel(tf4, "the TPoint button.");
+    //l3 = new TGLabel(tf4, "the TPoint button. To set the Shaftencoder offset");
+    //l4 = new TGLabel(tf4, "use the Calib SE button.");
     l1->Move(x, y);
     l2->Move(x, y+h);
@@ -425,4 +396,5 @@
     l1->Move(x, y);
     fList->Add(l1);
+#endif
 
     //
@@ -465,11 +437,19 @@
     fList->Add(but);
 
-    but = new TGTextButton(tf1, "Home", kPB_HOME);
-    but->Resize(80, 25);
-    but->Move(160, 197);
-    but->SetToolTipText("Initiate Home Drive.");
+    but = new TGTextButton(tf1, "Move'n'Track", kPB_TRACKPOS);
+    but->Resize(100, 25);
+    but->Move(25, 242);
+    but->SetToolTipText("Move telescope to a Zd/Az position and start tracking.");
     but->Associate(this);
     fList->Add(but);
 
+    but= new TGTextButton(tf2, "Calc Zd/Az",  kPB_CALCALTAZ);
+    but->Resize(80, 25);
+    but->Move(165, 197);
+    but->SetToolTipText("Calculate Zd/Az corresponding to Ra/Dec.");
+    but->Associate(this);
+    fList->Add(but);
+
+#ifdef EXPERT
     but = new TGTextButton(tf5, "Display", kPB_DISPLAY1);
     but->Resize(80, 25);
@@ -486,18 +466,5 @@
     fList->Add(but);
 
-    but= new TGTextButton(tf2, "Calc Zd/Az",  kPB_CALCALTAZ);
-    but->Resize(80, 25);
-    but->Move(165, 197);
-    but->SetToolTipText("Calculate Zd/Az corresponding to Ra/Dec.");
-    but->Associate(this);
-    fList->Add(but);
-
-    but = new TGTextButton(tf4, "TPoint", kPB_TPOINT);
-    but->Resize(80, 25);
-    but->Move(25, 190);
-    but->SetToolTipText("Trigger writing a tpoint coordinate pair.");
-    but->Associate(this);
-    fList->Add(but);
-
+    /*
     but = new TGTextButton(tf4, "Calib SE", kPB_CALIBSE);
     but->Resize(80, 25);
@@ -506,8 +473,8 @@
     but->Associate(this);
     fList->Add(but);
-
+    */
     but = new TGTextButton(tf4, "Load", kPB_LoadBending);
     but->Resize(80, 25);
-    but->Move(25, 220);
+    but->Move(25, 190);
     but->SetToolTipText("Load bending corrections from file 'bending.txt'");
     but->Associate(this);
@@ -516,8 +483,16 @@
     but = new TGTextButton(tf4, "Reset", kPB_ResetBending);
     but->Resize(80, 25);
-    but->Move(25, 250);
+    but->Move(25, 220);
     but->SetToolTipText("Reset bending correction (coefficients=0)");
     but->Associate(this);
     fList->Add(but);
+
+    but = new TGTextButton(tf4, "TPoint", kPB_TPOINT);
+    but->Resize(80, 25);
+    but->Move(25, 250);
+    but->SetToolTipText("Trigger writing a tpoint coordinate pair.");
+    but->Associate(this);
+    fList->Add(but);
+#endif
 
     ULong_t color;
@@ -958,4 +933,7 @@
                     ZdAz soll, UInt_t stat, UInt_t stat2)
 {
+    // acc [rad]
+    acc *= kRad2Deg;   // [deg]
+
     double mjd = UpdateTime();
     fSkyPosition->Update(pos, mjd);
@@ -984,5 +962,5 @@
     SetLabelColor(fAvailMac1, stat2&0x01);
     SetLabelColor(fAvailMac2, stat2&0x02);
-    SetLabelColor(fAvailMac3, stat2&0x04);
+    //SetLabelColor(fAvailMac3, stat2&0x04);
     SetLabelColor(fAvailSe1,  stat2&0x08);
     SetLabelColor(fAvailSe2,  stat2&0x10);
@@ -1033,4 +1011,19 @@
 }
 
+void MGCosy::StartTrackPos()
+{
+    cout << "Start tracking Zd/Az pos." << endl;
+
+    const XY &xy = fCZdAz->GetCoordinates();
+
+    ZdAz za(xy.X(), xy.Y());
+
+    cout << za.Zd() << "\xb0 " << za.Az() << "\xb0" << endl;
+
+    fQueue->PostMsg(WM_TRACKPOS, &za, sizeof(za));
+
+    cout << "PostMsg (WM_TrackPos) returned." << endl;
+}
+
 void MGCosy::StartPos()
 {
@@ -1050,4 +1043,5 @@
 // ************************** For demo purpose **********************
 //
+/*
 #include <TRandom.h>
 class MDemo : public MThread
@@ -1068,29 +1062,15 @@
             Timer tm;
             tm.Now();
-            /*
-            Float_t h = 2.+tm.H()+(10.7+tm.M())/60.;
-            RaDec dest(h*15, 129.7);
-
-            cout << dest.Ra()/15 << "h " << dest.Dec() << "°" << endl;
-
-            fQueue->PostMsg(WM_TRACK, &dest, sizeof(dest));
+
+            //fQueue->PostMsg(WM_STOP, 0, 0);
+
+            ZdAz dest1((float)fRand.Integer(120)-60., 0);//fRand.Integer(25)+90);
+
+            cout << "Demo: Zd=" << dest1.Zd() << "° Az=" << dest1.Az() << "°" << endl;
+
+            fQueue->PostMsg(WM_POSITION, &dest1, sizeof(dest1));
 
             int i = 0;
-            while (!HasStopFlag() && i++<60)  // 2.5min
-            usleep(1000000);
-            if (HasStopFlag())
-                break;
-            */
-
-            //fQueue->PostMsg(WM_STOP, 0, 0);
-
-            ZdAz dest1((float)fRand.Integer(120)-60., 0);//fRand.Integer(25)+90);
-
-            cout << "Demo: Zd=" << dest1.Zd() << "° Az=" << dest1.Az() << "°" << endl;
-
-            fQueue->PostMsg(WM_POSITION, &dest1, sizeof(dest1));
-
-            int i = 0;
-            while (!HasStopFlag() && i++<5/*5*/)  // 30s
+            while (!HasStopFlag() && i++<5)  // 30s
                 usleep(1000000);
             if (HasStopFlag())
@@ -1099,9 +1079,4 @@
             //ZdAz dest2(5, 30);
             //fQueue->PostMsg(WM_POSITION, &dest2, sizeof(dest2));
-            /*
-            i = 0;
-            while (!HasStopFlag() && i++<30)  // 30s
-                usleep(1000000);
-            */
             //if (HasStopFlag())
             //    break;
@@ -1129,5 +1104,6 @@
     demo.Stop();
 }
-
+*/
+/*
 void MGCosy::StartCalib()
 {
@@ -1141,5 +1117,5 @@
     cout << "PostMsg (WM_Calib) returned." << endl;
 }
-
+*/
 void MGCosy::StartTPoint()
 {
@@ -1213,7 +1189,9 @@
                     fQueue->Proc(WM_GEAR, (void*)1);
                     return kTRUE;
+                    /*
                 case 5:
                     StartDemo();
                     return kTRUE;
+                    */
                 }
                 return kTRUE;
@@ -1221,5 +1199,5 @@
             case kPB_STOP:
                 cout << "Sending stop movement msg." << endl;
-                StopDemo();
+                //StopDemo();
                 fQueue->PostMsg(WM_STOP, 0, 0);
                 if (fTab->GetCurrent()==3)
@@ -1270,7 +1248,9 @@
                 StartTPoint();
                 return kTRUE;
+                /*
             case kPB_CALIBSE:
                 StartCalib();
                 return kTRUE;
+                */
             case kPB_LoadBending:
                 fQueue->Proc(WM_LOADBENDING, NULL);
@@ -1279,6 +1259,11 @@
                 fQueue->Proc(WM_RESETBENDING, NULL);
                 return kTRUE;
+                /*
             case kPB_HOME:
                 fQueue->PostMsg(WM_HOME, 0, 0);
+                return kTRUE;
+                */
+            case kPB_TRACKPOS:
+                StartTrackPos();
                 return kTRUE;
             case kPB_DISPLAY1:
Index: trunk/MagicSoft/Cosy/gui/MGCosy.h
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGCosy.h	(revision 1819)
+++ trunk/MagicSoft/Cosy/gui/MGCosy.h	(revision 1953)
@@ -49,7 +49,7 @@
     MGList        *fList;
 
-    TGLabel      **fLabel1;
-    TGLabel      **fLabel2;
-    TGLabel      **fLabel3;
+    TGLabel       *fLabel1;
+    TGLabel       *fLabel2;
+    TGLabel       *fLabel3;
 
     TGLabel       *fOffsetZd;
@@ -104,6 +104,7 @@
     void StartPos();
     void StartTrack();
+    void StartTrackPos();
     void StartDemo();
-    void StartCalib();
+    //void StartCalib();
     void StartTPoint();
 
@@ -121,7 +122,7 @@
     void CloseWindow();
 
-    TGLabel **GetLabel1() const { return fLabel1; }
-    TGLabel **GetLabel2() const { return fLabel2; }
-    TGLabel **GetLabel3() const { return fLabel3; }
+    TGLabel *GetLabel1() const { return fLabel1; }
+    TGLabel *GetLabel2() const { return fLabel2; }
+    TGLabel *GetLabel3() const { return fLabel3; }
 
     TGListBox *GetLog() const { return fLog; }
Index: trunk/MagicSoft/Cosy/gui/MGStarguider.cc
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGStarguider.cc	(revision 1819)
+++ trunk/MagicSoft/Cosy/gui/MGStarguider.cc	(revision 1953)
@@ -74,4 +74,5 @@
     IDM_kLimMag9,
     IDM_kPixSize,
+    IDM_kAngle,
     IDM_kInterpol125,
     IDM_kInterpol25,
@@ -217,4 +218,5 @@
     fWriteType->AddEntry("&Once",      IDM_kOnce);
     fWriteType->AddEntry("&Continous", IDM_kContinous);
+    fWriteType->CheckEntry(IDM_kOnce);
     fWriteType->Associate(this);
     fList->Add(fWriteType);
@@ -334,5 +336,11 @@
     l = new TGLabel(this, "arcsec/pix");
     l->SetTextJustify(kTextLeft);
-    l->Move(605, fMenu->GetDefaultHeight()+619);
+    l->Move(605, fMenu->GetDefaultHeight()+619+13);
+    AddFrame(l);
+    fList->Add(l);
+
+    l = new TGLabel(this, "deg");
+    l->SetTextJustify(kTextLeft);
+    l->Move(605, fMenu->GetDefaultHeight()+619-10);
     AddFrame(l);
     fList->Add(l);
@@ -347,4 +355,5 @@
 
     fSao->SetPixSize(pixsize/3600);
+    fSao->SetRotationAngle(0);
 
     TString txt;
@@ -353,7 +362,13 @@
     fPixSize = new TGTextEntry(this, txt, IDM_kPixSize);
     fPixSize->SetAlignment(kTextCenterX);
-    fPixSize->Move(547, fMenu->GetDefaultHeight()+617);
+    fPixSize->Move(547, fMenu->GetDefaultHeight()+617+13);
     AddFrame(fPixSize);
     fList->Add(fPixSize);
+
+    fAngle = new TGTextEntry(this, "         0", IDM_kAngle);
+    fAngle->SetAlignment(kTextCenterX);
+    fAngle->Move(547, fMenu->GetDefaultHeight()+617-10);
+    AddFrame(fAngle);
+    fList->Add(fAngle);
 
     // TGHorizontal3DLine *fLineSep = new TGHorizontal3DLine(this);
@@ -582,9 +597,21 @@
     case kC_TEXTENTRY:
         if (GET_SUBMSG(msg)==kTE_ENTER)
-        {
-            const Float_t pixsize = atof(fPixSize->GetText());
-            cout << "Pixel Size changed to " << pixsize << "\"/pix" << endl;
-            fSao->SetPixSize(pixsize/3600);
-        }
+            switch (mp1)
+            {
+            case IDM_kPixSize:
+                {
+                    const Float_t pixsize = atof(fPixSize->GetText());
+                    cout << "Pixel Size changed to " << pixsize << "\"/pix" << endl;
+                    fSao->SetPixSize(pixsize/3600);
+                    return kTRUE;
+                }
+            case IDM_kAngle:
+                {
+                    const Float_t angle = atof(fAngle->GetText());
+                    cout << "Rotation Angle changed to " << angle << "deg" << endl;
+                    fSao->SetRotationAngle(angle);
+                    return kTRUE;
+                }
+            }
         return kTRUE;
 
@@ -896,9 +923,11 @@
     AltAz pos1 = fSao->CalcAltAzFromPix(768/2+g.GetMean(1), 576/2+g.GetMean(2))*kRad2Deg;
 
+    ofstream fout1("pointingpos.txt");
+    fout1 << setprecision(10) << fSao->GetMjd()-52000 << " " << -pos1.Alt() << " " << pos1.Az() << endl;
+
     pos1 -= pos0;
 
-    ofstream fout("tracking_error.txt");
-    fout << setprecision(10) << fSao->GetMjd()-52000 << " " << -pos1.Alt() << " " << pos1.Az() << endl;
-    fout.close();
+    ofstream fout2("tracking_error.txt");
+    fout2 << setprecision(10) << fSao->GetMjd()-52000 << " " << -pos1.Alt() << " " << pos1.Az() << endl;
 
     return ZdAz(-pos1.Alt(), pos1.Az());
@@ -1172,5 +1201,9 @@
     fDy = dy;
 
-    cout << "New coordinates for zoom: " << fDx << " " << fDy << endl;
+    fSao->Now();
+    AltAz aa = fSao->CalcAltAzFromPix(fDx, fDy)*kRad2Deg;
+
+    cout << "New coordinates for zoom - x, y   : " << fDx << " " << fDy << endl;
+    cout << "New coordinates for zoom - Alt, az: " << aa.Alt() << " " << aa.Az() << endl;
 
     return kTRUE;
Index: trunk/MagicSoft/Cosy/gui/MGStarguider.h
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGStarguider.h	(revision 1819)
+++ trunk/MagicSoft/Cosy/gui/MGStarguider.h	(revision 1953)
@@ -89,4 +89,5 @@
 
     TGTextEntry   *fPixSize;
+    TGTextEntry   *fAngle;
 
     StarCatalog   *fSao;
