Changeset 2518 for trunk/MagicSoft/Cosy
- Timestamp:
- 11/17/03 13:50:48 (21 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/Changelog
r2514 r2518 1 1 -*-*- END -*-*- 2 2003/11/17 - Thomas Bretz (La Palma) 3 4 * Makefile.conf.general: 5 - added libThread.a 6 7 * prepos_magic.txt: 8 - exchanged order 9 - fixed positions 10 11 * stars.txt: 12 - added many sources taken from the CC input file 13 14 * base/MTimeout.[h,cc]: 15 - changed to use check system time (using timers 16 always resulted in trouble) 17 18 * base/msgqueue.[h,cc]: 19 - replaced Posix mutex by TMutex 20 21 * base/timer.cc: 22 - display hour with two digits 23 24 * candrv/canopen.[h,cc]: 25 - replaced Posix semaphores bt TCondition 26 27 * candrv/network.cc: 28 - minor change to output 29 30 * candrv/nodedrv.[h,cc]: 31 - removed old timer stuff, replaced by a watch-dog thread 32 - added MGuard 33 - removed HandleTimer 34 - added argument to SetZombie 35 - nodedrv don't derive from TObject anymore 36 37 * candrv/sdolist.[h,cc]: 38 - replaced Posix sempahores by TMutex 39 40 * candrv/vmodican.cc: 41 - minor change to Send() 42 43 * devdrv/macs.cc: 44 - added to HandleSDO: 0x100c, 0x100d 45 - added to HandleSDOOk: 0x1000, 0x100c, 0x100d, 0x1800, 0x6000, 46 0x6002, 0x6003 47 - Enabled Guarding for Macs 48 49 * devdrv/shaftencoder.cc: 50 - added HandleSDOOk: 0x1802, 0x6001, 0x6002, 0x6003 51 52 * gui/MGAccuracy.[h,cc]: 53 - added fBar 54 55 * gui/MGCosy.cc: 56 - added button for Endswitch alignment printout 57 - merged Move and Resize to MoveResize 58 - fixed UpdateZdAz (uses Slalib now) 59 60 * gui/MGImage.[h,cc]: 61 - replaced Posix sempahores by TMutex 62 - added DrawColImg16 63 64 * main/MCosy.[h,cc]: 65 - some changes to output 66 - some changes to state transmission 67 - fixed (hopefully) treating of endswitch positions 68 - fixed positioning mode for tracking 69 - do not display weird values in case of Zombie 70 Shaftencoders anymore 71 72 * main/MStarguider.cc: 73 - if display is not set locally use 125 avaraged pictures 74 by default. 75 76 * tcpip/MCeCoCom.[h,cc]: 77 - some small fixes 78 - some changes to output 79 - read 30 instead of 29 dummy tokens 80 - added solar radiation and wind speed 81 - moved corresponding code to InterpreteReport 82 83 * tcpip/MDriveCom.[h,cc]: 84 - added ReadAngle for interpretation of Angle in CC commands 85 - added ReadPosition 86 - added Command* 87 - implemented CC commands 88 89 * tcpip/MTcpIpIO.cc: 90 - Stop thread before deleting data members 91 - replace -1 for fRxSocket by 0 92 93 * videodev/Camera.[h,cc]: 94 - replaced Posix sempahores by TMutex and TCondition 95 96 2 97 2003/11/14 - Thomas Bretz (La Palma) 3 98 -
trunk/MagicSoft/Cosy/Makefile.conf.general
r910 r2518 4 4 5 5 ROOTVER = `root-config --version` 6 ROOTLIBS = `root-config --libs` 7 ROOTGLIBS = `root-config --glibs` 6 ROOTLIBS = `root-config --libs` -lThread 7 ROOTGLIBS = `root-config --glibs` -lThread 8 8 ROOTCFLAGS = `root-config --cflags` 9 9 -
trunk/MagicSoft/Cosy/base/MTimeout.cc
r911 r2518 1 1 #include "MTimeout.h" 2 3 #include <TSystem.h> 4 5 MTimeout::MTimeout(unsigned long ms=500) : fTimeout((ULong_t)gSystem->Now()+ms) 6 { 7 // Use SetTime to change the timing 8 // if (ms) TurnOn(); // Add to system list 9 } 10 11 bool MTimeout::HasTimedOut() 12 { 13 return fTimeout<(ULong_t)gSystem->Now(); 14 } 15 16 void MTimeout::Start(unsigned long ms=500) 17 { 18 fTimeout = (ULong_t)gSystem->Now()+ms; 19 //Reset(); // reset before adding 20 //TurnOn(); // Add to system list 21 } -
trunk/MagicSoft/Cosy/base/MTimeout.h
r1702 r2518 1 #ifndef MTIMEOUT_H2 #define MTIMEOUT_H1 #ifndef COSY_MTimeout 2 #define COSY_MTimeout 3 3 4 #include <TTimer.h>4 //#include <TTimer.h> 5 5 6 class MTimeout : public TTimer6 class MTimeout// : public TTimer 7 7 { 8 /* 8 9 Bool_t Notify() 9 10 { … … 11 12 return kFALSE; 12 13 } 14 */ 15 unsigned long fTimeout; 13 16 14 17 public: 15 MTimeout(Long_t ms=500) : TTimer(ms, kFALSE) 16 { 17 // Use SetTime to change the timing 18 if (ms) TurnOn(); // Add to system list 19 } 18 MTimeout(unsigned long ms=500); 20 19 21 void Start() 22 { 23 Reset(); // reset before adding 24 TurnOn(); // Add to system list 25 } 20 bool HasTimedOut(); 21 22 void Start(unsigned long ms=500); 26 23 }; 27 24 -
trunk/MagicSoft/Cosy/base/msgqueue.cc
r1953 r2518 89 89 // a PostMsg is processed correctly 90 90 // 91 pthread_mutex_lock(&fMuxMsg);91 fMuxMsg.Lock(); 92 92 fBreak = 0; 93 pthread_mutex_unlock(&fMuxMsg);93 fMuxMsg.UnLock(); 94 94 95 95 #ifdef DEBUG … … 130 130 cout << "MsgQueue::PostMsg: Locking MsgQueue mutex..." << flush; 131 131 #endif 132 pthread_mutex_lock(&fMuxMsg);132 fMuxMsg.Lock(); 133 133 #ifdef DEBUG 134 134 cout << "done." << endl; … … 145 145 if (fBreak) 146 146 { 147 pthread_mutex_unlock(&fMuxMsg);147 fMuxMsg.UnLock(); 148 148 #ifdef DEBUG 149 149 cout << "------------> MsgQueue::PostMsg: Proc still pending... Message IGNORED." << endl; … … 176 176 #endif 177 177 fStart = 1; 178 pthread_mutex_unlock(&fMuxMsg);178 fMuxMsg.UnLock(); 179 179 #ifdef DEBUG 180 180 cout << "done." << endl; -
trunk/MagicSoft/Cosy/base/msgqueue.h
r1273 r2518 6 6 #define WM_NULL 0x0000 7 7 #define WM_QUIT 0xffff 8 9 #ifndef ROOT_TMutex 10 #include <TMutex.h> 11 #endif 8 12 9 13 class MsgQueue … … 19 23 void *fRc; // Proc return code 20 24 21 pthread_t fThread; 22 pthread_mutex_t fMuxMsg; 23 pthread_cond_t fCondMsg; 24 pthread_mutex_t fMuxRc; 25 pthread_cond_t fCondRc; 25 pthread_t fThread; 26 TMutex fMuxMsg; 26 27 27 28 static void *MapThread(void *arg); … … 36 37 37 38 virtual void *Proc(int msg, void *mp1); 39 void *Proc(int msg) { return Proc(msg, 0); } 38 40 39 41 void *PostMsg(int msg, void *mp1, int size); 42 void *PostMsg(int msg) { return PostMsg(msg, 0, 0); } 40 43 }; 41 44 -
trunk/MagicSoft/Cosy/base/timer.cc
r2278 r2518 136 136 const char *Timer::GetTimeStr() 137 137 { 138 sprintf(fDateStr, "% d/%02d/%02d %d:%02d:%02d.%06li",138 sprintf(fDateStr, "%2d/%02d/%02d %d:%02d:%02d.%06li", 139 139 fYea, fMon, fDay, fHor, fMin, fSec, (long)(1000000.0*fMs)); 140 140 … … 146 146 char text[256]; 147 147 148 sprintf(text, "% d/%02d/%02d %d:%02d:%02d.%01li",148 sprintf(text, "%2d/%02d/%02d %d:%02d:%02d.%01li", 149 149 t.fYea, t.fMon, t.fDay, t.fHor, t.fMin, t.fSec, (long)(10.0*t.fMs)); 150 150 -
trunk/MagicSoft/Cosy/candrv/canopen.cc
r1727 r2518 32 32 #include "canopen.h" 33 33 34 #include <iostream .h> // cout35 #include <iomanip .h> // setw, setfill34 #include <iostream> // cout 35 #include <iomanip> // setw, setfill 36 36 37 37 ClassImp(CanOpen); 38 39 using namespace std; 38 40 39 41 // -------------------------------------------------------------------------- … … 44 46 CanOpen::CanOpen(const char *dev, const int baud, MLog &out) : VmodIcan(dev, baud, out) 45 47 { 46 for (int i=0; i<32; i++)47 for (int j=0; j<4; j++)48 {49 pthread_cond_init(&fPdoCond[i][j], NULL);50 pthread_mutex_init(&fPdoMux[i][j], NULL);51 pthread_mutex_lock(&fPdoMux[i][j]);52 }53 54 48 lout << "- CanOpen initialized." << endl; 55 49 } … … 61 55 CanOpen::~CanOpen() 62 56 { 63 for (int i=0; i<32; i++)64 for (int j=0; j<4; j++)65 {66 pthread_cond_destroy(&fPdoCond[i][j]);67 pthread_mutex_destroy(&fPdoMux[i][j]);68 }69 57 lout << "- CanOpen destroyed." << endl; 70 58 } … … 126 114 { 127 115 HandlePDO1(node, data, tv); 128 pthread_cond_broadcast(&fPdoCond[node-1][0]);116 fPdoCond[node-1][0].Broadcast(); 129 117 } 130 118 return; … … 133 121 { 134 122 HandlePDO2(node, data, tv); 135 pthread_cond_broadcast(&fPdoCond[node-1][1]);123 fPdoCond[node-1][1].Broadcast(); 136 124 } 137 125 return; … … 140 128 { 141 129 HandlePDO3(node, data, tv); 142 pthread_cond_broadcast(&fPdoCond[node-1][2]);130 fPdoCond[node-1][2].Broadcast(); 143 131 } 144 132 return; … … 147 135 { 148 136 HandlePDO4(node, data, tv); 149 pthread_cond_broadcast(&fPdoCond[node-1][3]);137 fPdoCond[node-1][3].Broadcast(); 150 138 } 151 139 return; -
trunk/MagicSoft/Cosy/candrv/network.cc
r2278 r2518 269 269 if (fNodes[i] && fNodeInitialized[i]) 270 270 { 271 lout << "- Stopping Node #" << dec << i << endl; 271 lout << "- Stopping Node #" << dec << i; 272 lout << " (" << fNodes[i]->GetNodeName() << ")" << endl; 272 273 fNodes[i]->StopDevice(); 273 274 } -
trunk/MagicSoft/Cosy/candrv/nodedrv.cc
r2278 r2518 61 61 // and the node name. The name is a name for debug output. 62 62 // 63 NodeDrv::NodeDrv(BYTE_t nodeid, const char *name, MLog &out) : Log(out), fNetwork(NULL), fId(32), fError(0), fIsZombie(kTRUE) 63 NodeDrv::NodeDrv(BYTE_t nodeid, const char *name, MLog &out) : Log(out), fNetwork(NULL), fId(32), fError(0), fIsZombie(kTRUE), fGuard(NULL) 64 64 { 65 65 if (nodeid>0x1f) … … 79 79 } 80 80 81 fTimerOn = kFALSE;82 fTimeout = new TTimer(this, 100, kFALSE); // 100ms, asynchronous83 84 81 lout << "- Node #" << (int)nodeid << " (" << name << ") initialized." << endl; 85 82 … … 92 89 NodeDrv::~NodeDrv() 93 90 { 94 fTimerOn = kFALSE;95 delete fTimeout;96 91 } 97 92 … … 492 487 // least one Nodeguard message was answered. 493 488 // 489 class NodeGuard : public MThread 490 { 491 Double_t fTimeoutTime; 492 Double_t fGuardTime; 493 Int_t fLifeTimeFactor; 494 495 Bool_t fIsCanOpen; 496 497 NodeDrv *fDrv; 498 499 public: 500 NodeGuard(NodeDrv *drv, Int_t guard, Int_t ltf, Bool_t canopen) 501 : MThread(false), fGuardTime(guard/1000.), fLifeTimeFactor(ltf), fIsCanOpen(canopen), fDrv(drv) { } 502 503 void Reset(timeval_t *tv=NULL) 504 { 505 Timer t; 506 if (tv) 507 t.SetTimer(tv); 508 else 509 t.Now(); 510 511 fTimeoutTime = t + (fGuardTime*fLifeTimeFactor); 512 } 513 514 void *Thread() 515 { 516 Reset(); 517 518 while (!HasStopFlag()) 519 { 520 // Sending nodeguards seems to result in 521 // loosing CANbus messages or CANbus answers... 522 // strange. Also protecting VmodIcan::SendCanFrame 523 // by a Mutex doesn't help. 524 if (fIsCanOpen) 525 fDrv->SendNodeguard(); 526 527 Timer t; 528 t.Now(); 529 530 const Timer t0 = t+fGuardTime; 531 532 while (!HasStopFlag() && t<t0 && t<fTimeoutTime) 533 { 534 usleep(5); 535 t.Now(); 536 } 537 538 //cout << "-d-> " << (Long_t)((fTimeoutTime-t)*1000) << endl; 539 //cout << "-o-> " << (ULong_t)((fTimeoutTime)*1000)<< " " << (ULong_t)((t)*1000) << endl; 540 //cout << "-g-> " << (Long_t)((t-t0)*1000)<< endl; 541 542 if (t<fTimeoutTime) 543 continue; 544 545 fDrv->SetZombie(false); 546 return 0; 547 } 548 return 0; 549 } 550 }; 551 494 552 void NodeDrv::StartGuarding(Bool_t real=kTRUE) 495 553 { 496 if (f TimerOn)554 if (fGuard) 497 555 return; 498 556 499 if (!real) 500 SendNodeguard(); 501 502 fTimerOn = kTRUE; 503 fTimeout->SetTime(fGuardTime); 504 fTimeout->Reset(); 505 506 Timer t; 507 fTimeoutTime = t.Now() + (fGuardTime*fLifeTimeFactor/1000.); 508 //cout << GetNodeName() << ": " << fmod(fTimeoutTime*10000, 10000)/10 << endl; 509 510 fTimeout->TurnOn(); 511 //fTimeout->Start(fGuardTime, kTRUE); 557 fGuard = new NodeGuard(this, fGuardTime, fLifeTimeFactor, real); 558 fGuard->Start(); 512 559 513 560 lout << "- " << GetNodeName() << ": Guarding (" << dec; … … 517 564 void NodeDrv::StartGuarding(Int_t ms, Int_t ltf, Bool_t real) 518 565 { 519 if (f TimerOn)566 if (fGuard) 520 567 { 521 568 lout << "- " << GetNodeName() << ": ERROR - Guarding already started." << endl; 522 569 return; 523 570 } 571 524 572 fGuardTime = ms; 525 573 fLifeTimeFactor = ltf; … … 530 578 void NodeDrv::StopGuarding() 531 579 { 532 if (!f TimerOn)580 if (!fGuard) 533 581 return; 534 582 535 fTimeout->TurnOff();536 f TimerOn = kFALSE;583 delete fGuard; 584 fGuard=NULL; 537 585 538 586 lout << "- " << GetNodeName() << ": Guarding stopped." << endl; 539 }540 541 // --------------------------------------------------------------------------542 //543 // Handle the Nodeguard-Timer Event.544 // It checks whether the node timed out. If it timed out it is set to545 // the Zombie state.546 // A new Nodeguard request is send and a new timer event is triggered.547 //548 Bool_t NodeDrv::HandleTimer(TTimer *t)549 {550 //551 // WARNING:552 // It seems, that you should never access ANY output from553 // here. Neither the GUI, nor COUT. This can result in554 // 'unexpected async reply'555 //556 557 /*558 Fons:559 -----560 561 timers never trigger at the same time or when in a TTimer::Notify.562 Little explanation:563 564 - there are two types of timers synchronous and a-synchronous.565 - synchronous timers are only handled via the ROOT eventloop566 (see TUnixSystem::DispatchOneEvent()). If there are no mouse/keyboard567 events then the synchronous timer queue is checked. So if the processing568 of a mouse/keyboard event takes a long time synchronous timers are not569 called for a while. To prevent this from happening one can call in long570 procedures gSystem->ProcessEvents(). The system schedules only the571 next timer in the queue when the current one's Notify() has finished.572 - a-synchronous timers are triggered via SIGALARM, i.e. the program is573 interupted and execution jumps to the Notify() function. When the574 notify is finished the next a-sync timer is scheduled and the system575 resumes from the place where it was initially interrupted. One of the576 things to remember when using a-sync timers is don't make any graphics577 calls in them. X11 is not re-entrant and it might be that the SIGALARM578 signal interrupted the system while being in X11. A-sync timers are best579 used to set flags that you can test at a convenient and controlled580 time.581 */582 if (fIsZombie)583 return kTRUE;584 585 Timer time;586 Double_t now = time.Now();587 if (now > fTimeoutTime)588 {589 cout << GetNodeName() << ": " << "==out==> " << fmod(now*1000, 10000)/10 << " > " << fmod(fTimeoutTime*10000, 10000)/10 << endl;590 //cout << "ERROR - " << GetNodeName() << " didn't respond in timeout window." << endl;591 //lout << "ERROR - " << GetNodeName() << " didn't respond in timeout window." << endl;592 //cout << dec << "+" << (int)GetId() << ": Handle: " << fmod(now, 500) << endl;593 //cout << dec << "+" << (int)GetId() << ": Handle: " << fmod(fTimeoutTime, 500) << endl;594 //cout << fGuardTime << endl;595 fIsZombie = true;596 //SetZombie();597 598 return kTRUE;599 }600 601 SendNodeguard();602 603 return kTRUE;604 587 } 605 588 … … 611 594 void NodeDrv::HandleNodeguard(timeval_t *tv) 612 595 { 613 Timer t(tv); 614 fTimeoutTime = t + (fGuardTime*fLifeTimeFactor/1000.); 615 //cout << GetNodeName() << ": " << fmod(fTimeoutTime*10000, 10000)/10 << endl; 616 } 617 618 void NodeDrv::SetZombie() 596 if (fGuard) 597 fGuard->Reset(tv); 598 } 599 600 void NodeDrv::SetZombie(bool stopguard) 619 601 { 620 602 fIsZombie = true; 621 StopGuarding(); 622 } 603 if (stopguard) 604 StopGuarding(); 605 else 606 lout << " - " << GetNodeName() << ": Zombie set due to timeout." << endl; 607 } -
trunk/MagicSoft/Cosy/candrv/nodedrv.h
r2278 r2518 19 19 20 20 class Network; 21 class NodeGuard; 21 22 22 class NodeDrv : public Log , public TObject23 class NodeDrv : public Log 23 24 { 24 25 private: … … 30 31 int fError; 31 32 32 Bool_t fIsZombie; // A Zombie node is a node which doesn't answer...33 Bool_t fIsZombie; // A Zombie node is a node which doesn't answer... 33 34 34 TTimer *fTimeout; 35 Int_t fGuardTime; // Guardtime [ms] 36 Int_t fLifeTimeFactor; 37 Double_t fTimeoutTime; 38 Bool_t fTimerOn; 35 NodeGuard *fGuard; 39 36 40 Bool_t HandleTimer(TTimer *t); 37 Int_t fGuardTime; // Guardtime [ms] 38 Int_t fLifeTimeFactor; 41 39 42 40 protected: … … 46 44 Int_t GetLifeTimeFactor() const { return fLifeTimeFactor; } 47 45 Int_t GetGuardTime() const { return fGuardTime; } 48 49 virtual void SetZombie();50 46 51 47 public: … … 67 63 68 64 bool IsZombieNode() const { return fIsZombie; } 65 void SetZombie(bool stopguard=true); 69 66 70 67 virtual void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, timeval_t *tv); -
trunk/MagicSoft/Cosy/candrv/sdolist.cc
r1109 r2518 10 10 fFirst = new PendingSDO; 11 11 fLast = fFirst; 12 13 pthread_mutex_init(&fMux, NULL);14 12 } 15 13 16 14 PendingSDOList::~PendingSDOList() 17 15 { 18 // pthread_mutex_lock(&fMux);19 20 16 DelAll(); 21 17 delete fFirst; 22 23 pthread_mutex_destroy(&fMux);24 18 } 25 19 26 20 void PendingSDOList::DelAll() 27 21 { 28 pthread_mutex_lock(&fMux);22 fMux.Lock(); 29 23 30 24 PendingSDO *prev = fFirst; … … 41 35 fLast = fFirst; 42 36 43 pthread_mutex_unlock(&fMux);37 fMux.UnLock(); 44 38 } 45 39 … … 48 42 PendingSDO *sdo = fFirst; 49 43 50 pthread_mutex_lock(&fMux);44 fMux.Lock(); 51 45 while ((sdo=sdo->Next)) 52 46 if (sdo->Node==node && sdo->Idx==idx && sdo->Subidx==subidx) … … 60 54 fLast->Next = new PendingSDO(node, idx, subidx); 61 55 fLast = fLast->Next; 62 pthread_mutex_unlock(&fMux);56 fMux.UnLock(); 63 57 } 64 58 … … 68 62 PendingSDO *sdo; 69 63 70 pthread_mutex_lock(&fMux);64 fMux.Lock(); 71 65 while ((sdo=prev->Next)) 72 66 { … … 86 80 break; 87 81 } 88 pthread_mutex_unlock(&fMux);82 fMux.UnLock(); 89 83 } 90 84 … … 99 93 PendingSDO *sdo = fFirst; 100 94 101 pthread_mutex_lock(&fMux);95 fMux.Lock(); 102 96 while ((sdo=sdo->Next)) 103 97 if (sdo->Node==node) … … 106 100 break; 107 101 } 108 pthread_mutex_unlock(&fMux);102 fMux.UnLock(); 109 103 110 104 return rc; … … 116 110 PendingSDO *sdo = fFirst; 117 111 118 pthread_mutex_lock(&fMux);112 fMux.Lock(); 119 113 while ((sdo=sdo->Next)) 120 114 if (sdo->Node==node && sdo->Idx==idx && sdo->Subidx==subidx) … … 123 117 break; 124 118 } 125 pthread_mutex_unlock(&fMux);119 fMux.UnLock(); 126 120 127 121 return rc; -
trunk/MagicSoft/Cosy/candrv/sdolist.h
r1109 r2518 1 #ifndef SDOLIST_H 2 #define SDOLIST_H 3 4 #ifdef __CINT__ 5 struct pthread_mutex_t; 6 #else 7 #include <pthread.h> 8 #endif 1 #ifndef COSY_SdoList 2 #define COSY_SdoList 9 3 10 4 #ifdef __CINT__ … … 14 8 #include <TROOT.h> 15 9 #include "gendef.h" 10 #endif 11 12 #ifndef ROOT_TMutex 13 #include <TMutex.h> 16 14 #endif 17 15 … … 36 34 PendingSDO *fLast; 37 35 38 pthread_mutex_tfMux;36 TMutex fMux; 39 37 40 38 public: -
trunk/MagicSoft/Cosy/candrv/vmodican.cc
r2407 r2518 783 783 arg.pm = pm; 784 784 785 if (!Ioctl(DPM_WRITE_MBOX, &arg)) 786 return FALSE; 787 788 return arg.rval; 785 return Ioctl(DPM_WRITE_MBOX, &arg) ? arg.rval : 0; 789 786 } 790 787 -
trunk/MagicSoft/Cosy/devdrv/macs.cc
r2280 r2518 1 1 #include "macs.h" 2 2 3 #include <iostream .h>3 #include <iostream> 4 4 #include <sys/time.h> // timeval->tv_sec 5 5 … … 9 9 10 10 ClassImp(Macs); 11 12 using namespace std; 11 13 12 14 /* … … 66 68 return; 67 69 70 case 0x100c: 71 lout << "- " << GetNodeName() << ": Guard time:" << dec << val << endl; 72 return; 73 74 case 0x100d: 75 lout << "- " << GetNodeName() << ": Life time factor:" << dec << val << endl; 76 return; 77 68 78 case 0x2002: 69 79 cout << GetNodeName() << ": Current velocity: " << dec << val << endl; … … 140 150 switch (idx) 141 151 { 152 case 0x1000: 153 switch (subidx) 154 { 155 case 1: 156 //lout << ddev(MLog::eGui); 157 lout << "- " << GetNodeName() << ": State of node set." << endl; 158 //lout << edev(MLog::eGui); 159 return; 160 } 161 break; 162 163 case 0x100c: 164 switch (subidx) 165 { 166 case 0: 167 //lout << ddev(MLog::eGui); 168 lout << "- " << GetNodeName() << ": Guard time set." << endl; 169 //lout << edev(MLog::eGui); 170 return; 171 } 172 break; 173 174 case 0x100d: 175 switch (subidx) 176 { 177 case 0: 178 //lout << ddev(MLog::eGui); 179 lout << "- " << GetNodeName() << ": Life time factor set." << endl; 180 //lout << edev(MLog::eGui); 181 return; 182 } 183 break; 184 185 case 0x1800: 186 switch (subidx) 187 { 188 case 1: 189 //lout << ddev(MLog::eGui); 190 lout << "- " << GetNodeName() << ": Status of PDO1 set." << endl; 191 //lout << edev(MLog::eGui); 192 return; 193 } 194 break; 195 142 196 case 0x2002: 143 197 switch (subidx) … … 189 243 HandleNodeguard(tv); 190 244 return; 245 246 case 0x6000: 247 //lout << ddev(MLog::eGui); 248 lout << "- " << GetNodeName() << ": Rotation direction set." << endl; 249 //lout << edev(MLog::eGui); 250 return; 251 252 case 0x6002: 253 //lout << ddev(MLog::eGui); 254 lout << "- " << GetNodeName() << ": Velocitz resolution set." << endl; 255 //lout << edev(MLog::eGui); 256 return; 257 258 case 0x6003: 259 switch (subidx) 260 { 261 case 0: 262 //lout << ddev(MLog::eGui); 263 lout << "- " << GetNodeName() << ": Absolute positioning started." << endl; 264 //lout << edev(MLog::eGui); 265 return; 266 267 case 1: 268 //lout << ddev(MLog::eGui); 269 lout << "- " << GetNodeName() << ": Relative positioning started." << endl; 270 //lout << edev(MLog::eGui); 271 return; 272 } 273 break; 191 274 192 275 case 0x6004: … … 271 354 StopGuarding(); 272 355 273 // ****FIXME*** usleep(2000*GetGuardTime());274 275 356 lout << "- " << GetNodeName() << ": Requesting Mac Software Version." << endl; 276 357 RequestSDO(0x100a); … … 302 383 //SetNoWait(TRUE); 303 384 304 // StartGuarding(200, 2, kFALSE); // Using PDO1 @ 100ms305 // 306 // 385 StartGuarding(250, 1, kFALSE); // Using PDO1 @ 100ms 386 //StartGuarding(250, 4); 387 //StartHostGuarding(); 307 388 308 389 StartNode(); … … 478 559 void Macs::HandlePDO1(BYTE_t *data, timeval_t *tv) 479 560 { 480 // FIXME!!!! 561 // FIXME!!!! Only 0x4000 should do this to be 562 // CanOpen conform 481 563 HandleNodeguard(tv); 482 /* 483 Timer t(tv); 484 cout << GetNodeName()<< " " <<t.GetTimeStr() << endl; 485 */ 564 486 565 fPdoPos = (data[4]<<24) | (data[5]<<16) | (data[6]<<8) | data[7]; 487 566 … … 656 735 return; 657 736 658 lout << GetNodeName() << ": Status PDO3 = "; 737 Timer time; 738 time.Now(); 739 740 lout << time << ": " << GetNodeName() << " - PDO3 = "; 659 741 const Bool_t ready = data[3]&0x01; 660 742 const Bool_t fuse = data[3]&0x02; -
trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc
r2278 r2518 4 4 #include "network.h" 5 5 6 #include <iostream.h> // cout 7 #include <iomanip.h> // setw, setfill 8 9 #include <TSystem.h> // gSystem 6 #include <iostream> // cout 7 #include <iomanip> // setw, setfill 8 10 9 #include <TGLabel.h> // TGLabel->SetText 11 10 12 #include <pthread.h>13 #include <sys/resource.h> // PRIO_PROCESS14 15 11 ClassImp(ShaftEncoder); 12 13 using namespace std; 16 14 17 15 ShaftEncoder::ShaftEncoder(const BYTE_t nodeid, const char *name, MLog &out) … … 104 102 } 105 103 104 void ShaftEncoder::HandleSDOOK(WORD_t idx, BYTE_t subidx, LWORD_t data, timeval_t *tv) 105 { 106 switch (idx) 107 { 108 case 0x1802: 109 switch (subidx) 110 { 111 case 1: 112 //lout << ddev(MLog::eGui); 113 lout << "- " << GetNodeName() << ": PDOs configured." << endl; 114 //lout << edev(MLog::eGui); 115 return; 116 } 117 break; 118 119 case 0x6001: 120 switch (subidx) 121 { 122 case 0: 123 //lout << ddev(MLog::eGui); 124 lout << "- " << GetNodeName() << ": Log.ticks/revolution set." << endl; 125 //lout << edev(MLog::eGui); 126 return; 127 } 128 break; 129 130 case 0x6002: 131 switch (subidx) 132 { 133 case 0: 134 //lout << ddev(MLog::eGui); 135 lout << "- " << GetNodeName() << ": Max number of ticks set." << endl; 136 //lout << edev(MLog::eGui); 137 return; 138 } 139 break; 140 141 case 0x6003: 142 switch (subidx) 143 { 144 case 0: 145 //lout << ddev(MLog::eGui); 146 lout << "- " << GetNodeName() << ": Preset value set." << endl; 147 //lout << edev(MLog::eGui); 148 return; 149 } 150 break; 151 } 152 NodeDrv::HandleSDOOK(idx, subidx, data, tv); 153 } 154 106 155 void ShaftEncoder::DisplayVal() 107 156 { … … 288 337 */ 289 338 290 // StartGuarding(175, 2); // 175339 // StartGuarding(200, 1, kTRUE); // 175 291 340 // StartGuarding(10*GetId(), 2); // 175 292 341 } -
trunk/MagicSoft/Cosy/devdrv/shaftencoder.h
r1953 r2518 43 43 44 44 void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, timeval_t *tv); 45 void HandleSDOOK(WORD_t idx, BYTE_t subidx, LWORD_t data, timeval_t *tv); 45 46 /* 46 47 void HandleSDOOK(WORD_t idx, BYTE_t subidx, timeval_t *tv) { NodeDrv::HandleSDOOK(idx, subidx, tv); } -
trunk/MagicSoft/Cosy/gui/MGAccuracy.cc
r2278 r2518 149 149 } 150 150 151 void MGAccuracy::InitBar() 152 { 153 fBar = new TLine(0, 0, 0, 0); 154 fBar->SetLineColor(kBlack); 155 fBar->SetLineStyle(1); 156 fBar->SetLineWidth(5); 157 fBar->Draw(); 158 159 fList->Add(fBar); 160 } 161 151 162 void MGAccuracy::InitCross() 152 163 { … … 176 187 InitText(); 177 188 InitCross(); 189 InitBar(); 178 190 179 191 InitCanvas(); … … 215 227 double dist = acos(d); 216 228 217 dist *= 3600./d2r; 229 dist *= 3600./d2r; // [min] 218 230 219 231 int rs = (int)floor(fmod(dist, 60.)); 232 220 233 dist /= 60.; 221 234 int rm = (int)dist;//floor(fmod(dist, 60.)); … … 225 238 226 239 fTxt->SetText(fTxt->GetX(), fTxt->GetY(), txt); 240 241 fBar->SetX2(dist*60); 242 if (dist*16384<1*360*60) 243 fBar->SetLineColor(kGreen); 244 else 245 if (dist*16384<2*360*60) 246 fBar->SetLineColor(kYellow); 247 else 248 fBar->SetLineColor(kRed); 227 249 } 228 250 -
trunk/MagicSoft/Cosy/gui/MGAccuracy.h
r1111 r2518 24 24 TText *fTxt; 25 25 26 TLine *fBar; 27 26 28 void DrawCoordinateSystem(); 27 29 28 30 void InitText(); 29 31 void InitCross(); 32 void InitBar(); 30 33 31 34 void UpdateText(Float_t zd, Float_t x, Float_t y); -
trunk/MagicSoft/Cosy/gui/MGCosy.cc
r2514 r2518 53 53 kPB_CALCALTAZ, 54 54 kPB_TPOINT, 55 kPB_ENDSWITCH, 55 56 kPB_START, 56 57 kPB_DISPLAY1, … … 270 271 fStopped->SetBackgroundColor(color); 271 272 272 fError ->Move (10, 25);273 fMoving ->Move (10, 25+20);274 fTracking->Move (10, 25+40);275 fStopping->Move (10, 25+60);276 fStopped ->Move (10, 25+80);277 fAvailMac1->Move (10, 25+120);278 fAvailMac2->Move (10, 25+140);273 fError ->MoveResize(10, 25, 60, 20); 274 fMoving ->MoveResize(10, 25+20, 60, 20); 275 fTracking->MoveResize(10, 25+40, 60, 20); 276 fStopping->MoveResize(10, 25+60, 60, 20); 277 fStopped ->MoveResize(10, 25+80, 60, 20); 278 fAvailMac1->MoveResize(10, 25+120, 60, 20); 279 fAvailMac2->MoveResize(10, 25+140, 60, 20); 279 280 //fAvailMac3->Move(10, 25+160); 280 fAvailSe1->Move(10, 25+180); 281 fAvailSe2->Move(10, 25+200); 282 fAvailSe3->Move(10, 25+220); 283 284 fError ->Resize(60, 20); 285 fMoving ->Resize(60, 20); 286 fTracking->Resize(60, 20); 287 fStopping->Resize(60, 20); 288 fStopped ->Resize(60, 20); 289 fAvailMac1->Resize(60, 20); 290 fAvailMac2->Resize(60, 20); 291 //fAvailMac3->Resize(60, 20); 292 fAvailSe1->Resize(60, 20); 293 fAvailSe2->Resize(60, 20); 294 fAvailSe3->Resize(60, 20); 281 fAvailSe1->MoveResize(10, 25+200, 60, 20); 282 fAvailSe2->MoveResize(10, 25+220, 60, 20); 283 fAvailSe3->MoveResize(10, 25+180, 60, 20); 295 284 296 285 fList->Add(fError); … … 486 475 487 476 but= new TGTextButton(tf2, "Ra -", kPB_RAm); 488 but->Resize(50, 25); 489 but->Move(25, 210); 477 but->MoveResize(25, 210, 50, 25); 490 478 but->SetToolTipText("Right ascension -= 1'"); 491 479 but->Associate(this); 492 480 fList->Add(but); 493 481 but= new TGTextButton(tf2, "RA +", kPB_RAp); 494 but->Resize(50, 25); 495 but->Move(90, 210); 482 but->MoveResize(90, 210, 50, 25); 496 483 but->SetToolTipText("Right ascension += 1'"); 497 484 but->Associate(this); 498 485 fList->Add(but); 499 486 but= new TGTextButton(tf2, "DEC +", kPB_DECp); 500 but->Resize(50, 25); 501 but->Move(55, 185); 487 but->MoveResize(55, 185, 50, 25); 502 488 but->SetToolTipText("Declination += 1'"); 503 489 but->Associate(this); 504 490 fList->Add(but); 505 491 but= new TGTextButton(tf2, "DEC -", kPB_DECm); 506 but->Resize(50, 25); 507 but->Move(55, 235); 492 but->MoveResize(55, 235, 50, 25); 508 493 but->SetToolTipText("Declination -= 1'"); 509 494 but->Associate(this); … … 511 496 512 497 but = new TGTextButton(tf1, "Move'n'Track", kPB_TRACKPOS); 513 but->Resize(100, 25); 514 but->Move(25, 242); 498 but->MoveResize(25, 242, 100, 25); 515 499 but->SetToolTipText("Move telescope to a Zd/Az position and start tracking."); 516 500 but->Associate(this); … … 518 502 519 503 but= new TGTextButton(tf2, "Calc Zd/Az", kPB_CALCALTAZ); 520 but->Resize(80, 25); 521 but->Move(165, 197); 504 but->MoveResize(165, 197, 80, 25); 522 505 but->SetToolTipText("Calculate Zd/Az corresponding to Ra/Dec."); 523 506 but->Associate(this); … … 525 508 526 509 but = new TGTextButton(tf4, "TPoint", kPB_TPOINT); 527 but->Resize(50, 25); 528 but->Move(176/*231*/, 213); 510 but->MoveResize(139, 213, 62, 25); 529 511 but->SetToolTipText("Trigger writing a tpoint coordinate pair."); 512 but->Associate(this); 513 fList->Add(but); 514 515 but = new TGTextButton(tf4, "Endswitch", kPB_ENDSWITCH); 516 but->MoveResize(204, 213, 62, 25); 517 but->SetToolTipText("Print coordinates in 'Endswitch-Position' units."); 530 518 but->Associate(this); 531 519 fList->Add(but); … … 533 521 #ifdef EXPERT 534 522 but= new TGTextButton(tf1, "New Position", kPB_SavePreDef); 535 but->Resize(80, 25); 536 but->Move(165, 197); 523 but->MoveResize(165, 197, 80, 25); 537 524 but->SetToolTipText("Save new predefined position."); 538 525 but->Associate(this); … … 540 527 541 528 but= new TGTextButton(tf4, "New", kPB_SaveStar); 542 but->Resize(60, 23); 543 but->Move(211, 69); 529 but->MoveResize(211, 69, 60, 23); 544 530 but->SetToolTipText("Save new Source position."); 545 531 but->Associate(this); … … 547 533 548 534 but = new TGTextButton(tf5, "Display", kPB_DISPLAY1); 549 but->Resize(80, 25); 550 but->Move(160, 197); 535 but->MoveResize(160, 197, 80, 25); 551 536 but->SetToolTipText("Display Histogram."); 552 537 but->Associate(this); … … 554 539 555 540 but = new TGTextButton(tf6, "Display", kPB_DISPLAY2); 556 but->Resize(80, 25); 557 but->Move(160, 197); 541 but->MoveResize(160, 197, 80, 25); 558 542 but->SetToolTipText("Display Histogram."); 559 543 but->Associate(this); … … 561 545 562 546 but = new TGTextButton(tf4, "Load", kPB_LoadBending); 563 but->Resize(50, 25); 564 but->Move(151, 185); 547 but->ResizeMove(151, 185, 50, 25); 565 548 but->SetToolTipText("Load bending corrections from file 'bending.txt'"); 566 549 but->Associate(this); … … 568 551 569 552 but = new TGTextButton(tf4, "Reset", kPB_ResetBending); 570 but->Resize(50, 25); 571 but->Move(206, 185); 553 but->MoveResize(206, 185, 50, 25); 572 554 but->SetToolTipText("Reset bending correction (coefficients=0)"); 573 555 but->Associate(this); … … 575 557 576 558 but= new TGTextButton(tf4, "Zd -", kPB_ZDm); 577 but->Resize(50, 25); 578 but->Move(25, 210); 559 but->MoveResize(25, 210, 50, 25); 579 560 but->SetToolTipText("Zenith Distance -= 1SE"); 580 561 but->Associate(this); 581 562 fList->Add(but); 582 563 but= new TGTextButton(tf4, "Zd +", kPB_ZDp); 583 but->Resize(50, 25); 584 but->Move(90, 210); 564 but->MoveResize(90, 210, 50, 25); 585 565 but->SetToolTipText("Zenith Distance += 1SE"); 586 566 but->Associate(this); 587 567 fList->Add(but); 588 568 but= new TGTextButton(tf4, "Az +", kPB_AZp); 589 but->Resize(50, 25); 590 but->Move(55, 185); 569 but->MoveResize(55, 185, 50, 25); 591 570 but->SetToolTipText("Azimuth += 1SE"); 592 571 but->Associate(this); 593 572 fList->Add(but); 594 573 but= new TGTextButton(tf4, "Az -", kPB_AZm); 595 but->Resize(50, 25); 596 but->Move(55, 235); 574 but->MoveResize(55, 235, 50, 25); 597 575 but->SetToolTipText("Azimuth -= 1SE"); 598 576 but->Associate(this); … … 605 583 gClient->GetColorByName("Green", color); 606 584 but->SetBackgroundColor(color); 607 but->Move(147, 295); 608 but->Resize(62, 25); 585 but->MoveResize(147, 295, 62, 25); 609 586 but->SetToolTipText("Start a telescope movement."); 610 587 fList->Add(but); … … 614 591 gClient->GetColorByName("Red", color); 615 592 but->SetBackgroundColor(color); 616 but->Move(212, 295); 617 but->Resize(62, 25); 593 but->MoveResize(212, 295, 62, 25); 618 594 but->SetToolTipText("Stop any movement of telescope."); 619 595 fList->Add(but); … … 989 965 void MGCosy::UpdateZdAz(ZdAz &soll) 990 966 { 991 soll *= kRad2Deg;992 993 967 static Int_t zd=~0; 994 968 static Int_t az=~0; … … 996 970 char text[21]; 997 971 998 ZdAz test = soll*600; 999 972 UShort_t z, a; 973 Double_t zm, am; 974 Char_t sz, sa; 975 976 Slalib::Rad2Dm(soll.Zd(), sz, z, zm); 977 Slalib::Rad2Dm(soll.Az(), sa, a, am); 978 979 const ZdAz test = soll*kRad2Deg*600; 1000 980 if (zd!=(int)test.Zd()) 1001 981 { 1002 982 zd = (int)test.Zd(); 1003 sprintf(text, "%c%dd %.1fm", s oll.Zd()<0?'-':'+', abs((int)soll.Zd()), 0.1*(abs((int)test.Zd())%600));983 sprintf(text, "%c%dd %.1fm", sz, z, zm); 1004 984 fZdSoll->SetText(new TGString(text)); 1005 985 } … … 1007 987 { 1008 988 az = (int)test.Az(); 1009 sprintf(text, "%c%dd %.1fm", s oll.Az()<0?'-':'+' , abs((int)soll.Az()), 0.1*(abs((int)test.Az())%600));989 sprintf(text, "%c%dd %.1fm", sa, a, am); 1010 990 fAzSoll->SetText(new TGString(text)); 1011 991 } … … 1113 1093 // TGMainFrame::CloseWindow(); 1114 1094 cout << "Closing window - waiting until all nodes are stopped." << endl; 1115 fQueue->PostMsg(WM_QUIT , 0, 0);1095 fQueue->PostMsg(WM_QUIT); 1116 1096 cout << "Closing window - done." << endl; 1117 1097 // gApplication->Terminate(0); … … 1376 1356 StopDemo(); 1377 1357 #endif 1378 fQueue->PostMsg(WM_STOP , 0, 0);1358 fQueue->PostMsg(WM_STOP); 1379 1359 if (fTab->GetCurrent()==3) 1380 fQueue->Proc(WM_TESTSE , NULL);1360 fQueue->Proc(WM_TESTSE); 1381 1361 if (fTab->GetCurrent()==4) 1382 fQueue->Proc(WM_GEAR , NULL);1362 fQueue->Proc(WM_GEAR); 1383 1363 cout << "PostMsg (WM_Stop) returned." << endl; 1384 1364 return kTRUE; … … 1458 1438 StartTPoint(); 1459 1439 return kTRUE; 1440 1441 case kPB_ENDSWITCH: 1442 fQueue->Proc(WM_ENDSWITCH); 1443 return kTRUE; 1460 1444 /* 1461 1445 case kPB_CALIBSE: … … 1464 1448 */ 1465 1449 case kPB_LoadBending: 1466 fQueue->Proc(WM_LOADBENDING , NULL);1450 fQueue->Proc(WM_LOADBENDING); 1467 1451 return kTRUE; 1468 1452 case kPB_ResetBending: 1469 fQueue->Proc(WM_RESETBENDING , NULL);1453 fQueue->Proc(WM_RESETBENDING); 1470 1454 return kTRUE; 1471 1455 /* … … 1479 1463 case kPB_DISPLAY1: 1480 1464 case kPB_DISPLAY2: 1481 fQueue->PostMsg(WM_DISPLAY , 0, 0);1465 fQueue->PostMsg(WM_DISPLAY); 1482 1466 return kTRUE; 1483 1467 … … 1493 1477 case IDM_EXIT: 1494 1478 cout << "IDM_EXIT: Posting WM_QUIT." << endl; 1495 fQueue->PostMsg(WM_QUIT , 0, 0);1479 fQueue->PostMsg(WM_QUIT); 1496 1480 cout << "IDM_EXIT: WM_QUIT done." << endl; 1497 1481 //cout << "Idm_Exit." << endl; -
trunk/MagicSoft/Cosy/gui/MGImage.cc
r2514 r2518 9 9 #include "MGImage.h" 10 10 11 #include <iostream.h> 12 #include <pthread.h> 13 14 #include <X11/Xlib.h> 15 16 #include <TTimer.h> 17 #include <TSystem.h> 18 #include <TVirtualX.h> 11 #include <iostream> 12 19 13 #include <TGX11.h> 14 #include <TMutex.h> 20 15 21 16 ClassImp(MGImage); 17 18 using namespace std; 22 19 /* 23 20 class MyX11 : public TGX11 … … 41 38 // Creat drawing semaphore 42 39 // 43 fMuxPixmap = new pthread_mutex_t; 44 pthread_mutex_init((pthread_mutex_t*)fMuxPixmap, NULL); 40 fMuxPixmap = new TMutex; 45 41 46 42 Resize(w, h); … … 58 54 MGImage::~MGImage() 59 55 { 60 pthread_mutex_lock((pthread_mutex_t*)fMuxPixmap);56 fMuxPixmap->Lock(); 61 57 62 58 cout << "Deleting MGImage..." << endl; … … 66 62 gVirtualX->DeleteImage((Drawable_t)fImage); 67 63 68 pthread_mutex_destroy((pthread_mutex_t*)fMuxPixmap);64 delete fMuxPixmap; 69 65 70 66 cout << "MGImage destroyed." << endl; … … 73 69 void MGImage::DoRedraw() 74 70 { 75 pthread_mutex_lock((pthread_mutex_t*)fMuxPixmap);71 fMuxPixmap->Lock(); 76 72 77 73 if (TestBit(kNeedRedraw)) … … 81 77 } 82 78 83 pthread_mutex_unlock((pthread_mutex_t*)fMuxPixmap);79 fMuxPixmap->UnLock(); 84 80 } 85 81 … … 91 87 while (s<e) 92 88 { 89 // 11111100 11111000 11111100 93 90 *d++ = (*s&0xfc) | (*s&0xf8)<<5 | (*s&0xfc)<<11; 94 91 s++; … … 107 104 *d++ = *s++; 108 105 d++; 106 } 107 } 108 109 void MGImage::DrawImg(const byte *buffer) 110 { 111 if (fMuxPixmap->TryLock()==13) 112 return; 113 114 switch (gVirtualX->GetDepth()) 115 { 116 case 8: 117 memcpy(fImage->data, buffer, fWidth*fHeight); 118 break; 119 case 16: 120 DrawImg16((unsigned short*)fImage->data, (char*)buffer, (char*)(buffer+fWidth*fHeight)); 121 break; 122 case 24: 123 DrawImg24(fImage->data, (char*)buffer, (char*)(buffer+fWidth*fHeight)); 124 break; 125 default: 126 cout << "Sorry, " << gVirtualX->GetDepth() << "bit color depth not yet implemented." << endl; 127 } 128 129 SetBit(kNeedRedraw); 130 131 fMuxPixmap->UnLock(); 132 } 133 134 void MGImage::DrawColImg16(unsigned short *d, char *s1, char *s2, char *e) 135 { 136 // d=destination, s1=source1, s2=source2, e=end 137 // d: rrrrrggg gggbbbbb 138 // s2: 00rrggbb 139 // 140 while (s1<e) 141 { 142 if (*s2) 143 { 144 // 00000011 00001100 00110000 145 *d++ = (*s2&0x3) | (*s2&0xb)<<3 | (*s2&0x30)<<7; 146 s1++; 147 } 148 else 149 { 150 // 11111100 11111000 11111100 151 *d++ = (*s1&0xfc) | (*s1&0xf8)<<5 | (*s1&0xfc)<<11; 152 s2++; 153 } 109 154 } 110 155 } … … 134 179 } 135 180 136 void MGImage::DrawImg(const byte *buffer)137 {138 if (pthread_mutex_trylock((pthread_mutex_t*)fMuxPixmap))139 return;140 141 switch (gVirtualX->GetDepth())142 {143 case 8:144 memcpy(fImage->data, buffer, fWidth*fHeight);145 break;146 case 16:147 DrawImg16((unsigned short*)fImage->data, (char*)buffer, (char*)(buffer+fWidth*fHeight));148 break;149 case 24:150 DrawImg24(fImage->data, (char*)buffer, (char*)(buffer+fWidth*fHeight));151 break;152 default:153 cout << "Sorry, " << gVirtualX->GetDepth() << "bit color depth not yet implemented." << endl;154 }155 156 SetBit(kNeedRedraw);157 158 pthread_mutex_unlock((pthread_mutex_t*)fMuxPixmap);159 }160 161 181 void MGImage::DrawColImg(const byte *gbuf, const byte *cbuf) 162 182 { 163 if ( pthread_mutex_trylock((pthread_mutex_t*)fMuxPixmap))183 if (fMuxPixmap->TryLock()==13) 164 184 return; 165 185 … … 179 199 switch (gVirtualX->GetDepth()) 180 200 { 201 case 16: 202 DrawColImg16((unsigned short*)fImage->data, (char*)gbuf, (char*)cbuf, (char*)(gbuf+fWidth*fHeight)); 203 break; 181 204 case 24: 182 DrawColImg 32(fImage->data, (char*)gbuf, (char*)cbuf, (char*)(gbuf+fWidth*fHeight));205 DrawColImg24(fImage->data, (char*)gbuf, (char*)cbuf, (char*)(gbuf+fWidth*fHeight)); 183 206 break; 184 207 default: … … 188 211 SetBit(kNeedRedraw); 189 212 190 pthread_mutex_unlock((pthread_mutex_t*)fMuxPixmap);191 } 213 fMuxPixmap->UnLock(); 214 } -
trunk/MagicSoft/Cosy/gui/MGImage.h
r2514 r2518 15 15 #endif 16 16 17 class T Timer;17 class TMutex; 18 18 19 19 typedef unsigned char byte; … … 29 29 UInt_t fHeight; 30 30 31 void *fMuxPixmap; //! test 32 33 TTimer *fTimer; 31 TMutex *fMuxPixmap; //! test 34 32 35 33 enum { kNeedRedraw = BIT(17) }; … … 37 35 void DrawImg16(unsigned short *d, char *s, char *e); 38 36 void DrawImg24(char *d, char *s, char *e); 37 void DrawColImg16(unsigned short *d, char *s1, char *s2, char *e); 39 38 void DrawColImg24(char *d, char *s1, char *s2, char *e); 40 39 -
trunk/MagicSoft/Cosy/main/MBending.cc
r2407 r2518 68 68 ClassImp(MBending); 69 69 70 #undef DEBUG 71 #define DEBUG(txt) txt 72 //#define DEBUG(txt) 73 70 74 const Int_t MBending::fNumPar=19; 71 75 … … 286 290 AltAz p = aa; 287 291 292 DEBUG(cout << setprecision(16)); 293 DEBUG(cout << "Bend8: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl); 294 288 295 const AltAz CRX(-fCrx*sin(p.Az()-p.Alt()), fCrx*cos(p.Az()-p.Alt())/cos(p.Alt())); 289 296 const AltAz CRY(-fCry*cos(p.Az()-p.Alt()), -fCry*sin(p.Az()-p.Alt())/cos(p.Alt())); … … 291 298 p += CRY; 292 299 300 DEBUG(cout << "Bend7: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl); 301 293 302 const AltAz NRX(fNrx*sin(p.Alt()), -fNrx); 294 303 const AltAz NRY(fNry*cos(p.Alt()), -fNry*tan(p.Alt())); … … 296 305 p += NRY; 297 306 307 DEBUG(cout << "Bend6: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl); 308 298 309 const AltAz CES(-fEces*sin(p.Alt()), -fAces*sin(p.Az())); 299 310 const AltAz CEC(-fEcec*cos(p.Alt()), -fAcec*cos(p.Az())); … … 301 312 p += CEC; 302 313 314 DEBUG(cout << "Bend5: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl); 315 303 316 const AltAz TX(Sign(fTx/tan(p.Alt()), p.Alt()), 0); 304 317 const AltAz TF(Sign(fTf*cos(p.Alt()), p.Alt()), 0); 305 p += TX;318 //p += TX; 306 319 p += TF; 320 321 DEBUG(cout << "Bend4: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl); 322 323 cout << fAw << " " << cos(p.Az()) << " " << tan(p.Alt()) << endl; 324 cout << fAw* cos(p.Az())*tan(p.Alt())*180/3.1415 << endl; 307 325 308 326 const AltAz AW( fAw*sin(p.Az()), -fAw*cos(p.Az())*tan(p.Alt())); … … 311 329 p += AN; 312 330 331 DEBUG(cout << "Bend3: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl); 332 313 333 const AltAz CA(0, -fCa/cos(p.Alt())); 314 334 p += CA; 315 335 336 DEBUG(cout << "Bend2: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl); 337 316 338 const AltAz NPAE(0, -fNpae*tan(p.Alt())); 317 339 p += NPAE; 318 340 341 DEBUG(cout << "Bend1: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl); 342 319 343 const AltAz FLOP(Sign(fFlop, p.Alt()), 0); 320 344 p += FLOP; … … 323 347 p += I; 324 348 349 DEBUG(cout << "Bend0: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl); 350 325 351 return p; 326 352 } 327 353 328 AltAz MBending:: CorrectBack(const AltAz &aa) const354 AltAz MBending::AddOffsets(const AltAz &aa) const 329 355 { 330 356 // Correct [rad] … … 333 359 334 360 const AltAz I(fIe, fIa); 361 p += I; 362 363 return p; 364 } 365 366 AltAz MBending::CorrectBack(const AltAz &aa) const 367 { 368 // Correct [rad] 369 // zdaz [rad] 370 AltAz p = aa; 371 372 DEBUG(cout << setprecision(16)); 373 DEBUG(cout << "Back0: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl); 374 375 const AltAz I(fIe, fIa); 335 376 p -= I; 336 377 … … 338 379 p -= FLOP; 339 380 381 DEBUG(cout << "Back1: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl); 382 340 383 const AltAz NPAE(0, -fNpae*tan(p.Alt())); 341 384 p -= NPAE; 342 385 386 DEBUG(cout << "Back2: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl); 387 343 388 const AltAz CA(0, -fCa/cos(p.Alt())); 344 389 p -= CA; 390 391 DEBUG(cout << "Back3: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl); 392 393 cout << fAw << " " << cos(p.Az()) << " " << tan(p.Alt()) << endl; 394 cout << fAw* cos(p.Az())*tan(p.Alt())*180/3.1415 << endl; 345 395 346 396 const AltAz AN(-fAn*cos(p.Az()), -fAn*sin(p.Az())*tan(p.Alt())); … … 349 399 p -= AW; 350 400 401 DEBUG(cout << "Back4: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl); 402 351 403 const AltAz TF(Sign(fTf*cos(p.Alt()), p.Alt()), 0); 352 404 const AltAz TX(Sign(fTx/tan(p.Alt()), p.Alt()), 0); 353 405 p -= TF; 354 p -= TX; 406 //p -= TX; 407 408 DEBUG(cout << "Back5: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl); 355 409 356 410 const AltAz CEC(-fEcec*cos(p.Alt()), -fAcec*cos(p.Az())); … … 359 413 p -= CES; 360 414 415 DEBUG(cout << "Back6: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl); 416 361 417 const AltAz NRY(fNry*cos(p.Alt()), -fNry*tan(p.Alt())); 362 418 const AltAz NRX(fNrx*sin(p.Alt()), -fNrx); … … 364 420 p -= NRX; 365 421 422 DEBUG(cout << "Back7: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl); 423 366 424 const AltAz CRY(-fCry*cos(p.Az()-p.Alt()), -fCry*sin(p.Az()-p.Alt())/cos(p.Alt())); 367 425 const AltAz CRX(-fCrx*sin(p.Az()-p.Alt()), fCrx*cos(p.Az()-p.Alt())/cos(p.Alt())); … … 369 427 p -= CRX; 370 428 429 DEBUG(cout << "Back8: " << 90-p.Alt()*180/TMath::Pi() << " " << p.Az()*180/TMath::Pi() << endl); 430 371 431 return p; 372 432 } 433 434 AltAz MBending::SubtractOffsets(const AltAz &aa) const 435 { 436 // Correct [rad] 437 // zdaz [rad] 438 AltAz p = aa; 439 440 const AltAz I(fIe, fIa); 441 p -= I; 442 443 return p; 444 } 445 373 446 374 447 ZdAz MBending::Correct(const ZdAz &zdaz) const -
trunk/MagicSoft/Cosy/main/MBending.h
r2407 r2518 91 91 } 92 92 93 AltAz AddOffsets(const AltAz &aa) const; 94 ZdAz AddOffsets(const ZdAz &zdaz) const 95 { 96 AltAz p(TMath::Pi()/2-zdaz.Zd(), zdaz.Az()); 97 AltAz c = AddOffsets(p); 98 return ZdAz(TMath::Pi()/2-c.Alt(), c.Az()); 99 } 100 101 AltAz SubtractOffsets(const AltAz &aa) const; 102 ZdAz SubtractOffsets(const ZdAz &zdaz) const 103 { 104 AltAz p(TMath::Pi()/2-zdaz.Zd(), zdaz.Az()); 105 AltAz c = SubtractOffsets(p); 106 return ZdAz(TMath::Pi()/2-c.Alt(), c.Az()); 107 } 108 93 109 void SetParameters(const Double_t *par, Int_t n=fNumPar); 94 110 void GetParameters(Double_t *par, Int_t n=fNumPar) const; -
trunk/MagicSoft/Cosy/main/MCosy.cc
r2420 r2518 251 251 } 252 252 253 254 255 253 // -------------------------------------------------------------------------- 256 254 // … … 340 338 usleep(1); 341 339 342 if (Break() || HasError() || HasZombie()) 343 { 344 lout << "WaitForEndMovement aborted... "; 345 if (Break()) 346 lout << "Break signal." << endl; 347 if (HasError()) 348 lout << "Network has error." << endl; 349 if (HasZombie()) 350 lout << "Network has zombie." << endl; 351 } 340 if (!Break() && !HasError() && !HasZombie()) 341 return; 342 343 Timer t; 344 t.Now(); 345 lout << t << " - MCosy::WaitForEndMovement aborted..."; 346 if (Break()) 347 lout << " Break signal..."; 348 if (HasError()) 349 lout << " Network has error..."; 350 if (HasZombie()) 351 lout << " Network has zombie..."; 352 lout << endl; 352 353 } 353 354 … … 364 365 // status is set to stopped. 365 366 // 366 if (!HasError()) 367 { 367 if (HasError() || HasZombie()) 368 { 369 SetStatus(MDriveCom::kError); 370 return; 371 } 372 373 if (fMac1->IsPositioning() || fMac2->IsPositioning()) 374 SetStatus(MDriveCom::kMoving); 375 else 368 376 SetStatus(MDriveCom::kStopped); 369 return;370 }371 377 372 378 // 373 379 // If there is an error, the error status is set to Error. 374 380 // 375 SetStatus(MDriveCom::kError);376 381 377 382 /* … … 399 404 Bool_t MCosy::CheckRange(const ZdAz &d) const 400 405 { 401 // d [deg] 402 403 if (d.Zd()<fMin.Zd() || d.Zd()>fMax.Zd()) 404 { 405 lout << "ERROR: Requested Zenith Angle (" << d.Zd() << "deg, Az="; 406 lout << d.Az() << ") not inside allowed range." << endl; 406 // d [rad] 407 408 if (d.Zd()<fMin.Zd()) 409 { 410 lout << "ERROR: Requested Zenith Angle below negative endswitch." << endl; 407 411 return kFALSE; 408 412 } 409 413 410 if (d.Az()<fMin.Az() || d.Az()>fMax.Az()) 411 { 412 lout << "ERROR: Requested Azimuth Angle (" << d.Az() << "deg, Zd="; 413 lout << d.Zd() << ") not inside allowed range." << endl; 414 if (d.Zd()>fMax.Zd()) 415 { 416 lout << "ERROR: Requested Zenith Angle behind positive endswitch." << endl; 414 417 return kFALSE; 415 418 } 419 420 if (d.Az()<fMin.Az()) 421 { 422 lout << "ERROR: Requested Azimuth Angle below negative endswitch." << endl; 423 return kFALSE; 424 } 425 426 if (d.Az()>fMax.Az()) 427 { 428 lout << "ERROR: Requested Azimuth Angle behind positive endswitch." << endl; 429 return kFALSE; 430 } 431 416 432 417 433 return kTRUE; … … 437 453 lout << t << " - Target Position: " << d.Zd() << "deg, " << d.Az() << "deg (Zd/Az)" << endl; 438 454 439 if (!CheckRange(d))440 return kFALSE;441 442 455 // 443 456 // Calculate new target position (shortest distance to go) … … 459 472 // const ZdAz dest = CorrectTarget(src, dst); 460 473 // 461 const ZdAz dest = fBending(dst)*16384/2/TMath::Pi(); // [se] 474 ZdAz bend = fBending(dst); // [rad] 475 476 const ZdAz dest = bend*16384/2/TMath::Pi(); // [se] 477 478 if (!CheckRange(bend)) 479 return kFALSE; 480 481 bend *= kRad2Deg; 462 482 fZdAzSoll = dst; 463 483 464 484 cout << "Source Zd: " << src.Zd() << "se Az:" << src.Az() << "se" << endl; 465 485 cout << "Destination Zd: " << Rad2SE(dst.Zd()) << "se Az:" << Rad2SE(dst.Az()) << "se" << endl; 466 cout << "Bend'd Dest Zd: " << Rad2SE(fZdAzSoll.Zd()) << "se Az:" << Rad2SE(fZdAzSoll.Az())<< "se" << endl;467 cout << " Shortest Dest Zd: " << dest.Zd() << "se Az:" << dest.Az() << "se" << endl;486 cout << "Bend'd Dest Zd: " << dest.Zd() << "se Az:" << dest.Az() << "se" << endl; 487 cout << "Bend'd Dest Zd: " << bend.Zd() << "deg Az:" << bend.Az() << "deg" << endl; 468 488 469 489 // … … 476 496 { 477 497 478 lout << " Step #" << i << endl;498 lout << "- Step #" << i << endl; 479 499 // 480 500 // Get Shaft Encoder Positions … … 586 606 // 587 607 588 lout << " Do Relative Positioning..." << endl;608 lout << "- Do Relative Positioning..." << endl; 589 609 DoRelPos(rd, cdzd, cdaz); 590 lout << "Relative Positioning Done" << endl; 610 lout << "- Relative Positioning Done" << endl; 611 } 612 if (i==1 && track && !(Break() || HasError() || HasZombie())) 613 { 614 t.Now(); 615 lout << t << " - Positioning done." << endl; 616 SetStatus(MDriveCom::kStopped); 617 return TRUE; 591 618 } 592 619 … … 597 624 598 625 t.Now(); 599 lout << t << " - Warning: Requested position not reached (i=" << i << ")" << endl;626 lout << t << " - Warning: Requested position not reached (i=" << dec << i << ")" << endl; 600 627 return FALSE; 601 628 } … … 759 786 } 760 787 } 761 788 /* 762 789 Bool_t MCosy::AlignTrackingPos(ZdAz pointing, ZdAz &za) const 763 790 { … … 789 816 return rc; 790 817 } 818 */ 819 820 ZdAz MCosy::AlignTrackingPos(ZdAz pointing) const 821 { 822 // pointing [rad] 823 // AlignTrackingPos [deg] 824 825 pointing *= kRad2Deg; 826 827 if (pointing.Zd()<0) 828 { 829 pointing.Zd(-pointing.Zd()); 830 pointing.Az(pointing.Az()+180); 831 } 832 833 const ZdAz se = GetSePos()*2*TMath::Pi()/16384; // [rad] 834 const ZdAz unbendedse = fBending.CorrectBack(se)*kRad2Deg; // ist pointing 835 836 do 837 { 838 const Double_t d = unbendedse.Az() - pointing.Az(); 839 if (d>-180 && d<=180) 840 break; 841 842 pointing.Az(pointing.Az()+TMath::Sign(360., d)); 843 } while (1); 844 845 return pointing/kRad2Deg; 846 /* 847 const Bool_t rc = CheckRange(pointing); 848 za = pointing/kRad2Deg; // [rad] 849 850 if (!rc) 851 lout << "Error: Aligned position out of Range." << endl; 852 853 return rc;*/ 854 } 791 855 792 856 Double_t MCosy::Starguider(Double_t mjd, ZdAz &dest) const … … 804 868 return -1; 805 869 806 ZdAz point; 870 ZdAz point=AlignTrackingPos(ZdAz(zd, az)/kRad2Deg); 871 /* 807 872 if (!AlignTrackingPos(ZdAz(zd, az), point)) 808 873 { 809 874 cout << "Starguider position couldn't be aligned..." << endl; 810 875 return -1; 811 } 876 }*/ 877 878 // FIXME: Check Range missing! 812 879 813 880 const ZdAz diff = (dest-point)*kRad2Deg; … … 854 921 855 922 if (!SetPosition(dest, kTRUE)) 923 //if (!SetPosition(dest, kFALSE)) 856 924 { 857 925 lout << "Error: Cannot start tracking, positioning failed." << endl; … … 925 993 // 926 994 const Double_t mjd = sla.GetMjd()+dt/(60*60*24); 927 const ZdAz pointing = sla.CalcZdAz(fRaDec, mjd)*kRad2Deg; // soll pointing [deg] 928 995 const ZdAz pointing = sla.CalcZdAz(fRaDec, mjd); // soll pointing [deg] 996 997 /* 929 998 ZdAz dest; 930 999 if (!AlignTrackingPos(pointing, dest)) 931 1000 break; 1001 */ 1002 ZdAz dest = AlignTrackingPos(pointing); 932 1003 933 1004 ZdAz vcalc = sla.GetApproxVel(fRaDec) * kGearRatio2*4./60.; // [re/min] … … 940 1011 { 941 1012 dest = fBending(dest); // [rad] 1013 1014 if (!CheckRange(dest)) 1015 break; 1016 942 1017 dest *= 16384/TMath::Pi()/2; // [se] 943 1018 dest *= kGearRatio; // [re] … … 1021 1096 */ 1022 1097 usleep(1000000); // 1s 1098 cout << "." << flush; 1023 1099 //usleep(50000); // 0.05s 1024 1100 } … … 1138 1214 //CheckConnections(); 1139 1215 1216 CheckForError(); 1217 1140 1218 if (HasZombie()) 1141 1219 { … … 1157 1235 } 1158 1236 1237 CheckForError(); 1159 1238 return true; 1160 1239 } … … 1274 1353 cout << "WM_Position: start." << endl; 1275 1354 { 1276 if (!CheckNetwork())1277 return (void*)0xebb0;1355 //if (!CheckNetwork()) 1356 // return (void*)0xebb0; 1278 1357 1279 1358 ZdAz dest = *((ZdAz*)mp); … … 1387 1466 1388 1467 ZdAz a1 = sla.CalcZdAz(rd*kDeg2Rad); // [rad] 1389 const ZdAz a0 = a1*kRad2Deg; // [deg]1390 1468 1391 1469 cout << "Ra/Dec source: " << xy.X() << "h " << xy.Y() << "°" << endl; 1392 cout << "Zd/Az target: " << a 0.Zd() << "° " << a0.Az()<< "°" << endl;1470 cout << "Zd/Az target: " << a1.Zd()*kRad2Deg << "° " << a1.Az()*kRad2Deg << "°" << endl; 1393 1471 1394 1472 if (fZd1 && fZd2 && fAz) 1395 AlignTrackingPos(a0, a1); 1396 1397 a1 = fBending(a1)*kRad2Deg; 1473 a1 = AlignTrackingPos(a1); 1474 1475 a1 = fBending(a1); 1476 CheckRange(a1); 1477 a1 *= kRad2Deg; 1398 1478 1399 1479 const ZdAz a2 = a1*16384/360; … … 1403 1483 } 1404 1484 return (void*)0xa17a; 1485 1486 case WM_ENDSWITCH: 1487 { 1488 ZdAz pos = GetSePos()*TMath::Pi()*2/16384; 1489 pos = fBending.SubtractOffsets(pos)*kRad2Deg; 1490 1491 cout << "Endswitch Position: Zd=" << pos.Zd() << "° Az="; 1492 cout << pos.Az() << "°" << endl; 1493 } 1494 1495 return (void*)0x1010; 1405 1496 1406 1497 case WM_QUIT: … … 1436 1527 fMin.Set(zmin, amin); 1437 1528 1438 cout << " Min: " << zmin << "deg " << amin << "deg" << endl;1439 1440 1529 const Double_t amax = env.GetValue("Az_Max[deg]", 305.0); 1441 1530 const Double_t zmax = env.GetValue("Zd_Max[deg]", 98.25); 1442 1531 fMax.Set(zmax, amax); 1443 1444 cout << " Max: " << zmax << "deg " << amax << "deg" << endl; 1532 cout << "done." << endl; 1533 1534 cout << " * Min: " << zmin << "deg " << amin << "deg" << endl; 1535 cout << " * Max: " << zmax << "deg " << amax << "deg" << endl; 1536 1537 fMin = fBending.AddOffsets(fMin/kRad2Deg); 1538 fMax = fBending.AddOffsets(fMax/kRad2Deg); 1539 1540 cout << " * Min': " << fMin.Zd()*kRad2Deg << "deg " << fMin.Az()*kRad2Deg << "deg" << endl; 1541 cout << " * Max': " << fMax.Zd()*kRad2Deg << "deg " << fMax.Az()*kRad2Deg << "deg" << endl; 1445 1542 1446 1543 cout << "Reading gear ratios..." << flush; … … 1515 1612 return; 1516 1613 1517 lout << " Tracking Thread started..." << endl;1614 lout << "- Tracking Thread started..." << endl; 1518 1615 1519 1616 SlaStars sla(fObservatory); … … 1616 1713 ZdAz soll(sollzd.Zd(), sollaz.Az()); // [rad] 1617 1714 1618 AlignTrackingPos(soll*kRad2Deg, fZdAzSoll);1715 fZdAzSoll = AlignTrackingPos(soll); 1619 1716 1620 1717 ist *= TMath::Pi()*2/16384; … … 1628 1725 } 1629 1726 1630 lout << " Tracking Thread done." << endl;1727 lout << "- Tracking Thread done." << endl; 1631 1728 1632 1729 //--- fout << endl << endl; … … 1818 1915 ZdAz MCosy::GetPointingPos() const 1819 1916 { 1917 if (fZd1->IsZombieNode() || fZd2->IsZombieNode() || fAz->IsZombieNode()) 1918 return ZdAz(0, 0); 1919 1820 1920 // GetPointingPos [deg] 1821 1921 const ZdAz seist = GetSePos()*2*TMath::Pi()/16384; // [se] 1822 return fBending.CorrectBack(seist)*180/TMath::Pi(); 1922 1923 cout << seist.Zd()*kRad2Deg << " " << seist.Az()*kRad2Deg << endl; 1924 1925 ZdAz back = fBending.CorrectBack(seist)*180/TMath::Pi(); 1926 1927 cout << back.Zd() << " " << back.Az() << endl; 1928 1929 return back; 1823 1930 } 1824 1931 … … 1865 1972 // FIXME: Not thread safe! 1866 1973 static int i=0; 1867 if (i++== 8)1974 if (i++==7) 1868 1975 { 1869 1976 fCom->SendReport(fStatus, fRaDec, fZdAzSoll, bendist, fTrackingError); … … 2002 2109 // Don't call this function twice! 2003 2110 Network::Start(); 2111 2112 CheckForError(); 2004 2113 2005 2114 ReadConfig(); … … 2180 2289 // temp(°C) pressure(mB) height(m) humidity(1) wavelength(microm) troplapserate(K/m) 2181 2290 2182 fCom = new MDriveCom( out);2291 fCom = new MDriveCom(this, out); 2183 2292 fCom->Start(); 2184 2293 } -
trunk/MagicSoft/Cosy/main/MCosy.h
r2384 r2518 31 31 #define WM_TRACKPOS 0x100e 32 32 #define WM_POSITION1 0x100f 33 #define WM_ENDSWITCH 0x1010 33 34 34 35 class ShaftEncoder; … … 115 116 ofstream *tpout; 116 117 117 Bool_t AlignTrackingPos(ZdAz pointing, ZdAz &za) const; 118 //Bool_t AlignTrackingPos(ZdAz pointing, ZdAz &za) const; 119 ZdAz AlignTrackingPos(ZdAz pointing) const; 118 120 Bool_t CheckRange(const ZdAz &d) const; 119 121 Double_t Starguider(Double_t mjd, ZdAz &dest) const; -
trunk/MagicSoft/Cosy/main/MStarguider.cc
r2278 r2518 176 176 fInterpol->AddEntry("2", IDM_kInterpol2); 177 177 fInterpol->AddEntry("Off", IDM_kInterpol1); 178 fInterpol->CheckEntry(IDM_kInterpol1);179 178 fInterpol->Associate(this); 180 179 fList->Add(fInterpol); 181 180 182 fIntRate = 1; 181 TString disp=gVirtualX->DisplayName(); 182 if (disp.First(':')>0) 183 disp=disp(0, disp.First(':')); 184 185 if (disp.IsNull() || disp==(TString)"localhost") 186 { 187 fInterpol->CheckEntry(IDM_kInterpol1); 188 fIntRate = 1; 189 } 190 else 191 { 192 fInterpol->CheckEntry(IDM_kInterpol125); 193 fIntRate = 125; 194 } 183 195 184 196 fSetup = new MGPopupMenu(p); … … 347 359 gVirtualX->GrabButton(fId, kButton2, 0, 0, 0, 0, kTRUE); 348 360 349 fTimer=new TTimer(this, 1000/25); // 100ms361 fTimer=new TTimer(this, 1000/25); // 40ms 350 362 fTimer->TurnOn(); 351 363 -
trunk/MagicSoft/Cosy/prepos_magic.txt
r1953 r2518 1 Camera-Access 98.05333333 -9.846666666 2 Celestial-Pole 61.23817667 0 3 Park 90 -9.846666666 4 Roque-Lamp 90 180 5 Zenith 4 0 1 100.045 -8.869999999 Camera Access 2 61.23817667 0 Celestial Pole 3 94.125 -9.23 Park 4 95.58527778 151.018055556 Roque Lamp 5 4 0 Zenith -
trunk/MagicSoft/Cosy/stars.txt
r2388 r2518 1 14 28 33 42 40 21 1ES1426+428 2 20 00 00 65 08 55 1ES1959+650 3 12 29 07 02 03 09 3C273 4 12 56 11 -05 47 22 3C279 1 5 12 54 02 55 57 35 Alioth (1.77) 2 6 00 08 24 29 05 26 Alpheratz (2.06) … … 5 9 14 15 40 19 10 57 Arcturus (-0.04) 6 10 13 47 33 49 18 48 Benetnasch (1.86) 11 22 02 43 42 16 40 BL-Lac 7 12 00 09 11 59 08 59 Caph (2.27) 13 12 59 49 27 58 50 Coma Cluster 14 05 34 32 22 00 52 Crab 15 20 32 26 40 57 28 Cygnus-X3 16 21 45 41 31 43 09 Dark Patch 2 8 17 20 41 26 45 16 49 Deneb (1.25) 9 18 11 03 44 61 45 03 Dubhe (1.79) 19 06 33 54 17 46 48 Geminga 10 20 18 24 10 -34 23 05 Kaus Australis (1.85) 11 21 05 34 32 22 00 52 M1 (8.4) 22 22 22 08 -13 51 08 Mars 12 23 13 23 56 54 55 31 Mizar A (2.23) 13 16 53 52 39 45 37 Mkn 501 24 11 04 26 38 12 36 Markarian-421 25 16 53 52 39 45 37 Markarian-501 14 26 02 31 49 89 15 51 Polaris (2.02) 15 27 17 34 56 12 33 36 Ras Alhague (2.08) 16 28 17 56 37 51 29 20 Rastaban (2.23) 29 17 45 12 -28 48 18 Sagittarius-A 17 30 18 55 16 -26 17 48 Sagittarius Sigma-34 (2.02) 18 31 00 40 31 56 32 14 Schedar (2.23) 32 15 02 22 -41 53 48 SN-1006 19 33 13 25 13 -11 09 41 Spica (0.98) 20 34 17 37 19 -42 59 52 Theta Scorpionis (1.87) -
trunk/MagicSoft/Cosy/videodev/Camera.cc
r2278 r2518 1 1 #include "Camera.h" 2 2 3 #include <iostream.h> 4 #include <stdio.h> 5 #include <stdlib.h> 6 #include <errno.h> 7 #include <fcntl.h> 8 #include <string.h> 9 #include <signal.h> 10 #include <endian.h> 11 #include <sys/ioctl.h> 12 #include <sys/mman.h> 13 #include <sys/ipc.h> 14 #include <sys/shm.h> 3 #include <iostream> 4 #include <errno.h> // errono 5 #include <pthread.h> 6 #include <sys/ioctl.h> // ioctl 7 #include <sys/mman.h> // PROT_READ 15 8 16 9 #include "MStopwatch.h" … … 18 11 #include "videodev.h" 19 12 20 #include <sys/time.h>21 #include <sys/resource.h>22 23 13 ClassImp(Camera); 14 15 using namespace std; 24 16 25 17 inline int Camera::Ioctl(int req, void *opt, const char *str) … … 103 95 } 104 96 105 Camera::Camera(PixClient &client) : fd(-1), iBufferSize(0), fClient(client) 97 Camera::Camera(PixClient &client) : fd(-1), iBufferSize(0), fClient(client), fMutex(), fCond(&fMutex) 106 98 { 107 99 cout << "Starting thread..." << flush; 108 pthread_cond_init(&fCond, NULL); 109 pthread_mutex_init(&fMux, NULL); 110 pthread_mutex_lock(&fMux); 100 //pthread_cond_init(&fCond, NULL); 101 //pthread_mutex_init(&fMux, NULL); 102 //pthread_mutex_lock(&fMux); 103 fMutex.Lock(); 111 104 pthread_create(&fThread, NULL, MapThread, this); 112 105 cout << "done." << endl; … … 173 166 cout << "Stopping thread..." << flush; 174 167 pthread_cancel(fThread); 175 pthread_mutex_destroy(&fMux);176 pthread_cond_destroy(&fCond);168 //pthread_mutex_destroy(&fMux); 169 //pthread_cond_destroy(&fCond); 177 170 cout << "done." << endl; 178 171 … … 226 219 while (1) 227 220 { 228 pthread_cond_wait(&fCond, &fMux); 221 //pthread_cond_wait(&fCond, &fMux); 222 fCond.Wait(); 223 229 224 MStopwatch t; 230 225 t.Start(); … … 286 281 // set new number of frames to process 287 282 // 288 pthread_mutex_lock(&fMux); 283 fMutex.Lock(); 284 //pthread_mutex_lock(&fMux); 289 285 fNum = nof; 290 286 fStop = 0; 291 287 fRunning = 1; 292 pthread_mutex_unlock(&fMux); 288 fMutex.UnLock(); 289 //pthread_mutex_unlock(&fMux); 293 290 294 291 // 295 292 // Start execution 296 293 // 297 pthread_cond_signal(&fCond); 294 fCond.Broadcast(); 295 //pthread_cond_signal(&fCond); 298 296 } 299 297 -
trunk/MagicSoft/Cosy/videodev/Camera.h
r2278 r2518 2 2 #define CAMERA_H 3 3 4 #ifndef ROOT_TMutex 5 #include <TMutex.h> 6 #endif 7 #ifndef ROOT_TCondition 8 #include <TCondition.h> 9 #endif 10 4 11 #ifdef __CINT__ 5 12 typedef unsigned long int pthread_t; 6 struct pthread_mutex_t;7 struct pthread_cond_t;8 13 struct timeval; 9 14 #else 10 #include <TROOT.h>11 #include <pthread.h>12 15 #include <unistd.h> 13 16 #include <sys/time.h> … … 47 50 struct timeval fTime; 48 51 49 pthread_t fThread; 50 pthread_mutex_t fMux; 51 pthread_cond_t fCond; 52 PixClient &fClient; 52 53 53 PixClient &fClient; 54 pthread_t fThread; 55 TMutex fMutex; 56 TCondition fCond; 57 //pthread_mutex_t fMux; 58 //pthread_cond_t fCond; 54 59 55 60 //
Note:
See TracChangeset
for help on using the changeset viewer.