Changeset 1760 for trunk/MagicSoft
- Timestamp:
- 02/16/03 17:02:06 (22 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/Changelog
r1759 r1760 1 1 -*-*- END -*-*- 2 2003/02/16 - Thomas Bretz (La Palma): 3 4 * base/MStarList.h: 5 - added default for mag to Add 6 7 * base/coord.h: 8 - replaced kRadDeg by including MAGIC.h 9 10 * base/timer.[h,cc]: 11 - changed Now to call virtual function SetMjd 12 13 * gui/MGAccuracy.cc: 14 - fixed a bug causing the display to display error%60 15 16 * gui/MGCosy.[h,cc]: 17 - added combo box for predifed positions 18 - update display of time only when time changed 19 20 * gui/MGSkyPosition.[h,cc]: 21 - added bright stars 22 23 * main/MCosy.[h,cc]: 24 - some changes to output 25 - replaced HasZombie by a preliminary one 26 - changed dT to 3s 27 - removed time correction factor in Tracking algorithm 28 - PRELIMINARY TalkThreadTracking 29 30 2 31 3 32 2003/02/14 - Thomas Bretz (La Palma): -
trunk/MagicSoft/Cosy/base/MStarList.h
r1691 r1760 20 20 new (fStars[idx]) MStar(meanx, meany, mag); 21 21 } 22 void Add(Double_t meanx, Double_t meany, Double_t mag )22 void Add(Double_t meanx, Double_t meany, Double_t mag=0) 23 23 { 24 24 AddAt(fStars.GetLast()+1, meanx, meany, mag); -
trunk/MagicSoft/Cosy/base/coord.h
r1393 r1760 5 5 #include <fstream.h> 6 6 7 #include "MAGIC.h" 8 7 9 /* pi/180: degrees to radians */ 8 10 const double kDeg2Rad = 0.017453292519943295769236907684886127134428718885417; 9 11 10 12 /* 180/pi: radians to degrees */ 11 const double kRad2Deg = 57.295779513082320876798154814105170332405472466564;13 //const double kRad2Deg = 57.295779513082320876798154814105170332405472466564; 12 14 13 15 /* pi/2: 90 degrees in radians */ -
trunk/MagicSoft/Cosy/base/timer.cc
r1759 r1760 13 13 fMs = tv_usec; 14 14 15 SetMjd((fMs+fSecs)/(60*60*24) + 40587); 16 15 17 fSec = tv_sec%60; 16 18 tv_sec /= 60; … … 22 24 tv_sec /= 24; 23 25 24 Set(tv_sec + 40587); 25 26 fDiv = fmod((fMs+fSecs)/(60*60*24), 1.0); 26 // fDiv = fmod((fMs+fSecs)/(60*60*24), 1.0); 27 27 } 28 28 /* 29 29 void Timer::Set(const long mjd) 30 30 { 31 SetMjd(mjd); 32 31 33 // 32 34 // Express day in Gregorian calendar 33 35 // (taken from slalib slaDjcl) 34 36 // 35 fMjd = mjd;36 37 37 const long jd = mjd + 2400001; 38 38 const long n4 = (((((jd*4-17918)/146097)*6)/4+1)/2+jd-37)*4; … … 43 43 fDay = (nd10%306)/10 + 1; 44 44 } 45 45 */ 46 46 void Timer::SetTimer(const struct timeval *tv) 47 47 { … … 77 77 void Timer::SetMjd(double mjd) 78 78 { 79 Set((long)mjd); 79 // 80 // Express day in Gregorian calendar 81 // (taken from slalib slaDjcl) 82 // 83 fMjd = mjd; 84 85 const long jd = (long)mjd + 2400001; 86 const long n4 = (((((jd*4-17918)/146097)*6)/4+1)/2+jd-37)*4; 87 const long nd10 = (((n4-237)%1461)/4)*10+5; 88 89 fYea = n4/1461 - 4712; 90 fMon = ((nd10/306+2)%12) + 1; 91 fDay = (nd10%306)/10 + 1; 80 92 81 93 fDiv = fmod(mjd, 1.0); … … 84 96 85 97 mjd *= 24; 86 fHor = (int) mjd;98 fHor = (int)fmod(mjd, 24); 87 99 88 100 mjd *= 60; 89 fMin = (int) mjd;101 fMin = (int)fmod(mjd, 60); 90 102 91 103 mjd *= 60; 92 fSec = (int) mjd;104 fSec = (int)fmod(mjd, 60); 93 105 94 fMs = mjd * 1000;106 fMs = fmod(mjd * 1000, 1000); 95 107 } 96 108 -
trunk/MagicSoft/Cosy/base/timer.h
r1759 r1760 22 22 char fDateStr[30]; 23 23 24 void Set(const long mjd);24 //void Set(const long mjd); 25 25 26 26 public: … … 36 36 37 37 double Now(); //[s] 38 double GetMjd() const { return fMjd +fDiv; }38 double GetMjd() const { return fMjd/*+fDiv*/; } 39 39 40 40 virtual void SetMjd(double mjd); -
trunk/MagicSoft/Cosy/gui/MGAccuracy.cc
r1702 r1760 206 206 int rs = (int)floor(fmod(dist, 60.)); 207 207 dist /= 60.; 208 int rm = (int) floor(fmod(dist, 60.));208 int rm = (int)dist;//floor(fmod(dist, 60.)); 209 209 210 210 char txt[100]; -
trunk/MagicSoft/Cosy/gui/MGCosy.cc
r1758 r1760 14 14 #include <TGLabel.h> // TGLabel 15 15 #include <TGListBox.h> // TGListBox 16 #include <TGComboBox.h> // TGComboBox 16 17 #include <TG3DLine.h> // TGHorizontal3DLine (TGSplitter) 17 18 #include <TGTextEntry.h> // TGTextEntry … … 53 54 kPB_LoadBending, 54 55 kPB_ResetBending, 55 kPB_CALIBSE 56 kPB_CALIBSE, 57 kCB_PredefPos 58 56 59 }; 57 60 … … 306 309 } 307 310 311 void MGCosy::CreatePredefinedPos(TGCompositeFrame *tf1) 312 { 313 TGComboBox *box = new TGComboBox(tf1, kCB_PredefPos); 314 box->Resize(120, 20); 315 box->Associate(this); 316 317 TGLayoutHints *lay = new TGLayoutHints(kLHintsLeft|kLHintsTop, 318 27, 0, 200, 0); 319 tf1->AddFrame(box, lay); 320 321 fList->Add(box); 322 fList->Add(lay); 323 324 ifstream fin("prepos.txt"); 325 if (!fin) 326 { 327 cout << "ERROR: Predifined posiion in 'prepos.txt' not found." << endl; 328 return; 329 } 330 331 int i=0; 332 while (!fin.eof()) 333 { 334 TString str; 335 Double_t zd, az; 336 fin >> str >> zd >> az; 337 box->AddEntry(str, i++); 338 339 fStarList.Add(zd, az); 340 } 341 } 342 308 343 void MGCosy::CreateTabs(TGTab *fTab) 309 344 { … … 317 352 fCZdAz->Move(27, 105); 318 353 fList->Add(fCZdAz); 354 355 CreatePredefinedPos(tf1); 319 356 320 357 fCRaDec = new MGCoordinates(tf2, kETypeRaDec); … … 866 903 time.Now(); 867 904 905 static char oldtxt[256]; 906 868 907 char text[256]; 869 908 … … 875 914 dot[2] = 0; 876 915 877 fUtc->SetText(new TGString(text)); 878 916 if (strcmp(oldtxt, text)) 917 { 918 fUtc->SetText(new TGString(text)); 919 strcpy(oldtxt, text); 920 } 921 922 static long oldmjd; 879 923 double mjd = time.GetMjd(); 880 924 881 sprintf(text, "%12.6f", mjd); 882 fMjd->SetText(new TGString(text)); 925 if (oldmjd != 1000000*mjd) 926 { 927 sprintf(text, "%12.6f", mjd); 928 fMjd->SetText(new TGString(text)); 929 930 oldmjd = (long)(1000000*mjd); 931 } 883 932 884 933 return mjd; … … 1098 1147 switch (GET_SUBMSG(msg)) 1099 1148 { 1149 case kCM_COMBOBOX: 1150 if (mp1==kCB_PredefPos) 1151 { 1152 MStar *pos = fStarList[mp2]; 1153 if (!pos) 1154 return kTRUE; 1155 fCZdAz->SetCoordinates(ZdAz(pos->GetX(), pos->GetY())); 1156 } 1157 return kTRUE; 1158 1100 1159 case kCM_TAB: 1101 1160 //cout << "Tab: " << mp1 << endl; -
trunk/MagicSoft/Cosy/gui/MGCosy.h
r1758 r1760 7 7 8 8 #ifndef MARS_MObservatory 9 #include <MObservatory.h> 9 #include "MObservatory.h" 10 #endif 11 12 #ifndef COSY_MStarList 13 #include "MStarList.h" 10 14 #endif 11 15 … … 64 68 TGLabel *fMjd; 65 69 70 MStarList fStarList; 71 66 72 MGCoordinates *fCZdAz; 67 73 MGCoordinates *fCRaDec; … … 94 100 void CreateLabel(TGCompositeFrame *f); 95 101 void CreateTabs(TGTab *fTab); 102 void CreatePredefinedPos(TGCompositeFrame *tf1); 96 103 97 104 void StartPos(); -
trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc
r1758 r1760 69 69 InitArc(fSaturn, 1001, kYellow/*17*/, 16); 70 70 71 for (int i=0; i<13; i++) 72 { 73 fStars[i] = new TArc(0, 0, 1); 74 InitArc(fStars[i], 1001, kWhite, kWhite); 75 fList->Add(fStars[i]); 76 } 77 71 78 for (int i=0; i<4; i++) 72 79 { … … 97 104 } 98 105 106 void MGSkyPosition::UpdateStars() 107 { 108 RaDec stars[13]; 109 110 // 32349 Sirius -1.44 1.45 2.64 0.009 A0m 111 stars[0] = RaDec(MObservatory::Hms2Rad( 6, 45, 0), MObservatory::Dms2Rad(-16, 42, 0)); 112 // 30438 Canopus -0.62 -5.53 95.88 0.164 F0Ib 113 stars[1] = RaDec(MObservatory::Hms2Rad( 6, 23, 0), MObservatory::Dms2Rad(-52, 41, 0)); 114 // 69673 Arcturus -0.05 -0.31 11.25 1.239 K2IIIp 115 stars[2] = RaDec(MObservatory::Hms2Rad( 14, 15, 0), MObservatory::Dms2Rad( 19, 10, 0)); 116 stars[3] = RaDec(MObservatory::Hms2Rad( 01, 37, 6), MObservatory::Dms2Rad(-57, 14, 0)); 117 stars[4] = RaDec(MObservatory::Hms2Rad( 12, 26, 6), MObservatory::Dms2Rad(-63, 06, 0)); 118 stars[5] = RaDec(MObservatory::Hms2Rad( 13, 25, 2), MObservatory::Dms2Rad(-11, 10, 0)); 119 stars[6] = RaDec(MObservatory::Hms2Rad( 5, 14, 0), MObservatory::Dms2Rad(- 8, 12, 5)); 120 stars[7] = RaDec(MObservatory::Hms2Rad( 19, 50, 0), MObservatory::Dms2Rad(- 8, 52, 6)); 121 stars[8] = RaDec(MObservatory::Hms2Rad( 18, 37, 0), MObservatory::Dms2Rad( 38, 47, 0)); 122 stars[9] = RaDec(MObservatory::Hms2Rad( 5, 16, 0), MObservatory::Dms2Rad( 46, 00, 0)); 123 stars[10] = RaDec(MObservatory::Hms2Rad( 7, 39, 0), MObservatory::Dms2Rad( 5, 14, 0)); 124 stars[11] = RaDec(MObservatory::Hms2Rad( 5, 55, 0), MObservatory::Dms2Rad( 7, 24, 0)); 125 stars[12] = RaDec(MObservatory::Hms2Rad( 19, 50, 0), MObservatory::Dms2Rad( 8, 52, 0)); 126 127 for (int i=0; i<13; i++) 128 SetDot(fStars[i], stars[i], 0); 129 130 } 99 131 void MGSkyPosition::InitText() 100 132 { … … 327 359 UpdatePlanet(kESaturn, fSaturn); 328 360 361 UpdateStars(); 362 329 363 RaDec radec = fSlaStar->CalcRaDecFast(pos*kDeg2Rad); 330 364 -
trunk/MagicSoft/Cosy/gui/MGSkyPosition.h
r1758 r1760 35 35 TArc *fSaturn; 36 36 37 TArc *fStars[13]; 38 37 39 TArc *fSaturnRing; 38 40 … … 67 69 void SetDot(TArc *arc, RaDec &radec, Int_t off); 68 70 71 void UpdateStars(); 69 72 void UpdateText(Float_t zd, Float_t az); 70 73 void UpdatePlanet(Int_t planet, TArc *arc); -
trunk/MagicSoft/Cosy/main/MCosy.cc
r1758 r1760 1 #include "MCosy.h" 1 2 #include "MCosy.h" 2 3 … … 307 308 if (HasZombie()) 308 309 return; 309 310 310 SetStatus(MCosy::kMoving); 311 311 … … 408 408 409 409 const ZdAz d = dst*kRad2Deg; 410 if (d.Zd()<fMin.Zd() || d.Zd()>fMax.Zd() || d.Az()<fMin.Az() || d.Az()>fMax.Az()) 411 { 412 lout << "ERROR: Requested Position not inside allowed range." << endl; 410 411 lout << "Target Position: " << d.Zd() << "deg, " << d.Az() << "deg (Zd/Az)" << endl; 412 413 if (d.Zd()<fMin.Zd() || d.Zd()>fMax.Zd()) 414 { 415 lout << "ERROR: Requested Zenith Angle (" << d.Zd() << "deg) not "; 416 lout << "inside allowed range." << endl; 417 return kFALSE; 418 } 419 420 if (d.Az()<fMin.Az() || d.Az()>fMax.Az()) 421 { 422 lout << "ERROR: Requested Azimuth Angle (" << d.Az() << "deg) not "; 423 lout << "inside allowed range." << endl; 413 424 return kFALSE; 414 425 } … … 445 456 fZdAzSoll = dst; 446 457 447 lout << "Positioning to Target..." << endl;448 458 cout << "Source Zd: " << src.Zd() << "se Az:" << src.Az() << "se" << endl; 449 459 cout << "Destination Zd: " << Rad2SE(dst.Zd()) << "se Az:" << Rad2SE(dst.Az()) << "se" << endl; … … 451 461 cout << "Shortest Dest Zd: " << dest.Zd() << "se Az:" << dest.Az() << "se" << endl; 452 462 453 for (int i=0; i<10 && !(Break() || HasError()) && !HasZombie(); i++) 454 { 463 int i; 464 for (i=0; i<10 && !(Break() || HasError()) && !HasZombie(); i++) 465 { 466 467 lout << "Step #" << i << endl; 455 468 // 456 469 // Get Shaft Encoder Positions … … 491 504 // at the same time 492 505 // 506 lout << "SetVelocity" << endl; 493 507 if (i) 494 508 SetPosVelocity(1.0, 0.1, 0.1); 495 509 else 496 SetPosVelocity(fabs(rd.Ratio()), 0. 9, 0.5);510 SetPosVelocity(fabs(rd.Ratio()), 0.1, 0.3); 497 511 498 512 rd.Round(); … … 511 525 // repositioning (relative) 512 526 // 527 lout << "Do Relative Positioning Done" << endl; 513 528 DoRelPos(rd, cdzd, cdaz); 529 530 lout << "Relative Positioning Done" << endl; 514 531 } 515 532 516 533 StopMovement(); 517 lout << "Warning: Requested position not reached ." << endl;534 lout << "Warning: Requested position not reached (i=" << i << ")" << endl; 518 535 return FALSE; 519 536 } … … 670 687 void MCosy::TrackPosition(const RaDec &dst) // ra, dec [rad] 671 688 { 689 lout << "Track Position: " << dst.Ra()*kRad2Deg/15 << "h, " << dst.Dec()*kRad2Deg << "deg (Ra/Dec)" << endl; 690 672 691 SlaStars sla(fObservatory); 673 692 … … 733 752 // We want to reach the theoretical position exactly in about 0.5s 734 753 // 735 const float dt = 1; // 1 second 754 // *OLD*const float dt = 1; // 1 second 755 const float dt = 3; // 1 second 736 756 while (!(Break() || HasError()) && !HasZombie()) 737 757 { … … 751 771 dest *= kGearRatio; // [re] 752 772 753 if (d.Zd()<fMin.Zd() || d.Zd()>fMax.Zd() || d.Az()<fMin.Az() || d.Az()>fMax.Az()) 773 ZdAz min = fBending(fMin/kRad2Deg)*kRad2Deg; 774 ZdAz max = fBending(fMax/kRad2Deg)*kRad2Deg; 775 776 if (d.Zd()<min.Zd() || d.Az()<min.Az()) 754 777 { 755 778 lout << "ERROR: Calculated position for T+dt not inside allowed range." << endl; 779 lout << "< " << d.Zd() << " " << min.Zd() << " " << d.Az() << " " << min.Az() << endl; 780 break; 781 } 782 if (d.Zd()>max.Zd() || d.Az()>max.Az()) 783 { 784 lout << "ERROR: Calculated position for T+dt not inside allowed range." << endl; 785 lout << "> " << d.Zd() << " " << max.Zd() << " " << d.Az() << " " << max.Az() << endl; 756 786 break; 757 787 } … … 777 807 // correct for the duration of RaDec2AltAz 778 808 // 779 const ZdAz v = dest*60.0/(dt -(fMac2->GetTime()-sla));809 const ZdAz v = dest*60.0/(dt/*-(fMac2->GetTime()-sla)*/); 780 810 781 811 // … … 830 860 // 831 861 usleep(50000); // 0.05s 862 //usleep(500000); // 0.5s 832 863 } 833 864 … … 876 907 bool MCosy::CheckNetwork() 877 908 { 909 return kTRUE; 878 910 //CheckConnections(); 911 879 912 if (HasZombie()) 880 913 { … … 1034 1067 else 1035 1068 { 1069 cout << "HOME NOT ALLOWED... for Magic." << endl; 1070 /* 1036 1071 cout << "Going Home..." << endl; 1037 1072 TEnv env(".cosyrc"); … … 1053 1088 fMac2->ReqPos(); 1054 1089 fMac3->StopMotor(); 1090 */ 1055 1091 } 1056 1092 cout << "WM_Home: done. (return 0x403e)" << endl; … … 1065 1101 1066 1102 XY xy = *((XY*)mp); 1067 RaDec rd(xy.X()*15., xy.Y()); 1103 RaDec rd(xy.X()*15., xy.Y()); // [deg] 1068 1104 1069 1105 ZdAz a0 = sla.CalcZdAz(rd*kDeg2Rad); … … 1109 1145 1110 1146 cout << "Reading telescope range..." << flush; 1111 const Double_t amin = env.GetValue("Az_Min ", -90.0);1112 const Double_t zmin = env.GetValue("Zd_Min ", -90.0);1147 const Double_t amin = env.GetValue("Az_Min[deg]", -74.5); 1148 const Double_t zmin = env.GetValue("Zd_Min[deg]", -90.0); 1113 1149 fMin.Set(zmin, amin); 1114 1150 1115 1151 cout << " Min: " << zmin << "deg " << amin << "deg" << endl; 1116 1152 1117 const Double_t amax = env.GetValue("Az_Max ", 318.0);1118 const Double_t zmax = env.GetValue("Zd_Max ", 100.0);1153 const Double_t amax = env.GetValue("Az_Max[deg]", 318.0); 1154 const Double_t zmax = env.GetValue("Zd_Max[deg]", 100.5); 1119 1155 fMax.Set(zmax, amax); 1120 1156 … … 1155 1191 resseaz = env.GetValue("Az_ResSE[se/U_mot]", 16384); 1156 1192 1157 kGearRatio.Set (gzd*resrezd /ressezd, gaz*resreaz/resseaz); //[re/se]1158 kGearRatio2.Set(gzd*resrezd /360.0, gaz*resreaz/360.0); //[re/deg]1193 kGearRatio.Set (gzd*resrezd*4/ressezd, gaz*resreaz*4/resseaz); //[re/se] 1194 kGearRatio2.Set(gzd*resrezd*4/360.0, gaz*resreaz*4/360.0); //[re/deg] 1159 1195 cout << "done." << endl; 1160 1196 … … 1183 1219 void MCosy::TalkThreadTracking() 1184 1220 { 1185 if (fZd1->IsZombieNode() || fZd2->IsZombieNode() || fAz->IsZombieNode())1221 if (fZd1->IsZombieNode() && fZd2->IsZombieNode()) 1186 1222 return; 1223 1224 if (fAz->IsZombieNode()) 1225 return; 1226 1187 1227 if (!fMac1 || !fMac2) 1188 1228 return; 1229 1230 lout << "Tracking Thread started..." << endl; 1189 1231 1190 1232 SlaStars sla(fObservatory); … … 1223 1265 { 1224 1266 phca1 = fZd1->PosHasChanged(); 1225 phca2 = fZd2->PosHasChanged();1267 // phca2 = fZd2->PosHasChanged(); 1226 1268 phcaz = fAz->PosHasChanged(); 1227 1269 usleep(1); … … 1250 1292 // FIXME: I cannot take the avarage 1251 1293 // 1294 // FIXME 1295 time.Zd(fZd1->GetMjd()); 1296 /* OLD* 1252 1297 if (fZd1->GetMjd()>fZd2->GetMjd()) 1253 1298 time.Zd(fZd1->GetMjd()); 1254 1299 else 1255 1300 time.Zd(fZd2->GetMjd()); 1301 */ 1256 1302 //time.Zd((fZd1->GetMjd()+fZd2->GetMjd())/2.0); 1257 1303 time.Az(fAz->GetMjd()); … … 1281 1327 } 1282 1328 1283 ZdAz soll(sollzd.Zd(), sollaz.Az()); 1329 ZdAz soll(sollzd.Zd(), sollaz.Az()); // [se] 1284 1330 fZdAzSoll = fBending.CorrectBack(soll*2*TMath::Pi()/16384); 1285 1331 … … 1603 1649 lout << "- Starting GUI." << endl; 1604 1650 fWin=new MGCosy(fObservatory, this, gClient->GetRoot(), 1, 1); 1651 } 1652 1653 bool MCosy::HasZombie() const 1654 { 1655 bool ses = fZd1->IsZombieNode() & fZd2->IsZombieNode(); 1656 1657 return fMac1->IsZombieNode() | fMac2->IsZombieNode() | fAz->IsZombieNode() | ses; 1605 1658 } 1606 1659 -
trunk/MagicSoft/Cosy/main/MCosy.h
r1758 r1760 161 161 bool CheckNetwork(); 162 162 163 virtual bool HasZombie() const; 164 163 165 public: 164 166 MCosy(int mode, const char *dev, const int baud, MLog &out=gLog);
Note:
See TracChangeset
for help on using the changeset viewer.