$treeview $search $mathjax $extrastylesheet
artdaq
v3_04_01
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #ifndef artdaq_Application_Commandable_hh 00002 #define artdaq_Application_Commandable_hh 00003 00004 #include <string> 00005 #include <vector> 00006 #include <mutex> 00007 00008 #include "fhiclcpp/ParameterSet.h" 00009 #include "canvas/Persistency/Provenance/RunID.h" 00010 #include "artdaq/Application/Commandable_sm.h" // must be included after others 00011 00012 namespace artdaq 00013 { 00014 class Commandable; 00015 } 00016 00020 class artdaq::Commandable 00021 { 00022 public: 00026 Commandable(); 00027 00031 Commandable(Commandable const&) = delete; 00032 00036 virtual ~Commandable() = default; 00037 00042 Commandable& operator=(Commandable const&) = delete; 00043 00051 bool initialize(fhicl::ParameterSet const& pset, uint64_t timeout, uint64_t timestamp); 00052 00060 bool start(art::RunID id, uint64_t timeout, uint64_t timestamp); 00061 00068 bool stop(uint64_t timeout, uint64_t timestamp); 00069 00076 bool pause(uint64_t timeout, uint64_t timestamp); 00077 00084 bool resume(uint64_t timeout, uint64_t timestamp); 00085 00091 bool shutdown(uint64_t timeout); 00092 00100 bool soft_initialize(fhicl::ParameterSet const& pset, uint64_t timeout, uint64_t timestamp); 00101 00109 bool reinitialize(fhicl::ParameterSet const& pset, uint64_t timeout, uint64_t timestamp); 00110 00115 bool in_run_failure(); 00116 00121 virtual std::string report(std::string const&) const 00122 { 00123 std::lock_guard<std::mutex> lk(primary_mutex_); 00124 return report_string_; 00125 } 00126 00131 std::string status() const; 00132 00139 virtual std::string register_monitor(fhicl::ParameterSet const&) 00140 { 00141 return "This string is returned from Commandable::register_monitor; register_monitor should either be overridden in a derived class or this process should not have been sent the register_monitor call"; 00142 } 00143 00150 virtual std::string unregister_monitor(std::string const&) 00151 { 00152 return "This string is returned from Commandable::unregister_monitor; unregister_monitor should either be overridden in a derived class or this process should not have been sent the unregister_monitor call"; 00153 } 00154 00159 std::vector<std::string> legal_commands() const; 00160 00161 // these methods provide the operations that are used by the state machine 00168 virtual bool do_initialize(fhicl::ParameterSet const&, uint64_t, uint64_t); 00169 00176 virtual bool do_start(art::RunID, uint64_t, uint64_t); 00177 00184 virtual bool do_stop(uint64_t, uint64_t); 00185 00192 virtual bool do_pause(uint64_t, uint64_t); 00193 00200 virtual bool do_resume(uint64_t, uint64_t); 00201 00208 virtual bool do_shutdown(uint64_t); 00209 00216 virtual bool do_reinitialize(fhicl::ParameterSet const&, uint64_t, uint64_t); 00217 00224 virtual bool do_soft_initialize(fhicl::ParameterSet const&, uint64_t, uint64_t); 00225 00232 virtual bool do_rollover_subrun(uint64_t eventNum, uint32_t subrunNum); 00233 00238 virtual void badTransition(const std::string& trans); 00239 00245 virtual void BootedEnter(); 00246 00252 virtual void InRunExit(); 00253 00262 virtual std::string do_trace_get(std::string const& name); 00263 00273 virtual bool do_trace_set(std::string const& type, std::string const& name, uint64_t mask); 00274 00283 virtual bool do_meta_command(std::string const& command, std::string const& args); 00284 00291 virtual bool do_add_config_archive_entry(std::string const&, std::string const&); 00292 00299 virtual bool do_clear_config_archive(); 00300 00301 protected: 00306 std::string current_state() const; 00307 00308 CommandableContext fsm_; 00309 bool external_request_status_; 00310 std::string report_string_; 00311 00312 private: 00313 // 06-May-2015, KAB: added a mutex to be used in avoiding problems when 00314 // requests are sent to a Commandable object from different threads. The 00315 // reason that we're doing this now is that we've added the in_run_failure() 00316 // transition that will generally be called from inside the Application. 00317 // Prior to this, the only way that transitions were requested was via 00318 // external XMLRPC commands, and those were presumed to be called one 00319 // at a time. The use of scoped locks based on the mutex will prevent 00320 // the in_run_failure() transition from being called at the same time as 00321 // an externally requested transition. We only lock the methods that 00322 // are externally called. 00323 mutable std::mutex primary_mutex_; 00324 }; 00325 00326 #endif /* artdaq_Application_Commandable_hh */