Changeset 13893
- Timestamp:
- 05/25/12 21:04:52 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/ratescan.cc
r13847 r13893 38 38 kStateConnecting, 39 39 kStateConnected, 40 kStateConfiguring, 40 41 kStateInProgress, 41 42 }; … … 103 104 return GetCurrentState(); 104 105 105 if ( fThreshold<0/* || fDimFTM.state()!=FTM::kTakingData*/)106 if (GetCurrentState()!=kStateInProgress) 106 107 return GetCurrentState(); 107 108 … … 192 193 { 193 194 Message("Rate scan stopped due to timeout."); 194 fThreshold=-1; 195 return GetCurrentState(); 195 return kStateConnected; 196 196 } 197 197 … … 199 199 { 200 200 Message("Rate scan finished."); 201 fThreshold = -1; 202 return GetCurrentState(); 201 return kStateConnected; 203 202 } 204 203 … … 245 244 246 245 UpdateProc(); 246 247 const string data = "\0\0\0\0\0\0\0\0ratescan"; 248 249 Dim::SendCommand("FAD_CONTROL/SET_FILE_FORMAT", uint16_t(0)); 250 Dim::SendCommand("FTM_CONTROL/CONFIGURE", data); 251 252 Message("Configuration for ratescan started."); 253 254 return kStateConfiguring; 255 } 256 257 int HandleFtmStateChange(/*const EventImp &evt*/) 258 { 259 if (GetCurrentState()!=kStateConfiguring) 260 return GetCurrentState(); 261 262 if (fDimFTM.state()!=FTM::kConfigured) 263 return GetCurrentState(); 264 265 const int32_t data[2] = { -1, fThresholdMin }; 266 267 Dim::SendCommand(fCommand, data); 268 269 fThreshold = fThresholdMin; 270 fCounter = -2; 247 271 248 272 const Time now; … … 262 286 fout << "# -----" << endl; 263 287 264 Dim::SendCommand("FAD_CONTROL/SET_FILE_FORMAT", uint16_t(0));265 266 const int32_t data[2] = { -1, fThresholdMin };267 268 //Message("Starting Trigger (FTM)");269 //Dim::SendCommand("FTM_CONTROL/SET_PRESCALING", int32_t(20));270 Dim::SendCommand(fCommand, data);271 //Dim::SendCommand("FTM_CONTROL/STOP_TRIGGER");272 273 fThreshold = fThresholdMin;274 fCounter = -2;275 276 288 ostringstream msg; 277 289 msg << "Rate scan " << now << "(" << fStartTime << ") from " << fThresholdMin << " to "; … … 280 292 Message(msg); 281 293 282 return GetCurrentState();294 return kStateInProgress; 283 295 } 284 296 285 297 int StopRateScan() 286 298 { 287 fThreshold = -1; 299 if (GetCurrentState()!=kStateConfiguring && GetCurrentState()!=kStateInProgress) 300 return GetCurrentState(); 301 288 302 Message("Rate scan manually stopped."); 289 303 290 //if (fDimFTM.state()==FTM::kTakingData) 291 { 292 //Message("Stopping FTM"); 293 //Dim::SendCommand("FTM_CONTROL/STOP_TRIGGER"); 294 } 295 296 return GetCurrentState(); 304 return kStateConnected; 297 305 } 298 306 … … 366 374 int Execute() 367 375 { 368 // Dispatch (execute) at most one handler from the queue. In contrary369 // to run_one(), it doesn't wait until a handler is available370 // which can be dispatched, so poll_one() might return with 0371 // handlers dispatched. The handlers are always dispatched/executed372 // synchronously, i.e. within the call to poll_one()373 //poll_one();374 375 376 if (!fDim.online()) 376 377 return kStateDimNetworkNA; … … 380 381 return kStateDisconnected; 381 382 382 // At least one subsystem is not connected 383 // if (fDimFTM.state()>=FTM::kConnected) 384 return fThreshold<0 ? kStateConnected : kStateInProgress; 383 return GetCurrentState(); 385 384 } 386 385 … … 412 411 fDim.Subscribe(*this); 413 412 fDimFTM.Subscribe(*this); 413 fDimFTM.SetCallback(bind(&StateMachineRateScan::HandleFtmStateChange, this)); 414 414 415 415 Subscribe("FTM_CONTROL/TRIGGER_RATES") … … 453 453 "|max[int]:Limiting value in DAC counts"); 454 454 455 AddEvent("STOP", kState InProgress)455 AddEvent("STOP", kStateConfiguring, kStateInProgress) 456 456 (bind(&StateMachineRateScan::StopRateScan, this)) 457 457 ("Stop a ratescan in progress");
Note:
See TracChangeset
for help on using the changeset viewer.