FACT++  1.0
StateMachineMCP::StateMachineMCP ( ostream &  out = cout)
inline

Definition at line 510 of file mcp.cc.

References HandleFadConnections(), HandleFtmStaticData(), HandleStateChange(), MCP::State::kConfigured, MCP::State::kConfiguring1, MCP::State::kConfiguring2, MCP::State::kConfiguring3, MCP::State::kConnected, MCP::State::kConnecting, MCP::State::kDimNetworkNA, MCP::State::kDisconnected, MCP::State::kIdle, MCP::State::kTakingData, MCP::State::kTriggerOn, Print(), Reset(), DimState::SetCallback(), StartRun(), StopRun(), DimState::Subscribe(), and DimDescribedState::Subscribe().

510  : StateMachineDim(out, "MCP"),
512  fDimFTM("FTM_CONTROL"),
513  fDimFAD("FAD_CONTROL"),
514  fDimLog("DATA_LOGGER"),
515  fDimRC("RATE_CONTROL"),
516  fService("MCP/CONFIGURATION", "X:1;X:1;C", "Run configuration information"
517  "|MaxTime[s]:Maximum time before the run gets stopped"
518  "|MaxEvents[num]:Maximum number of events before the run gets stopped"
519  "|Name[text]:Name of the chosen configuration")
520  {
521  // ba::io_service::work is a kind of keep_alive for the loop.
522  // It prevents the io_service to go to stopped state, which
523  // would prevent any consecutive calls to run()
524  // or poll() to do nothing. reset() could also revoke to the
525  // previous state but this might introduce some overhead of
526  // deletion and creation of threads and more.
527 
528  fDim.Subscribe(*this);
529  fDimFTM.Subscribe(*this);
530  fDimFAD.Subscribe(*this);
531  fDimLog.Subscribe(*this);
532  fDimRC.Subscribe(*this);
533 
539 
540  Subscribe("FAD_CONTROL/CONNECTIONS")
541  (bind(&StateMachineMCP::HandleFadConnections, this, placeholders::_1));
542  Subscribe("FTM_CONTROL/STATIC_DATA")
543  (bind(&StateMachineMCP::HandleFtmStaticData, this, placeholders::_1));
544 
545  // State names
546  AddStateName(MCP::State::kDimNetworkNA, "DimNetworkNotAvailable",
547  "DIM dns server not available.");
548  AddStateName(MCP::State::kDisconnected, "Disconnected",
549  "Neither ftmctrl, fadctrl, datalogger nor rate control online.");
551  "Either ftmctrl, fadctrl, datalogger or rate control not online.");
553  "All needed subsystems online.");
555  "Waiting for next configuration command");
556  AddStateName(MCP::State::kConfiguring1, "Configuring1",
557  "Starting configuration procedure, checking datalogger/ratecontrol state");
558  AddStateName(MCP::State::kConfiguring2, "Configuring2",
559  "Starting ratecontrol, waiting for FTM to get configured and Datalogger to get ready");
560  AddStateName(MCP::State::kConfiguring3, "Configuring3",
561  "Waiting for FADs and ratecontrol to get ready");
562  /*
563  AddStateName(MCP::State::kCrateReset0, "CrateReset0",
564  "Disabling FTUs, disconnecting FADs");
565  AddStateName(MCP::State::kCrateReset1, "CrateReset1",
566  "Waiting for FTUs to be disabled and for FADs to be disconnected");
567  AddStateName(MCP::State::kCrateReset2, "CrateReset2",
568  "Waiting 45s");
569  AddStateName(MCP::State::kCrateReset3, "CrateReset3",
570  "Waiting for FTUs to be enabled and for FADs to be re-connected");
571  */
573  "Everything is configured, trigger will be switched on now");
575  "The trigger is switched on, waiting for FAD to receive data");
577  "The trigger is switched on, FADs are sending data");
578 
579 
580  AddEvent("START", "X:2;C")//, MCP::State::kIdle)
581  (bind(&StateMachineMCP::StartRun, this, placeholders::_1))
582  ("Start the configuration and data taking for a run-type of a pre-defined setup"
583  "|TimeMax[s]:Maximum number of seconds before the run will be closed automatically"
584  "|NumMax[count]:Maximum number events before the run will be closed automatically"
585  "|Name[text]:Name of the configuration to be used for taking data");
586 
587  AddEvent("STOP")
588  (bind(&StateMachineMCP::StopRun, this))
589  ("Stops the trigger (either disables the FTM trigger or the internal DRS trigger)");
590 
591  AddEvent("RESET")
592  (bind(&StateMachineMCP::Reset, this))
593  ("If a configuration blockes because a system cannot configure itself properly, "
594  "this command can be called to leave the configuration procedure. The command "
595  "is also propagated to FTM and FAD");
596 
597  AddEvent("PRINT")
598  (bind(&StateMachineMCP::Print, this))
599  ("Print the states and connection status of all systems connected to the MCP.");
600  }
EventImp & AddEvent(const std::string &name, const std::string &states, const std::string &fmt)
virtual void Subscribe(StateMachineImp &imp)
Definition: DimState.h:134
int HandleFadConnections(const EventImp &d)
Definition: mcp.cc:55
vector< bool > fFadNeedsReset
Definition: mcp.cc:35
int StartRun(const EventImp &evt)
Definition: mcp.cc:184
DimDescribedState fDimFTM
Definition: mcp.cc:46
StateMachineDim(std::ostream &out=std::cout, const std::string &name="DEFAULT")
int Print() const
Definition: mcp.cc:108
DimVersion fDim
Definition: mcp.cc:45
DimDescribedService fService
Definition: mcp.cc:51
DimDescribedState fDimFAD
Definition: mcp.cc:47
virtual void Subscribe(StateMachineImp &imp)
Definition: DimState.h:68
EventImp & Subscribe(const std::string &name)
DimDescribedState fDimLog
Definition: mcp.cc:48
uint16_t fNumConnectedFtu
Definition: mcp.cc:40
int HandleStateChange()
Definition: mcp.cc:289
int StopRun()
Definition: mcp.cc:124
bool AddStateName(const int state, const std::string &name, const std::string &doc="")
int Reset()
Definition: mcp.cc:145
void SetCallback(const callback &cb)
Definition: DimState.h:74
int HandleFtmStaticData(const EventImp &d)
Definition: mcp.cc:92
DimDescribedState fDimRC
Definition: mcp.cc:49

+ Here is the call graph for this function: