otsdaq  v2_04_02
ARTDAQSupervisor.hh
1 #ifndef _ots_ARTDAQSupervisorr_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 // clang-format off
23 
24 
25 // ARTDAQSupervisor
26 // This class provides the otsdaq Supervisor interface to a single artdaq Data Logger.
28 {
29  public:
30  XDAQ_INSTANTIATOR();
31 
32  ARTDAQSupervisor (xdaq::ApplicationStub* s);
33  virtual ~ARTDAQSupervisor (void);
34 
35 
36 
37  void init (void);
38  void destroy (void);
39 
40  virtual void transitionConfiguring (toolbox::Event::Reference event) override;
41  virtual void transitionHalting (toolbox::Event::Reference event) override;
42  virtual void transitionInitializing (toolbox::Event::Reference event) override;
43  virtual void transitionPausing (toolbox::Event::Reference event) override;
44  virtual void transitionResuming (toolbox::Event::Reference event) override;
45  virtual void transitionStarting (toolbox::Event::Reference event) override;
46  virtual void transitionStopping (toolbox::Event::Reference event) override;
47  virtual void enteringError (toolbox::Event::Reference event);
48 
49  private:
50  static void configuringThread(ARTDAQSupervisor* cs);
51 
52  PyObject* daqinterface_ptr_;
53  std::mutex daqinterface_mutex_;
54  int partition_;
55  std::string daqinterface_state_;
56  std::unique_ptr<std::thread> runner_thread_;
57  std::atomic<bool> runner_running_;
58 
59 
60  void getDAQState_ (void);
61  void daqinterfaceRunner_ (void);
62  void stop_runner_ (void);
63  void start_runner_ (void);
64 };
65 
66 } // namespace ots
67 
68 // clang-format on
69 #endif