- Timestamp:
- 01/24/08 11:49:25 (17 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/Makefile
r8809 r8830 19 19 20 20 # 21 PROGRAMS = cosy readcam 22 SOLIB = cosy.so21 PROGRAMS = cosy readcam telesto 22 SOLIB = libcosy.so 23 23 CINT = M 24 24 MARS_LIB = libmars.so 25 25 26 INCLUDES = -I. -Imain -Imars -Ibase -Icandrv -Iincl -Ivideodev -Igui -Imvideo -Itcpip 26 INCLUDES = -I. -Imain -Imars -Ibase -Icandrv -Iincl -Ivideodev \ 27 -Igui -Imvideo -Itcpip -Itpoint 27 28 28 29 # … … 47 48 tcpip \ 48 49 videodev \ 49 mvideo 50 mvideo \ 51 tpoint 50 52 51 53 #LIBRARIES = $(SUBDIRS:%=lib/lib%.a) -
trunk/MagicSoft/Cosy/base/MThread.cc
r8376 r8830 1 1 #include <MThread.h> 2 3 #include <iostream>4 5 #include <pthread.h>6 #include <sys/resource.h> // PRIO_PROCESS7 8 #undef DEBUG9 //#define DEBUG10 2 11 3 using namespace std; 12 4 13 // ---------------------------------------------------------------------- 14 // 15 // Constructor 16 // 17 // Starts the derived thread if you don't specify false. 18 // 19 MThread::MThread(bool start, int prio) : fIsRunning(false), fIsDetached(false), fThread(NULL), fReturn(NULL) 5 TString MyThreadX::GetThreadStateStr() const 20 6 { 21 #ifdef DEBUG 22 cout << "MThread::MThread" << endl; 23 #endif 24 if (!start) 25 return; 26 27 SetPriority(prio); 28 Start(); 7 switch (fThread.GetState()) 8 { 9 case TThread::kInvalidState: 10 return "Invalid - thread was not created properly"; 11 case TThread::kNewState: 12 return "New - thread object exists but hasn't started"; 13 case TThread::kRunningState: 14 return "Running - thread is running"; 15 case TThread::kTerminatedState: 16 return "Terminated - thread has terminated but storage has not yet been reclaimed (i.e. waiting to be joined)"; 17 case TThread::kFinishedState: 18 return "Finished - thread has finished"; 19 case TThread::kCancelingState: 20 return "Canceling - thread in process of canceling"; 21 case TThread::kCanceledState: 22 return "Canceled - thread has been canceled"; 23 case TThread::kDeletingState: 24 return "Deleting - thread in process of deleting"; 25 }; 26 return "Unknown"; 29 27 } 30 31 // ----------------------------------------------------------------------32 //33 // Destructor34 //35 // Stops the derived thread if it is still running.36 //37 MThread::~MThread()38 {39 #ifdef DEBUG40 cout << "~MThread::MThread" << endl;41 #endif42 Stop();43 }44 45 // ----------------------------------------------------------------------46 //47 // Detach the derived thread. This means, that if the thread ends the48 // needed resources (eg. for storing the return code) are freed.49 // In other word you cannot get any value back from the Thread.50 //51 void MThread::Detach()52 {53 if (fIsRunning)54 pthread_detach(*fThread);55 56 fIsDetached = true;57 }58 59 // ----------------------------------------------------------------------60 //61 // Sets the priority of the thread.62 // -20 highest priority63 // 0 standard64 // +20 lowest priority65 // This can only be done before the thread is started.66 //67 bool MThread::SetPriority(int prio)68 {69 if (fIsRunning)70 return false;71 72 fPriority = prio;73 return true;74 }75 76 // ----------------------------------------------------------------------77 //78 // Now we are back in a class instance, but running in new thread.79 // All class members can be accessed like before.80 // Set the flag for a running thread. Check if the thread should get81 // detached. Set the priority of the thread. Now reset the stop flag and82 // execute the thread. After the thread stopped it's execution reset the83 // running flag and exit.84 //85 void *MThread::RunThread()86 {87 fIsRunning = true;88 89 if (fIsDetached)90 pthread_detach(pthread_self());91 92 setpriority(PRIO_PROCESS, 0, fPriority); //lowest priority93 94 fStop = false;95 96 #ifdef DEBUG97 cout << "MThread::RunThread" << endl;98 #endif99 100 void *rc = Thread();101 102 #ifdef DEBUG103 cout << "MThread::RunThread...done." << endl;104 #endif105 106 fIsRunning = false;107 108 return rc;109 }110 111 // ----------------------------------------------------------------------112 //113 // Get the Instance back from the thread argument and call the114 // RunThread member function, which handles all MThread bspecific stuff.115 //116 void *MThread::MapThread(void *arg)117 {118 MThread *thread = (MThread*)arg;119 #ifdef DEBUG120 cout << "MThread::MapThread" << endl;121 #endif122 return thread->RunThread();123 }124 125 // ----------------------------------------------------------------------126 //127 // A thread is created and started (MapThread).128 // As an argument the actual instance is used.129 //130 void MThread::Start()131 {132 fThread = new pthread_t;133 pthread_create(fThread, NULL, MapThread, this);134 }135 136 // ----------------------------------------------------------------------137 //138 // Check if a thread is existing and running.139 // If the thread is detached, cancel the thread. Otherwise set the stop140 // flag and wait for the thread to exit.141 //142 void MThread::Stop()143 {144 #ifdef DEBUG145 cout << "MThread::Stop: fThread=" << fThread << ", fIsRunning=" << (int)fIsRunning << endl;146 #endif147 148 if (!fThread || !fIsRunning)149 return;150 151 if (fIsDetached)152 {153 #ifdef DEBUG154 cout << "Stopping detached thread..." << flush;155 #endif156 pthread_cancel(*fThread);157 fIsRunning = false;158 }159 else160 {161 #ifdef DEBUG162 cout << "Stopping thread..." << flush;163 #endif164 fStop = true;165 pthread_join(*fThread, &fReturn);166 }167 #ifdef DEBUG168 cout << "done." << endl;169 #endif170 171 delete fThread;172 fThread = NULL;173 174 #ifdef DEBUG175 cout << "MThread::Stop() done." << endl;176 #endif177 } -
trunk/MagicSoft/Cosy/base/MThread.h
r4105 r8830 1 #ifndef COSY_MThread2 #define COSY_MThread1 #ifndef MARS_MThread 2 #define MARS_MThread 3 3 4 #ifdef __CINT__ 5 typedef unsigned long int pthread_t; 6 #else 7 #include <pthread.h> 4 #ifndef ROOT_TThread 5 #include <TThread.h> 8 6 #endif 9 7 10 class MThread 8 /* 9 class MyThread : public TThread 10 { 11 friend class MyThreadX; 12 13 private: 14 15 virtual Int_t Thread() = 0; 16 static void *MapThread(void *arg) 17 { 18 // GetPriority(); High: -1 - -20, Norm: 0, Low: 1-20 19 // pthread_setschedprio(SelfId(), priority); 20 // 0: ok, 21 22 MyThread *th = (MyThread*)arg; 23 return (void*)th->Thread(); 24 } 25 26 public: 27 MyThread(EPriority pri = kNormalPriority) 28 : TThread(MapThread, this, pri) { } 29 MyThread(const char *thname, EPriority pri = kNormalPriority) 30 : TThread(thname, MapThread, this, pri) { } 31 }; 32 */ 33 34 class MyThreadX 11 35 { 12 36 private: 13 bool fIsRunning; 14 bool fIsDetached; 15 bool fStop; 37 TThread fThread; 16 38 17 pthread_t *fThread;39 Int_t fNumCleanups; 18 40 19 void *fReturn; 41 virtual void CleanUp() { } 42 static void MapCleanUp(void *arg) 43 { 44 MyThreadX *th = (MyThreadX*)arg; 45 th->CleanUp(); 46 } 20 47 21 int fPriority; 48 virtual Int_t Thread() = 0; 49 static void *MapThread(void *arg) 50 { 51 // GetPriority(); High: -1 - -20, Norm: 0, Low: 1-20 52 // pthread_setschedprio(SelfId(), priority); 53 // 0: ok, 22 54 23 static void *MapThread(void *arg); 24 void *RunThread(); 25 virtual void *Thread() = 0; 55 TThread::CleanUpPush((void*)&MapCleanUp, arg); 56 57 MyThreadX *th = (MyThreadX*)arg; 58 return (void*)th->Thread(); 59 } 26 60 27 61 public: 28 MThread(bool start=true, int prio=0); 29 virtual ~MThread(); 62 MyThreadX(TThread::EPriority pri = TThread::kNormalPriority) 63 : fThread(MapThread, this, pri), fNumCleanups(0) { } 64 MyThreadX(const char *thname, TThread::EPriority pri = TThread::kNormalPriority) 65 : fThread(thname, MapThread, this, pri), fNumCleanups(0) { } 66 virtual ~MyThreadX() { } 30 67 31 bool SetPriority(int prio); 68 // Int_t Kill() { return fThread.Kill(); } 69 Int_t RunThread(void *arg = 0) { return fThread.Run(); } 70 // void SetPriority(EPriority pri) 71 // void Delete(Option_t *option="") { TObject::Delete(option); } 72 // EPriority GetPriority() const { return fPriority; } 73 TThread::EState GetThreadState() const { return fThread.GetState(); } 74 Long_t GetThreadId() const { return fThread.GetId(); } 75 // Long_t Join(void **ret = 0) { return fThread.Join(ret); } 32 76 33 void Detach();77 TString GetThreadStateStr() const; 34 78 35 void Start();36 void Stop();79 Bool_t IsThreadRunning() const { return fThread.GetState()==TThread::kRunningState; } 80 Bool_t IsThreadCanceled() const { return fThread.GetState()==TThread::kCancelingState; } 37 81 38 bool HasStopFlag() const { return fStop; } 82 // Send cancel request and wait for cancellation 83 // 13 is returned if thread is not running, 84 // the return code of Join otherwise 85 Int_t CancelThread(void **ret = 0) { 86 const Int_t rc = fThread.Kill(); 87 if (rc==13) // Thread not running 88 return rc; 89 return fThread.Join(ret); 90 } 91 92 // This is a version of usleep which is a cancel point 93 static void Sleep(UInt_t us) 94 { 95 TThread::SetCancelOn(); 96 usleep(us); 97 TThread::SetCancelOff(); 98 } 99 100 101 // ClassDef(MyThreadX,0) // Thread class 39 102 }; 40 103 -
trunk/MagicSoft/Cosy/base/coord.h
r8376 r8830 2 2 #define COORD_H 3 3 4 #include <math.h> // floor 5 #include <iostream> 4 #ifndef MARS_MPointing 5 #include "MPointing.h" 6 #endif 6 7 7 #include "MAGIC.h"8 9 /* pi/180: degrees to radians */10 const double kDeg2Rad = 0.017453292519943295769236907684886127134428718885417;11 12 /* 180/pi: radians to degrees */13 //const double kRad2Deg = 57.295779513082320876798154814105170332405472466564;14 15 /* pi/2: 90 degrees in radians */16 const double kPiDiv2 = 1.5707963267948966192313216916397514420985846996876;17 18 /* 2pi */19 const double k2Pi = 6.2831853071795864769252867665590057683943387987502;20 21 class Deg22 {23 protected:24 double fDeg;25 26 public:27 Deg(const double d) : fDeg(d) {}28 Deg(const Deg &c) { fDeg = c.fDeg; }29 30 void Set(double d) { fDeg=d; }31 32 double operator()() { return fDeg; }33 34 operator double() const { return fDeg*kDeg2Rad; }35 };36 37 class XY38 {39 friend istream& operator>>(istream &in, XY &xy);40 friend ostream& operator<<(ostream &in, XY &xy);41 42 protected:43 double fX;44 double fY;45 46 public:47 XY(double x=0, double y=0) : fX(x), fY(y) {}48 XY(const XY &c) { fX = c.fX; fY = c.fY; }49 50 void Set(double x, double y) { fX=x; fY=y; }51 52 double X() const { return fX; }53 double Y() const { return fY; }54 55 void X(double x) { fX=x; }56 void Y(double y) { fY=y; }57 58 void operator/=(double c) { fX/=c; fY/=c; }59 void operator*=(double c) { fX*=c; fY*=c; }60 61 XY operator/(double c) const { return XY(fX/c, fY/c); }62 XY operator*(double c) const { return XY(fX*c, fY*c); }63 XY operator*(const XY &c) const { return XY(fX*c.fX, fY*c.fY); }64 XY operator/(const XY &c) const { return XY(fX/c.fX, fY/c.fY); }65 XY operator+(const XY &c) const { return XY(fX+c.fX, fY+c.fY); }66 XY operator-(const XY &c) const { return XY(fX-c.fX, fY-c.fY); }67 XY operator-() const { return XY(-fX, -fY); }68 69 double Sqr() const { return fX*fX + fY*fY; }70 double Sqrt() const { return sqrt(Sqr()); }71 double Ratio() const { return fX/fY; }72 void Round() { fX=(int)(floor(fX+.5)); fY=(int)(floor(fY+.5)); }73 };74 75 inline std::istream& operator>>(std::istream &in, XY &xy) { in >> xy.fX; in >> xy.fY; return in; }76 inline std::ostream& operator<<(std::ostream &out, const XY &xy) { out << xy.X() << " " << xy.Y(); return out; }77 78 class AltAz : public XY79 {80 public:81 AltAz(double alt=0, double az=0) : XY(alt, az) {}82 83 double Alt() const { return fX; }84 double Az() const { return fY; }85 86 void operator*=(double c) { fX*=c; fY*=c; }87 void operator/=(double c) { fX*=c; fY*=c; }88 89 void Alt(double d) { fX=d; }90 void Az(double d) { fY=d; }91 void operator*=(const XY &c) { fX*=c.X(); fY*=c.Y(); }92 void operator/=(const XY &c) { fX/=c.X(); fY/=c.Y(); }93 void operator-=(const AltAz &c) { fX-=c.fX; fY-=c.fY; }94 void operator+=(const AltAz &c) { fX+=c.fX; fY+=c.fY; }95 96 AltAz operator/(double c) const { return AltAz(fX/c, fY/c); }97 AltAz operator*(double c) const { return AltAz(fX*c, fY*c); }98 AltAz operator*(const XY &c) const { return AltAz(fX*c.X(), fY*c.Y()); }99 AltAz operator/(const XY &c) const { return AltAz(fX/c.X(), fY/c.Y()); }100 AltAz operator+(const AltAz &c) const { return AltAz(fX+c.fX, fY+c.fY); }101 AltAz operator-(const AltAz &c) const { return AltAz(fX-c.fX, fY-c.fY); }102 AltAz operator-() const { return AltAz(-fX, -fY); }103 };104 105 class ZdAz : public XY106 {107 public:108 ZdAz(double zd=0, double az=0) : XY(zd, az) {}109 ZdAz(const ZdAz &c) : XY(c) {}110 111 void operator*=(double c) { fX*=c; fY*=c; }112 void operator/=(double c) { fX*=c; fY*=c; }113 114 double Zd() const { return fX; }115 double Az() const { return fY; }116 117 void Zd(double d) { fX=d; }118 void Az(double d) { fY=d; }119 void operator*=(const XY &c) { fX*=c.X(); fY*=c.Y(); }120 void operator/=(const XY &c) { fX/=c.X(); fY/=c.Y(); }121 void operator-=(const ZdAz &c) { fX-=c.fX; fY-=c.fY; }122 void operator+=(const ZdAz &c) { fX+=c.fX; fY+=c.fY; }123 124 ZdAz operator/(double c) const { return ZdAz(fX/c, fY/c); }125 ZdAz operator*(double c) const { return ZdAz(fX*c, fY*c); }126 ZdAz operator*(const XY &c) const { return ZdAz(fX*c.X(), fY*c.Y()); }127 ZdAz operator/(const XY &c) const { return ZdAz(fX/c.X(), fY/c.Y()); }128 ZdAz operator+(const ZdAz &c) const { return ZdAz(fX+c.fX, fY+c.fY); }129 ZdAz operator-(const ZdAz &c) const { return ZdAz(fX-c.fX, fY-c.fY); }130 ZdAz operator-() const { return ZdAz(-fX, -fY); }131 };132 133 class RaDec : public XY134 {135 public:136 RaDec(double ra=0, double dec=0) : XY(ra, dec) {}137 138 double Ra() const { return fX; }139 double Dec() const { return fY; }140 141 void operator*=(double c) { fX*=c; fY*=c; }142 void operator/=(double c) { fX*=c; fY*=c; }143 144 void Ra(double x) { fX = x; }145 void Dec(double y) { fY = y; }146 147 RaDec operator/(double c) const { return RaDec(fX/c, fY/c); }148 RaDec operator*(double c) const { return RaDec(fX*c, fY*c); }149 RaDec operator*(const XY &c) const { return RaDec(fX*c.X(), fY*c.Y()); }150 RaDec operator+(const RaDec &c) const { return RaDec(fX+c.fX, fY+c.fY); }151 RaDec operator-(const RaDec &c) const { return RaDec(fX-c.fX, fY-c.fY); }152 RaDec operator-() const { return RaDec(-fX, -fY); }153 };154 155 inline double Rad2Deg(double rad)156 {157 return kRad2Deg*rad;158 }159 160 inline double Deg2Rad(double rad)161 {162 return kDeg2Rad*rad;163 }164 8 #endif -
trunk/MagicSoft/Cosy/base/msgqueue.cc
r8376 r8830 1 1 #include "msgqueue.h" 2 3 #include <iostream>4 5 #include <unistd.h> // usleep6 #include <sys/resource.h> // PRIO_PROCESS7 8 #undef DEBUG9 2 10 3 using namespace std; … … 14 7 // This creates the Message queue thread, 15 8 // 16 MsgQueue::MsgQueue() : fBreak(0)9 MsgQueue::MsgQueue() : MyThreadX("MsqQueue"), fNextMsg(0), fNextPtr(0) 17 10 { 18 fMp = new unsigned char; 19 pthread_create(&fThread, NULL, MapThread, this); 11 RunThread(); 20 12 } 21 13 … … 26 18 MsgQueue::~MsgQueue() 27 19 { 28 #ifdef DEBUG 29 cout << "~MsgQueue::MsgQueue" << endl; 30 #endif 31 pthread_cancel(fThread); 32 delete (unsigned char*)fMp; 20 CancelThread(); 21 22 fMuxMsg.Lock(); 23 24 if (fNextPtr) 25 { 26 delete [] fNextPtr; 27 fNextPtr = 0; 28 } 29 30 fMuxMsg.UnLock(); 33 31 } 34 32 … … 45 43 // the old action can be finished correctly by the user. 46 44 // 47 void *MsgQueue::Proc(int msg, void *mp)45 Int_t MsgQueue::Proc(int msg, void *mp) 48 46 { 49 return NULL;47 return 0; 50 48 } 51 49 52 // -------------------------------------------------------------------------- 53 // 54 // This is the thread mapper. 55 // 56 void *MsgQueue::MapThread(void *arg) 50 int MsgQueue::Break() const 57 51 { 58 pthread_detach(pthread_self()); 59 60 setpriority(PRIO_PROCESS, 0, -5); 61 62 ((MsgQueue*)arg)->Thread(); 63 64 return NULL; 52 return fNextMsg>0 || IsThreadCanceled(); 65 53 } 66 54 … … 72 60 // in this thread. This makes sure, that the calling program is not stalled. 73 61 // 74 voidMsgQueue::Thread()62 Int_t MsgQueue::Thread() 75 63 { 76 // 77 // Tell the poster that processing is done 78 // 79 fStart = 0; 80 while (!fBreak) 64 while (1) 65 { 66 Int_t msg = 0; 67 char *ptr = 0; 68 69 fMuxMsg.Lock(); 70 71 if (fNextMsg) 72 { 73 msg = fNextMsg; 74 ptr = fNextPtr; 75 76 fNextMsg = 0; 77 fNextPtr = 0; 78 } 79 80 fMuxMsg.UnLock(); 81 82 if (ptr) 83 { 84 Proc(msg, ptr); 85 delete [] ptr; 86 } 87 81 88 usleep(1); 89 TThread::CancelPoint(); 90 } 91 return 0; 92 } 82 93 83 while(1)84 {85 while (!fStart)86 usleep(1);87 fStart = 0;88 89 //90 // This makes sure that also a very fast Break() after91 // a PostMsg is processed correctly92 //93 if (fMuxMsg.Lock()==13)94 cout << "MsgQueue::Thread - mutex is already locked by this thread." << endl;95 fBreak = 0;96 if (fMuxMsg.UnLock()==13)97 cout << "MsgQueue::Thread - tried to unlock mutex locked by other thread." << endl;98 99 #ifdef DEBUG100 cout << "MsgQueue::Thread: Processing Msg 0x" << hex << fMsg << endl;101 #endif102 // --- bool quit = fMsg==WM_QUIT;103 fRc=Proc(fMsg, fMp);104 #ifdef DEBUG105 cout << "MsgQueue::PostMsg: Msg 0x" << hex << fMsg << " processed (rc=" << fRc << ")" << endl;106 #endif107 108 // --- if (quit)109 // --- break;110 }111 112 // --- fStart = 0;113 // --- cout << "WM_QUIT posted... leaving msg queue." << endl;114 }115 94 116 95 // -------------------------------------------------------------------------- … … 123 102 void *MsgQueue::PostMsg(int msg, void *mp, int size) 124 103 { 125 // 126 // Lock Mutex, put msg on stack and tell thread to process message 127 // 104 fMuxMsg.Lock(); 128 105 129 // 130 // Make sure that only one Proc() is running and can be stopped 131 // stopped and the messages are processed serialized 132 // 133 #ifdef DEBUG 134 cout << "MsgQueue::PostMsg: Locking MsgQueue mutex..." << flush; 135 #endif 136 if (fMuxMsg.Lock()==13) 137 cout << "MsgQueue::PostMsg - mutex is already locked by this thread." << endl; 138 #ifdef DEBUG 139 cout << "done." << endl; 140 #endif 106 fNextMsg = msg; 141 107 142 // 143 // Set break state and wait until Proc() returned (break state deleted) 144 // This means, that a new command is invoked and (if forseen) the 145 // running command should stop execution. 146 // 147 // This is some kind of controlled user break without using signals 148 // 149 /**** NEW 20/01/2003 ****/ 150 if (fBreak) 151 { 152 if (fMuxMsg.UnLock()==13) 153 cout << "MsgQueue::PostMsg - tried to unlock mutex locked by other thread." << endl; 154 #ifdef DEBUG 155 cout << "------------> MsgQueue::PostMsg: Proc still pending... Message IGNORED." << endl; 156 #endif 157 return NULL; 158 } 159 /**** NEW 20/01/2003 ****/ 160 #ifdef DEBUG 161 cout << "MsgQueue::PostMsg: ---> Break <---" << endl; 162 #endif 163 fBreak = 1; 108 if (fNextPtr) 109 delete [] fNextPtr; 110 fNextPtr = new char[size]; 164 111 165 // 166 // copy return code from Proc() and set new message 167 // 168 void *rc = fRc; 112 memcpy(fNextPtr, mp, size); 169 113 170 fM sg = msg;114 fMuxMsg.UnLock(); 171 115 172 delete (unsigned char*)fMp; 173 fMp = new unsigned char[size]; 174 175 memcpy(fMp, mp, size); 176 177 // 178 // Start Proc() 179 // 180 #ifdef DEBUG 181 cout << "MsgQueue::PostMsg: Releasing MsgQueue mutex..." << flush; 182 #endif 183 fStart = 1; 184 if (fMuxMsg.UnLock()==13) 185 cout << "MsgQueue::PostMsg - tried to unlock mutex locked by other thread." << endl; 186 #ifdef DEBUG 187 cout << "done." << endl; 188 #endif 189 190 /* 191 * **** NEW 20/01/2003 *** 192 * 193 * This can halt the main thread, because it is waiting until 194 * Proc has finished its execution which can take a while 195 * 196 * A side effect is, because you don't wait for the end of 197 * the execution of Proc, if a new message is posted fBreak 198 * and fStart is set again, new values are copied to fMsg and 199 * fMp (FIXME? Harmefull?) and the message is not processed at all. 200 */ 201 //while (fStart) 202 // usleep(1); 203 204 #ifdef DEBUG 205 cout << "MsgQueue::PostMsg: Returning rc = " << hex << rc << endl; 206 #endif 207 return rc; 116 return 0; 208 117 } 209 /*210 Start positioning.211 MsgQueue::PostMsg: Locking MsgQueue mutex...done.212 MsgQueue::PostMsg: ---> Break <---213 +++++ MsgQueue::PostMsg: Releasing MsgQueue mutex...done.214 215 ===== MsgQueue::PostMsg: Returning rc = (nil)216 PostMsg (WM_Position) returned.217 done.218 Stopping movement...Movement stopped.219 WM_Position: done. (return 0x7777)220 MsgQueue::PostMsg: Msg 0x1001 processed (rc=0x7777)221 MsgQueue::Thread: Processing Msg 0x1001222 WM_Position: start.223 Positioning to Target...224 */225 /*226 Start positioning.227 MsgQueue::PostMsg: Locking MsgQueue mutex...done.228 MsgQueue::PostMsg: ---> Break <---229 +++++ MsgQueue::PostMsg: Releasing MsgQueue mutex...done.230 231 done.232 Stopping movement...Movement stopped.233 WM_Position: done. (return 0x7777)234 MsgQueue::PostMsg: Msg 0x1001 processed (rc=0x7777)235 MsgQueue::Thread: Processing Msg 0x1001236 WM_Position: start.237 Positioning to Target...238 ===== MsgQueue::PostMsg: Returning rc = (nil)239 */ -
trunk/MagicSoft/Cosy/base/msgqueue.h
r2518 r8830 1 #ifndef MSGQUEUE_H 2 #define MSGQUEUE_H 3 4 #include "threads.h" 5 6 #define WM_NULL 0x0000 7 #define WM_QUIT 0xffff 1 #ifndef COSY_MsgQueue 2 #define COSY_MsgQueue 8 3 9 4 #ifndef ROOT_TMutex … … 11 6 #endif 12 7 13 class MsgQueue 8 #ifndef MARS_MThread 9 #include "MThread.h" 10 #endif 11 12 #define WM_NULL 0x0000 13 #define WM_QUIT 0xffff 14 15 class MsgQueue : public MyThreadX 14 16 { 15 17 private: 16 int fBreak; 17 int fStart; 18 int fStop; 18 int fNextMsg; 19 char *fNextPtr; 19 20 20 int fMsg; // Message identifier 21 void *fMp; // Message Parameter 22 void *fSize; // Message Parameter Size 23 void *fRc; // Proc return code 21 TMutex fMuxMsg; 24 22 25 pthread_t fThread; 26 TMutex fMuxMsg; 27 28 static void *MapThread(void *arg); 29 30 void Thread(); 23 Int_t Thread(); 31 24 32 25 public: … … 34 27 virtual ~MsgQueue(); 35 28 36 int Break() const { return fBreak; }29 int Break() const; 37 30 38 virtual void *Proc(int msg, void *mp1);39 void *Proc(int msg) { return Proc(msg, 0); }31 virtual Int_t Proc(int msg, void *mp1); 32 Int_t Proc(int msg) { return Proc(msg, 0); } 40 33 41 34 void *PostMsg(int msg, void *mp1, int size);
Note:
See TracChangeset
for help on using the changeset viewer.