- Timestamp:
- 04/12/02 16:59:23 (23 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/Changelog
r1266 r1275 1 1 -*-*- END -*-*- 2 3 2002/04/12 - Thomas Bretz: 4 5 * Makefile.conf.linux-gnu: 6 - added -D_REENTRANT 7 8 * base/MThread.cc: 9 - added debug output 10 11 * candrv/canopen.cc: 12 - added debug output to destructor 13 14 * candrv/vmodican.cc: 15 - added debug output to failing read 16 - added some general debug output 17 18 * catalog/SlaStars.[h,cc]: 19 - added CalcRaDecFast 20 - added Calc*AzFast 21 - added some comments 22 23 * devdrv/macs.cc: 24 - added some HandleSDOOK output 25 - changed timer frequency to Guard Time third instead of half 26 - added some degub output 27 - changed timer to single shot timer 28 - switched off Mac timeout handling!!! 29 30 * gui/MGCosy.cc: 31 - added demo mode for 'Tag-der-Physik' 32 33 * gui/MGSkyPosition.cc: 34 - changed 'dots' to fast calculation functions 35 36 * gui/MGEmbeddedCanvas.cc: 37 - added some output 38 - fixed a bug with zero range 39 40 * main/MCosy.[h,cc]: 41 - added and changed some output 42 - changed LimitSpeed 43 - changed TalkThread 44 + only change offset when a new value for this axis is available 45 + reset the HasChanged flag before testing it 46 47 48 49 2002/04/11 - Thomas Bretz: 50 51 * base/MThread.[h,cc]: 52 - added priority to constructor 53 54 * base/coord.h: 55 - added setter functions to RaDec 56 57 * base/msgqueue.[h,cc]: 58 - added some comments 59 60 * candrv/network.cc: 61 - HasError now checks all nodes 62 63 * candrv/nodedrv.[h,cc]: 64 - fixed some buggy output 65 66 * candrv/vmodican.cc: 67 - removed nonsens SetPriority (doesn't have any effect) 68 69 * gui/MGCosy.cc: 70 - replaced colors by the correct requested colors 71 72 * gui/MGSkyPosition.[h,cc]: 73 - added dots for the position in the past and future 74 75 2 76 3 77 2002/04/04 - Thomas Bretz: -
trunk/MagicSoft/Cosy/Makefile.conf.linux-gnu
r909 r1275 20 20 # 21 21 22 OPTIM = -O2 -Wall -fno-rtti -fno-exceptions -fPIC -Wtraditional -Wpointer-arith -Wcast-align -Wwrite-strings -Wconversion -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Woverloaded-virtual 22 OPTIM = -O2 -Wall -fno-rtti -fno-exceptions -fPIC -Wtraditional -Wpointer-arith -Wcast-align -Wwrite-strings -Wconversion -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Woverloaded-virtual -D_REENTRANT 23 23 DEBUG = -g 24 24 -
trunk/MagicSoft/Cosy/base/MThread.cc
r1273 r1275 1 1 #include <MThread.h> 2 3 #include <iostream.h> 2 4 3 5 #include <pthread.h> … … 12 14 MThread::MThread(bool start, int prio) : fIsRunning(false), fIsDetached(false), fThread(NULL), fReturn(NULL) 13 15 { 14 if ( start)15 {16 SetPriority(prio); 17 Start();18 }16 if (!start) 17 return; 18 19 SetPriority(prio); 20 Start(); 19 21 } 20 22 … … 27 29 MThread::~MThread() 28 30 { 29 if (fIsRunning)30 31 cout << "~MThread::MThread" << endl; 32 Stop(); 31 33 } 32 34 … … 120 122 void MThread::Stop() 121 123 { 124 cout << "MThread::Stop: fThread=" << fThread << ", fIsRunning=" << (int)fIsRunning << endl; 122 125 if (!fThread || !fIsRunning) 123 126 return; … … 125 128 if (fIsDetached) 126 129 { 130 cout << "Stopping detached thread..." << flush; 127 131 pthread_cancel(*fThread); 128 132 fIsRunning = false; … … 130 134 else 131 135 { 136 cout << "Stopping thread..." << flush; 132 137 fStop = true; 133 138 pthread_join(*fThread, &fReturn); 134 139 } 140 cout << "done." << endl; 135 141 136 142 delete fThread; 137 143 fThread = NULL; 144 145 cout << "MThread::Stop() done." << endl; 138 146 } -
trunk/MagicSoft/Cosy/base/msgqueue.cc
r1273 r1275 6 6 #include <sys/resource.h> // PRIO_PROCESS 7 7 8 // -------------------------------------------------------------------------- 9 // 10 // This creates the Message queue thread, 11 // 8 12 MsgQueue::MsgQueue() : fBreak(0) 9 13 { … … 12 16 } 13 17 18 // -------------------------------------------------------------------------- 19 // 20 // The destructor terminates the thread. 21 // 14 22 MsgQueue::~MsgQueue() 15 23 { 24 cout << "~MsgQueue::MsgQueue" << endl; 16 25 pthread_cancel(fThread); 17 26 delete (unsigned char*)fMp; 18 27 } 19 28 29 // -------------------------------------------------------------------------- 30 // 31 // This is the function which must be overloaded. 32 // Here you process the messages. mp is a pointer which you can 33 // specify when posting the message. 34 // 35 // If a new messages is posted while the old one is not yet 36 // finished the fBreak flag is set. Please test this flag with 37 // Break() and try to finish (or stop) the current action as soon 38 // as possible. This makes sure, that before a new action is started 39 // the old action can be finished correctly by the user. 40 // 20 41 void *MsgQueue::Proc(int msg, void *mp) 21 42 { … … 23 44 } 24 45 46 // -------------------------------------------------------------------------- 47 // 48 // This is the thread mapper. 49 // 25 50 void *MsgQueue::MapThread(void *arg) 26 51 { … … 34 59 } 35 60 61 // -------------------------------------------------------------------------- 62 // 63 // This is the thread which handles the processing. 64 // As soon as a message is posted the fBreak flag is set (see PostMsg) 65 // And as soon as the current action is finished the new action is executed 66 // in this thread. This makes sure, that the calling program is not stalled. 67 // 36 68 void MsgQueue::Thread() 37 69 { … … 56 88 pthread_mutex_unlock(&fMuxMsg); 57 89 90 cout << "Processing Msg 0x" << hex << fMsg << endl; 91 // --- bool quit = fMsg==WM_QUIT; 58 92 fRc=Proc(fMsg, fMp); 93 cout << "Msg 0x" << hex << fMsg << " processed." << endl; 59 94 60 if (fMsg==WM_QUIT) 61 break; 95 // --- if (quit) 96 // --- break; 97 } 62 98 63 } 99 // --- fStart = 0; 100 // --- cout << "WM_QUIT posted... leaving msg queue." << endl; 64 101 } 65 102 103 // -------------------------------------------------------------------------- 104 // 105 // Use this function to post a message. 106 // mp can be a pointer to a data structure. size should be the size of it. 107 // size bytes of this structure are copied and a pointer to the copy 108 // is forwarded to the Proc function. 109 // 66 110 void *MsgQueue::PostMsg(int msg, void *mp, int size) 67 111 { … … 74 118 // stopped and the messages are processed serialized 75 119 // 120 cout << "Locking MsgQueue mutex..." << flush; 76 121 pthread_mutex_lock(&fMuxMsg); 122 cout << "done." << endl; 77 123 78 124 // … … 101 147 // 102 148 fStart = 1; 149 cout << "Releasing MsgQueue mutex..." << flush; 103 150 pthread_mutex_unlock(&fMuxMsg); 104 while (fStart) usleep(1); 151 cout << "done." << endl; 152 while (fStart) 153 usleep(1); 105 154 155 cout << "Returning rc = 0x" << hex << rc << endl; 106 156 return rc; 107 157 } -
trunk/MagicSoft/Cosy/candrv/canopen.cc
r1266 r1275 67 67 pthread_mutex_destroy(&fPdoMux[i][j]); 68 68 } 69 lout << "- CanOpen destroyed." << endl; 69 70 } 70 71 -
trunk/MagicSoft/Cosy/candrv/vmodican.cc
r1273 r1275 38 38 #include <errno.h> // errno 39 39 #include <unistd.h> // read 40 #include <pthread.h> // pthread_create41 40 #include <sys/time.h> // gettimeofday 42 41 #include <sys/ioctl.h> // ioctl 43 #include <sys/resource.h> // PRIO_PROCESS44 42 45 43 ClassImp(VmodIcan); … … 110 108 while (1) 111 109 { 110 // 111 // Sleeps until a message arrives 112 // 112 113 unsigned char c; 114 const int n = read(fd, &c, 1); 115 116 if (n<0) 117 { 118 cerr << "Vmodican: read(" << dec << (int)fd << "," << (void*)&c; 119 cerr << ",1) returned c=" << (int)c << " '" << strerror(errno); 120 cerr << "' (errno = " << errno << ")" << endl; 121 continue; 122 //return (void *)1; 123 } 124 125 // 126 // read the time for the message as soon as possible 127 // 113 128 timeval_t tv; 114 115 //116 // Sleeps until a message arrives117 //118 const int n = read(fd, &c, 1);119 120 //121 // read the time for the message as soon as possible122 //123 129 gettimeofday(&tv, NULL); 124 130 … … 128 134 if (n == 0) 129 135 { 130 cerr << "panic read (errno=" << errno << ") ..." << endl; 136 cerr << "Vmodican: Panic read '" << strerror(errno) << "' "; 137 cerr << "(errno=" << errno << ")" << endl; 131 138 return (void *)1; 132 139 } … … 155 162 156 163 cout << endl; 157 break;164 continue; 158 165 159 166 // … … 171 178 172 179 HandleMessage(&msg, &tv); 173 174 break; 180 continue; 175 181 } 182 183 cout << "Vmodican: read, Message c=" << (int)c << " unknown." << endl; 176 184 } 177 185 return NULL; … … 495 503 void VmodIcan::DisableCanBusConnection() 496 504 { 497 lout << "- Disconnect from Bus!" << endl;505 lout << "- Disconnect VmodIcan module from Bus!" << endl; 498 506 499 507 Message msg; /* buffer for module messages */ … … 503 511 504 512 while (!Send(&msg)); 513 514 lout << "- VmodIcan disconnected." << endl; 505 515 } 506 516 … … 529 539 void VmodIcan::Close() 530 540 { 531 lout << "- Clos e Device!"<< endl;541 lout << "- Closing device VmodIcan #" << (int)fd << endl; 532 542 533 543 Message msg; /* disconnect message */ … … 539 549 540 550 close(fd); 551 552 lout << "- Device closed." << endl; 541 553 } 542 554 … … 950 962 VmodIcan::~VmodIcan() 951 963 { 964 lout << "- Stopping VmodIcan module." << endl; 952 965 Stop(); 953 966 DisableCanBusConnection(); 954 967 Close(); 968 lout << "- VmodIcan stopped." << endl; 955 969 } 956 970 -
trunk/MagicSoft/Cosy/catalog/SlaStars.cc
r1109 r1275 40 40 slaMappa(2000.0, mjd, fAmprms); 41 41 slaAoppa(mjd, 0, // mjd, UT1-UTC 42 GetElong(), GetPhi(), 148, // g ttingen long, lat, height42 GetElong(), GetPhi(), 148, // göttingen long, lat, height 43 43 0, 0, // polar motion x, y-coordinate (radians) 44 44 273.155, 1013.25, 0.5, // temp, pressure, humidity … … 69 69 70 70 return RaDec(ra, dec); 71 } 72 73 RaDec SlaStars::CalcRaDecFast(const AltAz &altaz) const 74 { 75 // 76 // This function does a coordinate system transformation only. 77 // This is very fast compared to a correct tranformation with all 78 // effects, but much less accurate. 79 // 80 // It transforms Altitude/Azimuth [rad] into 81 // Right Ascension/Declination [rad] 82 // 83 double ha, dec; 84 slaDh2e(altaz.Az(), altaz.Alt(), GetPhi(), &ha, &dec); 85 return RaDec(GetAlpha()-ha, dec); 86 } 87 88 RaDec SlaStars::CalcRaDecFast(const ZdAz &zdaz) const 89 { 90 // 91 // This function does a coordinate system transformation only. 92 // This is very fast compared to a correct tranformation with all 93 // effects, but much less accurate. 94 // 95 // It transforms Zenith Distance/Azimuth [rad] into 96 // Right Ascension/Declination [rad] 97 // 98 return CalcRaDecFast(AltAz(kPiDiv2-zdaz.Zd(), zdaz.Az())); 99 } 100 101 ZdAz SlaStars::CalcZdAzFast(const RaDec &radec) const 102 { 103 // 104 // This function does a coordinate system transformation only. 105 // This is very fast compared to a correct tranformation with all 106 // effects, but much less accurate. 107 // 108 // It transforms Right Ascension/Declination [rad] into 109 // zenith Distance/Azimuth [rad] 110 // 111 AltAz altaz = CalcAltAzFast(radec); 112 return ZdAz(kPiDiv2-altaz.Alt(), altaz.Az()); 113 } 114 115 AltAz SlaStars::CalcAltAzFast(const RaDec &radec) const 116 { 117 // 118 // This function does a coordinate system transformation only. 119 // This is very fast compared to a correct tranformation with all 120 // effects, but much less accurate. 121 // 122 // It transforms Right Ascension/Declination [rad] into 123 // Altitude/Azimuth [rad] 124 // 125 double az, el; 126 slaDe2h(GetAlpha()-radec.Ra(), radec.Dec(), GetPhi(), &az, &el); 127 return AltAz(el, az); 71 128 } 72 129 -
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 } -
trunk/MagicSoft/Cosy/gui/MGCosy.cc
r1273 r1275 206 206 TGCompositeFrame *tf1 = fTab->AddTab("Position Zd/Az"); 207 207 TGCompositeFrame *tf2 = fTab->AddTab("Track Ra/Dec"); 208 TGCompositeFrame *tf3 = fTab->AddTab("Demo Mode"); 208 209 209 210 fCZdAz = new MGCoordinates(tf1, kETypeZdAz); … … 467 468 cout << "Closing window - waiting until all nodes are stopped." << endl; 468 469 fQueue->PostMsg(WM_QUIT, 0, 0); 470 cout << "Closing window - done." << endl; 469 471 // gApplication->Terminate(0); 470 472 } … … 497 499 cout << "PostMsg (WM_Position) returned." << endl; 498 500 } 501 502 // 503 // ************************** For demo purpose ********************** 504 // 505 #include <TRandom.h> 506 class MDemo : public MThread 507 { 508 private: 509 MsgQueue *fQueue; 510 TRandom fRand; 511 512 public: 513 MDemo() : MThread(false) {} 514 515 void SetQueue(MsgQueue *q) { fQueue = q; } 516 517 virtual void *Thread() 518 { 519 while (1) 520 { 521 Timer tm; 522 tm.Now(); 523 524 Float_t h = 2.+tm.H()+(8.+tm.M())/60.; 525 RaDec dest(h*15, 130); 526 527 cout << dest.Ra()/15 << "h " << dest.Dec() << "°" << endl; 528 529 fQueue->PostMsg(WM_TRACK, &dest, sizeof(dest)); 530 531 int i = 0; 532 while (!HasStopFlag() && i++<130) // 2.5min 533 usleep(1000000); 534 if (HasStopFlag()) 535 break; 536 537 //fQueue->PostMsg(WM_STOP, 0, 0); 538 539 ZdAz dest1(fRand.Integer(56)+5, fRand.Integer(360)); 540 541 cout << "Demo: Zd=" << dest1.Zd() << "° Az=" << dest1.Az() << "°" << endl; 542 543 fQueue->PostMsg(WM_POSITION, &dest1, sizeof(dest1)); 544 545 i = 0; 546 while (!HasStopFlag() && i++<30) // 30s 547 usleep(1000000); 548 if (HasStopFlag()) 549 break; 550 551 //ZdAz dest2(5, 30); 552 //fQueue->PostMsg(WM_POSITION, &dest2, sizeof(dest2)); 553 /* 554 i = 0; 555 while (!HasStopFlag() && i++<30) // 30s 556 usleep(1000000); 557 */ 558 //if (HasStopFlag()) 559 // break; 560 } 561 cout << "Demo Thread: done." << endl; 562 return NULL; 563 } 564 }; 565 566 MDemo demo; 567 568 void MGCosy::StartDemo() 569 { 570 cout << "Start Demo." << endl; 571 572 demo.SetQueue(fQueue); 573 demo.Start(); 574 575 cout << "PostMsg (WM_Demo) returned." << endl; 576 } 577 578 void StopDemo() 579 { 580 cout << "Stopping demo." << endl; 581 demo.Stop(); 582 } 583 // 584 // ****************************************************************** 585 // 499 586 500 587 Bool_t MGCosy::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2) … … 526 613 */ 527 614 case kPB_START: 528 fTab->GetCurrent() ? StartTrack() : StartPos(); 615 switch (fTab->GetCurrent()) 616 { 617 case 0: 618 StartPos(); 619 return kTRUE; 620 case 1: 621 StartTrack(); 622 return kTRUE; 623 case 2: 624 StartDemo(); 625 return kTRUE; 626 } 529 627 return kTRUE; 530 628 531 629 case kPB_STOP: 532 630 cout << "Sending stop movement msg." << endl; 631 StopDemo(); 533 632 fQueue->PostMsg(WM_STOP, 0, 0); 633 534 634 cout << "PostMsg (WM_Stop) returned." << endl; 535 635 return kTRUE; … … 563 663 { 564 664 case IDM_EXIT: 665 cout << "IDM_EXIT: Posting WM_QUIT." << endl; 565 666 fQueue->PostMsg(WM_QUIT, 0, 0); 667 cout << "IDM_EXIT: WM_QUIT done." << endl; 566 668 //cout << "Idm_Exit." << endl; 567 669 //CloseWindow(); -
trunk/MagicSoft/Cosy/gui/MGCosy.h
r1111 r1275 73 73 void StartPos(); 74 74 void StartTrack(); 75 void StartDemo(); 75 76 76 77 void EnableLabel(TGLabel *label, Bool_t stat); -
trunk/MagicSoft/Cosy/gui/MGEmbeddedCanvas.cc
r1111 r1275 6 6 7 7 #include "MGEmbeddedCanvas.h" 8 9 #include <iostream.h> 8 10 9 11 #include <TList.h> … … 17 19 fModified(kFALSE), fWidth(width), fRange(range), fPix(2.*range/width) 18 20 { 21 cout << "MGEmbeddedCanvas: Initializing." << endl; 19 22 fCanvas = GetCanvas(); 20 23 24 cout << "MGEmbeddedCanvas: fCanvas = 0x" << fCanvas << endl; 25 26 cout << "MGEmbeddedCanvas: SetFillColor." << endl; 21 27 fCanvas->SetFillColor(39); // s. TAttFill 22 fCanvas->Range(-fRange, -fRange, fRange, fRange); 28 cout << "MGEmbeddedCanvas: fRange=" << fRange << endl; 29 if (fRange>0) 30 fCanvas->Range(-fRange, -fRange, fRange, fRange); 23 31 24 32 fList = new TList; 25 33 fList->SetOwner(); 34 35 cout << "MGEmbeddedCanvas: Initializing done." << endl; 26 36 } 27 37 -
trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc
r1273 r1275 208 208 { 209 209 RaDec rd(radec.Ra()+off*360/24*kDeg2Rad, radec.Dec()); 210 ZdAz zdaz = fSlaStar->CalcZdAz (rd);210 ZdAz zdaz = fSlaStar->CalcZdAzFast(rd); 211 211 212 212 const float s = sin(zdaz.Az()); … … 319 319 UpdatePlanet(kEMars, fMars); 320 320 321 RaDec radec = fSlaStar->CalcRaDec (pos*kDeg2Rad);321 RaDec radec = fSlaStar->CalcRaDecFast(pos*kDeg2Rad); 322 322 323 323 UpdatePosition(radec, pos.Zd(), pos.Az()); -
trunk/MagicSoft/Cosy/main/MCosy.cc
r1111 r1275 187 187 // 188 188 if (HasError()) 189 lout << "Error #6004 (requesting re pos from Macs) happened." << endl;189 lout << "Error while requesting re pos from Macs (SDO #6004)" << endl; 190 190 191 191 return kFALSE; … … 400 400 if (!cdzd && !cdaz) 401 401 { 402 lout << "Positioning done with " << i << "manuvers." << endl; 402 lout << "Positioning done in " << i << (i==1?" step.":" steps.") << endl; 403 SetStatus(MCosy::kStopped); 403 404 return TRUE; 404 405 } … … 468 469 // 469 470 if (HasError()) 470 lout << "Error #3006 (setting velocity of Macs) happened." << endl;471 lout << "Error while setting velocity (SDO #3006)" << endl; 471 472 472 473 return kFALSE; … … 520 521 521 522 const Float_t limit = 0.25; 522 523 if (sgn(vt->Az()) != sgn(vcalc.Az()) && 524 fabs(vt->Az()) < limit*fabs(vcalc.Az())) 523 /* 524 if (sgn(vt->Az()) != sgn(vcalc.Az())) 525 vt->Az(0); 526 // else 527 { 528 if (fabs(vt->Az()) < fabs(vcalc.Az()) *0.5) 529 vt->Az(0.5*vcalc.Az()); 530 531 if (fabs(vt->Az()) > fabs(vcalc.Az()) *1.5) 532 vt->Az(1.5*vcalc.Az()); 533 } 534 535 if (sgn(vt->Zd()) != sgn(vcalc.Zd())) 536 vt->Zd(0); 537 // else 538 { 539 if (fabs(vt->Zd()) > fabs(vcalc.Az()) *1.5) 540 vt->Zd(1.5*vcalc.Zd()); 541 542 if (fabs(vt->Zd()) < fabs(vcalc.Az()) *0.5) 543 vt->Zd(0.5*vcalc.Zd()); 544 } 545 */ 546 547 if (sgn(vt->Az()) != sgn(vcalc.Az()) 548 && fabs(vt->Az()) < limit*fabs(vcalc.Az()) 549 ) 525 550 vt->Az(0); 526 551 else … … 531 556 } 532 557 533 if (sgn(vt->Zd()) != sgn(vcalc.Zd()) && 534 fabs(vt->Zd()) < limit*fabs(vcalc.Zd())) 558 if (sgn(vt->Zd()) != sgn(vcalc.Zd()) 559 && fabs(vt->Zd()) < limit*fabs(vcalc.Zd()) 560 ) 535 561 vt->Zd(0); 536 562 else … … 605 631 { 606 632 // 633 // The loop should not be executed faster than the ramp of 634 // a change in the velocity can be followed. 635 // (This is important on fast machines >500MHz) 636 // 637 //usleep(100000000); 638 639 // 607 640 // Request Target position for this moment 608 641 // … … 715 748 // Stop revolution mode (movement) 716 749 // 717 cout << "Stop ing possibleRPM mode..." << endl;750 cout << "Stopping possibleRPM mode..." << endl; 718 751 fMac1->SetRpmMode(FALSE); 719 752 fMac2->SetRpmMode(FALSE); … … 734 767 void *MCosy::Proc(int msg, void *mp) 735 768 { 769 cout << "MCosy::Proc: 0x" << msg << endl; 736 770 switch (msg) 737 771 { … … 846 880 << Deg2ZdRE(env.GetValue("MaxZd[Deg]", +1.0)) << "RE" << endl; 847 881 */ 882 848 883 849 884 cout << "Setting up software endswitch..." << flush; … … 890 925 // wait until a tracking session is started 891 926 // 892 while (!fTracking && !fTTalk->HasStopFlag())927 while (!fTracking) 893 928 usleep(1); 894 895 if (fTTalk->HasStopFlag())896 break;897 929 898 930 ofstream fout("log/cosy.err"); … … 915 947 // only update fTrackingError while tracking 916 948 // 917 while (fTracking && !fTTalk->HasStopFlag()) 949 bool phca1=false; 950 bool phca2=false; 951 bool phcaz=false; 952 953 while (fTracking) 918 954 { 919 955 // … … 922 958 const float weight = 1.; //0.3; 923 959 924 ZdAz offset(fOffset.Zd()*(1.-weight)+(ist.Zd()*kGearRatio.X()-istre.Zd())*weight,925 fOffset.Az()*(1.-weight)+(ist.Az()*kGearRatio.Y()-istre.Az())*weight);926 927 fOffset = offset;928 929 960 // 930 961 // This is the time constant which defines how fast 931 962 // you correct for external influences (like wind) 932 963 // 933 bool phca1; 934 bool phca2; 935 bool phcaz; 936 964 fZd1->ResetPosHasChanged(); 965 fZd2->ResetPosHasChanged(); 966 fAz->ResetPosHasChanged(); 937 967 do 938 968 { … … 941 971 phcaz = fAz->PosHasChanged(); 942 972 usleep(1); 943 } while (!phca1 && !phca2 && !phcaz); 973 } while (!phca1 && !phca2 && !phcaz && fTracking); 974 944 975 //---usleep(100000); // 0.1s 945 976 … … 975 1006 sla.SetMjd(time.Zd()); 976 1007 sollzd = CorrectTarget(ist, sla.CalcZdAz(fRaDec)); // [se] 1008 1009 fOffset.Zd(fOffset.Zd()*(1.-weight)+(ist.Zd()*kGearRatio.X()-istre.Zd())*weight); 977 1010 } 978 1011 … … 981 1014 sla.SetMjd(time.Az()); 982 1015 sollaz = CorrectTarget(ist, sla.CalcZdAz(fRaDec)); // [se] 1016 1017 fOffset.Az(fOffset.Az()*(1.-weight)+(ist.Az()*kGearRatio.Y()-istre.Az())*weight); 983 1018 } 984 1019 … … 1063 1098 // Create Nodes 1064 1099 // 1100 lout << "- Setting up network." << endl; 1101 1065 1102 fMac1=new Macs(1, "Mac.1/Az", lout); 1066 1103 fMac2=new Macs(2, "Mac.2/Zd", lout); … … 1084 1121 // Create Gui Event timer and Gui 1085 1122 // 1123 lout << "- Initializing GUI Timer." << endl; 1086 1124 fUpdateGui = new TTimer(this, 100); // 100ms 1087 1125 1126 lout << "- Starting GUI." << endl; 1088 1127 fWin=new MGCosy(this, gClient->GetRoot(), 1, 1); 1089 1128 … … 1108 1147 */ 1109 1148 1149 lout.DisableOutputDevice(MLog::eGui); 1150 lout.SetOutputGui(NULL, kFALSE); 1151 1110 1152 gApplication->Terminate(0); 1111 1153 } -
trunk/MagicSoft/Cosy/main/MCosy.h
r1111 r1275 15 15 #define WM_STOP 0x1003 16 16 #define WM_POLARIS 0x1004 17 #define WM_QUIT 0x100518 17 19 18 class ShaftEncoder; … … 33 32 { 34 33 SetPriority(10); 34 Detach(); 35 35 Start(); 36 36 } 37 ~MTTalk() { cout << "~MTTalk::MTTalk" << endl; } 37 38 }; 38 39 … … 41 42 class MCosy : public Network, public MsgQueue, public TObject 42 43 { 43 friend class MTGui;44 44 friend class MTTalk; 45 45 … … 94 94 95 95 void TalkThread(); 96 void GuiThread(MTGui *t);97 96 98 97 int SetPosition(const ZdAz &dst);
Note:
See TracChangeset
for help on using the changeset viewer.