otsdaq_utilities  v2_05_02_indev
ECLSupervisor.h
1 #ifndef _ots_ECLSupervisor_h
2 #define _ots_ECLSupervisor_h
3 
4 #include "otsdaq/FiniteStateMachine/RunControlStateMachine.h"
5 #include "otsdaq/SOAPUtilities/SOAPMessenger.h"
6 #include "otsdaq/WebUsersUtilities/RemoteWebUsers.h"
7 
8 #pragma GCC diagnostic push
9 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
10 #pragma GCC diagnostic ignored "-Wunused-variable"
11 #pragma GCC diagnostic ignored "-Wunused-parameter"
12 #if __GNUC__ >= 8
13 #pragma GCC diagnostic ignored "-Wcatch-value"
14 #endif
15 
16 #include <xdaq/Application.h>
17 #pragma GCC diagnostic pop
18 #include "otsdaq/Macros/XDAQApplicationMacros.h"
19 
20 #pragma GCC diagnostic push
21 #pragma GCC diagnostic ignored "-Wunknown-pragmas"
22 #include <xgi/Method.h> //for cgicc::Cgicc
23 #include <cgicc/HTMLClasses.h>
24 #include <cgicc/HTMLDoctype.h>
25 #include <cgicc/HTTPCookie.h>
26 #include <cgicc/HTTPHeader.h>
27 #pragma GCC diagnostic pop
28 
29 #include <chrono>
30 #include <map>
31 #include <string>
32 #include "otsdaq/CoreSupervisors/CoreSupervisorBase.h"
33 
34 namespace ots
35 {
36 class ConfigurationManager;
37 class TableGroupKey;
38 
39 class ECLSupervisor : public CoreSupervisorBase
40 {
41  public:
42  XDAQ_INSTANTIATOR();
43 
44  ECLSupervisor(xdaq::ApplicationStub* s);
45  virtual ~ECLSupervisor(void);
46  void init(void);
47  void destroy(void);
48 
49  void defaultPage(xgi::Input* in, xgi::Output* out);
50 
51  void transitionConfiguring(toolbox::Event::Reference e);
52  void transitionStarting(toolbox::Event::Reference e);
53  void transitionStopping(toolbox::Event::Reference e);
54  void transitionPausing(toolbox::Event::Reference e);
55  void transitionResuming(toolbox::Event::Reference e);
56  void enteringError(toolbox::Event::Reference e);
57 
58  xoap::MessageReference MakeSystemLogbookEntry(xoap::MessageReference msg);
59 
60  private:
61  ConfigurationManager* theConfigurationManager_;
62  const std::string supervisorContextUID_;
63  const std::string supervisorApplicationUID_;
64  const std::string supervisorConfigurationPath_;
65 
66  std::string ECLUser;
67  std::string ECLHost;
68  std::string ECLPwd;
69  std::string ExperimentName;
70  std::string run;
71  std::chrono::steady_clock::time_point run_start;
72  int duration_ms; // For paused runs, don't count time spend in pause state
73 
74  std::string EscapeECLString(std::string input = "");
75 
76  enum class WriteState
77  {
78  kStart,
79  kStop,
80  kPause,
81  kResume,
82  kError
83  };
84 
85  int Write(WriteState state);
86 };
87 }
88 
89 #endif