artdaq  v3_12_02
CommanderInterface.hh
1 #ifndef artdaq_ExternalComms_CommanderInterface_hh
2 #define artdaq_ExternalComms_CommanderInterface_hh
3 
4 #include "artdaq/Application/Commandable.hh"
5 
6 #include "fhiclcpp/ParameterSet.h"
7 #include "fhiclcpp/types/Atom.h"
8 #include "fhiclcpp/types/Comment.h"
9 #include "fhiclcpp/types/ConfigurationTable.h"
10 #include "fhiclcpp/types/Name.h"
11 
12 #include "cetlib/compiler_macros.h"
13 
14 #include <atomic>
15 #include <memory>
16 #include <string>
17 
18 namespace artdaq {
23 {
24 public:
28  struct Config
29  {
31  fhicl::Atom<int> id{fhicl::Name{"id"}, fhicl::Comment{"The unique ID associated with this Commander plugin. (ex. XMLRPC Port number)"}, 0};
33  fhicl::Atom<std::string> commanderPluginType{fhicl::Name{"commanderPluginType"}, fhicl::Comment{"String identifying the name of the CommanderInterface plugin to load"}};
34  };
36  using Parameters = fhicl::WrappedTable<Config>;
37 
43  CommanderInterface(const fhicl::ParameterSet& ps, artdaq::Commandable& commandable)
44  : _commandable(commandable)
45  , _id(ps.get<int>("id", 0))
46  {}
47 
51  CommanderInterface(const CommanderInterface&) = delete;
52 
58 
62  virtual ~CommanderInterface();
63 
92  virtual void run_server() = 0;
93 
104  virtual std::string send_init(fhicl::ParameterSet const& ps, uint64_t timeout, uint64_t timestamp);
105 
116  virtual std::string send_soft_init(fhicl::ParameterSet const& ps, uint64_t timeout, uint64_t timestamp);
117 
128  virtual std::string send_reinit(fhicl::ParameterSet const& ps, uint64_t timeout, uint64_t timestamp);
129 
140  virtual std::string send_start(art::RunID runNumber, uint64_t timeout, uint64_t timestamp);
141 
151  virtual std::string send_pause(uint64_t timeout, uint64_t timestamp);
152 
162  virtual std::string send_resume(uint64_t timeout, uint64_t timestamp);
163 
173  virtual std::string send_stop(uint64_t timeout, uint64_t timestamp);
174 
183  virtual std::string send_shutdown(uint64_t timeout);
184 
191  virtual std::string send_status();
192 
200  virtual std::string send_report(std::string const& which);
201 
208  virtual std::string send_legal_commands();
209 
217  virtual std::string send_register_monitor(std::string const& monitor_fhicl);
218 
226  virtual std::string send_unregister_monitor(std::string const& label);
227 
236  virtual std::string send_trace_get(std::string const& name);
237 
252  virtual std::string send_trace_set(std::string const& name, std::string const& type, std::string const& mask);
253 
262  virtual std::string send_meta_command(std::string const& command, std::string const& argument);
263 
273  virtual std::string send_rollover_subrun(uint64_t seq, uint32_t subrunNumber);
274 
279  bool GetStatus() { return running_.load(); }
280 
294  virtual std::string add_config_archive_entry(std::string const& key, std::string const& value);
295 
304  virtual std::string clear_config_archive();
305 
306 private:
309 
310 public:
315 
316 protected:
317  int _id;
318  std::atomic<bool> running_;
319 };
320 } // namespace artdaq
321 
322 #ifndef EXTERN_C_FUNC_DECLARE_START
323 #define EXTERN_C_FUNC_DECLARE_START extern "C" {
324 #endif
325 
326 #define DEFINE_ARTDAQ_COMMANDER(klass) \
327  EXTERN_C_FUNC_DECLARE_START \
328  std::unique_ptr<artdaq::CommanderInterface> make(fhicl::ParameterSet const& ps, \
329  artdaq::Commandable& commandable) \
330  { \
331  return std::unique_ptr<artdaq::CommanderInterface>(new klass(ps, commandable)); \
332  } \
333  }
334 
335 #endif /* artdaq_ExternalComms_CommanderInterface.hh */
336 
337 // Local Variables:
338 // mode: c++
339 // 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:22
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 send_init(fhicl::ParameterSet const &ps, uint64_t timeout, uint64_t timestamp)
Using the transport mechanism, send an init command
virtual std::string clear_config_archive()
Using the transport mechanism, send a clear_config_archive command
virtual std::string send_report(std::string const &which)
Using the transport mechanism, send a report command
fhicl::Atom< std::string > commanderPluginType
&quot;commanderPluginType&quot; (REQUIRED): The type of Commander plugin to load
int _id
ID Number of this Commander.
virtual std::string send_register_monitor(std::string const &monitor_fhicl)
Using the transport mechanism, send a register_monitor command
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_meta_command(std::string const &command, std::string const &argument)
Using the transport mechanism, send an send_meta_command command
virtual ~CommanderInterface()
Default virtual Destructor.
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
virtual std::string send_trace_get(std::string const &name)
Using the transport mechanism, send an send_trace_get command
virtual std::string add_config_archive_entry(std::string const &key, std::string const &value)
Using the transport mechanism, send an add_config_archive_entry command
CommanderInterface(const fhicl::ParameterSet &ps, artdaq::Commandable &commandable)
CommanderInterface Constructor.
virtual std::string send_unregister_monitor(std::string const &label)
Using the transport mechanism, send an unregister_monitor command
CommanderInterface & operator=(const CommanderInterface &)=delete
Copy Assignment operator is deleted.
virtual std::string send_soft_init(fhicl::ParameterSet const &ps, uint64_t timeout, uint64_t timestamp)
Using the transport mechanism, send a soft_init command
Configuration of the CommanderInterface. May be used for parameter validation
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_set(std::string const &name, std::string const &type, std::string const &mask)
Using the transport mechanism, send an send_trace_msgfacility_set 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_reinit(fhicl::ParameterSet const &ps, uint64_t timeout, uint64_t timestamp)
Using the transport mechanism, send a reinit command