Index: trunk/MagicSoft/Cosy/gui/MGCosy.cc
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGCosy.cc	(revision 1273)
+++ trunk/MagicSoft/Cosy/gui/MGCosy.cc	(revision 1275)
@@ -206,4 +206,5 @@
     TGCompositeFrame *tf1 = fTab->AddTab("Position Zd/Az");
     TGCompositeFrame *tf2 = fTab->AddTab("Track Ra/Dec");
+    TGCompositeFrame *tf3 = fTab->AddTab("Demo Mode");
 
     fCZdAz = new MGCoordinates(tf1, kETypeZdAz);
@@ -467,4 +468,5 @@
     cout << "Closing window - waiting until all nodes are stopped." << endl;
     fQueue->PostMsg(WM_QUIT, 0, 0);
+    cout << "Closing window - done." << endl;
     // gApplication->Terminate(0);
 }
@@ -497,4 +499,89 @@
     cout << "PostMsg (WM_Position) returned." << endl;
 }
+
+//
+// ************************** For demo purpose **********************
+//
+#include <TRandom.h>
+class MDemo : public MThread
+{
+private:
+    MsgQueue *fQueue;
+    TRandom  fRand;
+
+public:
+    MDemo() : MThread(false) {}
+
+    void SetQueue(MsgQueue *q) { fQueue = q; }
+
+    virtual void *Thread()
+    {
+        while (1)
+        {
+            Timer tm;
+            tm.Now();
+
+            Float_t h = 2.+tm.H()+(8.+tm.M())/60.;
+            RaDec dest(h*15, 130);
+
+            cout << dest.Ra()/15 << "h " << dest.Dec() << "°" << endl;
+
+            fQueue->PostMsg(WM_TRACK, &dest, sizeof(dest));
+
+            int i = 0;
+            while (!HasStopFlag() && i++<130)  // 2.5min
+                usleep(1000000);
+            if (HasStopFlag())
+                break;
+
+            //fQueue->PostMsg(WM_STOP, 0, 0);
+
+            ZdAz dest1(fRand.Integer(56)+5, fRand.Integer(360));
+
+            cout << "Demo: Zd=" << dest1.Zd() << "° Az=" << dest1.Az() << "°" << endl;
+
+            fQueue->PostMsg(WM_POSITION, &dest1, sizeof(dest1));
+
+            i = 0;
+            while (!HasStopFlag() && i++<30)  // 30s
+                usleep(1000000);
+            if (HasStopFlag())
+                break;
+
+            //ZdAz dest2(5, 30);
+            //fQueue->PostMsg(WM_POSITION, &dest2, sizeof(dest2));
+            /*
+            i = 0;
+            while (!HasStopFlag() && i++<30)  // 30s
+                usleep(1000000);
+            */
+            //if (HasStopFlag())
+            //    break;
+        }
+        cout << "Demo Thread: done." << endl;
+        return NULL;
+    }
+};
+
+MDemo demo;
+
+void MGCosy::StartDemo()
+{
+    cout << "Start Demo." << endl;
+
+    demo.SetQueue(fQueue);
+    demo.Start();
+
+    cout << "PostMsg (WM_Demo) returned." << endl;
+}
+
+void StopDemo()
+{
+    cout << "Stopping demo." << endl;
+    demo.Stop();
+}
+//
+// ******************************************************************
+//
 
 Bool_t MGCosy::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2)
@@ -526,10 +613,23 @@
              */
             case kPB_START:
-                fTab->GetCurrent() ? StartTrack() : StartPos();
+                switch (fTab->GetCurrent())
+                {
+                case 0:
+                    StartPos();
+                    return kTRUE;
+                case 1:
+                    StartTrack();
+                    return kTRUE;
+                case 2:
+                    StartDemo();
+                    return kTRUE;
+                }
                 return kTRUE;
 
             case kPB_STOP:
                 cout << "Sending stop movement msg." << endl;
+                StopDemo();
                 fQueue->PostMsg(WM_STOP, 0, 0);
+
                 cout << "PostMsg (WM_Stop) returned." << endl;
                 return kTRUE;
@@ -563,5 +663,7 @@
             {
             case IDM_EXIT:
+                cout << "IDM_EXIT: Posting WM_QUIT." << endl;
                 fQueue->PostMsg(WM_QUIT, 0, 0);
+                cout << "IDM_EXIT: WM_QUIT done." << endl;
                 //cout << "Idm_Exit." << endl;
                 //CloseWindow();
Index: trunk/MagicSoft/Cosy/gui/MGCosy.h
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGCosy.h	(revision 1273)
+++ trunk/MagicSoft/Cosy/gui/MGCosy.h	(revision 1275)
@@ -73,4 +73,5 @@
     void StartPos();
     void StartTrack();
+    void StartDemo();
 
     void EnableLabel(TGLabel *label, Bool_t stat);
Index: trunk/MagicSoft/Cosy/gui/MGEmbeddedCanvas.cc
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGEmbeddedCanvas.cc	(revision 1273)
+++ trunk/MagicSoft/Cosy/gui/MGEmbeddedCanvas.cc	(revision 1275)
@@ -6,4 +6,6 @@
 
 #include "MGEmbeddedCanvas.h"
+
+#include <iostream.h>
 
 #include <TList.h>
@@ -17,11 +19,19 @@
       fModified(kFALSE), fWidth(width), fRange(range), fPix(2.*range/width)
 {
+    cout << "MGEmbeddedCanvas: Initializing." << endl;
     fCanvas = GetCanvas();
 
+    cout << "MGEmbeddedCanvas: fCanvas = 0x" << fCanvas << endl;
+
+    cout << "MGEmbeddedCanvas: SetFillColor." << endl;
     fCanvas->SetFillColor(39); // s. TAttFill
-    fCanvas->Range(-fRange, -fRange, fRange, fRange);
+    cout << "MGEmbeddedCanvas: fRange=" << fRange << endl;
+    if (fRange>0)
+        fCanvas->Range(-fRange, -fRange, fRange, fRange);
 
     fList = new TList;
     fList->SetOwner();
+
+    cout << "MGEmbeddedCanvas: Initializing done." << endl;
 }
 
Index: trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc	(revision 1273)
+++ trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc	(revision 1275)
@@ -208,5 +208,5 @@
 {
     RaDec rd(radec.Ra()+off*360/24*kDeg2Rad, radec.Dec());
-    ZdAz zdaz = fSlaStar->CalcZdAz(rd);
+    ZdAz zdaz = fSlaStar->CalcZdAzFast(rd);
 
     const float s = sin(zdaz.Az());
@@ -319,5 +319,5 @@
     UpdatePlanet(kEMars,    fMars);
 
-    RaDec radec = fSlaStar->CalcRaDec(pos*kDeg2Rad);
+    RaDec radec = fSlaStar->CalcRaDecFast(pos*kDeg2Rad);
 
     UpdatePosition(radec, pos.Zd(), pos.Az());
