Index: /trunk/MagicSoft/Cosy/Makefile
===================================================================
--- /trunk/MagicSoft/Cosy/Makefile	(revision 8829)
+++ /trunk/MagicSoft/Cosy/Makefile	(revision 8830)
@@ -19,10 +19,11 @@
 
 #
-PROGRAMS = cosy readcam
-SOLIB    = cosy.so
+PROGRAMS = cosy readcam telesto
+SOLIB    = libcosy.so
 CINT     = M
 MARS_LIB = libmars.so
 
-INCLUDES = -I. -Imain -Imars -Ibase -Icandrv -Iincl -Ivideodev -Igui -Imvideo -Itcpip
+INCLUDES = -I. -Imain -Imars -Ibase -Icandrv -Iincl -Ivideodev \
+ 	   -Igui -Imvideo -Itcpip -Itpoint
 
 #
@@ -47,5 +48,6 @@
           tcpip \
           videodev \
-          mvideo
+          mvideo \
+          tpoint
 
 #LIBRARIES = $(SUBDIRS:%=lib/lib%.a)
Index: /trunk/MagicSoft/Cosy/base/MThread.cc
===================================================================
--- /trunk/MagicSoft/Cosy/base/MThread.cc	(revision 8829)
+++ /trunk/MagicSoft/Cosy/base/MThread.cc	(revision 8830)
@@ -1,177 +1,27 @@
 #include <MThread.h>
-
-#include <iostream>
-
-#include <pthread.h>
-#include <sys/resource.h>  // PRIO_PROCESS
-
-#undef DEBUG
-//#define DEBUG
 
 using namespace std;
 
-// ----------------------------------------------------------------------
-//
-// Constructor
-//
-// Starts the derived thread if you don't specify false.
-//
-MThread::MThread(bool start, int prio) : fIsRunning(false), fIsDetached(false), fThread(NULL), fReturn(NULL)
+TString MyThreadX::GetThreadStateStr() const
 {
-#ifdef DEBUG
-    cout << "MThread::MThread" << endl;
-#endif
-    if (!start)
-        return;
-
-    SetPriority(prio);
-    Start();
+    switch (fThread.GetState())
+    {
+    case TThread::kInvalidState:
+        return "Invalid - thread was not created properly";
+    case TThread::kNewState:
+        return "New - thread object exists but hasn't started";
+    case TThread::kRunningState:
+        return "Running - thread is running";
+    case TThread::kTerminatedState:
+        return "Terminated - thread has terminated but storage has not yet been reclaimed (i.e. waiting to be joined)";
+    case TThread::kFinishedState:
+        return "Finished - thread has finished";
+    case TThread::kCancelingState:
+        return "Canceling - thread in process of canceling";
+    case TThread::kCanceledState:
+        return "Canceled - thread has been canceled";
+    case TThread::kDeletingState:
+        return "Deleting - thread in process of deleting";
+    };
+    return "Unknown";
 }
-
-// ----------------------------------------------------------------------
-//
-// Destructor
-//
-// Stops the derived thread if it is still running.
-//
-MThread::~MThread()
-{
-#ifdef DEBUG
-    cout << "~MThread::MThread" << endl;
-#endif
-    Stop();
-}
-
-// ----------------------------------------------------------------------
-//
-// Detach the derived thread. This means, that if the thread ends the
-// needed resources (eg. for storing the return code) are freed.
-// In other word you cannot get any value back from the Thread.
-//
-void MThread::Detach()
-{
-    if (fIsRunning)
-        pthread_detach(*fThread);
-
-    fIsDetached = true;
-}
-
-// ----------------------------------------------------------------------
-//
-// Sets the priority of the thread.
-//  -20 highest priority
-//    0 standard
-//  +20 lowest priority
-// This can only be done before the thread is started.
-//
-bool MThread::SetPriority(int prio)
-{
-    if (fIsRunning)
-        return false;
-
-    fPriority = prio;
-    return true;
-}
-
-// ----------------------------------------------------------------------
-//
-// Now we are back in a class instance, but running in new thread.
-// All class members can be accessed like before.
-// Set the flag for a running thread. Check if the thread should get
-// detached. Set the priority of the thread. Now reset the stop flag and
-// execute the thread. After the thread stopped it's execution reset the
-// running flag and exit.
-//
-void *MThread::RunThread()
-{
-    fIsRunning = true;
-
-    if (fIsDetached)
-        pthread_detach(pthread_self());
-
-    setpriority(PRIO_PROCESS, 0, fPriority); //lowest priority
-
-    fStop = false;
-
-#ifdef DEBUG
-    cout << "MThread::RunThread" << endl;
-#endif
-
-    void *rc = Thread();
-
-#ifdef DEBUG
-    cout << "MThread::RunThread...done." << endl;
-#endif
-
-    fIsRunning = false;
-
-    return rc;
-}
-
-// ----------------------------------------------------------------------
-//
-// Get the Instance back from the thread argument and call the
-// RunThread member function, which handles all MThread bspecific stuff.
-//
-void *MThread::MapThread(void *arg)
-{
-    MThread *thread = (MThread*)arg;
-#ifdef DEBUG
-    cout << "MThread::MapThread" << endl;
-#endif
-    return thread->RunThread();
-}
-
-// ----------------------------------------------------------------------
-//
-// A thread is created and started (MapThread).
-// As an argument the actual instance is used.
-//
-void MThread::Start()
-{
-    fThread = new pthread_t;
-    pthread_create(fThread, NULL, MapThread, this);
-}
-
-// ----------------------------------------------------------------------
-//
-// Check if a thread is existing and running.
-// If the thread is detached, cancel the thread. Otherwise set the stop
-// flag and wait for the thread to exit.
-//
-void MThread::Stop()
-{
-#ifdef DEBUG
-    cout << "MThread::Stop: fThread=" << fThread << ", fIsRunning=" << (int)fIsRunning << endl;
-#endif
-
-    if (!fThread || !fIsRunning)
-        return;
-
-    if (fIsDetached)
-    {
-#ifdef DEBUG
-        cout << "Stopping detached thread..." << flush;
-#endif
-        pthread_cancel(*fThread);
-        fIsRunning = false;
-    }
-    else
-    {
-#ifdef DEBUG
-        cout << "Stopping thread..." << flush;
-#endif
-        fStop = true;
-        pthread_join(*fThread, &fReturn);
-    }
-#ifdef DEBUG
-    cout << "done." << endl;
-#endif
-
-    delete fThread;
-    fThread = NULL;
-
-#ifdef DEBUG
-    cout << "MThread::Stop() done." << endl;
-#endif
-}
Index: /trunk/MagicSoft/Cosy/base/MThread.h
===================================================================
--- /trunk/MagicSoft/Cosy/base/MThread.h	(revision 8829)
+++ /trunk/MagicSoft/Cosy/base/MThread.h	(revision 8830)
@@ -1,40 +1,103 @@
-#ifndef COSY_MThread
-#define COSY_MThread
+#ifndef MARS_MThread
+#define MARS_MThread
 
-#ifdef __CINT__
-typedef unsigned long int pthread_t;
-#else
-#include <pthread.h>
+#ifndef ROOT_TThread
+#include <TThread.h>
 #endif
 
-class MThread
+/*
+class MyThread : public TThread
+{
+    friend class MyThreadX;
+
+private:
+
+    virtual Int_t Thread() = 0;
+    static void *MapThread(void *arg)
+    {
+        // GetPriority();     High: -1 - -20, Norm: 0, Low: 1-20
+        // pthread_setschedprio(SelfId(), priority);
+        // 0: ok,
+
+        MyThread *th = (MyThread*)arg;
+        return (void*)th->Thread();
+    }
+
+public:
+    MyThread(EPriority pri = kNormalPriority)
+        : TThread(MapThread, this, pri) { }
+    MyThread(const char *thname, EPriority pri = kNormalPriority)
+        : TThread(thname, MapThread, this, pri) { }
+};
+*/
+
+class MyThreadX
 {
 private:
-    bool fIsRunning;
-    bool fIsDetached;
-    bool fStop;
+    TThread fThread;
 
-    pthread_t *fThread;
+    Int_t fNumCleanups;
 
-    void *fReturn;
+    virtual void CleanUp() { }
+    static void MapCleanUp(void *arg)
+    {
+        MyThreadX *th = (MyThreadX*)arg;
+        th->CleanUp();
+    }
 
-    int fPriority;
+    virtual Int_t Thread() = 0;
+    static void *MapThread(void *arg)
+    {
+        // GetPriority();     High: -1 - -20, Norm: 0, Low: 1-20
+        // pthread_setschedprio(SelfId(), priority);
+        // 0: ok,
 
-    static void *MapThread(void *arg);
-    void *RunThread();
-    virtual void *Thread() = 0;
+        TThread::CleanUpPush((void*)&MapCleanUp, arg);
+
+        MyThreadX *th = (MyThreadX*)arg;
+        return (void*)th->Thread();
+    }
 
 public:
-    MThread(bool start=true, int prio=0);
-    virtual ~MThread();
+    MyThreadX(TThread::EPriority pri = TThread::kNormalPriority)
+        : fThread(MapThread, this, pri), fNumCleanups(0) { }
+    MyThreadX(const char *thname, TThread::EPriority pri = TThread::kNormalPriority)
+        : fThread(thname, MapThread, this, pri), fNumCleanups(0) { }
+    virtual ~MyThreadX() { }
 
-    bool SetPriority(int prio);
+//        Int_t            Kill() { return fThread.Kill(); }
+        Int_t            RunThread(void *arg = 0) { return fThread.Run(); }
+//    void             SetPriority(EPriority pri)
+//    void             Delete(Option_t *option="") { TObject::Delete(option); }
+//    EPriority        GetPriority() const { return fPriority; }
+        TThread::EState  GetThreadState() const { return fThread.GetState(); }
+        Long_t           GetThreadId() const { return fThread.GetId(); }
+//        Long_t           Join(void **ret = 0) { return fThread.Join(ret); }
 
-    void Detach();
+        TString GetThreadStateStr() const;
 
-    void Start();
-    void Stop();
+        Bool_t IsThreadRunning()  const { return fThread.GetState()==TThread::kRunningState; }
+        Bool_t IsThreadCanceled() const { return fThread.GetState()==TThread::kCancelingState; }
 
-    bool HasStopFlag() const { return fStop; }
+        // Send cancel request and wait for cancellation
+        // 13 is returned if thread is not running,
+        // the return code of Join otherwise
+        Int_t CancelThread(void **ret = 0) {
+            const Int_t rc = fThread.Kill();
+            if (rc==13) // Thread not running
+                return rc;
+            return fThread.Join(ret);
+        }
+
+        // This is a version of usleep which is a cancel point
+        static void Sleep(UInt_t us)
+        {
+            TThread::SetCancelOn();
+            usleep(us);
+            TThread::SetCancelOff();
+        }
+
+
+//   ClassDef(MyThreadX,0)  // Thread class
 };
 
Index: /trunk/MagicSoft/Cosy/base/coord.h
===================================================================
--- /trunk/MagicSoft/Cosy/base/coord.h	(revision 8829)
+++ /trunk/MagicSoft/Cosy/base/coord.h	(revision 8830)
@@ -2,163 +2,7 @@
 #define COORD_H
 
-#include <math.h>          // floor
-#include <iostream>
+#ifndef MARS_MPointing
+#include "MPointing.h"
+#endif
 
-#include "MAGIC.h"
-
-/* pi/180:  degrees to radians */
-const double kDeg2Rad = 0.017453292519943295769236907684886127134428718885417;
-
-/* 180/pi:  radians to degrees */
-//const double kRad2Deg = 57.295779513082320876798154814105170332405472466564;
-
-/* pi/2:  90 degrees in radians */
-const double kPiDiv2 = 1.5707963267948966192313216916397514420985846996876;
-
-/* 2pi */
-const double k2Pi = 6.2831853071795864769252867665590057683943387987502;
-
-class Deg
-{
-protected:
-    double fDeg;
-
-public:
-    Deg(const double d) : fDeg(d) {}
-    Deg(const Deg &c) { fDeg = c.fDeg; }
-
-    void Set(double d) { fDeg=d; }
-
-    double operator()() { return fDeg; }
-
-    operator double() const { return fDeg*kDeg2Rad; }
-};
-
-class XY
-{
-    friend istream& operator>>(istream &in, XY &xy);
-    friend ostream& operator<<(ostream &in, XY &xy);
-
-protected:
-    double fX;
-    double fY;
-
-public:
-    XY(double x=0, double y=0) : fX(x), fY(y) {}
-    XY(const XY &c) { fX = c.fX; fY = c.fY; }
-
-    void Set(double x, double y) { fX=x; fY=y; }
-
-    double X() const { return fX; }
-    double Y() const { return fY; }
-
-    void X(double x) { fX=x; }
-    void Y(double y) { fY=y; }
-
-    void operator/=(double c) { fX/=c; fY/=c; }
-    void operator*=(double c) { fX*=c; fY*=c; }
-
-    XY operator/(double c) const { return XY(fX/c, fY/c); }
-    XY operator*(double c) const { return XY(fX*c, fY*c); }
-    XY operator*(const XY &c) const { return XY(fX*c.fX, fY*c.fY); }
-    XY operator/(const XY &c) const { return XY(fX/c.fX, fY/c.fY); }
-    XY operator+(const XY &c) const { return XY(fX+c.fX, fY+c.fY); }
-    XY operator-(const XY &c) const { return XY(fX-c.fX, fY-c.fY); }
-    XY operator-() const { return XY(-fX, -fY); }
-
-    double Sqr()   const { return fX*fX + fY*fY; }
-    double Sqrt()  const { return sqrt(Sqr()); }
-    double Ratio() const { return fX/fY; }
-    void Round()         { fX=(int)(floor(fX+.5)); fY=(int)(floor(fY+.5)); }
-};
-
-inline std::istream& operator>>(std::istream &in,  XY &xy) { in  >> xy.fX; in  >> xy.fY; return in; }
-inline std::ostream& operator<<(std::ostream &out, const XY &xy) { out << xy.X() << " " << xy.Y(); return out; }
-
-class AltAz : public XY
-{
-public:
-    AltAz(double alt=0, double az=0) : XY(alt, az) {}
-
-    double Alt() const { return fX; }
-    double Az()  const { return fY; }
-
-    void operator*=(double c) { fX*=c; fY*=c; }
-    void operator/=(double c) { fX*=c; fY*=c; }
-
-    void Alt(double d) { fX=d; }
-    void Az(double d)  { fY=d; }
-    void operator*=(const XY &c)    { fX*=c.X(); fY*=c.Y(); }
-    void operator/=(const XY &c)    { fX/=c.X(); fY/=c.Y(); }
-    void operator-=(const AltAz &c) { fX-=c.fX; fY-=c.fY; }
-    void operator+=(const AltAz &c) { fX+=c.fX; fY+=c.fY; }
-
-    AltAz operator/(double c) const { return AltAz(fX/c, fY/c); }
-    AltAz operator*(double c) const { return AltAz(fX*c, fY*c); }
-    AltAz operator*(const XY &c) const { return AltAz(fX*c.X(), fY*c.Y()); }
-    AltAz operator/(const XY &c) const { return AltAz(fX/c.X(), fY/c.Y()); }
-    AltAz operator+(const AltAz &c) const { return AltAz(fX+c.fX, fY+c.fY); }
-    AltAz operator-(const AltAz &c) const { return AltAz(fX-c.fX, fY-c.fY); }
-    AltAz operator-() const { return AltAz(-fX, -fY); }
-};
-
-class ZdAz : public XY
-{
-public:
-    ZdAz(double zd=0, double az=0) : XY(zd, az) {}
-    ZdAz(const ZdAz &c) : XY(c) {}
-
-    void operator*=(double c) { fX*=c; fY*=c; }
-    void operator/=(double c) { fX*=c; fY*=c; }
-
-    double Zd() const { return fX; }
-    double Az() const { return fY; }
-
-    void Zd(double d) { fX=d; }
-    void Az(double d) { fY=d; }
-    void operator*=(const XY &c)   { fX*=c.X(); fY*=c.Y(); }
-    void operator/=(const XY &c)   { fX/=c.X(); fY/=c.Y(); }
-    void operator-=(const ZdAz &c) { fX-=c.fX; fY-=c.fY; }
-    void operator+=(const ZdAz &c) { fX+=c.fX; fY+=c.fY; }
-
-    ZdAz operator/(double c) const { return ZdAz(fX/c, fY/c); }
-    ZdAz operator*(double c) const { return ZdAz(fX*c, fY*c); }
-    ZdAz operator*(const XY &c) const { return ZdAz(fX*c.X(), fY*c.Y()); }
-    ZdAz operator/(const XY &c) const { return ZdAz(fX/c.X(), fY/c.Y()); }
-    ZdAz operator+(const ZdAz &c) const { return ZdAz(fX+c.fX, fY+c.fY); }
-    ZdAz operator-(const ZdAz &c) const { return ZdAz(fX-c.fX, fY-c.fY); }
-    ZdAz operator-() const { return ZdAz(-fX, -fY); }
-};
-
-class RaDec : public XY
-{
-public:
-    RaDec(double ra=0, double dec=0) : XY(ra, dec) {}
-
-    double Ra()  const { return fX; }
-    double Dec() const { return fY; }
-
-    void operator*=(double c) { fX*=c; fY*=c; }
-    void operator/=(double c) { fX*=c; fY*=c; }
-
-    void Ra(double x)  { fX = x; }
-    void Dec(double y) { fY = y; }
-
-    RaDec operator/(double c) const { return RaDec(fX/c, fY/c); }
-    RaDec operator*(double c) const { return RaDec(fX*c, fY*c); }
-    RaDec operator*(const XY &c) const { return RaDec(fX*c.X(), fY*c.Y()); }
-    RaDec operator+(const RaDec &c) const { return RaDec(fX+c.fX, fY+c.fY); }
-    RaDec operator-(const RaDec &c) const { return RaDec(fX-c.fX, fY-c.fY); }
-    RaDec operator-() const { return RaDec(-fX, -fY); }
-};
-
-inline double Rad2Deg(double rad)
-{
-    return kRad2Deg*rad;
-}
-
-inline double Deg2Rad(double rad)
-{
-    return kDeg2Rad*rad;
-}
 #endif
Index: /trunk/MagicSoft/Cosy/base/msgqueue.cc
===================================================================
--- /trunk/MagicSoft/Cosy/base/msgqueue.cc	(revision 8829)
+++ /trunk/MagicSoft/Cosy/base/msgqueue.cc	(revision 8830)
@@ -1,10 +1,3 @@
 #include "msgqueue.h"
-
-#include <iostream>
-
-#include <unistd.h>        // usleep
-#include <sys/resource.h>  // PRIO_PROCESS
-
-#undef DEBUG
 
 using namespace std;
@@ -14,8 +7,7 @@
 // This creates the Message queue thread,
 //
-MsgQueue::MsgQueue() : fBreak(0)
+MsgQueue::MsgQueue() : MyThreadX("MsqQueue"), fNextMsg(0), fNextPtr(0)
 {
-    fMp = new unsigned char;
-    pthread_create(&fThread, NULL, MapThread, this);
+    RunThread();
 }
 
@@ -26,9 +18,15 @@
 MsgQueue::~MsgQueue()
 {
-#ifdef DEBUG
-    cout << "~MsgQueue::MsgQueue" << endl;
-#endif
-    pthread_cancel(fThread);
-    delete (unsigned char*)fMp;
+    CancelThread();
+
+    fMuxMsg.Lock();
+
+    if (fNextPtr)
+    {
+        delete [] fNextPtr;
+        fNextPtr = 0;
+    }
+
+    fMuxMsg.UnLock();
 }
 
@@ -45,22 +43,12 @@
 // the old action can be finished correctly by the user.
 //
-void *MsgQueue::Proc(int msg, void *mp)
+Int_t MsgQueue::Proc(int msg, void *mp)
 {
-    return NULL;
+    return 0;
 }
 
-// --------------------------------------------------------------------------
-//
-// This is the thread mapper.
-//
-void *MsgQueue::MapThread(void *arg)
+int MsgQueue::Break() const
 {
-    pthread_detach(pthread_self());
-
-    setpriority(PRIO_PROCESS, 0, -5);
-
-    ((MsgQueue*)arg)->Thread();
-
-    return NULL;
+    return fNextMsg>0 || IsThreadCanceled();
 }
 
@@ -72,45 +60,36 @@
 // in this thread. This makes sure, that the calling program is not stalled.
 //
-void MsgQueue::Thread()
+Int_t MsgQueue::Thread()
 {
-    //
-    // Tell the poster that processing is done
-    //
-    fStart = 0;
-    while (!fBreak)
+    while (1)
+    {
+        Int_t msg = 0;
+        char *ptr = 0;
+
+        fMuxMsg.Lock();
+
+        if (fNextMsg)
+        {
+            msg = fNextMsg;
+            ptr = fNextPtr;
+
+            fNextMsg = 0;
+            fNextPtr = 0;
+        }
+
+        fMuxMsg.UnLock();
+
+        if (ptr)
+        {
+            Proc(msg, ptr);
+            delete [] ptr;
+        }
+
         usleep(1);
+        TThread::CancelPoint();
+    }
+    return 0;
+}
 
-    while(1)
-    {
-        while (!fStart)
-            usleep(1);
-        fStart = 0;
-
-        //
-        // This makes sure that also a very fast Break() after
-        // a PostMsg is processed correctly
-        //
-        if (fMuxMsg.Lock()==13)
-            cout << "MsgQueue::Thread - mutex is already locked by this thread." << endl;
-        fBreak = 0;
-        if (fMuxMsg.UnLock()==13)
-            cout << "MsgQueue::Thread - tried to unlock mutex locked by other thread." << endl;
-
-#ifdef DEBUG
-        cout << "MsgQueue::Thread: Processing Msg 0x" << hex << fMsg << endl;
-#endif
-        // --- bool quit = fMsg==WM_QUIT;
-        fRc=Proc(fMsg, fMp);
-#ifdef DEBUG
-        cout << "MsgQueue::PostMsg: Msg 0x" << hex << fMsg << " processed (rc=" << fRc << ")" << endl;
-#endif
-
-        // --- if (quit)
-        // ---    break;
-    }
-
-    // --- fStart = 0;
-    // --- cout << "WM_QUIT posted... leaving msg queue." << endl;
-}
 
 // --------------------------------------------------------------------------
@@ -123,117 +102,16 @@
 void *MsgQueue::PostMsg(int msg, void *mp, int size)
 {
-    //
-    // Lock Mutex, put msg on stack and tell thread to process message
-    //
+    fMuxMsg.Lock();
 
-    //
-    // Make sure that only one Proc() is running and can be stopped
-    // stopped and the messages are processed serialized
-    //
-#ifdef DEBUG
-    cout << "MsgQueue::PostMsg: Locking MsgQueue mutex..." << flush;
-#endif
-    if (fMuxMsg.Lock()==13)
-        cout << "MsgQueue::PostMsg - mutex is already locked by this thread." << endl;
-#ifdef DEBUG
-    cout << "done." << endl;
-#endif
+    fNextMsg = msg;
 
-    //
-    // Set break state and wait until Proc() returned (break state deleted)
-    // This means, that a new command is invoked and (if forseen) the
-    // running command should stop execution.
-    //
-    // This is some kind of controlled user break without using signals
-    //
-    /**** NEW 20/01/2003 ****/
-    if (fBreak)
-    {
-        if (fMuxMsg.UnLock()==13)
-            cout << "MsgQueue::PostMsg - tried to unlock mutex locked by other thread." << endl;
-#ifdef DEBUG
-        cout << "------------> MsgQueue::PostMsg: Proc still pending... Message IGNORED." << endl;
-#endif
-        return NULL;
-    }
-    /**** NEW 20/01/2003 ****/
-#ifdef DEBUG
-    cout << "MsgQueue::PostMsg: ---> Break <---" << endl;
-#endif
-    fBreak = 1;
+    if (fNextPtr)
+        delete [] fNextPtr;
+    fNextPtr = new char[size];
 
-    //
-    // copy return code from Proc() and set new message
-    //
-    void *rc = fRc;
+    memcpy(fNextPtr, mp, size);
 
-    fMsg = msg;
+    fMuxMsg.UnLock();
 
-    delete (unsigned char*)fMp;
-    fMp = new unsigned char[size];
-
-    memcpy(fMp, mp, size);
-
-    //
-    // Start Proc()
-    //
-#ifdef DEBUG
-    cout << "MsgQueue::PostMsg: Releasing MsgQueue mutex..." << flush;
-#endif
-    fStart = 1;
-    if (fMuxMsg.UnLock()==13)
-        cout << "MsgQueue::PostMsg - tried to unlock mutex locked by other thread." << endl;
-#ifdef DEBUG
-    cout << "done." << endl;
-#endif
-
-    /*
-     * **** NEW 20/01/2003 ***
-     *
-     * This can halt the main thread, because it is waiting until
-     * Proc has finished its execution which can take a while
-     *
-     * A side effect is, because you don't wait for the end of
-     * the execution of Proc, if a new message is posted fBreak
-     * and fStart is set again, new values are copied to fMsg and
-     * fMp (FIXME? Harmefull?) and the message is not processed at all.
-     */
-    //while (fStart)
-    //    usleep(1);
- 
-#ifdef DEBUG
-    cout << "MsgQueue::PostMsg: Returning rc = " << hex << rc << endl;
-#endif
-    return rc;
+    return 0;
 }
-/*
-Start positioning.
-MsgQueue::PostMsg: Locking MsgQueue mutex...done.
-MsgQueue::PostMsg: ---> Break <---
-+++++ MsgQueue::PostMsg: Releasing MsgQueue mutex...done.
-
-===== MsgQueue::PostMsg: Returning rc = (nil)
-PostMsg (WM_Position) returned.
-done.
-Stopping movement...Movement stopped.
-WM_Position: done. (return 0x7777)
-MsgQueue::PostMsg: Msg 0x1001 processed (rc=0x7777)
-MsgQueue::Thread: Processing Msg 0x1001
-WM_Position: start.
-Positioning to Target...
- */
-/*
-Start positioning.
-MsgQueue::PostMsg: Locking MsgQueue mutex...done.
-MsgQueue::PostMsg: ---> Break <---
-+++++ MsgQueue::PostMsg: Releasing MsgQueue mutex...done.
-
-done.
-Stopping movement...Movement stopped.
-WM_Position: done. (return 0x7777)
-MsgQueue::PostMsg: Msg 0x1001 processed (rc=0x7777)
-MsgQueue::Thread: Processing Msg 0x1001
-WM_Position: start.
-Positioning to Target...
-===== MsgQueue::PostMsg: Returning rc = (nil)
-*/
Index: /trunk/MagicSoft/Cosy/base/msgqueue.h
===================================================================
--- /trunk/MagicSoft/Cosy/base/msgqueue.h	(revision 8829)
+++ /trunk/MagicSoft/Cosy/base/msgqueue.h	(revision 8830)
@@ -1,9 +1,4 @@
-#ifndef MSGQUEUE_H
-#define MSGQUEUE_H
-
-#include "threads.h"
-
-#define WM_NULL 0x0000
-#define WM_QUIT 0xffff
+#ifndef COSY_MsgQueue
+#define COSY_MsgQueue
 
 #ifndef ROOT_TMutex
@@ -11,22 +6,20 @@
 #endif
 
-class MsgQueue
+#ifndef MARS_MThread
+#include "MThread.h"
+#endif
+
+#define WM_NULL 0x0000
+#define WM_QUIT 0xffff
+
+class MsgQueue : public MyThreadX
 {
 private:
-    int fBreak;
-    int fStart;
-    int fStop;
+    int    fNextMsg;
+    char  *fNextPtr;
 
-    int fMsg;     // Message identifier
-    void *fMp;    // Message Parameter
-    void *fSize;  // Message Parameter Size
-    void *fRc;    // Proc return code
+    TMutex fMuxMsg;
 
-    pthread_t fThread;
-    TMutex    fMuxMsg;
-
-    static void *MapThread(void *arg);
-
-    void Thread();
+    Int_t Thread();
 
 public:
@@ -34,8 +27,8 @@
     virtual ~MsgQueue();
 
-    int Break() const { return fBreak; }
+    int Break() const;
 
-    virtual void *Proc(int msg, void *mp1);
-    void *Proc(int msg) { return Proc(msg, 0); }
+    virtual Int_t Proc(int msg, void *mp1);
+    Int_t Proc(int msg) { return Proc(msg, 0); }
 
     void *PostMsg(int msg, void *mp1, int size);
