Changeset 1275 for trunk/MagicSoft/Cosy/devdrv/macs.cc
- Timestamp:
- 04/12/02 16:59:23 (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/devdrv/macs.cc
r1140 r1275 9 9 10 10 ClassImp(Macs); 11 12 /* 13 --------------------------- 14 For test purposes 15 --------------------------- 16 17 class MyTimer : public TTimer 18 { 19 public: 20 MyTimer(TObject *obj, Long_t ms, Bool_t mode) : TTimer(obj, ms, mode) {} 21 Bool_t Notify() 22 { 23 cout << "Notify" << endl; 24 TTimer::Notify(); 25 return kTRUE; 26 } 27 }; 28 */ 11 29 12 30 Macs::Macs(const BYTE_t nodeid, const char *name, MLog &out) … … 15 33 fPosActive(0), fRpmActive(0) 16 34 { 17 fTimeout = new TTimer(this, 100, kFALSE); // 100ms 35 fTimeout = new TTimer(this, 100, kFALSE); // 100ms, asynchronous 18 36 } 19 37 … … 102 120 void Macs::HandleSDOOK(WORD_t idx, BYTE_t subidx) 103 121 { 104 if (idx==0x4000 && subidx==0 && fTimerOn) 105 { 106 ResetTimeout(); 107 return; 122 switch (idx) 123 { 124 case 0x2002: 125 switch (subidx) 126 { 127 case 0: 128 lout << ddev(MLog::eGui); 129 lout << "- Velocity set (" << GetNodeName() << ")" << endl; 130 lout << edev(MLog::eGui); 131 return; 132 } 133 break; 134 case 0x2003: 135 switch (subidx) 136 { 137 case 0: 138 lout << ddev(MLog::eGui); 139 lout << "- Acceleration set (" << GetNodeName() << ")" << endl; 140 lout << edev(MLog::eGui); 141 return; 142 case 1: 143 lout << ddev(MLog::eGui); 144 lout << "- Deceleration set (" << GetNodeName() << ")" << endl; 145 lout << edev(MLog::eGui); 146 return; 147 } 148 break; 149 case 0x3006: 150 switch (subidx) 151 { 152 case 0: 153 lout << ddev(MLog::eGui); 154 lout << "- RPM mode switched (" << GetNodeName() << ")" << endl; 155 lout << edev(MLog::eGui); 156 return; 157 158 case 1: 159 /* 160 lout << ddev(MLog::eGui); 161 lout << "- Velocity set (" << GetNodeName() << ")" << endl; 162 lout << edev(MLog::eGui); 163 */ 164 return; 165 } 166 break; 167 case 0x4000: 168 if (subidx==0 && fTimerOn) 169 { 170 ResetTimeout(); 171 return; 172 } 173 break; 174 case 0x6004: 175 switch (subidx) 176 { 177 case 0: 178 lout << ddev(MLog::eGui); 179 lout << "- Relative positioning started (" << GetNodeName() << ")" << endl; 180 lout << edev(MLog::eGui); 181 return; 182 183 case 1: 184 lout << ddev(MLog::eGui); 185 lout << "- Absolute positioning started (" << GetNodeName() << ")" << endl; 186 lout << edev(MLog::eGui); 187 return; 188 } 189 break; 190 191 108 192 } 109 193 NodeDrv::HandleSDOOK(idx, subidx); … … 348 432 if (!errnum) 349 433 { 350 cout << "Mac " << GetNodeName() << " reports Error occursion." << endl;434 lout << "Mac " << GetNodeName() << " reports Error occursion." << endl; 351 435 SetError(-1); 352 436 return; … … 358 442 // 359 443 if (GetError()>0) 360 cout << "Mac "<< GetNodeName() << " WARNING! Error #" << GetError() << " unhandled by software." << endl;444 lout << GetNodeName() << " WARNING! Error #" << GetError() << " unhandled by software." << endl; 361 445 362 446 SetError(errnum); 363 447 364 cout << "Mac "<< GetNodeName() << " reports: ";448 lout << GetNodeName() << " reports: "; 365 449 switch (errnum) 366 450 { 367 451 case 6: 368 cout << "Home position not the first positioning command." << endl;452 lout << "Home position not the first positioning command." << endl; 369 453 return; 370 454 371 455 case 8: 372 cout << "Control deviation overflow." << endl;456 lout << "Control deviation overflow." << endl; 373 457 return; 374 458 375 459 case 9: 376 cout << "Zero index not found." << endl;460 lout << "Zero index not found." << endl; 377 461 return; 378 462 … … 382 466 { 383 467 case -1: 384 cout << "Negative";468 lout << "Negative"; 385 469 break; 386 470 case 1: 387 cout << "Positive";471 lout << "Positive"; 388 472 break; 389 473 default: 390 cout << "-unknown-";474 lout << "-unknown-"; 391 475 } 392 476 switch (errnum) 393 477 { 394 478 case 11: 395 cout << " software endswitch activated." << endl;479 lout << " software endswitch activated." << endl; 396 480 break; 397 481 case 25: 398 cout << " hardware endswitch activated." << endl;482 lout << " hardware endswitch activated." << endl; 399 483 break; 400 484 } … … 402 486 403 487 case 84: 404 cout << "Too many (>12) ON TIME calls." << endl;488 lout << "Too many (>12) ON TIME calls." << endl; 405 489 return; 406 490 407 491 case 100: 408 cout << "Connection timed out." << endl;492 lout << "Connection timed out." << endl; 409 493 return; 410 494 411 495 default: 412 cout << "Error Nr. " << errnum << ", " << errinf << endl;496 lout << "Error Nr. " << errnum << ", " << errinf << endl; 413 497 } 414 498 } … … 436 520 // we can go on working 'as usual' Eg. Initialize a Display Update 437 521 // 438 cout << "Mac " <<GetNodeName() << " Handling Error #" << GetError() << endl;522 cout << GetNodeName() << " Handling Error #" << GetError() << endl; 439 523 switch (GetError()) 440 524 { … … 525 609 526 610 fTimerOn = kTRUE; 527 fTimeout->Start(fGuardTime, kFALSE); //kTRUE); 528 529 SendSDO(0x4000, 1, string('o', 'n')); 530 WaitForSdo(0x4000, 1); 611 fTimeout->Start(fGuardTime/*/3*2*/, kTRUE); //kFALSE); //TRUE); 612 // 613 // Start with kFALSE would be a continous timer, but this 614 // timer seems to stop it's activity at some stage without 615 // any reason 616 // 617 618 // SendSDO(0x4000, 1, string('o', 'n')); 619 // WaitForSdo(0x4000, 1); 531 620 } 532 621 lout << "- Timeout timer of " << GetNodeName() << " turned " … … 565 654 // FIXME! Use NMT! 566 655 // 656 // --- lout << ddev(MLog::eGui); 657 // --- lout << "Send 0x4000: " << GetNodeName() << endl; 658 567 659 SendSDO(0x4000, 0, (LWORD_t)0, false); 568 660 661 // --- lout << "Done 0x4000: " << GetNodeName() << endl; 662 569 663 Timer time; 570 if (time.Now() > fTimeoutTime) 664 665 // --- lout << "dT " << GetNodeName() << ": " << dec <<(int)((fTimeoutTime-time.Now())*1000) << endl; 666 // --- lout << edev(MLog::eGui); 667 668 if (time.Now() > fTimeoutTime+0.5) 571 669 { 572 670 lout << ddev(MLog::eGui); … … 576 674 } 577 675 578 579 676 //WaitForSdo(0x4000, 0, kDontWait); 580 // if (fTimerOn) 581 // fTimeout->Start(fGuardTime, kTRUE); 677 // 678 // Would not be necessary if I would Start the timer with 679 // kFALSE. This would be a continous timer, but this 680 // timer seems to stop it's activity at some stage without 681 // any reason 682 // 683 if (fTimerOn) 684 fTimeout->Start(fGuardTime/*/3*2*/, kTRUE); 582 685 583 686 return kTRUE; … … 587 690 { 588 691 Timer time; 589 fTimeoutTime = time.Now() + 2.*fGuardTime/1000.; //[usec] 692 693 // --- lout << ddev(MLog::eGui); 694 // --- lout << "Reset " << GetNodeName() << ": " << dec << (int)((fTimeoutTime-time.Now())*1000) << endl; 695 // --- lout << edev(MLog::eGui); 696 697 fTimeoutTime = time.Now() + 3.*fGuardTime/1000.; 590 698 } 591 699 592 700 void Macs::SetTimeoutTime(LWORD_t ms) 593 701 { 594 fGuardTime = ms/2; // FIXME: Is '/2' the best choose? 595 596 SendSDO(0x4000, 2, ms); 702 // FIXME: Is '/2' the best choose? 703 fGuardTime = ms/3; // how often do we send/request the handshake 704 705 SendSDO(0x4000, 2, ms); // How often do we check for the handshake 597 706 WaitForSdo(0x4000, 2); 598 707 }
Note:
See TracChangeset
for help on using the changeset viewer.