00001 #ifndef artdaq_ExternalComms_CommanderInterface_hh
00002 #define artdaq_ExternalComms_CommanderInterface_hh
00003
00004 #include "artdaq/DAQdata/Globals.hh"
00005 #include "fhiclcpp/ParameterSet.h"
00006 #include "artdaq/Application/Commandable.hh"
00007 #include "cetlib/compiler_macros.h"
00008
00009
00010 namespace artdaq
00011 {
00015 class CommanderInterface
00016 {
00017 public:
00021 struct Config
00022 {
00024 fhicl::Atom<int> id{ fhicl::Name{"id"}, fhicl::Comment{"The unique ID associated with this Commander plugin. (ex. XMLRPC Port number)"}, 0 };
00026 fhicl::Atom<std::string> commanderPluginType{ fhicl::Name{"commanderPluginType"}, fhicl::Comment{"String identifying the name of the CommanderInterface plugin to load"} };
00027 };
00028 using Parameters = fhicl::WrappedTable<Config>;
00029
00035 CommanderInterface(const fhicl::ParameterSet& ps, artdaq::Commandable& commandable)
00036 : _commandable(commandable)
00037 , _id(ps.get<int>("id", 0))
00038 {}
00039
00043 CommanderInterface(const CommanderInterface&) = delete;
00044
00049 CommanderInterface& operator=(const CommanderInterface&) = delete;
00050
00054 virtual ~CommanderInterface();
00055
00084 virtual void run_server() = 0;
00085
00093 virtual std::string send_init(fhicl::ParameterSet, uint64_t, uint64_t);
00094
00102 virtual std::string send_soft_init(fhicl::ParameterSet, uint64_t, uint64_t);
00103
00111 virtual std::string send_reinit(fhicl::ParameterSet, uint64_t, uint64_t);
00112
00120 virtual std::string send_start(art::RunID, uint64_t, uint64_t);
00121
00129 virtual std::string send_pause(uint64_t, uint64_t);
00130
00138 virtual std::string send_resume(uint64_t, uint64_t);
00139
00147 virtual std::string send_stop(uint64_t, uint64_t);
00148
00156 virtual std::string send_shutdown(uint64_t);
00157
00164 virtual std::string send_status();
00165
00172 virtual std::string send_report(std::string);
00173
00180 virtual std::string send_legal_commands();
00181
00188 virtual std::string send_register_monitor(std::string);
00189
00196 virtual std::string send_unregister_monitor(std::string);
00197
00205 virtual std::string send_trace_get(std::string);
00206
00217 virtual std::string send_trace_set(std::string, std::string, uint64_t);
00218
00225 virtual std::string send_meta_command(std::string, std::string);
00226
00234 virtual std::string send_rollover_subrun(uint64_t);
00235
00240 bool GetStatus() { return running_.load(); }
00241
00253 virtual std::string add_config_archive_entry(std::string, std::string);
00254
00263 virtual std::string clear_config_archive();
00264
00265 private:
00266
00267 public:
00271 artdaq::Commandable& _commandable;
00272
00273 protected:
00274 int _id;
00275 std::atomic<bool> running_;
00276 };
00277 }
00278
00279 #ifndef EXTERN_C_FUNC_DECLARE_START
00280 #define EXTERN_C_FUNC_DECLARE_START extern "C" {
00281 #endif
00282
00283 #define DEFINE_ARTDAQ_COMMANDER(klass) \
00284 EXTERN_C_FUNC_DECLARE_START \
00285 std::unique_ptr<artdaq::CommanderInterface> make(fhicl::ParameterSet const & ps, \
00286 artdaq::Commandable& commandable) { \
00287 return std::unique_ptr<artdaq::CommanderInterface>(new klass(ps, commandable)); \
00288 }}
00289
00290
00291 #endif
00292
00293
00294
00295