otsdaq  v2_05_02_indev
ARTDAQSupervisor.hh
1 #ifndef _ots_ARTDAQSupervisor_h
2 #define _ots_ARTDAQSupervisor_h
3 
4 #if __cplusplus > 201402L
5 #pragma GCC diagnostic push
6 #pragma GCC diagnostic ignored "-Wregister"
7 #include <Python.h>
8 #pragma GCC diagnostic pop
9 #else
10 #include <Python.h>
11 #endif
12 
13 #include <mutex>
14 #include <thread>
15 
16 #include "artdaq/ExternalComms/CommanderInterface.hh"
17 #include "otsdaq/CoreSupervisors/CoreSupervisorBase.h"
18 #include "otsdaq/TablePlugins/ARTDAQTableBase/ARTDAQTableBase.h"
19 
20 namespace ots
21 {
22 
23  // ARTDAQSupervisor
24  // This class provides the otsdaq Supervisor interface to a single artdaq Data Logger.
26  {
27  public:
28  XDAQ_INSTANTIATOR();
29 
31  std::string label;
32  std::string host;
33  int port;
34  int subsystem;
35  int rank;
36  std::string state;
37  };
38 
39  ARTDAQSupervisor(xdaq::ApplicationStub* s);
40  virtual ~ARTDAQSupervisor(void);
41 
42 
43 
44  void init(void);
45  void destroy(void);
46 
47  virtual void transitionConfiguring(toolbox::Event::Reference event) override;
48  virtual void transitionHalting(toolbox::Event::Reference event) override;
49  virtual void transitionInitializing(toolbox::Event::Reference event) override;
50  virtual void transitionPausing(toolbox::Event::Reference event) override;
51  virtual void transitionResuming(toolbox::Event::Reference event) override;
52  virtual void transitionStarting(toolbox::Event::Reference event) override;
53  virtual void transitionStopping(toolbox::Event::Reference event) override;
54  virtual void enteringError(toolbox::Event::Reference event) override;
55 
56  std::list<std::pair<DAQInterfaceProcessInfo, std::unique_ptr<artdaq::CommanderInterface>>> makeCommandersFromProcessInfo();
57 
58  static std::list<std::string> tokenize_(std::string const& input);
59  private:
60  void configuringThread(void);
61 
62  PyObject* daqinterface_ptr_;
63  std::recursive_mutex daqinterface_mutex_;
64  int partition_;
65  std::string daqinterface_state_;
66  std::unique_ptr<std::thread> runner_thread_;
67  std::atomic<bool> runner_running_;
68 
69 
70  std::mutex thread_mutex_;
71  ProgressBar thread_progress_bar_;
72  std::string thread_error_message_;
73  int last_thread_progress_read_;
74  time_t last_thread_progress_update_;
75 
76 
77  void getDAQState_(void);
78  std::string getProcessInfo_(void);
79  std::list<DAQInterfaceProcessInfo> getAndParseProcessInfo_(void);
80  void daqinterfaceRunner_(void);
81  void stop_runner_(void);
82  void start_runner_(void);
83  };
84 
85 } // namespace ots
86 
87 #endif