Changeset 1760 for trunk/MagicSoft/Cosy/main
- Timestamp:
- 02/16/03 17:02:06 (22 years ago)
- Location:
- trunk/MagicSoft/Cosy/main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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.