Changeset 1702 for trunk/MagicSoft/Cosy/main/MCosy.cc
- Timestamp:
- 01/13/03 18:18:15 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/main/MCosy.cc
r1701 r1702 150 150 // Get the values 151 151 // 152 const int p0 = fZd1? fZd1->GetPos() : 0;153 const int p1 = fZd2? fZd2->GetPos() : 0;154 const int p2 = fAz? fAz->GetPos() : 0;152 const int p0 = !fZd1->IsZombieNode() ? fZd1->GetPos() : 0; 153 const int p1 = !fZd2->IsZombieNode() ? fZd2->GetPos() : 0; 154 const int p2 = !fAz->IsZombieNode() ? fAz->GetPos() : 0; 155 155 156 156 const int a0 = p0; //p0>8192?p0-16384:p0; … … 177 177 Bool_t MCosy::RequestRePos() 178 178 { 179 if ( !(fMac1 && fMac2))179 if (fMac1->IsZombieNode() || fMac2->IsZombieNode()) 180 180 return kTRUE; 181 181 … … 192 192 193 193 // 194 // If wait ng was not interrupted everything is ok. return.194 // If waiting was not interrupted everything is ok. return. 195 195 // 196 196 if (!StopWaitingForSDO()) … … 216 216 ZdAz MCosy::GetRePos() 217 217 { 218 return fMac1 && fMac2? ZdAz(fMac2->GetPos(), fMac1->GetPos()) : ZdAz(0,0);218 return !fMac1->IsZombieNode() && !fMac2->IsZombieNode() ? ZdAz(fMac2->GetPos(), fMac1->GetPos()) : ZdAz(0,0); 219 219 } 220 220 … … 304 304 int MCosy::StopWaitingForSDO() const 305 305 { 306 return Break() || HasError() ;306 return Break() || HasError() || HasZombie(); 307 307 } 308 308 … … 346 346 347 347 // 348 // No try to handle the error.348 // Now try to handle the error. 349 349 // 350 350 fMac1->HandleError(); … … 378 378 // FIXME: Correct by fOffset ? 379 379 380 if ( !(fMac1 && fMac2))380 if (fMac1->IsZombieNode() || fMac2->IsZombieNode()) 381 381 { 382 cout << "SetPosition: No MACS!" << endl;382 cout << "SetPosition: No connection to at least one of the MACS!" << endl; 383 383 return TRUE; 384 384 } … … 515 515 void MCosy::InitTracking() 516 516 { 517 if ( !(fMac1 && fMac2))517 if (fMac1->IsZombieNode() || fMac2->IsZombieNode()) 518 518 return; 519 519 … … 656 656 fRaDec = dst; 657 657 658 if ( !(fMac1 && fMac2))658 if (fMac1->IsZombieNode() || fMac2->IsZombieNode()) 659 659 return; 660 660 … … 774 774 void MCosy::StopMovement() 775 775 { 776 if ( !fMac1 || !fMac2)776 if (fMac1->IsZombieNode() || fMac2->IsZombieNode()) 777 777 return; 778 778 779 // 779 780 // Set status to Stopping … … 810 811 void *MCosy::Proc(int msg, void *mp) 811 812 { 813 lout << "Checking for Zombies" << endl; 814 if (HasZombie()) 815 { 816 lout << "Found Zombies" << endl; 817 if (!RebootZombies()) 818 return (void*)0xebb0; 819 } 820 812 821 switch (msg) 813 822 { … … 823 832 case WM_PRESET: 824 833 cout << "WM_Preset: start." << endl; 825 if ( fZd1) fZd1->SetPreset();826 if ( fZd2) fZd2->SetPreset();827 if ( fAz) fAz->SetPreset();834 if (!fZd1->IsZombieNode()) fZd1->SetPreset(); 835 if (!fZd2->IsZombieNode()) fZd2->SetPreset(); 836 if (!fAz->IsZombieNode()) fAz->SetPreset(); 828 837 cout << "WM_Preset: done. (return 0xaffe)" << endl; 829 838 return (void*)0xaffe; … … 849 858 cout << "Got Zd: " << sepos.Zd() << " Az: " << sepos.Az() << endl; 850 859 851 if ( fZd1)860 if (!fZd1->IsZombieNode()) 852 861 fZd1->SetPreset(za.Zd()); 853 if (fZd2)862 if (!fZd2->IsZombieNode()) 854 863 fZd2->SetPreset(-za.Zd()); 855 if (fAz)864 if (!fAz->IsZombieNode()) 856 865 fAz->SetPreset(za.Az()); 857 866 … … 924 933 case WM_HOME: 925 934 cout << "WM_Home: START" << endl; 926 if ( fMac1 && fMac2)935 if (!fMac1->IsZombieNode() && !fMac2->IsZombieNode()) 927 936 { 928 937 cout << "Going Home..." << endl; 929 fMac1->SetHome(250000, 100); 930 fMac2->SetHome(250000, 100); 938 TEnv env(".cosyrc"); 939 fMac1->SetHome(250000, env.GetValue("Az_MaxTime2ReachHome[s]", 100)); 940 fMac2->SetHome(250000, env.GetValue("Zd_MaxTime2ReachHome[s]", 100)); 931 941 932 942 fAz->SetPreset(); … … 991 1001 992 1002 Double_t resreaz = 0; 993 if ( fMac1)1003 if (!fMac1->IsZombieNode()) 994 1004 resreaz = fMac1->GetRes(); 995 1005 else 996 if ( fMac3)1006 if (!fMac3->IsZombieNode()) 997 1007 resreaz = fMac3->GetRes(); 998 1008 else … … 1000 1010 1001 1011 Double_t resrezd = 0; 1002 if ( fMac2)1012 if (!fMac2->IsZombieNode()) 1003 1013 resrezd = fMac2->GetRes(); 1004 1014 else … … 1006 1016 1007 1017 Double_t ressezd = 0; 1008 if ( fZd1)1018 if (!fZd1->IsZombieNode()) 1009 1019 ressezd = fZd1->GetPhysRes(); 1010 1020 else 1011 if ( fZd2)1021 if (!fZd2->IsZombieNode()) 1012 1022 ressezd = fZd2->GetPhysRes(); 1013 1023 else … … 1015 1025 1016 1026 Double_t resseaz = 0; 1017 if ( fAz)1027 if (!fAz->IsZombieNode()) 1018 1028 resseaz = fAz->GetPhysRes(); 1019 1029 else … … 1024 1034 cout << "done." << endl; 1025 1035 1026 cout << " Setting Gear Ratios:" << endl;1027 cout << " --------------------" << endl;1028 cout << " X: " << gzd << "*" << resrezd << "/" << ressezd << "=" << kGearRatio.X() << endl;1029 cout << " Y: " << gaz << "*" << resreaz << "/" << resseaz << "=" << kGearRatio.Y() << endl;1036 cout << " * Setting Gear Ratios:" << endl; 1037 cout << " --------------------" << endl; 1038 cout << " * X: " << gzd << "*" << resrezd << "/" << ressezd << "=" << kGearRatio.X() << endl; 1039 cout << " * Y: " << gaz << "*" << resreaz << "/" << resseaz << "=" << kGearRatio.Y() << endl; 1030 1040 } 1031 1041 1032 1042 void MCosy::TalkThread() 1033 1043 { 1034 if ( !(fMac1 && fMac2))1044 if (fMac1->IsZombieNode() || fMac2->IsZombieNode()) 1035 1045 return; 1036 1046 … … 1048 1058 } 1049 1059 1050 //fMac1->EnableTimeout(kTRUE, 500); 1051 //fMac2->EnableTimeout(kTRUE, 500); 1052 1053 if (!(fZd1 && fZd2 && fAz)) 1060 if (fZd1->IsZombieNode() || fZd2->IsZombieNode() || fAz->IsZombieNode()) 1054 1061 return; 1055 1062 … … 1058 1065 // Start the Network 1059 1066 // 1060 cout << "Reading configuration file..." << flush;1061 TEnv env(".cosyrc");1062 cout << "done." << endl;1067 //cout << "Reading configuration file..." << flush; 1068 //TEnv env(".cosyrc"); 1069 //cout << "done." << endl; 1063 1070 /* 1064 1071 const int res = fMac3->GetVelRes(); … … 1067 1074 fMac3->SetAcceleration(res); 1068 1075 fMac3->SetDeceleration(res); 1069 1070 cout << "Going Home..." << endl;1071 fMac1->SetHome(250000, env.GetValue("Az_MaxTime2ReachHome[s]", 100));1072 fMac2->SetHome(250000, env.GetValue("Zd_MaxTime2ReachHome[s]", 100));1073 PostMsg(WM_PRESET, 0, 0);1074 PostMsg(WM_WAIT, 0, 0);1075 1076 1076 1077 fMac1->ReqPos(); … … 1098 1099 fMac2->EnableTimeout(kTRUE, 500); 1099 1100 1100 const Double_t gaz = env.GetValue("Az_GearRatio[U_mot/U_tel]");1101 const Double_t gzd = env.GetValue("Zd_GearRatio[U_mot/U_tel]");1102 1103 const Double_t resreaz = env.GetValue("Az_ResRE[re/U_mot]");1104 const Double_t resrezd = env.GetValue("Zd_ResRE[re/U_mot]");1105 1106 kGearRatio.Set (gzd*resrezd/RES_SE, gaz*resreaz/RES_SE); //[re/se]1107 kGearRatio2.Set(gzd*resrezd/360.0, gaz*resreaz/360.0); //[re/deg]1108 1109 1101 //fMac2->SetNegEndswitch(Deg2ZdRE(env.GetValue("MinZd[Deg]", -1.0))); 1110 1102 //fMac2->SetPosEndswitch(Deg2ZdRE(env.GetValue("MaxZd[Deg]", +1.0))); 1111 1103 // fMac3->StartVelSync(); 1112 1113 //cout << "PostMsg(WM_PRESET)" << endl;1114 //void *rc =1115 //cout << hex << "WM_PRESET: ret=" << rc << endl;1116 1117 //RaDec dest = RaDec(45.0, 30.0)*D2PI/360.0;1118 1119 //cout << "PostMsg(WM_TRACK)" << endl;1120 //cout << sizeof(RaDec) << "==" << sizeof(dest) << endl;1121 //rc=PostMsg(WM_TRACK, &dest, sizeof(dest));1122 //cout << "DEST killed." << endl;1123 1124 // AltAz dest = AltAz(45.0, 30.0);1125 // double ra, dec;1126 // slaDaf2r( 71, 0, 0, &ra, &status); // 0 WARNING: RANGE1127 // slaDaf2r( 89, 0, 0, &dec, &status); // 491128 // cout << "Start tracking: Ra: " << Rad2Deg(ra) << kDEG << " Dec: " << Rad2Deg(dec) << kDEG << endl;1129 1130 // dest = AltAz(-46.0, 210);1131 // SetPosition(dest);1132 1104 */ 1133 1105 SlaStars sla; … … 1255 1227 // Update Gui, foremer MTGui. 1256 1228 // 1257 if ( fZd1) fZd1->DisplayVal();1258 if ( fZd2) fZd2->DisplayVal();1259 if ( fAz) fAz->DisplayVal();1229 if (!fZd1->IsZombieNode()) fZd1->DisplayVal(); 1230 if (!fZd2->IsZombieNode()) fZd2->DisplayVal(); 1231 if (!fAz->IsZombieNode()) fAz->DisplayVal(); 1260 1232 1261 1233 ZdAz seist = GetSePos()*2*TMath::Pi()/16384; // [se] 1262 1234 ZdAz bendist = fBending.CorrectBack(seist); 1263 1235 1236 Byte_t avail = 0; 1237 1238 avail |= !fMac1->IsZombieNode() ? 0x01 : 0; 1239 avail |= !fMac2->IsZombieNode() ? 0x02 : 0; 1240 avail |= !fMac3->IsZombieNode() ? 0x04 : 0; 1241 avail |= !fZd1->IsZombieNode() ? 0x08 : 0; 1242 avail |= !fZd2->IsZombieNode() ? 0x10 : 0; 1243 avail |= !fAz->IsZombieNode() ? 0x20 : 0; 1244 1264 1245 fWin->Update(bendist*(360.0/2/TMath::Pi()), fTrackingError/kGearRatio2, 1265 fVelocity, fOffset/*/kGearRatio2*/, fRaDec, fZdAzSoll, 1266 fStatus); 1246 fVelocity, fOffset, fRaDec, fZdAzSoll, fStatus, avail); 1247 1248 /* 1249 cout << (int)(fMac1->GetStatus()&Macs::kOutOfControl) << " "; 1250 cout << (int)(fMac2->GetStatus()&Macs::kOutOfControl) << " "; 1251 cout << (int)(fMac3->GetStatus()&Macs::kOutOfControl) << endl; 1252 */ 1267 1253 1268 1254 return kTRUE; … … 1282 1268 // Don't call this function twice! 1283 1269 Network::Start(); 1284 1270 /* 1285 1271 if (fMac1) 1286 1272 if (fMac1->IsZombieNode()) { delete fMac1; fMac1=NULL; } … … 1289 1275 if (fMac3) 1290 1276 if (fMac3->IsZombieNode()) { delete fMac3; fMac3=NULL; } 1291 1292 if (fZd1)1277 */ 1278 /* if (fZd1) 1293 1279 if (fZd1->IsZombieNode()) { delete fZd1; fZd1=NULL; } 1294 else fZd1->SetDisplay(fWin->GetLabel2());1295 1296 if (fZd2)1280 else */fZd1->SetDisplay(fWin->GetLabel2()); 1281 1282 /* if (fZd2) 1297 1283 if (fZd2->IsZombieNode()) { delete fZd2; fZd2=NULL; } 1298 else fZd2->SetDisplay(fWin->GetLabel3());1299 1300 if (fAz)1284 else */fZd2->SetDisplay(fWin->GetLabel3()); 1285 1286 /* if (fAz) 1301 1287 if (fAz->IsZombieNode()) { delete fAz; fAz=NULL; } 1302 else fAz->SetDisplay(fWin->GetLabel1());1288 else */fAz->SetDisplay(fWin->GetLabel1()); 1303 1289 1304 1290 ReadConfig(); … … 1345 1331 lout << "- Setting up network." << endl; 1346 1332 1347 fMac1=new Macs(id1, "Mac/Az", 1348 fMac2=new Macs(id3, "Mac/Zd", 1333 fMac1=new Macs(id1, "Mac/Az", lout); 1334 fMac2=new Macs(id3, "Mac/Zd", lout); 1349 1335 if (id2>=0) 1350 1336 fMac3=new Macs(id2, "Mac/Az-Sync", lout);
Note:
See TracChangeset
for help on using the changeset viewer.