- Timestamp:
- 08/30/01 16:02:20 (23 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/Changelog
r920 r921 1 1 -*-*- END -*-*- 2 2001/08/30 - Thomas Bretz: 3 4 * MCosy.[h,cc] 5 - fixed some small bugs in tracking and positioning 6 - reorganized StopMovement and CheckForError 7 - added code into LimitSpeed 8 - added cosy.err 9 - rewrote MTTalk not to ba detached 10 - reorganized the code of MTTalk 11 - added StopMovement, WaitForEndMovement and IsPositioning 12 13 * Starguider.cc: 14 - ready for new MGCoordinates-Constructor 15 16 * base/coord.h: 17 - added pre-'-' operator 18 19 * devdrv/shaftencoder.[h,cc]: 20 - introduced an HasChanged - flag 21 22 * gui/MGAccuracy.cc: 23 - replaced floats by doubles in accuracy calculation, 24 gave wrong values 25 26 * gui/MGCoordinate.[h,cc]: 27 - made a bit wider 28 - added support for hms-system 29 30 * gui/MGCoordinates.[h,cc]: 31 - changed to use two fixed systems RaDec (hms), ZdAz(dms) 32 33 * gui/MGCosy.cc: 34 - added new MGCoordinates 35 - moved two MGCoordinates to CreateTabs 36 - renamed CreateButton to CreateTabs 37 - made MGCoordinates a Client of the two Tabs 38 - transform Ra of RaDec MGCoordinates to Degrees. 39 - Introduced StartPos, StartTrack 40 41 * gui/MGVelocity.cc: 42 - added displaying values of speed 43 44 45 2 46 2001/08/29 - Thomas Bretz: 3 47 -
trunk/MagicSoft/Cosy/MCosy.cc
r920 r921 54 54 return rad*kGearRatio2.Y(); 55 55 } 56 57 //double Rad2Deg(double rad)58 //{59 // return 360.0/D2PI*rad;60 //}61 56 62 57 ZdAz MCosy::CorrectTarget(const ZdAz &src, const ZdAz &dst) … … 200 195 cout << "Waiting for positioning..." << flush; 201 196 202 WaitForSdos(); 203 204 cout << "SDO..." << flush; 205 206 while ((fMac1->IsPositioning() || fMac2->IsPositioning()) && !StopWaitingForSDO()) 207 usleep(1); 197 WaitForEndMovement(); 208 198 209 199 cout << "done." << endl; 210 211 SetStatus(kStopped);212 200 } 213 201 … … 215 203 { 216 204 if (!HasError()) 205 { 206 SetStatus(kStopped); 217 207 return; 208 } 218 209 219 210 SetStatus(kError); … … 228 219 int MCosy::SetPosition(const ZdAz &dst) // [rad] 229 220 { 230 // FIXME: C ORRECT BY fTrackingError !!!!!!!!!!221 // FIXME: Correct by fOffset ? 231 222 232 223 // … … 253 244 ZdAz rd = dest-p; // [se] 254 245 255 ZdAz cd = rd; // [se]246 ZdAz cd = rd; // [se] 256 247 cd.Round(); 257 248 … … 300 291 } 301 292 302 CheckForError(); 303 293 StopMovement(); 304 294 lout << "Warning: Requested position not reached." << endl; 305 295 return FALSE; … … 354 344 void MCosy::LimitSpeed(ZdAz *vt, const ZdAz &vcalc) const 355 345 { 356 return;357 358 346 // 359 347 // How to limit the speed. If the wind comes and blowes … … 367 355 #define sgn(x) (x<0?-1:1) 368 356 369 if (sgn(vt->Az()) != sgn(vcalc.Az())) 370 vt->Az(0.1*vcalc.Az()); 357 const Float_t limit = 0.25; 358 359 if (sgn(vt->Az()) != sgn(vcalc.Az()) && 360 fabs(vt->Az()) < limit*fabs(vcalc.Az())) 361 vt->Az(0); 371 362 else 372 363 if (fabs(vt->Az()) > 0.9*vraz) 373 364 vt->Az(0.9*vraz*sgn(vt->Az())); 374 365 375 if (sgn(vt->Zd()) != sgn(vcalc.Zd())) 376 vt->Zd(0.1*vcalc.Zd()); 366 if (sgn(vt->Zd()) != sgn(vcalc.Zd()) && 367 fabs(vt->Zd()) < limit*fabs(vcalc.Zd())) 368 vt->Zd(0); 377 369 else 378 370 if (fabs(vt->Zd()) > 0.9*vrzd) … … 392 384 if (!SetPosition(dest)) 393 385 { 394 lout << "E RROR: Cannot start tracking, unable to reach requested position." << endl;386 lout << "Error: Cannot start tracking, positioning failed." << endl; 395 387 return; 396 388 } … … 421 413 422 414 lout << "Start tracking:"; 423 lout << " Ra: " << Rad2Deg(dst.Ra()) << " deg";424 lout << "Dec: " << Rad2Deg(dst.Dec()) << " deg" << endl;415 lout << " Ra: " << Rad2Deg(dst.Ra()) << "\xb0 "; 416 lout << "Dec: " << Rad2Deg(dst.Dec()) << "\xb0" << endl; 425 417 426 418 // … … 431 423 432 424 ofstream fout("cosy.pos"); 433 fout << " Mjd/10ms V/re/min/4" << endl; 425 fout << "Tracking:"; 426 fout << " Ra: " << Rad2Deg(dst.Ra()) << "\x9c "; 427 fout << "Dec: " << Rad2Deg(dst.Dec()) << "\x9c" << endl << endl; 428 fout << " Mjd/10ms V/re/min/4" << endl; 434 429 435 430 // … … 450 445 dest = CorrectTarget(GetSePos(), sla.CalcZdAz(dst)); // [se] 451 446 452 //ZdAz vcalc = sla.GetApproxVel(dst) * kGearRatio2*4./60.; // [re/min]447 ZdAz vcalc = sla.GetApproxVel(dst) * kGearRatio2*4./60.; // [re/min] 453 448 454 449 // … … 478 473 // 479 474 ZdAz vt = v/4; 480 //LimitSpeed(&vt, vcalc);475 LimitSpeed(&vt, vcalc); 481 476 vt.Round(); 482 477 … … 484 479 // check if the drive is fast enough to follow the star 485 480 // 486 if (v .Zd()>.9*fMac1->GetVelRes() || v.Az()>.9*fMac2->GetVelRes())481 if (vt.Zd()>.9*fMac1->GetVelRes() || vt.Az()>.9*fMac2->GetVelRes()) 487 482 { 488 lout << "Error: Tracking speed faster than possible maximum velocity." << endl;483 lout << "Error: Tracking speed faster than 90% of possible maximum velocity." << endl; 489 484 break; 490 485 } … … 506 501 fout << setw(4) << vt.Zd() << " "; 507 502 fout << setw(4) << vt.Az() << endl; 503 // 504 // FIXME? Calculate an accuracy for the tracking system? 505 // How good do we reach the calculated position in 'real' 506 // re valus? 507 // 508 508 509 509 510 // … … 516 517 517 518 fTracking = kFALSE; 518 519 // 520 // Stop revolution mode 521 // 519 StopMovement(); 520 lout << "Tracking stopped." << endl; 521 } 522 523 int MCosy::IsPositioning() const 524 { 525 return (fMac1->IsPositioning() || fMac2->IsPositioning()) && !StopWaitingForSDO(); 526 } 527 528 void MCosy::WaitForEndMovement() 529 { 530 WaitForSdos(); 531 532 while (IsPositioning()) 533 usleep(1); 534 } 535 536 void MCosy::StopMovement() 537 { 522 538 SetStatus(kStopping); 523 539 540 cout << "Stopping positioning..." << endl; 541 fMac1->SetDeceleration(0.5*fMac1->GetVelRes()); 542 fMac2->SetDeceleration(0.5*fMac2->GetVelRes()); 543 544 cout << "Stoping possible RPM mode..." << endl; 545 fMac1->SetRpmMode(FALSE); 524 546 fMac2->SetRpmMode(FALSE); 525 fMac1->SetRpmMode(FALSE); 526 527 SetStatus(kStopped); 528 529 lout << "Tracking stopped." << endl; 547 548 cout << "Waiting for silence..." << endl; 549 WaitForEndMovement(); 530 550 531 551 CheckForError(); 552 553 cout << "Movement stopped." << endl; 532 554 } 533 555 … … 541 563 542 564 case WM_STOP: 543 cout << "Stopping positioning..." << endl; 544 SetStatus(kStopping); 545 fMac1->SetDeceleration(0.5*fMac1->GetVelRes()); 546 fMac2->SetDeceleration(0.5*fMac2->GetVelRes()); 547 cout << "Stoping possible RPM mode..." << endl; 548 fMac1->SetRpmMode(FALSE); 549 fMac2->SetRpmMode(FALSE); 550 cout << "Stopping commands sent." << endl; 551 while (fMac1->IsPositioning() || fMac2->IsPositioning()) 552 usleep(1); 553 SetStatus(kStopped); 554 cout << "Positioning stopped." << endl; 565 StopMovement(); 555 566 return NULL; 556 567 … … 698 709 // wait until a tracking session is started 699 710 // 700 while (!fTracking )711 while (!fTracking && !fTTalk->HasStopFlag()) 701 712 usleep(1); 702 713 714 if (fTTalk->HasStopFlag()) 715 break; 716 717 ofstream fout("cosy.err"); 718 fout << "Tracking:"; 719 fout << " Ra: " << Rad2Deg(fRaDec.Ra()) << "\x9c "; 720 fout << "Dec: " << Rad2Deg(fRaDec.Dec()) << "\x9c" << endl << endl; 721 fout << " MjdZd/10ms ErrZd/re"; 722 fout << " MjdAz/10ms ErrAd/re" << endl; 723 703 724 ZdAz old; 704 ZdAz ist = fTrackingError/kGearRatio; // [se] 705 ZdAz istre = fOffset; // [re] 706 707 // 708 // only update fTrackingError while tracking 709 // 725 ZdAz ist; 726 710 727 ZdAz sollzd; 711 728 ZdAz sollaz; 712 while (fTracking) 729 730 ZdAz istre = -fOffset; // [re] 731 ZdAz time; 732 733 // 734 // only update fTrackingError while tracking 735 // 736 while (fTracking && !fTTalk->HasStopFlag()) 713 737 { 738 // 739 // Make changes (eg wind) smoother - attenuation of control function 740 // 741 const float weight = 0.3; 742 743 ZdAz offset(fOffset.Zd()*(1.-weight)+(ist.Zd()*kGearRatio.X()-istre.Zd())*weight, 744 fOffset.Az()*(1.-weight)+(ist.Az()*kGearRatio.Y()-istre.Az())*weight); 745 746 fOffset = offset; 747 714 748 // 715 749 // This is the time constant which defines how fast … … 719 753 720 754 // 721 // Make changes (eg wind) smoother - attenuation of control function722 //723 fTrackingError.Set((ist.Zd()-sollzd.Zd())*kGearRatio.X(),724 (ist.Az()-sollaz.Az())*kGearRatio.Y());725 726 727 const float weight = 0.3;728 729 ZdAz offset(fOffset.Zd()*(1.-weight)+(ist.Zd()*kGearRatio.X()-istre.Zd())*weight,730 fOffset.Az()*(1.-weight)+(ist.Az()*kGearRatio.Y()-istre.Az())*weight);731 732 fOffset = offset;733 // fTrackingError.Zd(((offset.Zd()>1000)||(offset.Zd()<-1000))?0:offset.Zd());734 // fTrackingError.Az(((offset.Az()>1000)||(offset.Az()<-1000))?0:offset.Az());735 736 //737 755 // get position, where we are 738 756 // 757 old = ist; 739 758 ist = GetSePos(); // [se] 740 759 … … 750 769 // 751 770 // Get time from last shaftencoder position change (position: ist) 752 // 753 const double tzd = (fAlt1->GetMjd()+fAlt2->GetMjd())/2.0; 754 const double taz = fAz->GetMjd(); 771 // FIXME: I cannot take the avarage 772 // 773 time.Zd((fAlt1->GetMjd()+fAlt2->GetMjd())/2.0); 774 time.Az(fAz->GetMjd()); 755 775 756 776 // … … 760 780 if ((int)ist.Zd() != (int)old.Zd()) 761 781 { 762 sla.SetMjd(t zd);782 sla.SetMjd(time.Zd()); 763 783 sollzd = CorrectTarget(ist, sla.CalcZdAz(fRaDec)); // [se] 764 784 } … … 766 786 if ((int)ist.Az() != (int)old.Az()) 767 787 { 768 sla.SetMjd(t az);788 sla.SetMjd(time.Az()); 769 789 sollaz = CorrectTarget(ist, sla.CalcZdAz(fRaDec)); // [se] 770 790 } 771 791 772 old = ist; 792 fTrackingError.Set((ist.Zd()-sollzd.Zd())*kGearRatio.X(), 793 (ist.Az()-sollaz.Az())*kGearRatio.Y()); 794 795 fout << setprecision(15) << setw(15) << time.Zd()*60.*60.*24. << " "; 796 fout << setprecision(5) << setw(5) << fTrackingError.Zd() << " "; 797 fout << setprecision(15) << setw(15) << time.Az()*60.*60.*24. << " "; 798 fout << setprecision(5) << setw(5) << fTrackingError.Az() << endl; 773 799 } 800 801 fout << endl << endl; 774 802 } 775 803 } … … 814 842 void MCosy::Stop() 815 843 { 816 cout << "- Stopping GUI update." << endl; 844 845 lout << "- Stopping GUI update." << endl; 817 846 fUpdateGui->TurnOff(); 818 // delete fTGui; 819 lout << "- GUI Thread stopped." << endl; 847 lout << "- GUI Update stopped." << endl; 820 848 821 849 delete fTTalk; -
trunk/MagicSoft/Cosy/MCosy.h
r920 r921 7 7 #include "MThread.h" 8 8 9 #define kDEG ((char)0x b0) // Linux 'ø'9 #define kDEG ((char)0x9c) // Linux 'ø' 10 10 11 11 #define WM_WAIT WM_NULL … … 33 33 { 34 34 SetPriority(10); 35 Detach();36 35 Start(); 37 36 } … … 100 99 101 100 int StopWaitingForSDO() const; 101 int IsPositioning() const; 102 102 void CheckForError(); 103 104 void StopMovement(); 105 void WaitForEndMovement(); 103 106 104 107 public: -
trunk/MagicSoft/Cosy/Starguider.cc
r912 r921 123 123 fList.Add(fMenu); 124 124 125 fCRaDec = new MGCoordinates(this, kTRUE, 126 "Right Ascension [\xb0]:", "Declination [\xb0]:"); 125 fCRaDec = new MGCoordinates(this, kETypeRaDec); 127 126 fCRaDec->Move(1, fMenu->GetDefaultHeight()+584); 128 127 AddFrame(fCRaDec); 129 128 fList.Add(fCRaDec); 130 129 131 fCZdAz = new MGCoordinates(this, kFALSE, 132 "Zenith Dist. [\xb0]:", "Azimuth [\xb0]:"); 130 fCZdAz = new MGCoordinates(this, kETypeZdAz); 133 131 fCZdAz->Move(240+12, fMenu->GetDefaultHeight()+584); 134 132 AddFrame(fCZdAz); -
trunk/MagicSoft/Cosy/ToDo
r920 r921 1 1 2 - GUI is missing a display for the actual state of the machine 3 (tracking, positioning, stopping, stopped, etc.) 2 - Implement the ZdAz Positioning in a more proper way (using some fOffset) 4 3 5 - Implement the ZdAz Positioning in a more proper way (using some fOffset) 4 - Add a MCallback interface to be able to get a notice if the 5 shaftencoder position changed (recalc fOffset, fTracking Error 6 as often as possible) 7 8 - Check why it crashes if you exit the program while 'going home' 9 10 - calc trajec with respect to bright stars and planets 11 12 - planet list 13 14 - handshaking 15 16 - calc tracking statistics 17 18 - display histogram for accuracy 19 20 - Add sanity checks to range of 'SetPosition' and 'TrackPosition' 21 22 - Devide MTTalk into NetworkInit and MCalcTrackingError/Offset-Class 6 23 7 - Add a MCallback interface to be able to get a notice if the8 shaftencoder position changed (recalc fOffset, fTracking Error9 as often as possible)10 11 - Check why it crashes if you exit the program while 'going home'12 13 - If one axis stops because of an error the other axis isn't stopped14 ( SetPosition, software endswitch activated)15 -
trunk/MagicSoft/Cosy/base/coord.h
r914 r921 46 46 XY operator+(const XY &c) const { return XY(fX+c.fX, fY+c.fY); } 47 47 XY operator-(const XY &c) const { return XY(fX-c.fX, fY-c.fY); } 48 XY operator-() const { return XY(-fX, -fY); } 48 49 49 50 double Sqr() const { return fX*fX + fY*fY; } … … 72 73 AltAz operator+(const AltAz &c) const { return AltAz(fX+c.fX, fY+c.fY); } 73 74 AltAz operator-(const AltAz &c) const { return AltAz(fX-c.fX, fY-c.fY); } 75 AltAz operator-() const { return AltAz(-fX, -fY); } 74 76 }; 75 77 … … 95 97 ZdAz operator+(const ZdAz &c) const { return ZdAz(fX+c.fX, fY+c.fY); } 96 98 ZdAz operator-(const ZdAz &c) const { return ZdAz(fX-c.fX, fY-c.fY); } 99 ZdAz operator-() const { return ZdAz(-fX, -fY); } 97 100 }; 98 101 … … 110 113 RaDec operator+(const RaDec &c) const { return RaDec(fX+c.fX, fY+c.fY); } 111 114 RaDec operator-(const RaDec &c) const { return RaDec(fX-c.fX, fY-c.fY); } 115 RaDec operator-() const { return RaDec(-fX, -fY); } 112 116 }; 113 117 -
trunk/MagicSoft/Cosy/catalog/Slalib.cc
r912 r921 17 17 slaDaf2r( 9, 56, 36.0, &fElong, &status); 18 18 19 cout << "Latitude: 51 ø38'48.0\" = " << 360.0/D2PI*fPhi << " ";20 cout << "Longitude: 9 ø56'36.0\" = " << 360.0/D2PI*fElong << endl;19 cout << "Latitude: 51\x9c 38'48.0\" = " << 360.0/D2PI*fPhi << " "; 20 cout << "Longitude: 9\x9c 56'36.0\" = " << 360.0/D2PI*fElong << endl; 21 21 } 22 22 -
trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc
r920 r921 13 13 #include <sys/resource.h> // PRIO_PROCESS 14 14 15 ShaftEncoder::ShaftEncoder(BYTE_t nodeid, MLog &out) : NodeDrv(nodeid, out), fLabel(NULL) 15 ShaftEncoder::ShaftEncoder(BYTE_t nodeid, MLog &out) : NodeDrv(nodeid, out), fLabel(NULL), fPosHasChanged(false) 16 16 { 17 17 } … … 112 112 } 113 113 114 void ShaftEncoder::HandlePDOType0(BYTE_t *data )114 void ShaftEncoder::HandlePDOType0(BYTE_t *data, struct timeval *tv) 115 115 { 116 116 // 117 117 // Decode information, we have a 14bit only 118 118 // 119 fPos = data[0] | (data[1]<<8) | (data[2]<<16); // | (data[3]<<24); 120 } 121 122 void ShaftEncoder::HandlePDOType1(BYTE_t *data) 119 LWORDS_t pos = data[0] | (data[1]<<8) | (data[2]<<16); // | (data[3]<<24); 120 if (pos==fPos) 121 return; 122 123 fPos = pos; 124 fTime.SetTimer(tv); 125 fPosHasChanged = true; 126 } 127 128 void ShaftEncoder::HandlePDOType1(BYTE_t *data, struct timeval *tv) 123 129 { 124 130 // … … 127 133 LWORDS_t pos = data[0] | (data[1]<<8) | (data[2]<<16); // | (data[3]<<24); 128 134 BYTE_t flag = data[4]; 129 pos=pos; 135 136 if (fPos==pos) 137 return; 138 139 fPos=pos; 140 fTime.SetTimer(tv); 141 fPosHasChanged=true; 142 130 143 flag=flag; 131 144 } … … 141 154 fAcc = data[6] | (data[7]<<8); 142 155 143 fTime.SetTimer(tv);144 145 156 const int uplim = 9*fTicks/10; 146 157 const int dnlim = 1*fTicks/10; 147 158 159 int turn = fTurn; 160 148 161 if (fPos > uplim && pos < dnlim) 149 fTurn++;162 turn++; 150 163 151 164 if (fPos < dnlim && pos > uplim) 152 fTurn--; 153 154 fPos = pos; 165 turn--; 166 167 if (fPos==pos && fTurn==fTurn) 168 return; 169 170 fPos = pos; 171 fTurn = turn; 172 fTime.SetTimer(tv); 173 fPosHasChanged=true; 155 174 } 156 175 -
trunk/MagicSoft/Cosy/devdrv/shaftencoder.h
r920 r921 22 22 WORDS_t fUpdAcc; // ticks per 25ms^2 23 23 24 bool fPosHasChanged; 25 24 26 Timer fTime; 25 27 26 void HandlePDOType0(BYTE_t *data );27 void HandlePDOType1(BYTE_t *data );28 void HandlePDOType0(BYTE_t *data, struct timeval *tv); 29 void HandlePDOType1(BYTE_t *data, struct timeval *tv); 28 30 void HandlePDOType2(BYTE_t *data, struct timeval *tv); 29 31 … … 56 58 57 59 void DisplayVal(); 60 61 bool IsPosHasChanged() const { return fPosHasChanged; } 62 void ResetPosHasChanged() { fPosHasChanged = false; } 58 63 }; 59 64 -
trunk/MagicSoft/Cosy/gui/MGAccuracy.cc
r920 r921 190 190 aaz *= d2r; 191 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); 192 const double dphi2 = aaz/2.; 193 const double cos2 = cos(dphi2)*cos(dphi2); 194 const double sin2 = sin(dphi2)*sin(dphi2); 195 const double d = cos(azd)*cos2 - cos(2*pzd+azd)*sin2; 196 197 double dist = acos(d); 197 198 198 199 dist *= 3600./d2r; -
trunk/MagicSoft/Cosy/gui/MGCoordinate.cc
r918 r921 23 23 }; 24 24 25 MGCoordinate::MGCoordinate(const TGWindow* p, 25 MGCoordinate::MGCoordinate(const TGWindow* p, const Int_t type=kETypeDeg, 26 26 const Bool_t flag, const char *txt, 27 27 const Int_t deg, const UInt_t min, const UInt_t sec) 28 : TGFrame(p, 11 4, flag?76:46, kSunkenFrame|kFixedSize), fDeg(deg), fMin(min), fSec(sec)28 : TGFrame(p, 119, flag?76:46, kSunkenFrame|kFixedSize), fDeg(deg), fMin(min), fSec(sec) 29 29 { 30 30 // p = pointer to MainFrame (not owner) … … 37 37 // fTextEntryMin->SetAlignment(kTextCenterX); 38 38 // fTextEntrySec->SetAlignment(kTextCenterX); 39 fTextEntryDeg->Move( 4, 26);40 fTextEntryMin->Move(4 4, 26);41 fTextEntrySec->Move( 78, 26);39 fTextEntryDeg->Move( 7, 26); 40 fTextEntryMin->Move(47, 26); 41 fTextEntrySec->Move(81, 26); 42 42 fTextEntryDeg->MapWindow(); 43 43 fTextEntryMin->MapWindow(); … … 60 60 fLabelMin->SetTextJustify(kTextRight); 61 61 fLabelSec->SetTextJustify(kTextRight); 62 fLabelDeg->Move( 4+6, ypos);63 fLabelMin->Move( 44+6, ypos);64 fLabelSec->Move( 78+6, ypos);62 fLabelDeg->Move(13, ypos); 63 fLabelMin->Move(53, ypos); 64 fLabelSec->Move(87, ypos); 65 65 fLabelDeg->MapWindow(); 66 66 fLabelMin->MapWindow(); … … 82 82 TGLabel *label; 83 83 84 const char *deg = type==kETypeDeg ? "\xb0" : "h"; 85 const char *min = type==kETypeDeg ? "'" : "m"; 86 const char *sec = type==kETypeDeg ? "\"" : "s"; 87 84 88 if (flag) 85 89 { 86 label = new TGLabel(this, "\xb0");90 label = new TGLabel(this, deg); 87 91 label->SetTextJustify(kTextLeft); 88 label->Move(3 6, 26);92 label->Move(39, 26); 89 93 label->MapWindow(); 90 94 fList.Add(label); 91 95 92 label = new TGLabel(this, "'");96 label = new TGLabel(this, min); 93 97 label->SetTextJustify(kTextLeft); 94 label->Move(7 0, 26);98 label->Move(73, 26); 95 99 label->MapWindow(); 96 100 fList.Add(label); 97 101 98 label = new TGLabel(this, "\"");102 label = new TGLabel(this, sec); 99 103 label->SetTextJustify(kTextLeft); 100 label->Move(10 4, 26);104 label->Move(107, 26); 101 105 label->MapWindow(); 102 106 fList.Add(label); 103 107 } 104 108 105 label = new TGLabel(this, "\xb0");109 label = new TGLabel(this, deg); 106 110 label->SetTextJustify(kTextLeft); 107 label->Move(3 6, ypos);111 label->Move(39, ypos); 108 112 label->MapWindow(); 109 113 fList.Add(label); 110 114 111 label = new TGLabel(this, "'");115 label = new TGLabel(this, min); 112 116 label->SetTextJustify(kTextLeft); 113 label->Move(7 0, ypos);117 label->Move(73, ypos); 114 118 label->MapWindow(); 115 119 fList.Add(label); 116 120 117 label = new TGLabel(this, "\"");121 label = new TGLabel(this, sec); 118 122 label->SetTextJustify(kTextLeft); 119 label->Move(10 4, ypos);123 label->Move(107, ypos); 120 124 label->MapWindow(); 121 125 fList.Add(label); -
trunk/MagicSoft/Cosy/gui/MGCoordinate.h
r808 r921 14 14 #include "MGList.h" 15 15 #endif 16 17 enum { 18 kETypeDeg, 19 kETypeH 20 }; 16 21 17 22 class TGLabel; … … 41 46 42 47 public: 43 MGCoordinate(const TGWindow* p, 48 MGCoordinate(const TGWindow* p, const Int_t type=kETypeDeg, 44 49 const Bool_t flag=kTRUE, const char *txt="Coordinates:", 45 50 const Int_t deg=0, const UInt_t min=0, const UInt_t sec=0); -
trunk/MagicSoft/Cosy/gui/MGCoordinates.cc
r808 r921 12 12 13 13 MGCoordinates::MGCoordinates(const TGWindow* p, 14 const Int_t type, 14 15 const Bool_t flag, 15 const char *txt1, const char *txt2,16 16 const Int_t deg1, const UInt_t min1, const UInt_t sec1, 17 17 const Int_t deg2, const UInt_t min2, const UInt_t sec2) 18 : TGFrame(p, 2 34, 76, kFixedSize)18 : TGFrame(p, 244, 76, kFixedSize) 19 19 { 20 const Int_t t = type==kETypeZdAz ? kETypeDeg : kETypeH; 21 const char *txt1 = type==kETypeZdAz ? "Zenith Dist [\xb0]:" : "Right Ascension [h]:"; 22 const char *txt2 = type==kETypeZdAz ? "Azimuth [\xb0]:" : "Declination [\xb0]:"; 23 20 24 // p = pointer to MainFrame (not owner) 21 fX = new MGCoordinate(this, flag, txt1, deg1, min1, sec1);25 fX = new MGCoordinate(this, t, flag, txt1, deg1, min1, sec1); 22 26 fX->Move(0, 0); 23 27 24 fY = new MGCoordinate(this, flag, txt2, deg2, min2, sec2);25 fY->Move(12 0, 0);28 fY = new MGCoordinate(this, kETypeDeg, flag, txt2, deg2, min2, sec2); 29 fY->Move(125, 0); 26 30 27 31 MapWindow(); -
trunk/MagicSoft/Cosy/gui/MGCoordinates.h
r808 r921 15 15 #endif 16 16 17 enum { 18 kETypeZdAz, 19 kETypeRaDec 20 }; 21 17 22 class MGCoordinate; 18 23 … … 23 28 24 29 public: 25 MGCoordinates(const TGWindow* p, 30 MGCoordinates(const TGWindow* p, const Int_t type=kETypeZdAz, 26 31 const Bool_t flag=kTRUE, 27 const char *txt1="Coordinate1:",28 const char *txt2="Coordinate2:",29 32 const Int_t deg1=0, const UInt_t min1=0, const UInt_t sec1=0, 30 33 const Int_t deg2=0, const UInt_t min2=0, const UInt_t sec2=0); -
trunk/MagicSoft/Cosy/gui/MGCosy.cc
r920 r921 191 191 } 192 192 193 void MGCosy::CreateButton(TGCompositeFrame *tf1, TGCompositeFrame *tf2) 194 { 193 void MGCosy::CreateTabs(TGTab *fTab) 194 { 195 TGCompositeFrame *tf1 = fTab->AddTab("Position Zd/Az"); 196 TGCompositeFrame *tf2 = fTab->AddTab("Track Ra/Dec"); 197 198 fCZdAz = new MGCoordinates(tf1, kETypeZdAz); 199 fCZdAz->Move(27, 105); 200 fList->Add(fCZdAz); 201 202 fCRaDec = new MGCoordinates(tf2, kETypeRaDec); 203 fCRaDec->Move(27, 105); 204 fList->Add(fCRaDec); 205 206 195 207 const int x=15; 196 208 const int y=12; … … 235 247 // red: 164, 192, 224, 232 236 248 // 237 238 // TGTextButton *fButton1 = new TGTextButton(this, "Position Zd/Az", kPB_POSITION); 239 // TGTextButton *fButton2 = new TGTextButton(this, "Track Ra/Dec", kPB_TRACK); 240 TGTextButton *fButton4 = new TGTextButton(this, "Calc Zd/Az", kPB_CALCALTAZ); 241 TGTextButton *fButton5 = new TGTextButton(this, "Set Polaris", kPB_POLARIS); 242 // fButton1->Move(120, 40); 243 // fButton2->Move(120, 65); 244 fButton4->Resize(80, 25); 245 fButton5->Resize(80, 25); 246 247 fButton4->Move(40, 257); 248 fButton5->Move(40, 288); 249 //fButton4->SetBackgroundColor(12); 250 //fButton5->SetBackgroundColor(16); 251 // fButton1->SetToolTipText("Move Telescope to Zd/Az position."); 252 // fButton2->SetToolTipText("Track the coordinates given in Ra/Dec."); 253 fButton4->SetToolTipText("Calculate Zd/Az corresponding to Ra/Dec."); 254 fButton5->SetToolTipText("Set the actual position as the position of Polaris."); 255 // fList->Add(fButton1); 256 // fList->Add(fButton2); 257 fList->Add(fButton4); 258 fList->Add(fButton5); 259 260 TGTextButton *fStart = new TGTextButton(this, "Start", kPB_START); 261 TGTextButton *fStop = new TGTextButton(this, "Stop", kPB_STOP); 262 fStart->SetBackgroundColor(20); 263 fStop ->SetBackgroundColor(224); 264 fStart->Move(147, 275); 265 fStop ->Move(212, 275); 266 fStart->Resize(60, 25); 267 fStop ->Resize(60, 25); 268 fStart->SetToolTipText("Start a telescope movement."); 269 fStop ->SetToolTipText("Stop any movement of telescope."); 270 fList->Add(fStart); 271 fList->Add(fStop); 249 TGTextButton *but; 250 251 but= new TGTextButton(this, "Calc Zd/Az", kPB_CALCALTAZ); 252 but->Resize(80, 25); 253 but->Move(37, 257); 254 but->SetToolTipText("Calculate Zd/Az corresponding to Ra/Dec."); 255 fList->Add(but); 256 257 but = new TGTextButton(this, "Set Polaris", kPB_POLARIS); 258 but->Resize(80, 25); 259 but->Move(37, 288); 260 but->SetToolTipText("Set the actual position as the position of Polaris."); 261 fList->Add(but); 262 263 but = new TGTextButton(this, "Start", kPB_START); 264 but->SetBackgroundColor(20); 265 but->Move(147, 275); 266 but->Resize(62, 25); 267 but->SetToolTipText("Start a telescope movement."); 268 fList->Add(but); 269 270 but = new TGTextButton(this, "Stop", kPB_STOP); 271 but->SetBackgroundColor(224); 272 but->Move(212, 275); 273 but->Resize(62, 25); 274 but->SetToolTipText("Stop any movement of telescope."); 275 fList->Add(but); 276 272 277 } 273 278 … … 284 289 285 290 fTab = new TGTab(f, 300, 300); 286 TGCompositeFrame *tf1 = fTab->AddTab("Position Zd/Az");287 TGCompositeFrame *tf2 = fTab->AddTab("Track Ra/Dec");288 291 fList->Add(fTab); 289 292 290 293 fSkyPosition = new MGSkyPosition(f, 300); 291 294 fAccuracy = new MGAccuracy (f, 300); 292 fVelocity = new MGVelocity (f, "Velocity [ '/min]", 300);295 fVelocity = new MGVelocity (f, "Velocity [\"/min]", 300); 293 296 // fOffset = new MGVelocity (f, "Offset se-re [']", 300); 294 297 … … 304 307 fLog = new TGListBox(f, -1, kSunkenFrame); //kSunkenFrame|kDoubleBorder, 305 308 fLog->Resize(300, 300); 309 fLog->ChangeBackground(TGFrame::GetBlackPixel()); 306 310 fList->Add(fLog); 307 311 … … 321 325 // FIXME! 322 326 // 323 fCoord = new MGCoordinates(this, kTRUE, 324 "Coordinate 1 [\xb0]:", "Coordinate 2 [\xb0]:"); 325 fCoord->Move(40, 165); 326 fList->Add(fCoord); 327 328 CreateButton(tf1, tf2); 327 CreateTabs(fTab); 329 328 CreateLabel(frame); 330 329 … … 384 383 { 385 384 zd = (Int_t)off.Zd(); 386 sprintf(text, "% ld", zd);385 sprintf(text, "%d", zd); 387 386 fOffsetZd->SetText(new TGString(text)); 388 387 } … … 390 389 { 391 390 az = (Int_t)off.Az(); 392 sprintf(text, "% ld", az);391 sprintf(text, "%d", az); 393 392 fOffsetAz->SetText(new TGString(text)); 394 393 } … … 442 441 } 443 442 444 void MGCosy::Start(UInt_t id) 445 { 446 cout << "Start " << (id?"tracking.":"positioning.") << endl; 447 448 XY xy = fCoord->GetCoordinates(); 449 450 if (id) 451 { 452 RaDec dest(xy.X(), xy.Y()); 453 cout << dest.Ra() << kDEG << " " << dest.Dec() << kDEG << endl; 454 fQueue->PostMsg(WM_TRACK, &dest, sizeof(dest)); 455 } 456 else 457 { 458 ZdAz dest(xy.X(), xy.Y()); 459 cout << dest.Zd() << kDEG << " " << dest.Az() << kDEG << endl; 460 fQueue->PostMsg(WM_POSITION, &dest, sizeof(dest)); 461 } 462 463 cout << "PostMsg (" << (id?"WM_Track":"WM_Position") << ") returned." << endl; 443 void MGCosy::StartTrack() 444 { 445 cout << "Start tracking." << endl; 446 447 XY xy = fCRaDec->GetCoordinates(); 448 RaDec dest(xy.X()*15., xy.Y()); // xy.X() [h]->[ø] 449 450 cout << dest.Ra() << "h " << dest.Dec() << "\xb0" << endl; 451 452 fQueue->PostMsg(WM_TRACK, &dest, sizeof(dest)); 453 454 cout << "PostMsg (WM_Track) returned." << endl; 455 } 456 457 void MGCosy::StartPos() 458 { 459 cout << "Start positioning." << endl; 460 461 XY xy = fCZdAz->GetCoordinates(); 462 ZdAz dest(xy.X(), xy.Y()); 463 464 cout << dest.Zd() << kDEG << " " << dest.Az() << kDEG << endl; 465 466 fQueue->PostMsg(WM_POSITION, &dest, sizeof(dest)); 467 468 cout << "PostMsg (WM_Position) returned." << endl; 464 469 } 465 470 … … 482 487 switch (mp1) 483 488 { 489 /* 484 490 case kPB_POSITION: 485 491 Start(0); … … 489 495 Start(1); 490 496 return kTRUE; 491 497 */ 492 498 case kPB_START: 493 Start(fTab->GetCurrent());499 fTab->GetCurrent() ? StartTrack() : StartPos(); 494 500 return kTRUE; 495 501 … … 505 511 sla.SetMjd2Now(); 506 512 507 XY xy = fC oord->GetCoordinates();508 RaDec rd(xy.X() , xy.Y());513 XY xy = fCRaDec->GetCoordinates(); 514 RaDec rd(xy.X()*15., xy.Y()); 509 515 510 516 cout << "Ra/Dec: " << rd.Ra() << kDEG << " " << rd.Dec() << kDEG << endl; -
trunk/MagicSoft/Cosy/gui/MGCosy.h
r920 r921 54 54 TGLabel *fOffsetAz; 55 55 56 MGCoordinates *fCoord; 56 MGCoordinates *fCZdAz; 57 MGCoordinates *fCRaDec; 58 57 59 MGSkyPosition *fSkyPosition; 58 60 MGAccuracy *fAccuracy; … … 74 76 void CreateMenu(); 75 77 void CreateLabel(TGCompositeFrame *f); 76 void Create Button(TGCompositeFrame *tf1, TGCompositeFrame *tf2);78 void CreateTabs(TGTab *fTab); 77 79 78 void Start(UInt_t id); 80 void StartPos(); 81 void StartTrack(); 79 82 80 83 void EnableLabel(TGLabel *label, Bool_t stat); -
trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc
r920 r921 259 259 Y = fy; 260 260 261 float /*int*/ xm = /*(int)floor*/(fmod(fabs(x), 60.));262 float /*int*/ ym = /*(int)floor*/(fmod(fabs(y), 60.));261 float xm = fmod(fabs(x), 60.); 262 float ym = fmod(fabs(y), 60.); 263 263 264 264 char txt[100]; -
trunk/MagicSoft/Cosy/gui/MGVelocity.cc
r918 r921 167 167 fText->Draw(); 168 168 fList->Add(fText); 169 170 fTextVel = new TText(2*70, 2*70, ""); 171 fTextVel->SetTextAlign(33); // right, top 172 fTextVel->SetTextColor(10); // white 173 fTextVel->Draw(); 174 fList->Add(fTextVel); 169 175 } 170 176 … … 198 204 sprintf(txt, "x%.0f", 1./fScale); 199 205 200 fText->SetText(fText->GetX() /*70*2*/, fText->GetY()/*70*2*/, txt);206 fText->SetText(fText->GetX(), fText->GetY(), txt); 201 207 } 202 208 … … 263 269 } 264 270 271 void MGVelocity::UpdateVelText(Float_t vx, Float_t vy) 272 { 273 static int X = ~0; 274 static int Y = ~0; 275 276 vx /= 60.; //['/min] 277 vy /= 60.; //['/min] 278 279 int fx = (int)floor(vx*10.); 280 int fy = (int)floor(vy*10.); 281 282 if (X==fx && Y==fy) 283 return; 284 285 X = fx; 286 Y = fy; 287 288 char txt[100]; 289 sprintf(txt, "Zd=%.1f'\nAz=%.1f'", 290 vx, vy); 291 292 fTextVel->SetText(fTextVel->GetX(), fTextVel->GetY(), txt); 293 } 265 294 266 295 void MGVelocity::Update(ZdAz &zdaz) … … 272 301 // static int Y = 0xaffe; 273 302 274 float x = zdaz.Az()*3600.; 275 float y = zdaz.Zd()*3600.; 276 277 int pixx = (int)(x*fScale/fPix); 278 int pixy = (int)(y*fScale/fPix); 303 float vx = zdaz.Az()*3600.; // ["/min] 304 float vy = zdaz.Zd()*3600.; // ["/min] 305 306 UpdateVelText(vx, vy); 307 308 int pixx = (int)(vx*fScale/fPix); 309 int pixy = (int)(vy*fScale/fPix); 279 310 280 311 // … … 284 315 285 316 if (pixx || pixy) 286 rc = UpdateAvg( x,y);317 rc = UpdateAvg(vx, vy); 287 318 288 319 if (rc) … … 296 327 // cout << zdaz.Az()*3600. << " " << zdaz.Zd()*3600. << endl; 297 328 298 x *= fScale;299 y *= fScale;300 301 fArrow->SetX2( x);302 fArrow->SetY2( y);303 304 fArrowX->SetX2( x);305 fArrowY->SetY2( y);329 vx *= fScale; 330 vy *= fScale; 331 332 fArrow->SetX2(vx); 333 fArrow->SetY2(vy); 334 335 fArrowX->SetX2(vx); 336 fArrowY->SetY2(vy); 306 337 307 338 fOld->Set(pixx, pixy); … … 309 340 SetModified(); 310 341 UpdateCanvas(); 311 312 } 342 } -
trunk/MagicSoft/Cosy/gui/MGVelocity.h
r913 r921 31 31 32 32 TText *fText; 33 TText *fTextVel; 33 34 34 35 XY *fOld; … … 43 44 void DrawCoordinateSystem(); 44 45 void UpdateText(); 46 void UpdateVelText(Float_t x, Float_t y); 45 47 46 48 public:
Note:
See TracChangeset
for help on using the changeset viewer.