Changeset 1727 for trunk/MagicSoft/Cosy
- Timestamp:
- 01/23/03 13:32:58 (22 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/Changelog
r1703 r1727 1 1 -*-*- END -*-*- 2 3 2003/01/23 - Thomas Bretz: 4 5 * cosy.cc: 6 - changed baudrate to 125kbps 7 8 * base/msgqueue.cc: 9 - changed output 10 - ignore pending messages 11 12 * candrv/canopen.[h,cc]: 13 - added Emergency Message 14 - added EnableNodeguard 15 - added SendNodeguard 16 17 * candrv/network.[h,cc]: 18 - call handles only if Fnodes[node]!=NULL 19 - added time to HandleSDOOK 20 - changed output 21 - added HandleNodeguard 22 - added HandleEmergency 23 24 * candrv/nodedrv.[h,cc]: 25 - added fTimeout for Nodeguarding 26 - Enable Nodeguard and Emergency messages 27 - added time to HandleSDOOK 28 - added SendNodeguard 29 - added StartGuarding 30 - added StopGuarding 31 - added HandleTimer 32 - added HandleNodeguard 33 - added SetZombie 34 35 * candrv/vmodican.[h,cc]: 36 - fixed a typo 37 - added rtr to SendCanFrame 38 39 * devdrv/macs.[h,cc]: 40 - removed guarding stuff (moved to nodedrv) 41 - changed 0x4000 handling to 0.63 style 42 - added check for software version 43 - added time to HandleSDOOk 44 - set node to Zombie in case of error 45 - don't do any error handling for the moment 46 - removed ReqTimeoutTime 47 - overload SendNodeguard 48 - removed EnableTimeout 49 - removed HandleTimer 50 - removed ResetTimeout 51 - added Start/StopHostGuarding 52 53 * devdrv/shaftencoder.[h,cc]: 54 - added 0x100c, 0x100d, 0x100e 55 - added Start/StopGuarding to Init 56 57 * gui/MGCosy.cc: 58 - enhanced labels for Offset 59 - changed 'soll' to 'nominal' 60 - changed the demo mode for tests 61 62 * gui/MGSkyPosition.[h,cc]: 63 - added saturn 64 - changed the colors a bit 65 66 67 68 2003/01/20 - Thomas Bretz: 69 70 * aposs/Manual.m 71 - added support for the elevation axis brake 72 - enabled check for operation mode (remote control/pc) 73 - added 'reset' label 74 - moved syncv/cstart to setting rf 75 76 77 2 78 2003/01/14 - Thomas Bretz: 3 79 -
trunk/MagicSoft/Cosy/base/msgqueue.cc
r1275 r1727 77 77 while(1) 78 78 { 79 while (!fStart) usleep(1); 79 while (!fStart) 80 usleep(1); 80 81 fStart = 0; 81 82 … … 88 89 pthread_mutex_unlock(&fMuxMsg); 89 90 90 cout << " Processing Msg 0x" << hex << fMsg << endl;91 cout << "MsgQueue::Thread: Processing Msg 0x" << hex << fMsg << endl; 91 92 // --- bool quit = fMsg==WM_QUIT; 92 93 fRc=Proc(fMsg, fMp); 93 cout << "Msg 0x" << hex << fMsg << " processed." << endl;94 cout << "MsgQueue::PostMsg: Msg 0x" << hex << fMsg << " processed (rc=" << fRc << ")" << endl; 94 95 95 96 // --- if (quit) … … 118 119 // stopped and the messages are processed serialized 119 120 // 120 cout << " Locking MsgQueue mutex..." << flush;121 cout << "MsgQueue::PostMsg: Locking MsgQueue mutex..." << flush; 121 122 pthread_mutex_lock(&fMuxMsg); 122 123 cout << "done." << endl; … … 129 130 // This is some kind of controlled user break without using signals 130 131 // 132 /**** NEW 20/01/2003 ****/ 133 if (fBreak) 134 { 135 pthread_mutex_unlock(&fMuxMsg); 136 cout << "------------> MsgQueue::PostMsg: Proc still pending... Message IGNORED." << endl; 137 return NULL; 138 } 139 /**** NEW 20/01/2003 ****/ 140 cout << "MsgQueue::PostMsg: ---> Break <---" << endl; 131 141 fBreak = 1; 132 142 … … 146 156 // Start Proc() 147 157 // 158 cout << "MsgQueue::PostMsg: Releasing MsgQueue mutex..." << flush; 148 159 fStart = 1; 149 cout << "Releasing MsgQueue mutex..." << flush;150 160 pthread_mutex_unlock(&fMuxMsg); 151 161 cout << "done." << endl; 152 while (fStart) 153 usleep(1); 154 155 cout << "Returning rc = 0x" << hex << rc << endl; 162 163 /* 164 * **** NEW 20/01/2003 *** 165 * 166 * This can halt the main thread, because it is waiting until 167 * Proc has finished its execution which can take a while 168 * 169 * A side effect is, because you don't wait for the end of 170 * the execution of Proc, if a new message is posted fBreak 171 * and fStart is set again, new values are copied to fMsg and 172 * fMp (FIXME? Harmefull?) and the message is not processed at all. 173 */ 174 //while (fStart) 175 // usleep(1); 176 177 cout << "MsgQueue::PostMsg: Returning rc = " << hex << rc << endl; 156 178 return rc; 157 179 } 158 180 /* 181 Start positioning. 182 MsgQueue::PostMsg: Locking MsgQueue mutex...done. 183 MsgQueue::PostMsg: ---> Break <--- 184 +++++ MsgQueue::PostMsg: Releasing MsgQueue mutex...done. 185 186 ===== MsgQueue::PostMsg: Returning rc = (nil) 187 PostMsg (WM_Position) returned. 188 done. 189 Stopping movement...Movement stopped. 190 WM_Position: done. (return 0x7777) 191 MsgQueue::PostMsg: Msg 0x1001 processed (rc=0x7777) 192 MsgQueue::Thread: Processing Msg 0x1001 193 WM_Position: start. 194 Positioning to Target... 195 */ 196 /* 197 Start positioning. 198 MsgQueue::PostMsg: Locking MsgQueue mutex...done. 199 MsgQueue::PostMsg: ---> Break <--- 200 +++++ MsgQueue::PostMsg: Releasing MsgQueue mutex...done. 201 202 done. 203 Stopping movement...Movement stopped. 204 WM_Position: done. (return 0x7777) 205 MsgQueue::PostMsg: Msg 0x1001 processed (rc=0x7777) 206 MsgQueue::Thread: Processing Msg 0x1001 207 WM_Position: start. 208 Positioning to Target... 209 ===== MsgQueue::PostMsg: Returning rc = (nil) 210 */ -
trunk/MagicSoft/Cosy/candrv/canopen.cc
r1275 r1727 16 16 ! 17 17 ! 18 ! Author(s): Thomas Bretz <mailto:tbretz@ uni-sw.gwdg.de>, 200119 ! 20 ! Copyright: MAGIC Software Development, 2000-200 118 ! Author(s): Thomas Bretz <mailto:tbretz@astro.uni-wuerzburg.de>, 2003 19 ! 20 ! Copyright: MAGIC Software Development, 2000-2003 21 21 ! 22 22 ! … … 84 84 { 85 85 const WORD_t fcode = cobid >> 7; 86 const BYTE_t node = cobid & 0x1f; 86 87 87 88 switch (fcode) … … 94 95 return; 95 96 96 case kSYNC: 97 cout << "Sync" << endl; 97 case kEMERGENCY: // also case kSYNC: 98 if (cobid==0) 99 cout << "Sync" << endl; 100 else 101 { 102 cout << "EMERGENCY Node #" << dec << (int)data[1] << endl; 103 HandleEmergency(node, tv); 104 } 105 return; 106 107 case kNodeguard: 108 //cout << "Nodeguard Node #" << dec << (int)node << endl; 109 HandleNodeguard(node, tv); 98 110 return; 99 111 100 112 case kSDO_RX: 101 113 { 102 const BYTE_t node = cobid & 0x1f;103 114 const BYTE_t cmd = data[0]; 104 115 const LWORD_t dat = data[4] | (data[5]<<8) | (data[6]<<16) | (data[7]<<24); … … 114 125 case kPDO1_TX: 115 126 { 116 const BYTE_t node = cobid & 0x1f;117 127 HandlePDO1(node, data, tv); 118 128 pthread_cond_broadcast(&fPdoCond[node-1][0]); … … 122 132 case kPDO2_TX: 123 133 { 124 const BYTE_t node = cobid & 0x1f;125 134 HandlePDO2(node, data, tv); 126 135 pthread_cond_broadcast(&fPdoCond[node-1][1]); … … 130 139 case kPDO3_TX: 131 140 { 132 const BYTE_t node = cobid & 0x1f;133 141 HandlePDO3(node, data, tv); 134 142 pthread_cond_broadcast(&fPdoCond[node-1][2]); … … 138 146 case kPDO4_TX: 139 147 { 140 const BYTE_t node = cobid & 0x1f;141 148 HandlePDO4(node, data, tv); 142 149 pthread_cond_broadcast(&fPdoCond[node-1][3]); … … 145 152 } 146 153 147 const BYTE_t node = cobid & 0x1f; 148 cout << "Function Code: 0x" << hex << fcode << " Node: " << dec << (int)node << endl; 154 cout << "CanOpen::HandleCanMessage - Unhandled Message: Function Code=0x" << hex << fcode << " Node #" << dec << (int)node << endl; 149 155 } 150 156 … … 168 174 { 169 175 EnableCanMsg(node, kEMERGENCY); 176 } 177 178 // -------------------------------------------------------------------------- 179 // 180 // Enables Nodeguard messages for a given node 181 // 182 void CanOpen::EnableNodeguard(BYTE_t node) 183 { 184 EnableCanMsg(node, kNodeguard); 170 185 } 171 186 … … 372 387 // -------------------------------------------------------------------------- 373 388 // 374 // Send a nNMT Message to the given node with command cmd389 // Send a NMT Message to the given node with command cmd 375 390 // 376 391 void CanOpen::SendNMT(BYTE_t node, BYTE_t cmd) … … 381 396 // -------------------------------------------------------------------------- 382 397 // 398 // Send a Nodeguard Message to the given node with command cmd 399 // 400 void CanOpen::SendNodeguard(BYTE_t node) 401 { 402 BYTE_t msg[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; 403 SendCanFrame(CobId(node, kNodeguard), msg, 1); 404 } 405 406 // -------------------------------------------------------------------------- 407 // 383 408 // Decodes node and function code into a CobId 384 409 // -
trunk/MagicSoft/Cosy/candrv/network.cc
r1703 r1727 89 89 void Network::HandleSDO(BYTE_t node, BYTE_t cmd, WORD_t idx, BYTE_t subidx, LWORD_t data, timeval_t *tv) 90 90 { 91 switch (cmd) 92 { 93 case kSDO_TX4: // answer to 0x40 with 4 bytes of data 94 if (fNodes[node]) 91 if (fNodes[node]) 92 switch (cmd) 95 93 { 94 case kSDO_TX4: // answer to 0x40 with 4 bytes of data 96 95 fNodes[node]->HandleSDO(idx, subidx, data, tv); 97 96 return; 97 98 case kSDO_TX3: // answer to 0x40 with 2 bytes of data 99 fNodes[node]->HandleSDO(idx, subidx, data>>16, tv); 100 return; 101 102 case kSDO_TX1: // answer to 0x40 with 1 byte of data 103 fNodes[node]->HandleSDO(idx, subidx, data>>24, tv); 104 return; 105 106 case kSDO_TX_OK: // answer to a SDO_TX message 107 fNodes[node]->HandleSDOOK(idx, subidx, tv); 108 return; 109 110 case kSDO_TX_ERROR: // error message (instead of 0x60) 111 fNodes[node]->HandleSDOError(data); 112 return; 98 113 } 99 break; 100 101 case kSDO_TX3: // answer to 0x40 with 2 bytes of data 102 if (fNodes[node]) 103 { 104 fNodes[node]->HandleSDO(idx, subidx, data>>16, tv); 105 return; 106 } 107 break; 108 109 case kSDO_TX1: // answer to 0x40 with 1 byte of data 110 if (fNodes[node]) 111 { 112 fNodes[node]->HandleSDO(idx, subidx, data>>24, tv); 113 return; 114 } 115 break; 116 117 case kSDO_TX_OK: // answer to a SDO_TX message 118 if (fNodes[node]) 119 { 120 fNodes[node]->HandleSDOOK(idx, subidx); 121 return; 122 } 123 break; 124 125 case kSDO_TX_ERROR: // error message (instead of 0x60) 126 if (fNodes[node]) 127 { 128 fNodes[node]->HandleSDOError(data); 129 return; 130 } 131 break; 132 } 114 133 115 cout << dec << setfill('0'); 134 cout << "N ode=" << (int)node << " Cmd=0x" << hex << (int)cmd << ": ";116 cout << "Network::HandleSDO: Node=" << (int)node << " Cmd=0x" << hex << (int)cmd << ": "; 135 117 cout << "Sdo=" << idx << "/" << (int)subidx << ": 0x" << setw(8) << data; 136 118 cout << endl; … … 145 127 if (!fNodes[node]) 146 128 { 147 cout << "N ode " << dec << (int)node << ",PDO1: " << hex;129 cout << "Network::HandlePDO1: Node #" << dec << (int)node << " not found - PDO1: " << hex; 148 130 for (int i=0; i<8; i++) 149 131 cout << " 0x" << (int)data[i]; … … 163 145 if (!fNodes[node]) 164 146 { 165 cout << "N ode " << dec << (int)node << ",PDO2: " << hex;147 cout << "Network::HandlePDO2: Node #" << dec << (int)node << " not found - PDO2: " << hex; 166 148 for (int i=0; i<8; i++) 167 149 cout << " 0x" << (int)data[i]; … … 181 163 if (!fNodes[node]) 182 164 { 183 cout << "N ode " << dec << (int)node << ",PDO3: " << hex;165 cout << "Network::HandlePDO3: Node #" << dec << (int)node << " not found - PDO3: " << hex; 184 166 for (int i=0; i<8; i++) 185 167 cout << " 0x" << (int)data[i]; … … 199 181 if (!fNodes[node]) 200 182 { 201 cout << "N ode " << dec << (int)node << ",PDO4: " << hex;183 cout << "Network::HandlePDO4: Node #" << dec << (int)node << " not found - PDO4: " << hex; 202 184 for (int i=0; i<8; i++) 203 185 cout << " 0x" << (int)data[i]; … … 208 190 fNodes[node]->HandlePDO4(data, tv); 209 191 } 192 193 // -------------------------------------------------------------------------- 194 // 195 // Distributes Nodeguard messages to the correspoding node calling 196 // HandleNodeguard 197 // 198 void Network::HandleNodeguard(BYTE_t node, timeval_t *tv) 199 { 200 if (!fNodes[node]) 201 { 202 cout << "Network::HandleNodeguard: Node #" << dec << (int)node << " not found: Nodeguard." << endl; 203 return; 204 } 205 206 fNodes[node]->HandleNodeguard(tv); 207 } 208 209 // -------------------------------------------------------------------------- 210 // 211 // Distributes Emergency messages to the correspoding node calling 212 // HandleEmergency 213 // 214 void Network::HandleEmergency(BYTE_t node, timeval_t *tv) 215 { 216 if (!fNodes[node]) 217 { 218 cout << "Network::HandleEmergency: Node #" << dec << (int)node << " not found: Emergency." << endl; 219 return; 220 } 221 222 fNodes[node]->HandleEmergency(tv); 223 } 224 210 225 211 226 // -------------------------------------------------------------------------- … … 281 296 continue; 282 297 283 lout << "- Node #" << dec << i << " '" << fNodes[i]->GetNodeName();284 lout << "' has error #" << fNodes[i]->GetError() << endl;298 //lout << "- Node #" << dec << i << " '" << fNodes[i]->GetNodeName(); 299 //lout << "' has error #" << fNodes[i]->GetError() << endl; 285 300 } 286 301 -
trunk/MagicSoft/Cosy/candrv/network.h
r1703 r1727 16 16 void HandlePDO3(BYTE_t node, BYTE_t *data, timeval_t *tv); 17 17 void HandlePDO4(BYTE_t node, BYTE_t *data, timeval_t *tv); 18 void HandleNodeguard(BYTE_t node, timeval_t *tv); 19 void HandleEmergency(BYTE_t node, timeval_t *tv); 18 20 19 21 void InitNodes(); -
trunk/MagicSoft/Cosy/candrv/nodedrv.cc
r1703 r1727 33 33 // virtual void StopDevice() 34 34 // virtual void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, timeval_t *tv) 35 // virtual void HandleSDOOK(WORD_t idx, BYTE_t subidx )35 // virtual void HandleSDOOK(WORD_t idx, BYTE_t subidx, timeval_t *tv) 36 36 // virtual void HandleSDOError(LWORD_t data) 37 37 // virtual void HandlePDO1(BYTE_t *data, timeval_t *tv) … … 48 48 #include <iostream.h> 49 49 50 #include <TTimer.h> 51 52 #include "base/timer.h" 50 53 #include "network.h" 51 54 #include "MLogManip.h" … … 76 79 } 77 80 81 fTimerOn = kFALSE; 82 fTimeout = new TTimer(this, 100, kFALSE); // 100ms, asynchronous 83 78 84 lout << "- Node #" << (int)nodeid << " (" << name << ") initialized." << endl; 79 } 80 81 // -------------------------------------------------------------------------- 82 // 83 // Empty destructor 85 86 } 87 88 // -------------------------------------------------------------------------- 89 // 90 // destructor 84 91 // 85 92 NodeDrv::~NodeDrv() 86 93 { 94 fTimerOn = kFALSE; 95 delete fTimeout; 87 96 } 88 97 … … 122 131 EnableCanMsg(kSDO_RX); 123 132 EnableCanMsg(kSDO_TX); 133 EnableCanMsg(kNodeguard); 134 EnableCanMsg(kEMERGENCY); 124 135 125 136 fIsZombie = kFALSE; … … 135 146 // This output is never redirected to the GUI 136 147 // 137 void NodeDrv::HandleSDOOK(WORD_t idx, BYTE_t subidx )148 void NodeDrv::HandleSDOOK(WORD_t idx, BYTE_t subidx, timeval_t *tv) 138 149 { 139 150 const Bool_t gui = lout.IsOutputDeviceEnabled(MLog::eGui); … … 367 378 // -------------------------------------------------------------------------- 368 379 // 369 // Send a nNMT message (command) to this device380 // Send a NMT message (command) to this device 370 381 // 371 382 // The message is not send if the node has the status Zombie. … … 377 388 fNetwork->SendNMT(fId, cmd); 378 389 return !fIsZombie; 390 } 391 392 // -------------------------------------------------------------------------- 393 // 394 // Send a Nodeguard message (command) to this device 395 // 396 void NodeDrv::SendNodeguard() 397 { 398 fNetwork->SendNodeguard(fId); 379 399 } 380 400 … … 404 424 405 425 if (!rc) 426 { 427 lout << "NodeDrv::WaitForSdo: 0x" << hex << idx << "/" << dec << (int)subidx << " " << GetNodeName() << " --> ZOMBIE!" << endl; 428 SetZombie(); 429 } 430 /* 431 if (HasError()) 432 { 433 lout << "NodeDrv::WaitForSdo: HasError 0x" << hex << idx << "/" << dec << (int)subidx << " " << GetNodeName() << " --> ZOMBIE!" << endl; 406 434 fIsZombie = kTRUE; 407 435 } 436 */ 408 437 return fIsZombie ? false : rc; 409 438 } … … 453 482 } 454 483 484 // -------------------------------------------------------------------------- 485 // 486 // Start the standard CANopen guarding of the device. 487 // While ms is the guard time in millisec. This is the time between 488 // two requests for a Nodeguard message. 489 // ltf is the LifeTimeFactor. This means how often it is checked, that at 490 // least one Nodeguard message was answered. 491 // 492 void NodeDrv::StartGuarding() 493 { 494 if (fTimerOn) 495 return; 496 497 SendNodeguard(); 498 499 fTimerOn = kTRUE; 500 fTimeout->SetTime(fGuardTime); 501 fTimeout->Reset(); 502 fTimeout->TurnOn(); 503 //fTimeout->Start(fGuardTime, kTRUE); 504 505 lout << "- " << GetNodeName() << ": Guarding (" << dec; 506 lout << fLifeTimeFactor << "*" << fGuardTime << "ms) started." << endl; 507 } 508 509 void NodeDrv::StartGuarding(Int_t ms, Int_t ltf) 510 { 511 if (fTimerOn) 512 { 513 lout << "- " << GetNodeName() << ": ERROR - Guarding already started." << endl; 514 return; 515 } 516 fGuardTime = ms; 517 fLifeTimeFactor = ltf; 518 519 StartGuarding(); 520 } 521 522 void NodeDrv::StopGuarding() 523 { 524 fTimeout->TurnOff(); 525 fTimerOn = kFALSE; 526 527 lout << "- " << GetNodeName() << ": Guarding stopped." << endl; 528 } 529 530 // -------------------------------------------------------------------------- 531 // 532 // Handle the Nodeguard-Timer Event. 533 // It checks whether the node timed out. If it timed out it is set to 534 // the Zombie state. 535 // A new Nodeguard request is send and a new timer event is triggered. 536 // 537 Bool_t NodeDrv::HandleTimer(TTimer *t) 538 { 539 // 540 // WARNING: 541 // It seems, that you should never access ANY output from 542 // here. Neither the GUI, nor COUT. This can result in 543 // 'unexpected async reply' 544 // 545 546 /* 547 Fons: 548 ----- 549 550 timers never trigger at the same time or when in a TTimer::Notify. 551 Little explanation: 552 553 - there are two types of timers synchronous and a-synchronous. 554 - synchronous timers are only handled via the ROOT eventloop 555 (see TUnixSystem::DispatchOneEvent()). If there are no mouse/keyboard 556 events then the synchronous timer queue is checked. So if the processing 557 of a mouse/keyboard event takes a long time synchronous timers are not 558 called for a while. To prevent this from happening one can call in long 559 procedures gSystem->ProcessEvents(). The system schedules only the 560 next timer in the queue when the current one's Notify() has finished. 561 - a-synchronous timers are triggered via SIGALARM, i.e. the program is 562 interupted and execution jumps to the Notify() function. When the 563 notify is finished the next a-sync timer is scheduled and the system 564 resumes from the place where it was initially interrupted. One of the 565 things to remember when using a-sync timers is don't make any graphics 566 calls in them. X11 is not re-entrant and it might be that the SIGALARM 567 signal interrupted the system while being in X11. A-sync timers are best 568 used to set flags that you can test at a convenient and controlled 569 time. 570 */ 571 if (fIsZombie) 572 return kTRUE; 573 574 Timer time; 575 Double_t now = time.Now(); 576 if (now > fTimeoutTime) 577 { 578 //cout << "ERROR - " << GetNodeName() << " didn't respond in timeout window." << endl; 579 //lout << "ERROR - " << GetNodeName() << " didn't respond in timeout window." << endl; 580 //cout << dec << "+" << (int)GetId() << ": Handle: " << fmod(now, 500) << endl; 581 //cout << dec << "+" << (int)GetId() << ": Handle: " << fmod(fTimeoutTime, 500) << endl; 582 //cout << fGuardTime << endl; 583 fIsZombie = true; 584 //SetZombie(); 585 586 return kTRUE; 587 } 588 589 SendNodeguard(); 590 591 return kTRUE; 592 } 593 594 // -------------------------------------------------------------------------- 595 // 596 // Set the timeout timer to the time the event was received plus the 597 // guard time times lifetimefactor. 598 // 599 void NodeDrv::HandleNodeguard(timeval_t *tv) 600 { 601 Timer t(tv); 602 fTimeoutTime = t + (fGuardTime*fLifeTimeFactor/1000.); 603 } 604 605 void NodeDrv::SetZombie() 606 { 607 fIsZombie = true; 608 StopGuarding(); 609 } -
trunk/MagicSoft/Cosy/candrv/nodedrv.h
r1703 r1727 20 20 class Network; 21 21 22 class NodeDrv : public Log 22 class NodeDrv : public Log, public TObject 23 23 { 24 24 private: … … 30 30 int fError; 31 31 32 Bool_t fIsZombie; // A Zombie node is a node which doesn't answer... 33 34 TTimer *fTimeout; 35 Int_t fGuardTime; // Guardtime [ms] 36 Int_t fLifeTimeFactor; 37 Double_t fTimeoutTime; 38 Bool_t fTimerOn; 39 40 Bool_t HandleTimer(TTimer *t); 41 32 42 protected: 33 43 void SetError(int err) { fError = err; } 34 44 void DelError() { fError = 0; } 35 45 36 Bool_t fIsZombie; // A Zombie node is a node which doesn't answer... 46 Int_t GetLifeTimeFactor() const { return fLifeTimeFactor; } 47 Int_t GetGuardTime() const { return fGuardTime; } 48 49 virtual void SetZombie(); 37 50 38 51 public: … … 56 69 57 70 virtual void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, timeval_t *tv); 58 virtual void HandleSDOOK(WORD_t idx, BYTE_t subidx );71 virtual void HandleSDOOK(WORD_t idx, BYTE_t subidx, timeval_t *tv); 59 72 virtual void HandleSDOError(LWORD_t data); 60 73 61 virtual void HandlePDO1(BYTE_t *data, timeval_t *tv) {}; 62 virtual void HandlePDO2(BYTE_t *data, timeval_t *tv) {}; 63 virtual void HandlePDO3(BYTE_t *data, timeval_t *tv) {}; 64 virtual void HandlePDO4(BYTE_t *data, timeval_t *tv) {}; 74 virtual void HandlePDO1(BYTE_t *data, timeval_t *tv) {} 75 virtual void HandlePDO2(BYTE_t *data, timeval_t *tv) {} 76 virtual void HandlePDO3(BYTE_t *data, timeval_t *tv) {} 77 virtual void HandlePDO4(BYTE_t *data, timeval_t *tv) {} 78 virtual void HandleNodeguard(timeval_t *tv); 79 virtual void HandleEmergency(timeval_t *tv) {} 65 80 66 81 bool SendPDO1(BYTE_t data[8]); … … 80 95 81 96 bool SendNMT(BYTE_t cmd); 97 virtual void SendNodeguard(); 82 98 83 99 bool RequestSDO(WORD_t idx, BYTE_t subidx=0); … … 93 109 void EnableCanMsg(BYTE_t fcode); 94 110 111 void StartGuarding(); 112 void StartGuarding(Int_t ms, Int_t ltf); 113 void StopGuarding(); 114 95 115 ClassDef(NodeDrv, 0) // base class for an object describing hardware 96 116 }; -
trunk/MagicSoft/Cosy/candrv/vmodican.cc
r1703 r1727 409 409 while (!Send(&msg)); /* transmitt to module */ 410 410 411 lout << "- Baudrate set to " << rate << " bps" << endl;411 lout << "- Baudrate set to " << rate << "kbps" << endl; 412 412 } 413 413 … … 904 904 // */ 905 905 // 906 void VmodIcan::SendCanFrame(WORD_t cobid, BYTE_t m[8] )907 { 908 const WORD_t desc = MsgDescr(cobid, 8 );906 void VmodIcan::SendCanFrame(WORD_t cobid, BYTE_t m[8], BYTE_t rtr) 907 { 908 const WORD_t desc = MsgDescr(cobid, 8, rtr); 909 909 910 910 Message msg; -
trunk/MagicSoft/Cosy/candrv/vmodican.h
r1140 r1727 73 73 void EnableCobId(WORD_t cobid, int flag=TRUE); 74 74 75 void SendCanFrame(WORD_t cobid, BYTE_t m[8] );75 void SendCanFrame(WORD_t cobid, BYTE_t m[8], BYTE_t rtr=0); 76 76 void SendCanFrame(WORD_t cobid, 77 77 BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0, -
trunk/MagicSoft/Cosy/cosy.cc
r1703 r1727 73 73 } 74 74 75 MCosy *cosy = new MCosy(mode, "/dev/dpm_00", 500, lout);75 MCosy *cosy = new MCosy(mode, "/dev/dpm_00", 125, lout); 76 76 77 77 clog("- Starting MCosy."); -
trunk/MagicSoft/Cosy/devdrv/macs.cc
r1703 r1727 33 33 fPosActive(0), fRpmActive(0) 34 34 { 35 fTimeout = new TTimer(this, 100, kFALSE); // 100ms, asynchronous35 // fTimeout = new TTimer(this, 100); //, kFALSE); // 100ms, asynchronous 36 36 } 37 37 38 38 Macs::~Macs() 39 39 { 40 fTimerOn = kFALSE;41 delete fTimeout;40 //fTimerOn = kFALSE; 41 // delete fTimeout; 42 42 } 43 43 … … 60 60 fVel = val; 61 61 return; 62 63 case 0x4000:64 switch (subidx)65 {66 case 1:67 cout << GetNodeName() << ": Timeout timer is " << (val?"en":"dis") << "abled." << endl;68 return;69 case 2:70 cout << GetNodeName() << ": Actual timeout time: " << dec << val << "ms" << endl;71 return;72 }73 break;74 62 75 63 case 0x6004: … … 129 117 } 130 118 131 void Macs::HandleSDOOK(WORD_t idx, BYTE_t subidx )119 void Macs::HandleSDOOK(WORD_t idx, BYTE_t subidx, timeval_t *tv) 132 120 { 133 121 switch (idx) … … 137 125 { 138 126 case 0: 139 lout << ddev(MLog::eGui);127 //lout << ddev(MLog::eGui); 140 128 lout << "- " << GetNodeName() << ": Velocity set." << endl; 141 lout << edev(MLog::eGui);129 //lout << edev(MLog::eGui); 142 130 return; 143 131 } 144 132 break; 133 145 134 case 0x2003: 146 135 switch (subidx) 147 136 { 148 137 case 0: 149 lout << ddev(MLog::eGui);138 //lout << ddev(MLog::eGui); 150 139 lout << "- " << GetNodeName() << ": Acceleration set." << endl; 151 lout << edev(MLog::eGui);140 //lout << edev(MLog::eGui); 152 141 return; 153 142 case 1: 154 lout << ddev(MLog::eGui);143 //lout << ddev(MLog::eGui); 155 144 lout << "- " << GetNodeName() << ": Decceleration set." << endl; 156 lout << edev(MLog::eGui);145 //lout << edev(MLog::eGui); 157 146 return; 158 147 } 159 148 break; 149 160 150 case 0x3006: 161 151 switch (subidx) 162 152 { 163 153 case 0: 164 lout << ddev(MLog::eGui);154 //lout << ddev(MLog::eGui); 165 155 lout << "- " << GetNodeName() << ": RPM mode switched." << endl; 166 lout << edev(MLog::eGui);156 //lout << edev(MLog::eGui); 167 157 return; 168 158 … … 176 166 } 177 167 break; 168 178 169 case 0x4000: 179 if (subidx==0 && fTimerOn) 180 { 181 ResetTimeout(); 182 return; 183 } 184 break; 170 HandleNodeguard(tv); 171 return; 172 185 173 case 0x6004: 186 174 switch (subidx) 187 175 { 188 176 case 0: 189 lout << ddev(MLog::eGui);177 //lout << ddev(MLog::eGui); 190 178 lout << "- " << GetNodeName() << ": Absolute positioning started." << endl; 191 lout << edev(MLog::eGui);179 //lout << edev(MLog::eGui); 192 180 return; 193 181 194 182 case 1: 195 lout << ddev(MLog::eGui);183 //lout << ddev(MLog::eGui); 196 184 lout << "- " << GetNodeName() << ": Relative positioning started." << endl; 197 lout << edev(MLog::eGui);185 //lout << edev(MLog::eGui); 198 186 return; 199 187 } … … 202 190 203 191 } 204 NodeDrv::HandleSDOOK(idx, subidx );192 NodeDrv::HandleSDOOK(idx, subidx, tv); 205 193 } 206 194 … … 231 219 RequestSDO(0x100b); 232 220 WaitForSdo(0x100b); 233 234 // FIXME! Not statically linked!235 // if (fSoftVersion<0x00000035)236 // fIsZombie = true;237 221 } 238 222 … … 240 224 void Macs::Init() 241 225 { 226 if (HasError()) 227 { 228 lout << "Macs::Init: " << GetNodeName() << " has error --> ZOMBIE!" << endl; 229 SetZombie(); 230 } 231 232 StopHostGuarding(); 233 StopGuarding(); 234 235 usleep(2000.*GetGuardTime()); 236 242 237 lout << "- " << GetNodeName() << ": Requesting Mac Software Version." << endl; 243 238 RequestSDO(0x100a); 244 239 WaitForSdo(0x100a); 245 240 246 if ( fIsZombie)241 if (IsZombieNode()) 247 242 { 248 243 lout << GetNodeName() << " - InitDevice failed!" << endl; … … 250 245 } 251 246 252 EnableTimeout(kFALSE); 247 // FIXME! Not statically linked! 248 if (fSoftVersion<0x00000042) // 00.66 249 { 250 lout << GetNodeName() << " - Software Version too old!" << endl; 251 SetZombie(); 252 return; 253 } 254 253 255 SetRpmMode(FALSE); 254 256 … … 270 272 271 273 SetNoWait(TRUE); 274 275 StartGuarding(100, 2); 276 StartHostGuarding(); 272 277 } 273 278 … … 283 288 void Macs::StopDevice() 284 289 { 285 EnableTimeout(kFALSE);290 //EnableTimeout(kFALSE); 286 291 287 292 SetNoWait(FALSE); … … 348 353 { 349 354 SendSDO(0x2002, vel); // velocity 350 WaitForSdo(0x2002 );355 WaitForSdo(0x2002, 0); 351 356 } 352 357 … … 466 471 { 467 472 lout << "- " << GetNodeName() << ": reports Error occursion." << endl; 473 lout << "Macs::HandlePDO2: " << GetNodeName() << " --> ZOMBIE!" << endl; 474 SetZombie(); 468 475 SetError(-1); 469 476 return; … … 537 544 538 545 case 100: 539 lout << "Connection timed out." << endl;540 EnableTimeout(false);546 //lout << "Connection timed out." << endl; 547 //EnableTimeout(false); 541 548 return; 542 549 … … 562 569 // FIXME: Timeout??? 563 570 // 564 565 571 // while (GetError()<0) 572 // usleep(1); 566 573 567 574 // … … 569 576 // we can go on working 'as usual' Eg. Initialize a Display Update 570 577 // 571 cout << GetNodeName() << " Handling Error #" << GetError() << endl;578 cout << GetNodeName() << " Handling Error #" << dec << GetError() << endl; 572 579 switch (GetError()) 573 580 { … … 576 583 case 9: // zero idx 577 584 case 84: // ON TIME 578 // Stop program?585 lout << "- " << GetNodeName() << ": Cannot handle error #" << GetError() << endl; 579 586 return; 580 587 581 588 case 11: // software endswitch 582 589 case 25: // hardware endswitch 590 lout << "- " << GetNodeName() << ": Cannot handle error 'Endswitch!'" << endl; 591 return; 592 583 593 case 100: // timeout (movement has been stopped, so we can go on) 584 594 DelError(); 585 595 return; 586 596 /* 587 597 case 101: 588 lout << "Warning: " << GetNodeName() << " didn't respond in timeout window - try again." << endl;598 //lout << "Warning: " << GetNodeName() << " didn't respond in timeout window - try again." << endl; 589 599 DelError(); 590 600 return; 601 */ 602 default: 603 lout << "- " << GetNodeName() << ": Cannot handle error #" << GetError() << endl; 604 591 605 } 592 606 } … … 633 647 } 634 648 635 void Macs::ReqTimeoutTime() 636 { 637 RequestSDO(0x4000, 2); 638 WaitForSdo(0x4000, 2); 639 } 640 641 void Macs::EnableTimeout(bool enable, LWORDS_t ms) 642 { 643 lout << "- " << GetNodeName() << ": " << (enable?"En":"Dis") << "able timeout, " << dec << ms << "ms." << endl; 644 if (!enable) 645 { 646 SendSDO(0x4000, 1, string('o', 'f', 'f')); 647 WaitForSdo(0x4000, 1); 648 649 lout << "- " << GetNodeName() << ": Stopping handshake (PC)." << endl; 650 651 fTimeout->Stop(); //kTRUE); 652 653 fTimerOn = kFALSE; 654 } 655 else 656 { 657 if (ms>0) 658 SetTimeoutTime(ms); 659 660 ResetTimeout(); 661 662 fTimerOn = kTRUE; 663 fTimeout->Start(fGuardTime/*/3*2*/, kTRUE); //kFALSE); //TRUE); 664 665 // 666 // Start with kFALSE would be a continous timer, but this 667 // timer seems to stop it's activity at some stage without 668 // any reason 669 // 670 lout << "- " << GetNodeName() << ": starting handshake." << endl; 671 SendSDO(0x4000, 1, string('o', 'n')); 672 WaitForSdo(0x4000, 1); 673 } 674 lout << "- " << GetNodeName() << ": Timeout timer turned " 675 << (enable?"on.":"off.") << endl; 676 } 677 678 Bool_t Macs::HandleTimer(TTimer *t) 679 { 680 /* 681 Fons: 682 ----- 683 684 timers never trigger at the same time or when in a TTimer::Notify. 685 Little explanation: 686 687 - there are two types of timers synchronous and a-synchronous. 688 - synchronous timers are only handled via the ROOT eventloop 689 (see TUnixSystem::DispatchOneEvent()). If there are no mouse/keyboard 690 events then the synchronous timer queue is checked. So if the processing 691 of a mouse/keyboard event takes a long time synchronous timers are not 692 called for a while. To prevent this from happening one can call in long 693 procedures gSystem->ProcessEvents(). The system schedules only the 694 next timer in the queue when the current one's Notify() has finished. 695 - a-synchronous timers are triggered via SIGALARM, i.e. the program is 696 interupted and execution jumps to the Notify() function. When the 697 notify is finished the next a-sync timer is scheduled and the system 698 resumes from the place where it was initially interrupted. One of the 699 things to remember when using a-sync timers is don't make any graphics 700 calls in them. X11 is not re-entrant and it might be that the SIGALARM 701 signal interrupted the system while being in X11. A-sync timers are best 702 used to set flags that you can test at a convenient and controlled 703 time. 704 */ 705 706 // 707 // FIXME! Use NMT! 708 // 709 // --- lout << ddev(MLog::eGui); 710 // --- lout << "Send 0x4000: " << GetNodeName() << endl; 711 649 void Macs::SendNodeguard() 650 { 712 651 SendSDO(0x4000, 0, (LWORD_t)0, false); 713 714 // --- lout << "Done 0x4000: " << GetNodeName() << endl; 715 716 Timer time; 717 718 // --- lout << "dT " << GetNodeName() << ": " << dec <<(int)((fTimeoutTime-time.Now())*1000) << endl; 719 // --- lout << edev(MLog::eGui); 720 721 if (time.Now() > fTimeoutTime) 722 { 723 lout << ddev(MLog::eGui); 724 lout << "Warning: " << GetNodeName() << " didn't respond in timeout window." << endl; 725 lout << edev(MLog::eGui); 726 SetError(101); 727 } 728 729 //WaitForSdo(0x4000, 0, kDontWait); 730 // 731 // Would not be necessary if I would Start the timer with 732 // kFALSE. This would be a continous timer, but this 733 // timer seems to stop it's activity at some stage without 734 // any reason 735 // 736 if (fTimerOn) 737 fTimeout->Start(fGuardTime/*/3*2*/, kTRUE); 738 739 return kTRUE; 740 } 741 742 void Macs::ResetTimeout() 743 { 744 Timer time; 745 746 // --- lout << ddev(MLog::eGui); 747 // --- lout << "Reset " << GetNodeName() << ": " << dec << (int)((fTimeoutTime-time.Now())*1000) << endl; 748 // --- lout << edev(MLog::eGui); 749 750 fTimeoutTime = time.Now() + 3.*fGuardTime/1000.; 751 } 752 753 void Macs::SetTimeoutTime(LWORD_t ms) 754 { 755 // FIXME: Is '/2' the best choose? 756 fGuardTime = ms/3; // how often do we send/request the handshake 757 758 SendSDO(0x4000, 2, ms*2); // How often do we check for the handshake 759 WaitForSdo(0x4000, 2); 760 } 761 652 } 653 654 // -------------------------------------------------------------------------- 655 // 656 // This starts the host guarding. The host guarding is only available 657 // if the node guarding is running. The host guarding works with the 658 // guardtime and the lifetimefactor from the nodeguarding. 659 // 660 void Macs::StartHostGuarding() 661 { 662 SendSDO(0x100c, 0, (LWORD_t)GetGuardTime()); 663 WaitForSdo(0x100c); 664 665 SendSDO(0x100d, 0, (LWORD_t)GetLifeTimeFactor()); 666 WaitForSdo(0x100d); 667 668 lout << "- " << GetNodeName() << ": Hostguarding started (" << dec; 669 lout << GetLifeTimeFactor() << "*" << GetGuardTime() << "ms)" << endl; 670 } 671 672 // -------------------------------------------------------------------------- 673 // 674 // Stop the host guarding. 675 // 676 void Macs::StopHostGuarding() 677 { 678 SendSDO(0x100c, 0, (LWORD_t)0); 679 WaitForSdo(0x100c); 680 681 SendSDO(0x100d, 0, (LWORD_t)0); 682 WaitForSdo(0x100d); 683 684 lout << "- " << GetNodeName() << ": Hostguarding stopped." << endl; 685 } 686 -
trunk/MagicSoft/Cosy/devdrv/macs.h
r1703 r1727 1 1 #ifndef MACS_H 2 2 #define MACS_H 3 4 #include <TObject.h>5 3 6 4 #include "nodedrv.h" 7 5 #include "base/timer.h" 8 6 9 class Macs : public NodeDrv , public TObject7 class Macs : public NodeDrv 10 8 { 11 9 private: … … 30 28 BYTE_t fStatus; 31 29 32 TTimer *fTimeout;33 Bool_t fTimerOn;34 LWORD_t fGuardTime;35 double fTimeoutTime;36 37 30 LWORD_t string(BYTE_t b0=0, BYTE_t b1=0, BYTE_t b2=0, BYTE_t b3=0) 38 31 { … … 40 33 } 41 34 42 void ResetTimeout();43 Bool_t HandleTimer(TTimer *t);44 45 35 void Init(); 46 //bool Reboot();47 48 //bool InitDevice(Network *);49 50 //void StartDevice();51 36 void StopDevice(); 52 37 53 38 void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, timeval_t *tv); 54 void HandleSDOOK(WORD_t idx, BYTE_t subidx );55 void HandleSDOError(LWORD_t data){ NodeDrv::HandleSDOError(data); }39 void HandleSDOOK(WORD_t idx, BYTE_t subidx, timeval_t *tv); 40 //void HandleSDOError(LWORD_t data) { NodeDrv::HandleSDOError(data); } 56 41 57 42 void HandlePDO1(BYTE_t *data, timeval_t *tv); 58 43 void HandlePDO2(BYTE_t *data, timeval_t *tv); 44 //void HandleNodeguard(timeval_t *tv); 45 46 void SendNodeguard(); 59 47 60 48 void CheckConnection(); … … 108 96 void StartAbsPos(LWORDS_t pos); 109 97 110 void SetTimeoutTime(LWORD_t ms);111 void ReqTimeoutTime();112 113 void EnableTimeout(bool enable=true, LWORDS_t ms=-1);114 115 98 void StopMotor(); 116 99 … … 131 114 LWORD_t GetRes() const { return fRes; } // Encoder resolution 132 115 116 void StartHostGuarding(); 117 void StopHostGuarding(); 118 133 119 void HandleError(); 134 120 -
trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc
r1703 r1727 1 1 #include "shaftencoder.h" 2 2 3 #include " timer.h"3 #include "base/timer.h" 4 4 #include "network.h" 5 5 … … 17 17 ShaftEncoder::ShaftEncoder(const BYTE_t nodeid, const char *name, MLog &out) 18 18 : NodeDrv(nodeid, name, out), fLabel(NULL), fPosHasChanged(false) 19 {20 }21 22 ShaftEncoder::~ShaftEncoder()23 19 { 24 20 } … … 55 51 return; 56 52 53 case 0x100c: 54 lout << "- Guardtime: " << dec << val << "ms" << endl; 55 return; 56 57 case 0x100d: 58 lout << "- Lifetimefactor: " << dec << val << endl; 59 return; 60 61 case 0x100e: 62 lout << "- CobId for guarding: 0x" << hex << val << endl; 63 return; 64 57 65 case 0x6000: 58 66 case 0x6500: 59 lout << "- Counting: " << (val&1 67 lout << "- Counting: " << (val&1 ?"anti-clockwise":"clockwise") << " "; 60 68 lout << "HwTest: " << (val&2 ?"on":"off") << " "; 61 69 lout << "Scaling: " << (val&4 ?"on":"off") << " "; … … 95 103 void ShaftEncoder::DisplayVal() 96 104 { 97 if ( fIsZombie)105 if (IsZombieNode()) 98 106 { 99 107 fLabel[0]->SetText(new TGString("")); … … 162 170 } 163 171 172 //#include <fstream.h> 173 //ofstream fout("log/shaftencoder.log"); 174 164 175 void ShaftEncoder::HandlePDOType2(BYTE_t *data, timeval_t *tv) 165 176 { … … 188 199 fPos = pos; 189 200 fTurn = turn; 201 202 //fout << dec << (int)GetId() << " " << turn << " " << pos << endl; 203 190 204 fTime.SetTimer(tv); 191 205 fPosHasChanged=true; … … 208 222 //----------------------------------------------------------------------- 209 223 224 StopGuarding(); 225 210 226 // 211 227 // Requesting and checking (FIXME) type of encoder … … 215 231 WaitForSdo(0x1000); 216 232 217 if ( fIsZombie)233 if (IsZombieNode()) 218 234 { 219 235 lout << GetNodeName() << " - Init failed!" << endl; … … 274 290 lout << "- " << GetNodeName() << ": Start Node (NMT)." << endl; 275 291 SendNMT(kNMT_START); 292 293 StartGuarding(125, 2); 276 294 } 277 295 … … 282 300 WaitForSdo(0x100b); 283 301 } 284 /*285 bool ShaftEncoder::InitDevice(Network *net)286 {287 NodeDrv::InitDevice(net);288 289 Init();290 291 return !fIsZombie;292 }293 294 // --------------------------------------------------------------------------295 //296 // This should be called from a master or main thread to get a node out297 // of the Zombie-Status.298 //299 bool ShaftEncoder::Reboot()300 {301 fIsZombie = false;302 303 Init();304 305 return !fIsZombie;306 }307 */308 302 309 303 void ShaftEncoder::ReqPos() … … 321 315 lout << "- " << GetNodeName() << ": Setting Preset." << endl; 322 316 323 SendSDO(0x6003, (LWORD_t) fPos);317 SendSDO(0x6003, (LWORD_t)pre); 324 318 if (!WaitForSdo(0x6003)) 325 319 return; -
trunk/MagicSoft/Cosy/devdrv/shaftencoder.h
r1703 r1727 2 2 #define SHAFTENCODER_H 3 3 4 #include " timer.h"4 #include "base/timer.h" 5 5 #include "nodedrv.h" 6 6 … … 17 17 WORD_t fTurns; // Number of possible turns 18 18 19 TGLabel **fLabel; 20 LWORDS_t fUpdPos; // ticks21 WORDS_t fUpdVel; // ticks per 5ms22 WORDS_t fUpdAcc; // ticks per 25ms^219 TGLabel **fLabel; // 20 LWORDS_t fUpdPos; // ticks 21 WORDS_t fUpdVel; // ticks per 5ms 22 WORDS_t fUpdAcc; // ticks per 25ms^2 23 23 24 bool fPosHasChanged; 24 bool fPosHasChanged; //! 25 25 26 26 Timer fTime; … … 37 37 public: 38 38 ShaftEncoder(const BYTE_t nodeid, const char *name=NULL, MLog &out=gLog); 39 virtual ~ShaftEncoder();40 39 41 //bool InitDevice(Network *);42 //bool Reboot();43 44 //void StartDevice();45 40 void StopDevice(); 46 41 … … 48 43 49 44 void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, timeval_t *tv); 50 void HandleSDOOK(WORD_t idx, BYTE_t subidx) { NodeDrv::HandleSDOOK(idx, subidx); } 51 void HandleSDOError(LWORD_t data) { NodeDrv::HandleSDOError(data); } 52 45 /* 46 void HandleSDOOK(WORD_t idx, BYTE_t subidx, timeval_t *tv) { NodeDrv::HandleSDOOK(idx, subidx, tv); } 47 void HandleSDOError(LWORD_t data) { NodeDrv::HandleSDOError(data); } 48 */ 53 49 void HandlePDO1(BYTE_t *data, timeval_t *tv) { HandlePDOType2(data, tv); } 54 50 void HandlePDO2(BYTE_t *data, timeval_t *tv) { HandlePDOType2(data, tv); } 55 51 56 LWORDS_t GetPos() { return fIsZombie? 0 : fPos+fTurn*fTicks; } // FIXME? 0?52 LWORDS_t GetPos() { return IsZombieNode() ? 0 : fPos+fTurn*fTicks; } // FIXME? 0? 57 53 LWORD_t GetPhysRes() { return fTicks; } 58 54 -
trunk/MagicSoft/Cosy/gui/MGCosy.cc
r1702 r1727 180 180 fList->Add(l); 181 181 182 fOffsetZd = new TGLabel(f, "0000000 ");183 fOffsetAz = new TGLabel(f, "0000000 ");182 fOffsetZd = new TGLabel(f, "000000000"); 183 fOffsetAz = new TGLabel(f, "000000000"); 184 184 fOffsetZd->SetTextJustify(kTextRight); 185 185 fOffsetAz->SetTextJustify(kTextRight); 186 fOffsetZd->Move(x , y+102);187 fOffsetAz->Move(x , y+119);186 fOffsetZd->Move(x+15, y+102); 187 fOffsetAz->Move(x+15, y+119); 188 188 fList->Add(fOffsetZd); 189 189 fList->Add(fOffsetAz); … … 193 193 fList->Add(l); 194 194 195 l = new TGLabel(f, "Ra ( soll):");195 l = new TGLabel(f, "Ra (nominal):"); 196 196 l->Move(x-60, y+159); 197 197 fList->Add(l); … … 201 201 fList->Add(l); 202 202 203 l = new TGLabel(f, "Dec ( soll):");203 l = new TGLabel(f, "Dec (nominal):"); 204 204 l->Move(x-60, y+199); 205 205 fList->Add(l); 206 206 207 l = new TGLabel(f, "Zd ( soll):");207 l = new TGLabel(f, "Zd (nominal):"); 208 208 l->Move(x-60, y+222); 209 209 fList->Add(l); 210 210 211 l = new TGLabel(f, "Az ( soll):");211 l = new TGLabel(f, "Az (nominal):"); 212 212 l->Move(x-60, y+239); 213 213 fList->Add(l); … … 836 836 { 837 837 zd = (int)test.Zd(); 838 sprintf(text, "%c%d h%.1fm", soll.Zd()<0?'-':'+', abs((int)soll.Zd()), 0.1*(abs((int)test.Zd())%600));838 sprintf(text, "%c%dd %.1fm", soll.Zd()<0?'-':'+', abs((int)soll.Zd()), 0.1*(abs((int)test.Zd())%600)); 839 839 fZdSoll->SetText(new TGString(text)); 840 840 } … … 984 984 Timer tm; 985 985 tm.Now(); 986 986 /* 987 987 Float_t h = 2.+tm.H()+(10.7+tm.M())/60.; 988 988 RaDec dest(h*15, 129.7); … … 994 994 int i = 0; 995 995 while (!HasStopFlag() && i++<60) // 2.5min 996 996 usleep(1000000); 997 997 if (HasStopFlag()) 998 998 break; 999 */ 999 1000 1000 1001 //fQueue->PostMsg(WM_STOP, 0, 0); 1001 1002 1002 ZdAz dest1( fRand.Integer(36)+25, fRand.Integer(360));1003 ZdAz dest1((float)fRand.Integer(120)-60., 0);//fRand.Integer(25)+90); 1003 1004 1004 1005 cout << "Demo: Zd=" << dest1.Zd() << "° Az=" << dest1.Az() << "°" << endl; … … 1006 1007 fQueue->PostMsg(WM_POSITION, &dest1, sizeof(dest1)); 1007 1008 1008 i = 0;1009 while (!HasStopFlag() && i++< 15) // 30s1009 int i = 0; 1010 while (!HasStopFlag() && i++<5/*5*/) // 30s 1010 1011 usleep(1000000); 1011 1012 if (HasStopFlag()) -
trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc
r1702 r1727 56 56 fMoon = new TArc(0, 0, 3, 290, 70); 57 57 fSun = new TArc(0, 0, 2); 58 59 InitArc(fMars, 1001, 13, 12); 58 fSaturn = new TArc(0, 0, 1); 59 60 fSaturnRing = new TArc(0, 0, 2); 61 fSaturnRing->SetFillStyle(4000); // (s. TAttFill) 62 fSaturnRing->SetLineColor(kRed); 63 fSaturnRing->Draw(); 64 65 InitArc(fMars, 1001, kRed/*13*/, kRed/*12*/); 60 66 InitArc(fVenus, 1001, 15, 14); 61 67 InitArc(fJupiter, 1001, 17, 16); 62 68 InitArc(fMoon, 1001, 19, 15); 63 InitArc(fS un, 1001, 10, 19);69 InitArc(fSaturn, 1001, kYellow/*17*/, 16); 64 70 65 71 for (int i=0; i<4; i++) … … 72 78 fList->Add(fSunL[i]); 73 79 } 80 InitArc(fSun, 1001, kYellow/*10*/, kYellow/*19*/); 74 81 75 82 fList->Add(fMars); … … 78 85 fList->Add(fMoon); 79 86 fList->Add(fSun); 87 fList->Add(fSaturn); 80 88 81 89 // … … 317 325 UpdatePlanet(kEVenus, fVenus); 318 326 UpdatePlanet(kEMars, fMars); 327 UpdatePlanet(kESaturn, fSaturn); 319 328 320 329 RaDec radec = fSlaStar->CalcRaDecFast(pos*kDeg2Rad); … … 363 372 SetModified(); 364 373 365 if (planet!=kESun) 366 return; 367 368 // cout << "Sun: x=" << x << " y=" << y; 369 // cout << " Zd=" << deg << " Az=" << 360./D2PI*zdaz.Az() << endl; 370 371 fSunL[0]->SetX1(x-3.5); fSunL[0]->SetX2(x+3.5); 372 fSunL[1]->SetX1(x-2.5); fSunL[1]->SetX2(x+2.5); 373 fSunL[2]->SetX1(x-2.5); fSunL[2]->SetX2(x+2.5); 374 fSunL[3]->SetX1(x); fSunL[3]->SetX2(x); 375 376 fSunL[0]->SetY1(y); fSunL[0]->SetY2(y); 377 fSunL[1]->SetY1(y-2.5); fSunL[1]->SetY2(y+2.5); 378 fSunL[2]->SetY1(y+2.5); fSunL[2]->SetY2(y-2.5); 379 fSunL[3]->SetY1(y-3.5); fSunL[3]->SetY2(y+3.5); 380 } 374 if (planet==kESaturn) 375 { 376 fSaturnRing->SetX1(x); 377 fSaturnRing->SetY1(y); 378 } 379 380 if (planet==kESun) 381 { 382 fSunL[0]->SetX1(x-3.5); fSunL[0]->SetX2(x+3.5); 383 fSunL[1]->SetX1(x-2.5); fSunL[1]->SetX2(x+2.5); 384 fSunL[2]->SetX1(x-2.5); fSunL[2]->SetX2(x+2.5); 385 fSunL[3]->SetX1(x); fSunL[3]->SetX2(x); 386 387 fSunL[0]->SetY1(y); fSunL[0]->SetY2(y); 388 fSunL[1]->SetY1(y-2.5); fSunL[1]->SetY2(y+2.5); 389 fSunL[2]->SetY1(y+2.5); fSunL[2]->SetY2(y-2.5); 390 fSunL[3]->SetY1(y-3.5); fSunL[3]->SetY2(y+3.5); 391 } 392 } -
trunk/MagicSoft/Cosy/gui/MGSkyPosition.h
r1690 r1727 29 29 TArc *fMars; 30 30 TArc *fSun; 31 TArc *fSaturn; 32 33 TArc *fSaturnRing; 31 34 32 35 TArc *fDot[6];
Note:
See TracChangeset
for help on using the changeset viewer.