artdaq  v3_07_02
CommanderInterface.hh
1 #ifndef artdaq_ExternalComms_CommanderInterface_hh
2 #define artdaq_ExternalComms_CommanderInterface_hh
3 
4 #include "artdaq/Application/Commandable.hh"
5 #include "artdaq/DAQdata/Globals.hh"
6 #include "cetlib/compiler_macros.h"
7 #include "fhiclcpp/ParameterSet.h"
8 
9 namespace artdaq {
14 {
15 public:
19  struct Config
20  {
22  fhicl::Atom<int> id{fhicl::Name{"id"}, fhicl::Comment{"The unique ID associated with this Commander plugin. (ex. XMLRPC Port number)"}, 0};
24  fhicl::Atom<std::string> commanderPluginType{fhicl::Name{"commanderPluginType"}, fhicl::Comment{"String identifying the name of the CommanderInterface plugin to load"}};
25  };
27  using Parameters = fhicl::WrappedTable<Config>;
28 
34  CommanderInterface(const fhicl::ParameterSet& ps, artdaq::Commandable& commandable)
35  : _commandable(commandable)
36  , _id(ps.get<int>("id", 0))
37  {}
38 
42  CommanderInterface(const CommanderInterface&) = delete;
43 
49 
53  virtual ~CommanderInterface();
54 
83  virtual void run_server() = 0;
84 
92  virtual std::string send_init(fhicl::ParameterSet ps, uint64_t timeout, uint64_t timestamp);
93 
101  virtual std::string send_soft_init(fhicl::ParameterSet ps, uint64_t timeout, uint64_t timestamp);
102 
110  virtual std::string send_reinit(fhicl::ParameterSet ps, uint64_t timeout, uint64_t timestamp);
111 
119  virtual std::string send_start(art::RunID runNumber, uint64_t timeout, uint64_t timestamp);
120 
128  virtual std::string send_pause(uint64_t timeout, uint64_t timestamp);
129 
137  virtual std::string send_resume(uint64_t timeout, uint64_t timestamp);
138 
146  virtual std::string send_stop(uint64_t timeout, uint64_t timestamp);
147 
155  virtual std::string send_shutdown(uint64_t timeout);
156 
163  virtual std::string send_status();
164 
171  virtual std::string send_report(std::string which);
172 
179  virtual std::string send_legal_commands();
180 
187  virtual std::string send_register_monitor(std::string monitor_fhicl);
188 
195  virtual std::string send_unregister_monitor(std::string label);
196 
204  virtual std::string send_trace_get(std::string name);
205 
217  virtual std::string send_trace_set(std::string name, std::string type, std::string mask);
218 
225  virtual std::string send_meta_command(std::string command, std::string argument);
226 
234  virtual std::string send_rollover_subrun(uint64_t seq, uint32_t subrunNumber);
235 
240  bool GetStatus() { return running_.load(); }
241 
253  virtual std::string add_config_archive_entry(std::string key, std::string value);
254 
263  virtual std::string clear_config_archive();
264 
265 private:
266 public:
271 
272 protected:
273  int _id;
274  std::atomic<bool> running_;
275 };
276 } // namespace artdaq
277 
278 #ifndef EXTERN_C_FUNC_DECLARE_START
279 #define EXTERN_C_FUNC_DECLARE_START extern "C" {
280 #endif
281 
282 #define DEFINE_ARTDAQ_COMMANDER(klass) \
283  EXTERN_C_FUNC_DECLARE_START \
284  std::unique_ptr<artdaq::CommanderInterface> make(fhicl::ParameterSet const& ps, \
285  artdaq::Commandable& commandable) \
286  { \
287  return std::unique_ptr<artdaq::CommanderInterface>(new klass(ps, commandable)); \
288  } \
289  }
290 
291 #endif /* artdaq_ExternalComms_CommanderInterface.hh */
292 
293 // Local Variables:
294 // mode: c++
295 // End:
virtual std::string send_shutdown(uint64_t timeout)
Using the transport mechanism, send a shutdown command
This interface defines the functions used to transfer data between artdaq applications.
Commandable is the base class for all artdaq components which implement the artdaq state machine...
Definition: Commandable.hh:20
fhicl::WrappedTable< Config > Parameters
Used for ParameterSet validation (if desired)
virtual std::string send_resume(uint64_t timeout, uint64_t timestamp)
Using the transport mechanism, send a resume command
virtual std::string clear_config_archive()
Using the transport mechanism, send a clear_config_archive command
fhicl::Atom< std::string > commanderPluginType
&quot;commanderPluginType&quot; (REQUIRED): The type of Commander plugin to load
virtual std::string send_meta_command(std::string command, std::string argument)
Using the transport mechanism, send an send_meta_command command
int _id
ID Number of this Commander.
virtual std::string send_stop(uint64_t timeout, uint64_t timestamp)
Using the transport mechanism, send a stop command
virtual std::string send_legal_commands()
Using the transport mechanism, send a legal_commands command
virtual std::string send_init(fhicl::ParameterSet ps, uint64_t timeout, uint64_t timestamp)
Using the transport mechanism, send an init command
virtual std::string send_register_monitor(std::string monitor_fhicl)
Using the transport mechanism, send a register_monitor command
virtual ~CommanderInterface()
Default virtual Destructor.
virtual std::string send_soft_init(fhicl::ParameterSet ps, uint64_t timeout, uint64_t timestamp)
Using the transport mechanism, send a soft_init command
artdaq::Commandable & _commandable
Reference to the Commandable that this Commander Commands.
virtual std::string send_rollover_subrun(uint64_t seq, uint32_t subrunNumber)
Using the transport mechanism, send a send_rollover_subrun command
CommanderInterface(const fhicl::ParameterSet &ps, artdaq::Commandable &commandable)
CommanderInterface Constructor.
CommanderInterface & operator=(const CommanderInterface &)=delete
Copy Assignment operator is deleted.
virtual std::string add_config_archive_entry(std::string key, std::string value)
Using the transport mechanism, send an add_config_archive_entry command
virtual std::string send_reinit(fhicl::ParameterSet ps, uint64_t timeout, uint64_t timestamp)
Using the transport mechanism, send a reinit command
Configuration of the CommanderInterface. May be used for parameter validation
virtual std::string send_report(std::string which)
Using the transport mechanism, send a report command
virtual void run_server()=0
run_server is the main work loop for the Commander.
virtual std::string send_status()
Using the transport mechanism, send a status command
bool GetStatus()
Determine whether the Commander plugin is ready to accept commands
virtual std::string send_pause(uint64_t timeout, uint64_t timestamp)
Using the transport mechanism, send a pause command
virtual std::string send_trace_get(std::string name)
Using the transport mechanism, send an send_trace_get command
virtual std::string send_start(art::RunID runNumber, uint64_t timeout, uint64_t timestamp)
Using the transport mechanism, send a start command
std::atomic< bool > running_
Whether the server is running and able to respond to requests.
virtual std::string send_trace_set(std::string name, std::string type, std::string mask)
Using the transport mechanism, send an send_trace_msgfacility_set command
virtual std::string send_unregister_monitor(std::string label)
Using the transport mechanism, send an unregister_monitor command