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"
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
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
00231 virtual bool do_rollover_subrun(uint64_t eventNum);
00232
00237 virtual void badTransition(const std::string& trans);
00238
00244 virtual void BootedEnter();
00245
00251 virtual void InRunExit();
00252
00261 virtual std::string do_trace_get(std::string const& name);
00262
00272 virtual bool do_trace_set(std::string const& type, std::string const& name, uint64_t mask);
00273
00282 virtual bool do_meta_command(std::string const& command, std::string const& args);
00283
00284 protected:
00289 std::string current_state() const;
00290
00291 CommandableContext fsm_;
00292 bool external_request_status_;
00293 std::string report_string_;
00294
00295 private:
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306 mutable std::mutex primary_mutex_;
00307 };
00308
00309 #endif