Changeset 14495
- Timestamp:
- 10/19/12 13:38:50 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/drivectrl.cc
r14368 r14495 346 346 // Status 4: Tracking 347 347 if (status1==0) 348 status1 = 0x100-Drive::State::kNotReady;348 status1 = StateMachineImp::kSM_Error - Drive::State::kNotReady; 349 349 350 350 const bool ready = (pdo3&0xef00ef)==0xef00ef; … … 673 673 sources fSources; 674 674 675 string fLastCommand; // Last tracking (RADEC) command 676 int fAutoResume; // 0: disabled, 1: enables, 2: resuming 677 675 678 // Status 0: Error 676 679 // Status 1: Unlocked … … 720 723 int SendCommand(const string &str, bool upd=true) 721 724 { 725 // This happens if fLastCommand should be send, 726 // but the last command was not a tracking command 727 if (str.empty()) 728 { 729 T::Info("Last command was not a tracking command. RESUME ignored."); 730 return T::GetCurrentState(); 731 } 732 733 fLastCommand = str.compare(0, 6, "RADEC ")==0 ? str : ""; 734 722 735 fDrive.PostMessage(str); 723 736 T::Message("Sending: "+str); … … 727 740 728 741 return T::GetCurrentState(); 742 } 743 744 int Resume() 745 { 746 if (fLastCommand.empty()) 747 { 748 T::Info("Last command was not a tracking command. RESUME ignored."); 749 return T::GetCurrentState(); 750 } 751 752 return SendCommand(fLastCommand, false); 729 753 } 730 754 … … 923 947 } 924 948 949 int SetAutoResume(const EventImp &evt) 950 { 951 if (!CheckEventSize(evt.GetSize(), "SetAutoResume", 1)) 952 return T::kSM_FatalError; 953 954 fAutoResume = evt.GetBool(); 955 956 return T::GetCurrentState(); 957 } 958 925 959 int Unlock() 926 960 { … … 1054 1088 } 1055 1089 1056 return fDrive.GetState(); 1090 const int state = fDrive.GetState(); 1091 1092 if (!fLastCommand.empty()) 1093 { 1094 // If auto resume is enabled and the drive is in error, 1095 // resume tracking 1096 if (fAutoResume==1 && state==StateMachineImp::kSM_Error) 1097 { 1098 Resume(); 1099 fAutoResume = 2; 1100 } 1101 1102 // If drive got out of the error state, 1103 // enable auto resume again 1104 if (fAutoResume==2 && state!=StateMachineImp::kSM_Error) 1105 fAutoResume = 1; 1106 } 1107 1108 return state; 1057 1109 } 1058 1110 … … 1145 1197 "|id:Wobble angle id (1 or 2)" 1146 1198 "|Name[string]:Source name"); 1199 1200 T::AddEvent("RESUME", StateMachineImp::kSM_Error) 1201 (bind(&StateMachineDrive::Resume, this)) 1202 ("If drive is in Error state, this can b used to resume the last tracking command, if the last command sent to cosy was a tracking command."); 1147 1203 1148 1204 T::AddEvent("MOON", State::kArmed, State::kTracking) … … 1192 1248 ("Stop any kind of movement."); 1193 1249 1250 T::AddEvent("SET_AUTORESUME", "B") 1251 (bind(&StateMachineDrive::SetAutoResume, this, placeholders::_1)) 1252 ("Enable/disable auto resume" 1253 "|resume[bool]:if enabled, drive is tracking and goes to error state, the last tracking command is repeated automatically."); 1194 1254 1195 1255 // Verbosity commands 1196 1256 T::AddEvent("SET_VERBOSE", "B") 1197 1257 (bind(&StateMachineDrive::SetVerbosity, this, placeholders::_1)) 1198 (" set verbosity state"1258 ("Set verbosity state" 1199 1259 "|verbosity[bool]:disable or enable verbosity for received data (yes/no), except dynamic data"); 1200 1260 … … 1304 1364 } 1305 1365 } 1366 1367 fAutoResume = conf.Get<bool>("auto-resume"); 1306 1368 1307 1369 if (conf.Has("source-database")) … … 1346 1408 ("source-database", var<string>(), "Database link as in\n\tuser:password@server[:port]/database.") 1347 1409 ("source", vars<string>(), "Additional source entry in the form \"name,hh:mm:ss,dd:mm:ss\"") 1410 ("auto-resume", po_bool(false), "Enable auto result during tracking") 1348 1411 ; 1349 1412
Note:
See TracChangeset
for help on using the changeset viewer.