otsdaq  3.09.00
FESupervisor.h
1 #ifndef _ots_FESupervisor_h_
2 #define _ots_FESupervisor_h_
3 
4 #include "otsdaq/CoreSupervisors/CoreSupervisorBase.h"
5 
6 #include "zmq.hpp"
7 
8 #include <memory>
9 #include <mutex>
10 #include <thread>
11 #include <vector>
12 
13 namespace ots
14 {
15 class FEVInterfacesManager;
16 
26 {
27  // friend FEVInterface;
28 
29  public:
30  XDAQ_INSTANTIATOR();
31 
32  FESupervisor(xdaq::ApplicationStub* s);
33  virtual ~FESupervisor(void);
34 
35  xoap::MessageReference frontEndCommunicationRequest(xoap::MessageReference message);
36  xoap::MessageReference macroMakerSupervisorRequest(xoap::MessageReference message);
37  virtual xoap::MessageReference workLoopStatusRequest(
38  xoap::MessageReference message) override;
39 
40  virtual void transitionConfiguring(toolbox::Event::Reference event) override;
41  virtual void transitionHalting(toolbox::Event::Reference event) override;
42 
53  void publishData(const char* dataPtr, size_t dataSize);
54  bool isPublishingData() const { return dp_isInitialized_; }
55 
56  protected:
57  FEVInterfacesManager* theFEInterfacesManager_;
58 
69  void initDataPublishing(const std::string& endpoint,
70  const std::string& topic = "test");
71 
75  void closeDataPublishing(bool alsoCloseContext = true);
76 
77  private:
79  extractFEInterfacesManager();
80 
81  // Async FE Macro task tracking (for long-running macros that exceed SOAP timeout)
82  struct AsyncMacroTask
83  {
84  uint64_t taskID;
85  std::string interfaceID;
86  std::thread::id threadID;
87  std::string outputArgs;
88  std::string error;
89  bool done = false;
90  time_t startTime = 0;
91  time_t doneTime = 0;
92  };
93  std::mutex asyncMacroMutex_;
94  std::vector<std::shared_ptr<AsyncMacroTask>> asyncMacroTasks_;
95  uint64_t asyncMacroTaskIDCounter_ = 0;
96 
97  // ZeroMQ Publisher
98  zmq::context_t dp_context_;
99  zmq::socket_t dp_socket_;
100  std::string dp_endpoint_;
101  std::string dp_topic_;
102  bool dp_isInitialized_ = false;
103 };
104 
105 } // namespace ots
106 
107 #endif
void publishData(const char *dataPtr, size_t dataSize)
virtual void transitionHalting(toolbox::Event::Reference event) override
void initDataPublishing(const std::string &endpoint, const std::string &topic="test")
void closeDataPublishing(bool alsoCloseContext=true)
xoap::MessageReference macroMakerSupervisorRequest(xoap::MessageReference message)
defines used also by OtsConfigurationWizardSupervisor