Changeset 918
- Timestamp:
- 08/29/01 11:23:55 (23 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/Changelog
r915 r918 1 1 -*-*- END -*-*- 2 2001/08/29 - Thomas Bretz: 3 4 * MCosy.[cc,h]: 5 - added fStatus support and update 6 - added some new function to outsource some code from 7 positioning and tracking algorithms 8 - TerminateApp now sends WM_QUIT 9 - removed comments with old GUI thread 10 - 11 12 * base/MGList.h: 13 - added DBG_MGLIST for debugging 14 15 * devdrv/shaftencoder.[h,cc]: 16 - removed old updating thread stuff 17 18 * gui/MGAccuracy.[h,cc]: 19 - added more accurate calculation of one dimensional 20 tracking error value 21 22 * gui/MGCoordinate.cc: 23 - removed logging statement from destructor 24 25 * gui/MGCosy.cc: 26 - changed layout of dialog 27 - added layout manager 28 - added status frame 29 - added tabs 30 - added status display and update 31 32 * gui/MGEmbeddedCanvas.cc: 33 - enhanced size by 1 34 35 * gui/MGSkyPosition.cc: 36 - removed debugging output 37 38 * gui/MGVelocity.cc: 39 - the factor 4 is now applied outside of the dialog. 40 41 42 2 43 2001/08/23 - Thomas Bretz: 3 44 -
trunk/MagicSoft/Cosy/MCosy.cc
r914 r918 157 157 } 158 158 159 void MCosy::SetPosVelocity(const Float_t ratio, Float_t vel, Float_t acc) 160 { 161 // 162 // Set velocities 163 // 164 const int vr = fMac1->GetVelRes(); 165 166 vel *= vr; 167 acc *= vr; 168 169 if (ratio <1) 170 { 171 fMac1->SetVelocity(vel); 172 fMac1->SetAcceleration(acc); 173 fMac1->SetDeceleration(acc); 174 175 fMac2->SetVelocity(vel*ratio); 176 fMac2->SetAcceleration(acc*ratio); 177 fMac2->SetDeceleration(acc*ratio); 178 } 179 else 180 { 181 fMac1->SetVelocity(vel/ratio); 182 fMac1->SetAcceleration(acc/ratio); 183 fMac1->SetDeceleration(acc/ratio); 184 185 fMac2->SetVelocity(vel); 186 fMac2->SetAcceleration(acc); 187 fMac2->SetDeceleration(acc); 188 } 189 } 190 191 void MCosy::DoRelPos(const ZdAz &rd, const Bool_t axe1, const Bool_t axe2) 192 { 193 SetStatus(kMoving); 194 195 if (axe1) fMac2->StartRelPos(rd.Zd()); 196 if (axe2) fMac1->StartRelPos(rd.Az()); 197 198 cout << "Waiting for positioning..." << flush; 199 200 WaitForSdos(); 201 202 cout << "SDO..." << flush; 203 204 while (fMac1->IsPositioning() || fMac2->IsPositioning() && !StopWaitingForSDO()) 205 usleep(1); 206 207 cout << "done." << endl; 208 209 SetStatus(kStopped); 210 } 211 212 void MCosy::CheckForError() 213 { 214 if (!HasError()) 215 return; 216 217 SetStatus(kError); 218 fMac1->HandleError(); 219 fMac2->HandleError(); 220 if (HasError()) 221 return; 222 223 SetStatus(kStopped); 224 } 225 159 226 int MCosy::SetPosition(const ZdAz &dst) // [rad] 160 227 { … … 167 234 const ZdAz dest = CorrectTarget(src, dst); 168 235 169 cout << "Positioning to Target :" << endl;236 cout << "Positioning to Target..." << endl; 170 237 //cout << "Source Zd: " << src.Zd() << "se Az:" << src.Az() << "se" << endl; 171 238 //cout << "Destination Zd: " << Rad2SE(dst.Zd()) << "se Az:" << Rad2SE(dst.Az()) << "se" << endl; 172 cout << "Shortest Dest Zd: " << dest.Zd() << "se Az:" << dest.Az() << "se" << endl;239 //cout << "Shortest Dest Zd: " << dest.Zd() << "se Az:" << dest.Az() << "se" << endl; 173 240 174 241 for (int i=0; i<10 && !StopWaitingForSDO(); i++) … … 188 255 189 256 // 257 // Check if there is a control deviation on the axis 258 // 259 const Bool_t cdzd = (int)cd.Zd() ? kTRUE : kFALSE; 260 const Bool_t cdaz = (int)cd.Az() ? kTRUE : kFALSE; 261 262 // 190 263 // check if we reached the correct position already 191 264 // 192 if (! (int)cd.Zd() && !(int)cd.Az())265 if (!cdzd && !cdaz) 193 266 { 194 267 cout << "Positioning done with " << i << "manuvers." << endl; … … 202 275 203 276 // 204 // Set velocities 205 // 206 const int vr = fMac1->GetVelRes(); 207 const float maxvel = (i?0.1:0.9)*vr; // maxvel = 90% 208 const float maxacc = (i?0.1:0.5)*vr; // maxacc = 50%; 209 210 const float diff = i?1:fabs(rd.Ratio()); 211 212 cout << "Salt/Saz: " << diff << endl; 213 214 if (diff <1) 215 { 216 fMac1->SetVelocity(maxvel); 217 fMac1->SetAcceleration(maxacc); 218 fMac1->SetDeceleration(maxacc); 219 220 fMac2->SetVelocity(maxvel*diff); 221 fMac2->SetAcceleration(maxacc*diff); 222 fMac2->SetDeceleration(maxacc*diff); 223 } 277 // Initialize Velocities so that we reach both positions 278 // at the same time 279 // 280 if (i) 281 SetPosVelocity(1.0, 0.1, 0.1); 224 282 else 225 { 226 fMac1->SetVelocity(maxvel/diff); 227 fMac1->SetAcceleration(maxacc/diff); 228 fMac1->SetDeceleration(maxacc/diff); 229 230 fMac2->SetVelocity(maxvel); 231 fMac2->SetAcceleration(maxacc); 232 fMac2->SetDeceleration(maxacc); 233 } 283 SetPosVelocity(fabs(rd.Ratio()), 0.9, 0.5); 234 284 235 285 rd.Round(); 236 286 237 cout << " + APOS: Zd=" << setw(6) << p.Zd() << "se Az=" << setw(6) << p.Az() << "se" << endl; 238 cout << " + dZd=" << setw(6) << cd.Zd() << "se dAz=" << setw(6) << cd.Az() << "se" << endl; 239 cout << " + dZd=" << setw(6) << rd.Zd() << "re dAz=" << setw(6) << rd.Az() << "re" << endl; 287 /* 288 cout << " + " << cdzd << " " << cdaz << endl; 289 cout << " + APOS: Zd=" << setw(6) << p.Zd() << "se Az=" << setw(6) << p.Az() << "se" << endl; 290 cout << " + dZd=" << setw(6) << cd.Zd() << "se dAz=" << setw(6) << cd.Az() << "se" << endl; 291 cout << " + dZd=" << setw(6) << rd.Zd() << "re dAz=" << setw(6) << rd.Az() << "re" << endl; 292 */ 240 293 241 294 // 242 295 // repositioning (relative) 243 296 // 244 if ((int)cd.Zd()) fMac2->StartRelPos(rd.Zd()); 245 if ((int)cd.Az()) fMac1->StartRelPos(rd.Az()); 246 247 cout << "Waiting for positioning..." << flush; 248 249 WaitForSdos(); 250 251 cout << "SDO..." << flush; 252 253 while (fMac1->IsPositioning() || fMac2->IsPositioning() && !StopWaitingForSDO()) 254 usleep(1); 255 256 cout << "done." << endl; 297 DoRelPos(rd, cdzd, cdaz); 257 298 } 258 299 259 if (StopWaitingForSDO()) 260 { 261 fMac1->HandleError(); 262 fMac2->HandleError(); 263 } 300 CheckForError(); 264 301 265 302 cout << "Positioning ERROR!" << endl; 266 303 return FALSE; 304 } 305 306 Bool_t MCosy::RequestRePos() 307 { 308 309 fMac2->RequestSDO(0x6004); 310 fMac1->RequestSDO(0x6004); 311 WaitForSdos(); 312 if (!StopWaitingForSDO()) 313 return kTRUE; 314 315 lout << "Error #6004 (requesting re pos from Macs) happened." << endl; 316 return kFALSE; 317 } 318 319 Bool_t MCosy::SetVelocity(ZdAz v) 320 { 321 fMac2->SendSDO(0x3006, 1, (LWORD_t)v.Zd()); // SetRpmVelocity [re/min] 322 fMac1->SendSDO(0x3006, 1, (LWORD_t)v.Az()); // SetRpmVelocity [re/min] 323 WaitForSdos(); 324 if (!StopWaitingForSDO()) 325 return kTRUE; 326 327 lout << "Error #3006 (setting velocity of Macs) happened." << endl; 328 return kFALSE; 329 } 330 331 void MCosy::InitTracking() 332 { 333 // 334 // Start revolution mode 335 // 336 fMac2->SetAcceleration(0.90*fMac2->GetVelRes()); 337 fMac2->SetDeceleration(0.90*fMac2->GetVelRes()); 338 339 fMac1->SetAcceleration(0.90*fMac1->GetVelRes()); 340 fMac1->SetDeceleration(0.90*fMac1->GetVelRes()); 341 342 SetStatus(kMoving | kTracking); 343 344 fMac2->SetRpmMode(TRUE); 345 fMac1->SetRpmMode(TRUE); 267 346 } 268 347 … … 286 365 // calculate offset from present se position 287 366 // 288 289 367 const ZdAz sepos = GetSePos()*kGearRatio; 290 368 291 fMac1->ReqPos(); 292 fMac2->ReqPos(); 293 294 const ZdAz repos=GetRePos(); 295 296 fOffset = sepos-repos; 297 298 cout << "Offset: " << sepos.Zd() << "re, " << sepos.Az() << "re" << endl; 299 cout << "Offset: " << repos.Zd() << "re, " << repos.Az() << "re" << endl; 300 cout << "Offset: " << fOffset.Zd() << "re, " << fOffset.Az() << "re" << endl; 301 302 // 303 // Start revolution mode 304 // 305 fMac2->SetAcceleration(0.90*fMac2->GetVelRes()); 306 fMac2->SetDeceleration(0.90*fMac2->GetVelRes()); 307 308 fMac1->SetAcceleration(0.90*fMac1->GetVelRes()); 309 fMac1->SetDeceleration(0.90*fMac1->GetVelRes()); 310 311 fMac2->SetRpmMode(TRUE); 312 fMac1->SetRpmMode(TRUE); 313 314 /*-*/ int s = sla.GetSecs(); 315 cout << "Start tracking: Ra: " << Rad2Deg(dst.Ra()) << kDEG << " Dec: "; 316 cout << Rad2Deg(dst.Dec()) << kDEG << endl; 369 if (!RequestRePos()) 370 return; 371 372 // 373 // Estimate Offset before starting to track 374 // 375 fOffset = sepos-GetRePos(); 376 377 /* 378 cout << "Sepos: " << sepos.Zd() << "re, " << sepos.Az() << "re" << endl; 379 cout << "Repos: " << repos.Zd() << "re, " << repos.Az() << "re" << endl; 380 cout << "Offset: " << fOffset.Zd() << "re, " << fOffset.Az() << "re" << endl; 381 */ 382 383 // 384 // Init accelerations and Rpm Mode 385 // 386 InitTracking(); 387 388 cout << "Start tracking:"; 389 cout << " Ra: " << Rad2Deg(dst.Ra()) << "deg "; 390 cout << "Dec: " << Rad2Deg(dst.Dec()) << "deg" << endl; 317 391 318 392 // … … 323 397 324 398 ofstream fout("cosy.pos"); 325 fout << " Mjd/10ms Offset/RE Deviation/RE V/RE/MIN/4" << endl;399 fout << " Mjd/10ms V/re/min/4" << endl; 326 400 327 401 // … … 332 406 { 333 407 // 334 // Request Real Position from Drive408 // Request Target position for this moment 335 409 // 336 410 sla.Now(); … … 343 417 344 418 // 345 // Request absolute position of rotary encoder from MACS 346 // 347 fMac2->RequestSDO(0x6004); 348 fMac1->RequestSDO(0x6004); 349 WaitForSdos(); 350 if (StopWaitingForSDO()) 351 { 352 lout << "Error 6004 happened" << endl; 419 // Request absolute position of rotary encoder from Macs 420 // 421 if (!RequestRePos()) 353 422 break; 354 }355 356 //357 // Copy fTrackingError to a local variable358 //359 ZdAz offset = fOffset;360 423 361 424 // 362 425 // distance between (To+dt) and To [re] 363 426 // position time difference < 5usec 427 // fOffset does the synchronization between the 428 // Shaft- and the rotary encoders 364 429 // 365 430 dest *= kGearRatio; 366 dest -= GetRePos() + offset;431 dest -= GetRePos() + fOffset; 367 432 368 433 // … … 374 439 // 375 440 // calculate real velocity of future [re/min] 441 // believing the Macs manual '/4' shouldn't be necessary, but it is. 376 442 // 377 443 ZdAz vt = v/4; 378 444 vt.Round(); 379 445 446 // 447 // check if the drive is fast enough to follow the star 448 // 380 449 if (v.Zd()>.9*fMac1->GetVelRes() || v.Az()>.9*fMac2->GetVelRes()) 381 450 { … … 386 455 // 387 456 // Set theoretical velocity (as early after calculation as possible) 388 //389 //390 457 // Maybe we should attenuate the changes 391 458 // 392 fMac2->SendSDO(0x3006, 1, (LWORD_t)vt.Zd()); // SetRpmVelocity [re/min] 393 fMac1->SendSDO(0x3006, 1, (LWORD_t)vt.Az()); // SetRpmVelocity [re/min] 394 WaitForSdos(); 395 if (StopWaitingForSDO()) 396 { 397 lout << "Error 3006 happened" << endl; 459 if (!SetVelocity(vt)) 398 460 break; 399 }400 461 401 462 // 402 463 // Now do 'unnecessary' things 403 // calculate control deviation - for the moment for convinience 404 // 405 406 //if (fMac1->GetTime()-s > 1) 407 { 408 const double mjd = fMac2->GetMjd(); 409 sla.SetMjd(mjd); 410 ZdAz dest0=CorrectTarget(GetSePos(), sla.CalcZdAz(dst)); 411 dest0 *= kGearRatio; 412 dest0 -= GetRePos()+offset; 413 //dest0.Round(); 414 415 fAccuracy = dest0/kGearRatio2; // [deg] 416 fVelocity = vt/kGearRatio2; 417 418 //cout << "Control deviation: "; 419 fout << setprecision(15) << setw(15) << mjd*60.*60.*24. << " "; 420 fout << setw(4) << (int)fTrackingError.Zd() << " "; 421 fout << setw(4) << (int)fTrackingError.Az() << " "; 422 fout << setw(4) << dest0.Zd() << " "; 423 fout << setw(4) << dest0.Az() << " "; 424 fout << setw(4) << vt.Zd() << " "; 425 fout << setw(4) << vt.Az() << endl; 426 s = (int)fMac1->GetTime(); 427 } 464 // 465 fVelocity = vt/kGearRatio2*4; 466 467 const double mjd = fMac2->GetMjd(); 468 fout << setprecision(15) << setw(15) << mjd*60.*60.*24. << " "; 469 fout << setw(4) << vt.Zd() << " "; 470 fout << setw(4) << vt.Az() << endl; 428 471 429 472 // … … 440 483 // Stop revolution mode 441 484 // 485 SetStatus(kStopping); 486 442 487 fMac2->SetRpmMode(FALSE); 443 488 fMac1->SetRpmMode(FALSE); 444 489 490 SetStatus(kStopped); 491 445 492 cout << "Tracking stopped." << endl; 446 493 447 if (StopWaitingForSDO()) 448 { 449 fMac1->HandleError(); 450 fMac2->HandleError(); 451 } 494 CheckForError(); 452 495 } 453 496 … … 457 500 { 458 501 case WM_WAIT: 459 cout << "Wait for execution of Proc : done." << endl;502 cout << "Wait for execution of Proc(WM_*, ): done." << endl; 460 503 return NULL; 461 504 462 505 case WM_STOP: 463 cout << "Stopping positioning." << endl; 506 cout << "Stopping positioning..." << endl; 507 SetStatus(kStopping); 464 508 fMac1->SetDeceleration(0.5*fMac1->GetVelRes()); 465 509 fMac2->SetDeceleration(0.5*fMac2->GetVelRes()); 466 cout << "Stoping " << endl;510 cout << "Stoping possible RPM mode..." << endl; 467 511 fMac1->SetRpmMode(FALSE); 468 512 fMac2->SetRpmMode(FALSE); 469 cout << " Done." << endl;513 cout << "Stopping commands sent." << endl; 470 514 while (fMac1->IsPositioning() || fMac2->IsPositioning()) 471 515 usleep(1); 516 SetStatus(kStopped); 472 517 cout << "Positioning stopped." << endl; 473 518 return NULL; 474 519 475 520 case WM_PRESET: 476 cout << "WM_P RESET: START" << endl;521 cout << "WM_Preset: start." << endl; 477 522 fAlt1->SetPreset(); 478 523 fAlt2->SetPreset(); 479 524 fAz->SetPreset(); 480 cout << "WM_P RESET: DONE(return 0xaffe)" << endl;525 cout << "WM_Preset: done. (return 0xaffe)" << endl; 481 526 return (void*)0xaffe; 482 527 483 528 case WM_POLARIS: 484 529 { 485 cout << "WM_P OLARIS: START" << endl;530 cout << "WM_Polaris: start." << endl; 486 531 SlaStars sla; 487 532 sla.SetMjd2Now(); … … 499 544 fAz->SetPreset(za.Az()); 500 545 501 cout << "WM_P RESET: DONE(return 0xaffe)" << endl;546 cout << "WM_Polaris: done. (return 0xaffe)" << endl; 502 547 } 503 548 return (void*)0xaffe; 504 549 505 550 case WM_POSITION: 506 cout << "WM_P OSITION: START" << endl;551 cout << "WM_Position: start." << endl; 507 552 { 508 553 ZdAz dest = *((ZdAz*)mp); … … 510 555 SetPosition(dest*D2PI/360.0); 511 556 } 512 cout << "WM_P OSITION: DONE(return 0x7777)" << endl;557 cout << "WM_Position: done. (return 0x7777)" << endl; 513 558 return (void*)0x7777; 514 559 515 560 case WM_TRACK: 516 cout << "WM_T RACK: START" << endl;561 cout << "WM_Track: START" << endl; 517 562 { 518 563 RaDec dest = *((RaDec*)mp); 519 564 TrackPosition(dest*D2PI/360.0); 520 565 } 521 cout << "WM_T RACK: DONE(return 0x8888)" << endl;566 cout << "WM_Track: done. (return 0x8888)" << endl; 522 567 return (void*)0x8888; 568 569 case WM_QUIT: 570 cout << "WM_Quit: now." << endl; 571 TerminateApp(); 572 cout << "WM_Quit: done." << endl; 573 return (void*)0x9999; 523 574 } 524 575 cout << "Unknown Msg" << endl; 525 576 return (void*)0xffffffff; 526 577 } 527 /* 528 void *MTGui::Thread() 529 { 530 fCosy->GuiThread(this); 531 return NULL; 532 } 533 */ 578 534 579 void *MTTalk::Thread() 535 580 { … … 564 609 fMac2->ReqPos(); 565 610 566 const ZdAz repos=GetRePos();567 cout << "APOS: " << repos.Zd() << "re, " << repos.Az() << "re" << endl;611 //const ZdAz repos=GetRePos(); 612 //cout << "APOS: " << repos.Zd() << "re, " << repos.Az() << "re" << endl; 568 613 569 614 /* … … 622 667 ZdAz ist = fTrackingError/kGearRatio; // [se] 623 668 ZdAz istre = fOffset; // [re] 669 624 670 // 625 671 // only update fTrackingError while tracking … … 691 737 } 692 738 } 693 /* 694 void MCosy::GuiThread(MTGui *t) 695 { 696 fWin=new MGCosy(this, gClient->GetRoot(), 1, 1); 697 698 fAz->SetDisplay(fWin->GetLabel1()); 699 fAlt1->SetDisplay(fWin->GetLabel2()); 700 fAlt2->SetDisplay(fWin->GetLabel3()); 701 702 while (!t->HasStopFlag()) 703 { 704 usleep(100000); // 0.1s 705 706 fAlt1->DisplayVal(); 707 fAlt2->DisplayVal(); 708 fAz->DisplayVal(); 709 710 // gSystem->ProcessEvents(); 711 712 ZdAz ist = GetSePos()*(360.0/16384.0); // [se] 713 fWin->Update(ist, fAccuracy, fVelocity, fTrackingError/kGearRatio2); 714 715 } 716 717 delete fWin; 718 cout << "Not running anymore." << endl; 719 } 720 */ 739 721 740 Bool_t MCosy::HandleTimer(TTimer *t) 722 741 { … … 728 747 fAz->DisplayVal(); 729 748 730 // gSystem->ProcessEvents();731 732 // ZdAz err1 = fTrackingError/kGearRatio2;733 // ZdAz err2(30./3600., 20./3600.); // = fTrackingError/kGearRatio2;734 735 ZdAz dummy = fOffset/kGearRatio2/4.; // /4. because using velocity canvas736 737 749 ZdAz ist = GetSePos()*(360.0/16384.0); // [se] 738 750 739 fWin->Update(ist, fTrackingError/kGearRatio2, fVelocity, dummy); 740 741 // cout << fTrackingError.Zd()/kGearRatio2.X()*3600. << " "; 742 // cout << fTrackingError.Az()/kGearRatio2.Y()*3600. << endl; 751 fWin->Update(ist, fTrackingError/kGearRatio2, 752 fVelocity, fOffset/kGearRatio2, 753 fStatus); 743 754 744 755 return kTRUE; … … 759 770 fTTalk = new MTTalk(this); 760 771 761 lout << "- Starting GUI Thread." << endl;772 lout << "- Starting GUI update." << endl; 762 773 fUpdateGui->TurnOn(); 763 774 // fTGui = new MTGui(this); … … 766 777 void MCosy::Stop() 767 778 { 768 cout << " Stopping Gui Timer Events." << endl;779 cout << "- Stopping GUI update." << endl; 769 780 fUpdateGui->TurnOff(); 770 781 // delete fTGui; … … 831 842 MCosy::~MCosy() 832 843 { 844 cout << "Deleting GUI timer." << endl; 845 833 846 delete fUpdateGui; 834 847 … … 846 859 delete fWin; 847 860 848 cout << "MGCosy de leted." << endl;849 } 861 cout << "MGCosy destructed." << endl; 862 } -
trunk/MagicSoft/Cosy/MCosy.h
r914 r918 15 15 #define WM_STOP 0x1003 16 16 #define WM_POLARIS 0x1004 17 #define WM_QUIT 0x1005 17 18 18 19 class ShaftEncoder; … … 20 21 class MGCosy; 21 22 class MCosy; 22 23 /*24 class MTGui : public MThread25 {26 private:27 MCosy *fCosy;28 29 void *Thread();30 31 public:32 MTGui(MCosy *cosy) : MThread(false), fCosy(cosy)33 {34 SetPriority(20);35 Start();36 }37 };38 */39 23 40 24 class MTTalk : public MThread … … 53 37 } 54 38 }; 39 40 #define kError 0x01 41 #define kMoving 0x02 42 #define kTracking 0x04 43 #define kStopping 0x08 44 #define kStopped 0x10 45 55 46 class TTimer; 56 47 class MCosy : public Network, public MsgQueue, public TObject … … 71 62 72 63 TTimer *fUpdateGui; 73 74 //MTGui *fTGui; 75 MTTalk *fTTalk; 64 MTTalk *fTTalk; // should be outsourced, like the starguider. 65 // with a generic interface to both... 76 66 77 67 ZdAz fTrackingError; // Tracking Offset between SE and calc-pos [re] … … 82 72 ZdAz fVelocity; // Actual velocity of Tracking 83 73 74 UInt_t fStatus; 75 76 void SetStatus(UInt_t stat) { fStatus = stat; } 77 UInt_t GetStatus() const { return fStatus; } 78 84 79 ZdAz GetRePos(); 85 80 ZdAz GetRePosPdo(); 86 81 ZdAz GetSePos(); // [se] 82 83 Bool_t RequestRePos(); 84 Bool_t SetVelocity(ZdAz v); 85 void SetPosVelocity(const Float_t ratio, Float_t vel, Float_t acc); 86 87 void DoRelPos(const ZdAz &rd, const Bool_t axe1, const Bool_t axe2); 88 89 void InitTracking(); 87 90 88 91 void TalkThread(); … … 96 99 97 100 int StopWaitingForSDO() const; 101 void CheckForError(); 98 102 99 103 public: -
trunk/MagicSoft/Cosy/ToDo
r917 r918 8 8 shaftencoder position changed (recalc fOffset, fTracking Error 9 9 as often as possible) 10 11 - Check why it crashes if you exit the program while 'going home' 10 12 -
trunk/MagicSoft/Cosy/base/MGList.h
r909 r918 2 2 #define MGLIST_H 3 3 4 #ifdef DBG_MGLIST 4 5 #include <iostream.h> 6 #endif 5 7 6 8 #ifndef ROOT_TOrdCollection … … 13 15 ~MGList() 14 16 { 17 #ifdef DBG_MGLIST 15 18 cout << "Deleting:" << flush; 19 #endif 16 20 17 21 TIter Next(this); … … 20 24 while ((obj=Next())) 21 25 { 26 #ifdef DBG_MGLIST 22 27 cout << " <" << ((TGObject*)obj)->GetName() << ">" << flush; 28 #endif 23 29 delete (TGObject*)obj; 24 30 } 31 #ifdef DBG_MGLIST 25 32 cout << endl; 33 #endif 26 34 } 27 35 void Add(TGObject *obj) -
trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc
r912 r918 15 15 ShaftEncoder::ShaftEncoder(BYTE_t nodeid, ostream &out=cout) : NodeDrv(nodeid, out), fLabel(NULL) 16 16 { 17 //18 // Show information19 //20 // pthread_create(&fThread, NULL, MapUpdateThread, this);21 22 17 } 23 18 24 19 ShaftEncoder::~ShaftEncoder() 25 20 { 26 // pthread_cancel(fThread);27 21 } 28 22 … … 91 85 cout << endl; 92 86 } 93 /* 94 void *ShaftEncoder::MapUpdateThread(void *data) 95 { 96 ShaftEncoder *se = (ShaftEncoder*) data; 97 98 // 99 // Detach thread (make sure that it is really removed from memory) 100 // 101 pthread_detach(pthread_self()); 102 setpriority(PRIO_PROCESS, 0, 5); 103 104 se->UpdateThread(); 105 106 return NULL; 107 } 108 */ 87 109 88 void ShaftEncoder::DisplayVal() 110 89 { … … 133 112 } 134 113 } 135 /* 136 void ShaftEncoder::UpdateThread() 137 { 138 return; 139 // 140 // check for a running thread and lock mutex 141 // 142 143 // 144 // Wait until the network and the output widget is initialized 145 // 146 while (!GetNetwork() || !fLabel) 147 usleep(1); 148 149 while (1) 150 { 151 usleep(40000); 152 //WaitForNextPdo1(); 153 154 // 155 // Update information 156 // 157 158 159 // 160 // make updated information visible 161 // 162 //gSystem->ProcessEvents(); ----> MCosy::GuiThread 163 } 164 } 165 */ 114 166 115 void ShaftEncoder::HandlePDOType0(BYTE_t *data) 167 116 { -
trunk/MagicSoft/Cosy/devdrv/shaftencoder.h
r910 r918 4 4 #include "timer.h" 5 5 #include "nodedrv.h" 6 7 #include <pthread.h>8 6 9 7 class TGLabel; … … 22 20 23 21 Timer fTime; 24 25 // pthread_t fThread;26 // static void *MapUpdateThread(void *se);27 // void UpdateThread();28 22 29 23 void HandlePDOType0(BYTE_t *data); -
trunk/MagicSoft/Cosy/gui/MGAccuracy.cc
r913 r918 58 58 line.DrawLine( 0, -65*4, 0, 65*4); 59 59 60 // 61 // Can be replaced by TGaxis axe; in a later root version 62 // than 3.01/06. I talked to Rene 63 // 60 64 TGaxis *axe; 61 65 axe = new TGaxis(-60*4, 0, 60*4, 0, -4, 4, 30204, "+-N"); … … 175 179 MGAccuracy::~MGAccuracy() 176 180 { 177 cout << "MGAccuracy destroyed." << endl; 178 } 179 180 void MGAccuracy::UpdateText(Float_t x, Float_t y) 181 { 182 /* 183 int xs = (int)floor(fmod(fabs(x), 60.)); 184 int ys = (int)floor(fmod(fabs(y), 60.)); 185 x /= 60.; 186 y /= 60.; 187 int xm = (int)floor(fmod(fabs(x), 60.)); 188 int ym = (int)floor(fmod(fabs(y), 60.)); 189 190 char tx[100]; 191 char ty[100]; 192 193 xm ? sprintf(tx, "%d'%02d\"", xm, xs) : sprintf(tx, "%d\"", xs); 194 ym ? sprintf(ty, "%d'%02d\"", ym, ys) : sprintf(ty, "%d\"", ys); 195 196 char txt[200]; 197 sprintf(txt, "%s / %s", tx, ty); 198 */ 199 200 // FIXME: We are on a sphere 201 202 float r = sqrt(x*x+y*y); 203 204 int rs = (int)floor(fmod(r, 60.)); 205 r /= 60.; 206 int rm = (int)floor(fmod(r, 60.)); 181 // cout << "MGAccuracy destroyed." << endl; 182 } 183 184 void MGAccuracy::UpdateText(Float_t pzd, Float_t azd, Float_t aaz) 185 { 186 const Float_t d2r = TMath::Pi()/360.; 187 188 pzd *= d2r; 189 azd *= d2r; 190 aaz *= d2r; 191 192 const float dphi2 = aaz/2.; 193 const float cos2 = cos(dphi2)*cos(dphi2); 194 const float sin2 = sin(dphi2)*sin(dphi2); 195 196 float dist = acos(cos(azd)*cos2 - cos(2*pzd+azd)*sin2); 197 198 dist *= 3600./d2r; 199 200 int rs = (int)floor(fmod(dist, 60.)); 201 dist /= 60.; 202 int rm = (int)floor(fmod(dist, 60.)); 207 203 208 204 char txt[100]; … … 227 223 } 228 224 229 void MGAccuracy::Update(ZdAz & zdaz)225 void MGAccuracy::Update(ZdAz &pos, ZdAz &acc) 230 226 { 231 227 // … … 235 231 static int Y = ~0; 236 232 237 float x = zdaz.Az()*3600.; // ["]238 float y = zdaz.Zd()*3600.; // ["]233 float x = acc.Az()*3600.; // ["] 234 float y = acc.Zd()*3600.; // ["] 239 235 240 236 int pixx = (int)(x/fPix); // [pix] … … 248 244 249 245 UpdateCross(x, y); 250 UpdateText( x, y);246 UpdateText(pos.Zd(), acc.Az(), acc.Zd()); 251 247 252 248 SetModified(); -
trunk/MagicSoft/Cosy/gui/MGAccuracy.h
r913 r918 32 32 void InitCross(); 33 33 34 void UpdateText(Float_t x, Float_t y);34 void UpdateText(Float_t zd, Float_t x, Float_t y); 35 35 void UpdateCross(Float_t x, Float_t y); 36 36 … … 39 39 ~MGAccuracy(); 40 40 41 void Update(ZdAz &pos );41 void Update(ZdAz &pos, ZdAz &acc); 42 42 }; 43 43 -
trunk/MagicSoft/Cosy/gui/MGCoordinate.cc
r808 r918 126 126 MGCoordinate::~MGCoordinate() 127 127 { 128 cout << "MGCoordinate destroyed." << endl;128 // cout << "MGCoordinate destroyed." << endl; 129 129 } 130 130 -
trunk/MagicSoft/Cosy/gui/MGCosy.cc
r913 r918 1 1 #include "MGCosy.h" 2 2 3 #include <iostream.h> 4 3 5 #include "msgqueue.h" 4 6 5 7 #include <TROOT.h> 6 8 9 #include <TGTab.h> // TGTab 7 10 #include <TGMenu.h> // TGPopupMenu 8 11 #include <TGButton.h> // TGButton … … 10 13 #include <TGLabel.h> // TGLabel 11 14 #include <TG3DLine.h> // TGHorizontal3DLine (TGSplitter) 15 #include <TGFrame.h> // TGGroupFrame 12 16 #include <TApplication.h> // gApplication 13 17 … … 31 35 #define kPB_CALCALTAZ 0x1004 32 36 #define kPB_POLARIS 0x1005 37 #define kPB_START 0x1006 33 38 34 39 #define kEF_A 0x1010 … … 43 48 // crate the menu bar 44 49 // 45 TGPopupMenu *fFileMenu = new TGPopupMenu( fClient->GetRoot());50 TGPopupMenu *fFileMenu = new TGPopupMenu(gClient->GetRoot()); 46 51 fFileMenu->AddEntry ("Exit", IDM_EXIT) ; 47 fFileMenu->Associate(this);52 //fFileMenu->Associate(this); 48 53 fList->Add(fFileMenu); 49 54 … … 53 58 TGMenuBar *fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame); 54 59 fMenuBar->AddPopup("File", fFileMenu, fLayMenuItem); 55 AddFrame(fMenuBar );60 AddFrame(fMenuBar, fLayMenuBar); 56 61 fList->Add(fMenuBar); 57 62 58 63 // 59 // Seperator beyonf menubar 60 // 64 // Seperator beyond menubar 65 // 66 61 67 TGHorizontal3DLine *fLineSep = new TGHorizontal3DLine(this); 62 68 AddFrame(fLineSep, fLayMenuBar); 63 69 fList->Add(fLineSep); 64 65 } 66 67 void MGCosy::CreateLabel() 68 { 70 } 71 72 void MGCosy::CreateLabel(TGCompositeFrame *f) 73 { 74 const int y = 25; 75 const int x = 180; 76 69 77 fLabel1 = new TGLabel*[3]; 70 fLabel1[0] = new TGLabel(this, "00000"); // Max: 16384 78 fLabel1[0] = new TGLabel(f, "00000"); // Max: 16384 79 fLabel1[1] = new TGLabel(f, "000"); // Max: 256 80 fLabel1[2] = new TGLabel(f, "000"); // Max: 256 71 81 fLabel1[0]->SetTextJustify(kTextRight); 72 fLabel1[0]->Move(5, 40); 82 fLabel1[1]->SetTextJustify(kTextRight); 83 fLabel1[2]->SetTextJustify(kTextRight); 84 fLabel1[0]->Move(x, y); 85 fLabel1[1]->Move(x+43, y); 86 fLabel1[2]->Move(x+70, y); 73 87 fList->Add(fLabel1[0]); 74 // AddFrame(fLabel1[0], new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));75 fLabel1[1] = new TGLabel(this, "000"); // Max: 25676 fLabel1[1]->SetTextJustify(kTextRight);77 fLabel1[1]->Move(48, 40);78 88 fList->Add(fLabel1[1]); 79 // AddFrame(fLabel1[1], new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));80 fLabel1[2] = new TGLabel(this, "000"); // Max: 25681 fLabel1[2]->SetTextJustify(kTextRight);82 fLabel1[2]->Move(75, 40);83 89 fList->Add(fLabel1[2]); 84 // AddFrame(fLabel1[2], new TGLayoutHints(kLHintsNormal, 9, 9, 9, 9)); 90 //f->AddFrame(fLabel1[0]); 91 //f->AddFrame(fLabel1[1]); 92 //f->AddFrame(fLabel1[2]); 85 93 86 94 fLabel2 = new TGLabel*[3]; 87 fLabel2[0] = new TGLabel(this, "00000"); 95 fLabel2[0] = new TGLabel(f, "00000"); 96 fLabel2[1] = new TGLabel(f, "000"); 97 fLabel2[2] = new TGLabel(f, "000"); 88 98 fLabel2[0]->SetTextJustify(kTextRight); 89 fLabel2[0]->Move(5, 60); 99 fLabel2[1]->SetTextJustify(kTextRight); 100 fLabel2[2]->SetTextJustify(kTextRight); 101 fLabel2[0]->Move(x, y+20); 102 fLabel2[1]->Move(x+43, y+20); 103 fLabel2[2]->Move(x+70, y+20); 90 104 fList->Add(fLabel2[0]); 91 // AddFrame(fLabel2[0], new TGLayoutHints); //(kLHintsNormal, 0, 0, 0, 0));92 fLabel2[1] = new TGLabel(this, "000");93 fLabel2[1]->SetTextJustify(kTextRight);94 fLabel2[1]->Move(48, 60);95 105 fList->Add(fLabel2[1]); 96 // AddFrame(fLabel2[1], new TGLayoutHints); //(kLHintsNormal, 1, 0, 0, 0));97 fLabel2[2] = new TGLabel(this, "000");98 fLabel2[2]->SetTextJustify(kTextRight);99 fLabel2[2]->Move(75, 60);100 106 fList->Add(fLabel2[2]); 101 // AddFrame(fLabel2[2], new TGLayoutHints); //(kLHintsNormal, 2, 0, 0, 0)); 107 //f->AddFrame(fLabel2[0]); 108 //f->AddFrame(fLabel2[1]); 109 //f->AddFrame(fLabel2[2]); 102 110 103 111 fLabel3 = new TGLabel*[3]; 104 fLabel3[0] = new TGLabel(this, "00000"); 112 fLabel3[0] = new TGLabel(f, "00000"); 113 fLabel3[1] = new TGLabel(f, "000"); 114 fLabel3[2] = new TGLabel(f, "000"); 105 115 fLabel3[0]->SetTextJustify(kTextRight); 106 fLabel3[0]->Move(5, 80); 116 fLabel3[1]->SetTextJustify(kTextRight); 117 fLabel3[2]->SetTextJustify(kTextRight); 118 fLabel3[0]->Move(x, y+40); 119 fLabel3[1]->Move(x+43, y+40); 120 fLabel3[2]->Move(x+70, y+40); 107 121 fList->Add(fLabel3[0]); 108 // AddFrame(fLabel3[0]); //, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));109 fLabel3[1] = new TGLabel(this, "000");110 fLabel3[1]->SetTextJustify(kTextRight);111 fLabel3[1]->Move(48, 80);112 122 fList->Add(fLabel3[1]); 113 // AddFrame(fLabel3[1]); //, new TGLayoutHints(kLHintsNormal, 1, 0, 0, 0));114 fLabel3[2] = new TGLabel(this, "000");115 fLabel3[2]->SetTextJustify(kTextRight);116 fLabel3[2]->Move(75, 80);117 123 fList->Add(fLabel3[2]); 118 // AddFrame(fLabel3[2]); //, new TGLayoutHints(kLHintsNormal, 2, 0, 0, 0)); 119 } 120 121 void MGCosy::CreateButton() 122 { 123 TGTextButton *fButton1 = new TGTextButton(this, "Position Zd/Az", kPB_POSITION); 124 TGTextButton *fButton2 = new TGTextButton(this, "Track Ra/Dec", kPB_TRACK); 125 TGTextButton *fButton3 = new TGTextButton(this, "Stop", kPB_STOP); 126 TGTextButton *fButton4 = new TGTextButton(this, "Calc Zd/Az", kPB_CALCALTAZ); 127 TGTextButton *fButton5 = new TGTextButton(this, "Set Polaris", kPB_POLARIS); 128 fButton1->Move(110, 40); 129 fButton2->Move(110, 65); 130 fButton3->Move(260, 90); 131 fButton4->Move(110, 90); 132 fButton5->Move(110, 115); 133 fButton1->SetToolTipText("Move Telescope to Zd/Az position."); 134 fButton2->SetToolTipText("Track the coordinates given in Ra/Dec."); 135 fButton3->SetToolTipText("Stop movement of telescope."); 124 //f->AddFrame(fLabel3[0]); 125 //f->AddFrame(fLabel3[1]); 126 //f->AddFrame(fLabel3[2]); 127 128 129 fError = new TGLabel(f, "Error"); 130 fMoving = new TGLabel(f, "Moving"); 131 fTracking = new TGLabel(f, "Tracking"); 132 fStopping = new TGLabel(f, "Stopping"); 133 fStopped = new TGLabel(f, "Stopped"); 134 135 fError ->SetBackgroundColor(224); // red 136 fMoving ->SetBackgroundColor(10); // blue 137 fTracking->SetBackgroundColor(47); // blue 138 fStopping->SetBackgroundColor(164); // orange 139 fStopped ->SetBackgroundColor(20); // green 140 141 fError ->Move(10, 25); 142 fMoving ->Move(10, 25+20); 143 fTracking->Move(10, 25+40); 144 fStopping->Move(10, 25+60); 145 fStopped ->Move(10, 25+80); 146 147 fError ->Resize(60, 20); 148 fMoving ->Resize(60, 20); 149 fTracking->Resize(60, 20); 150 fStopping->Resize(60, 20); 151 fStopped ->Resize(60, 20); 152 153 fList->Add(fError); 154 fList->Add(fMoving); 155 fList->Add(fTracking); 156 fList->Add(fStopping); 157 fList->Add(fStopped); 158 } 159 160 void MGCosy::CreateButton(TGCompositeFrame *tf1, TGCompositeFrame *tf2) 161 { 162 const int x=15; 163 const int y=12; 164 const int h=16; 165 166 TGLabel *l1 = new TGLabel(tf1, "Move the telescope to a position given in"); 167 TGLabel *l2 = new TGLabel(tf1, "local coordinates. The given coordinates"); 168 TGLabel *l3 = new TGLabel(tf1, "are pointing coordinates, which means that the"); 169 TGLabel *l4 = new TGLabel(tf1, "coordinates are corrected for the bending of"); 170 TGLabel *l5 = new TGLabel(tf1, "the telescope."); 171 l1->Move(x, y); 172 l2->Move(x, y+h); 173 l3->Move(x, y+2*h); 174 l4->Move(x, y+3*h); 175 l5->Move(x, y+4*h); 176 fList->Add(l1); 177 fList->Add(l2); 178 fList->Add(l3); 179 fList->Add(l4); 180 fList->Add(l5); 181 182 l1 = new TGLabel(tf2, "Track a position given in sky coordinates."); 183 l2 = new TGLabel(tf2, "Right Ascension and declination must be given"); 184 l3 = new TGLabel(tf2, "in the FK5, J2000 coordinate system"); 185 l1->Move(x, y); 186 l2->Move(x, y+h); 187 l3->Move(x, y+2*h); 188 fList->Add(l1); 189 fList->Add(l2); 190 fList->Add(l3); 191 192 // 193 // light green: 3 light red: 2 blue?: 2 194 // dark green: 8 dark red: 50 dark blue?: 1 195 196 // 197 // blue: 0-7, 9, 10,11, 14, 15, 18, 19, 22, 23, 27, 31, 33-39, 41-43 198 // 46, 47 199 // green: 8, 12,13, 16, 17, 20, 21, 24, 25, 26, 28, 29, 30, 40, 44 200 // 45, 48 201 // gray: 31, 113- 202 // red: 164, 192, 224, 232 203 // 204 205 // TGTextButton *fButton1 = new TGTextButton(this, "Position Zd/Az", kPB_POSITION); 206 // TGTextButton *fButton2 = new TGTextButton(this, "Track Ra/Dec", kPB_TRACK); 207 TGTextButton *fButton4 = new TGTextButton(this, "Calc Zd/Az", kPB_CALCALTAZ); 208 TGTextButton *fButton5 = new TGTextButton(this, "Set Polaris", kPB_POLARIS); 209 // fButton1->Move(120, 40); 210 // fButton2->Move(120, 65); 211 fButton4->Resize(80, 25); 212 fButton5->Resize(80, 25); 213 214 fButton4->Move(40, 257); 215 fButton5->Move(40, 288); 216 //fButton4->SetBackgroundColor(12); 217 //fButton5->SetBackgroundColor(16); 218 // fButton1->SetToolTipText("Move Telescope to Zd/Az position."); 219 // fButton2->SetToolTipText("Track the coordinates given in Ra/Dec."); 136 220 fButton4->SetToolTipText("Calculate Zd/Az corresponding to Ra/Dec."); 137 221 fButton5->SetToolTipText("Set the actual position as the position of Polaris."); 138 fList->Add(fButton1); 139 fList->Add(fButton2); 140 fList->Add(fButton3); 222 // fList->Add(fButton1); 223 // fList->Add(fButton2); 141 224 fList->Add(fButton4); 142 225 fList->Add(fButton5); 226 227 TGTextButton *fStart = new TGTextButton(this, "Start", kPB_START); 228 TGTextButton *fStop = new TGTextButton(this, "Stop", kPB_STOP); 229 fStart->SetBackgroundColor(20); 230 fStop ->SetBackgroundColor(224); 231 fStart->Move(147, 275); 232 fStop ->Move(212, 275); 233 fStart->Resize(60, 25); 234 fStop ->Resize(60, 25); 235 fStart->SetToolTipText("Start a telescope movement."); 236 fStop ->SetToolTipText("Stop any movement of telescope."); 237 fList->Add(fStart); 238 fList->Add(fStop); 143 239 } 144 240 … … 149 245 150 246 CreateMenu(); 151 CreateLabel(); 152 CreateButton(); 153 247 248 TGCompositeFrame *f = new TGCompositeFrame(this, 0, 0); 249 f->SetLayoutManager(new TGMatrixLayout(f, 3, 2, 10)); 250 fList->Add(f); 251 252 fTab = new TGTab(f, 300, 300); 253 TGCompositeFrame *tf1 = fTab->AddTab("Position Zd/Az"); 254 TGCompositeFrame *tf2 = fTab->AddTab("Track Ra/Dec"); 255 fList->Add(fTab); 256 257 fSkyPosition = new MGSkyPosition(f, 300); 258 fAccuracy = new MGAccuracy (f, 300); 259 fVelocity = new MGVelocity (f, "Velocity ['/min]", 300); 260 fOffset = new MGVelocity (f, "Offset se-re [']", 300); 261 262 fList->Add(fSkyPosition); 263 fList->Add(fAccuracy); 264 fList->Add(fVelocity); 265 fList->Add(fOffset); 266 267 TGGroupFrame *frame = new TGGroupFrame(f, "Status"); 268 frame->Resize(300, 300); 269 fList->Add(frame); 270 271 // 272 // Layout the window, tile by tile... 273 // 274 f->AddFrame(fTab); 275 f->AddFrame(fSkyPosition); 276 f->AddFrame(fAccuracy); 277 f->AddFrame(frame); 278 f->AddFrame(fVelocity); 279 f->AddFrame(fOffset); 280 281 AddFrame(f, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 1, 0)); 282 283 // 284 // FIXME! 285 // 154 286 fCoord = new MGCoordinates(this, kTRUE, 155 287 "Coordinate 1 [\xb0]:", "Coordinate 2 [\xb0]:"); 156 fCoord->Move( 10, 160);288 fCoord->Move(40, 165); 157 289 fList->Add(fCoord); 158 290 159 fSkyPosition = new MGSkyPosition(this, 300); 160 fSkyPosition->Move(320, 40); 161 fList->Add(fSkyPosition); 162 163 fAccuracy = new MGAccuracy(this, 300); 164 fAccuracy->Move(320, 360); 165 fList->Add(fAccuracy); 166 167 fVelocity = new MGVelocity(this, "Velocity ['/min]", 300); 168 fVelocity->Move(10, 360); 169 fList->Add(fVelocity); 170 171 fOffset = new MGVelocity(this, "Offset se-re [']", 300); 172 fOffset->Move(630, 360); 173 fList->Add(fOffset); 291 CreateButton(tf1, tf2); 292 CreateLabel(frame); 174 293 175 294 // 176 295 // Map the window, set up the layout, etc. 177 296 // 178 const Int_t w = 650+310;179 const Int_t h = 6 90;297 const Int_t w = 940; 298 const Int_t h = 660; 180 299 SetWMSizeHints(w, h, w, h, 10, 10); // set the smallest and biggest size of the Main frame 181 182 MapSubwindows();183 Layout();184 300 185 301 SetWindowName("Cosy Main Window"); 186 302 SetIconName("Cosy"); 187 303 304 MapSubwindows(); 305 Resize(GetDefaultSize()); 188 306 MapWindow(); 189 307 } … … 193 311 MGCosy::~MGCosy() 194 312 { 195 cout << " Deleting MGCosy." << endl;313 cout << "MGCosy::~MGCosy called." << endl; 196 314 197 315 delete fLayMenuBar; … … 202 320 delete fList; 203 321 204 cout << "MGCosy deleted." << endl;322 cout << "MGCosy::~MGCosy done." << endl; 205 323 } 206 324 // ====================================================================== 207 void MGCosy::Update(ZdAz pos, ZdAz acc, ZdAz vel, ZdAz off) 325 void MGCosy::EnableLabel(TGLabel *label, Bool_t stat) 326 { 327 stat ? label->MapWindow() : label->UnmapWindow(); 328 329 /* 330 TGGC *fRedTextGC(TGButton::GetDefaultGC()) 331 // Set foreground color in graphics context for drawing of 332 // TGlabel and TGButtons with text in red. 333 ULong_t red; 334 gClient->GetColorByName("red", red); 335 fRedTextGC.SetForeground(red); 336 */ 337 } 338 339 void MGCosy::Update(ZdAz pos, ZdAz acc, ZdAz vel, ZdAz off, UInt_t stat) 208 340 { 209 341 fSkyPosition->Update(pos); 210 fAccuracy->Update( acc);342 fAccuracy->Update(pos, acc); 211 343 fVelocity->Update(vel); 212 344 fOffset->Update(off); 345 346 #define kError 0x01 347 #define kMoving 0x02 348 #define kTracking 0x04 349 #define kStopping 0x08 350 #define kStopped 0x10 351 352 EnableLabel(fError, stat&kError); 353 EnableLabel(fMoving, stat&kMoving); 354 EnableLabel(fTracking, stat&kTracking); 355 EnableLabel(fStopping, stat&kStopping); 356 EnableLabel(fStopped, stat&kStopped); 357 358 stat&kTracking ? fAccuracy->MapWindow() : fAccuracy->UnmapWindow(); 359 stat&kTracking ? fVelocity->MapWindow() : fVelocity->UnmapWindow(); 360 stat&kTracking ? fOffset->MapWindow() : fOffset->UnmapWindow(); 213 361 } 214 362 // ====================================================================== … … 221 369 // window menu item is selected. 222 370 223 //gSystem->ExitLoop(); 224 // gSystem->DispatchOneEvent(kTRUE); 225 226 // TGMainFrame::CloseWindow(); 227 gApplication->Terminate(0); 228 } 229 230 #include <iostream.h> 371 // gSystem->ExitLoop(); 372 // gSystem->DispatchOneEvent(kTRUE); 373 374 // TGMainFrame::CloseWindow(); 375 fQueue->PostMsg(WM_QUIT, 0, 0); 376 // gApplication->Terminate(0); 377 } 378 379 void MGCosy::Start(UInt_t id) 380 { 381 cout << "Start " << (id?"tracking.":"positioning.") << endl; 382 383 XY xy = fCoord->GetCoordinates(); 384 385 if (id) 386 { 387 RaDec dest(xy.X(), xy.Y()); 388 cout << dest.Ra() << kDEG << " " << dest.Dec() << kDEG << endl; 389 fQueue->PostMsg(WM_TRACK, &dest, sizeof(dest)); 390 } 391 else 392 { 393 ZdAz dest(xy.X(), xy.Y()); 394 cout << dest.Zd() << kDEG << " " << dest.Az() << kDEG << endl; 395 fQueue->PostMsg(WM_POSITION, &dest, sizeof(dest)); 396 } 397 398 cout << "PostMsg (" << (id?"WM_Track":"WM_Position") << ") returned." << endl; 399 } 231 400 232 401 Bool_t MGCosy::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2) … … 240 409 switch (GET_SUBMSG(msg)) 241 410 { 411 case kCM_TAB: 412 //cout << "Tab: " << mp1 << endl; 413 return kTRUE; 414 242 415 case kCM_BUTTON: 243 416 … … 245 418 { 246 419 case kPB_POSITION: 247 cout << "Start positioning." << endl; 248 { 249 XY xy = fCoord->GetCoordinates(); 250 ZdAz dest(xy.X(), xy.Y()); 251 cout << dest.Zd() << kDEG << " " << dest.Az() << kDEG << endl; 252 fQueue->PostMsg(WM_POSITION, &dest, sizeof(dest)); 253 } 254 cout << "PostMsg(WM_POSITION) returned." << endl; 420 Start(0); 255 421 return kTRUE; 256 422 257 423 case kPB_TRACK: 258 cout << "Start tracking." << endl; 259 { 260 XY xy = fCoord->GetCoordinates(); 261 RaDec dest(xy.X(), xy.Y()); 262 cout << dest.Ra() << kDEG << " " << dest.Dec() << kDEG << endl; 263 fQueue->PostMsg(WM_TRACK, &dest, sizeof(dest)); 264 } 265 cout << "PostMsg(WM_TRACK) returned." << endl; 424 Start(1); 425 return kTRUE; 426 427 case kPB_START: 428 Start(fTab->GetCurrent()); 266 429 return kTRUE; 267 430 … … 269 432 cout << "Sending stop movement msg." << endl; 270 433 fQueue->PostMsg(WM_STOP, 0, 0); 271 cout << "PostMsg (WM_STOP) returned." << endl;434 cout << "PostMsg (WM_Stop) returned." << endl; 272 435 return kTRUE; 273 436 … … 293 456 return kTRUE; 294 457 } 295 break;458 return kTRUE; 296 459 297 460 case kCM_MENU: … … 300 463 { 301 464 case IDM_EXIT: 302 cout << "Idm_Exit." << endl; 303 CloseWindow(); 304 return kTRUE; 305 306 default: 465 fQueue->PostMsg(WM_QUIT, 0, 0); 466 //cout << "Idm_Exit." << endl; 467 //CloseWindow(); 307 468 return kTRUE; 308 469 } 309 470 return kTRUE; 310 311 default:312 return kTRUE;313 471 } 314 315 default:316 return kTRUE;317 472 } 318 473 -
trunk/MagicSoft/Cosy/gui/MGCosy.h
r913 r918 31 31 class MGAccuracy; 32 32 class MGVelocity; 33 class TGCompositeFrame; 34 class TGTab; 33 35 34 36 class MGCosy : public TGMainFrame … … 56 58 MsgQueue *fQueue; 57 59 60 TGTab *fTab; 61 62 TGLabel *fError; 63 TGLabel *fMoving; 64 TGLabel *fTracking; 65 TGLabel *fStopping; 66 TGLabel *fStopped; 67 58 68 void CreateMenu(); 59 void CreateLabel(); 60 void CreateButton(); 69 void CreateLabel(TGCompositeFrame *f); 70 void CreateButton(TGCompositeFrame *tf1, TGCompositeFrame *tf2); 71 72 void Start(UInt_t id); 73 74 void EnableLabel(TGLabel *label, Bool_t stat); 61 75 62 76 public: … … 70 84 TGLabel **GetLabel3() { return fLabel3; } 71 85 72 void Update(ZdAz pos, ZdAz acc, ZdAz vel, ZdAz off );86 void Update(ZdAz pos, ZdAz acc, ZdAz vel, ZdAz off, UInt_t stat); 73 87 74 88 Bool_t ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2); -
trunk/MagicSoft/Cosy/gui/MGEmbeddedCanvas.cc
r913 r918 12 12 MGEmbeddedCanvas::MGEmbeddedCanvas(const char *name, const TGWindow* p, 13 13 const UInt_t width, Float_t range) 14 : TRootEmbeddedCanvas(name, p, width , width, kRaisedFrame),//, 0) //234, 76, kFixedSize)14 : TRootEmbeddedCanvas(name, p, width+1, width+1, kRaisedFrame),//, 0) //234, 76, kFixedSize) 15 15 fModified(kFALSE), fWidth(width), fRange(range), fPix(2.*range/width) 16 16 { … … 33 33 MapSubwindows(); 34 34 35 Resize(fWidth -1, fWidth-1); //GetDefaultSize()); // ???35 Resize(fWidth, fWidth); //GetDefaultSize()); // ??? 36 36 MapWindow(); 37 37 … … 44 44 return; 45 45 46 // 46 47 // FIXME: Sometimes (if the canvas couldn't be created correctly: 47 48 // X11 Pixmap error) Update hangs the Gui system. 49 // 50 // Fixed: Using root 3.01/06 and doing the update from within the 51 // mainthread. 52 // 48 53 49 54 fCanvas->Modified(); -
trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc
r913 r918 98 98 { 99 99 fText = new TText(105, 105, ""); 100 fText->SetFillStyle(4000); // transparent100 //fText->SetFillStyle(4000); // transparent 101 101 fText->SetTextAlign(33); // right, top 102 102 fText->SetTextColor(10); // white … … 323 323 return; 324 324 325 cout << "Sun: x=" << x << " y=" << y;326 cout << " Zd=" << deg << " Az=" << 360./D2PI*zdaz.Az() << endl;325 // cout << "Sun: x=" << x << " y=" << y; 326 // cout << " Zd=" << deg << " Az=" << 360./D2PI*zdaz.Az() << endl; 327 327 328 328 fSunL[0]->SetX1(x-3.5); fSunL[0]->SetX2(x+3.5); -
trunk/MagicSoft/Cosy/gui/MGVelocity.cc
r913 r918 109 109 line.DrawLine( 0, -65*2, 0, 65*2); 110 110 111 // 112 // Can be replaced by TGaxis axe; in a later root version 113 // than 3.01/06. I talked to Rene 114 // 111 115 TGaxis *axe; 112 116 axe = new TGaxis(-60*2, 0, 60*2, 0, -2, 2, 304, "+-N"); … … 179 183 MGVelocity::~MGVelocity() 180 184 { 181 delete fList;182 183 185 delete fOld; 184 186 delete fAvg; 185 187 186 cout << "MGVelocity destroyed." << endl;188 // cout << "MGVelocity destroyed." << endl; 187 189 } 188 190 … … 270 272 // static int Y = 0xaffe; 271 273 272 float x = zdaz.Az()*3600. *4;273 float y = zdaz.Zd()*3600. *4;274 float x = zdaz.Az()*3600.; 275 float y = zdaz.Zd()*3600.; 274 276 275 277 int pixx = (int)(x*fScale/fPix);
Note:
See TracChangeset
for help on using the changeset viewer.