1 #ifndef _ots_GatewaySupervisor_h
2 #define _ots_GatewaySupervisor_h
4 #include "otsdaq-core/SupervisorInfo/AllSupervisorInfo.h"
5 #include "otsdaq-core/SOAPUtilities/SOAPMessenger.h"
6 #include "otsdaq-core/WebUsersUtilities/WebUsers.h"
7 #include "otsdaq-core/SystemMessenger/SystemMessenger.h"
8 #include "otsdaq-core/WorkLoopManager/WorkLoopManager.h"
9 #include "otsdaq-core/FiniteStateMachine/RunControlStateMachine.h"
10 #include "otsdaq-core/SupervisorInfo/AllSupervisorInfo.h"
11 #include "otsdaq-core/GatewaySupervisor/Iterator.h"
12 #include "otsdaq-core/ConfigurationDataFormats/ConfigurationGroupKey.h"
13 #include "otsdaq-core/CoreSupervisors/CorePropertySupervisorBase.h"
14 #include "otsdaq-core/GatewaySupervisor/ARTDAQCommandable.h"
16 #pragma GCC diagnostic push
17 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
18 #include <xdaq/Application.h>
19 #pragma GCC diagnostic pop
20 #include "otsdaq-core/Macros/XDAQApplicationMacros.h"
22 #include <toolbox/task/WorkLoop.h>
23 #include <xgi/Method.h>
24 #include <xdata/String.h>
30 #define FSM_LAST_CONFIGURED_GROUP_ALIAS_FILE std::string("FSMLastConfiguredGroupAlias.hist")
31 #define FSM_LAST_STARTED_GROUP_ALIAS_FILE std::string("FSMLastStartedGroupAlias.hist")
37 class ConfigurationManager;
38 class ConfigurationGroupKey;
39 class WorkLoopManager;
61 void Default (xgi::Input* in, xgi::Output* out ) ;
64 void loginRequest (xgi::Input* in, xgi::Output* out ) ;
65 void request (xgi::Input* in, xgi::Output* out ) ;
66 void tooltipRequest (xgi::Input* in, xgi::Output* out ) ;
70 void stateMachineXgiHandler (xgi::Input* in, xgi::Output* out ) ;
73 xoap::MessageReference stateMachineXoapHandler (xoap::MessageReference msg ) ;
74 xoap::MessageReference stateMachineResultXoapHandler (xoap::MessageReference msg ) ;
76 bool stateMachineThread (toolbox::task::WorkLoop* workLoop);
79 void infoRequestHandler (xgi::Input* in, xgi::Output* out ) ;
80 void infoRequestResultHandler (xgi::Input* in, xgi::Output* out ) ;
81 bool infoRequestThread (toolbox::task::WorkLoop* workLoop);
84 xoap::MessageReference supervisorCookieCheck (xoap::MessageReference msg) ;
85 xoap::MessageReference supervisorGetActiveUsers (xoap::MessageReference msg) ;
86 xoap::MessageReference supervisorSystemMessage (xoap::MessageReference msg) ;
87 xoap::MessageReference supervisorGetUserInfo (xoap::MessageReference msg) ;
88 xoap::MessageReference supervisorSystemLogbookEntry (xoap::MessageReference msg) ;
89 xoap::MessageReference supervisorLastConfigGroupRequest(xoap::MessageReference msg) ;
92 void stateInitial (toolbox::fsm::FiniteStateMachine& fsm) ;
93 void statePaused (toolbox::fsm::FiniteStateMachine& fsm) ;
94 void stateRunning (toolbox::fsm::FiniteStateMachine& fsm) ;
95 void stateHalted (toolbox::fsm::FiniteStateMachine& fsm) ;
96 void stateConfigured (toolbox::fsm::FiniteStateMachine& fsm) ;
97 void inError (toolbox::fsm::FiniteStateMachine& fsm) ;
99 void transitionConfiguring (toolbox::Event::Reference e) ;
100 void transitionHalting (toolbox::Event::Reference e) ;
101 void transitionInitializing (toolbox::Event::Reference e) ;
102 void transitionPausing (toolbox::Event::Reference e) ;
103 void transitionResuming (toolbox::Event::Reference e) ;
104 void transitionStarting (toolbox::Event::Reference e) ;
105 void transitionStopping (toolbox::Event::Reference e) ;
106 void transitionShuttingDown (toolbox::Event::Reference e) ;
107 void transitionStartingUp (toolbox::Event::Reference e) ;
108 void enteringError (toolbox::Event::Reference e) ;
110 void makeSystemLogbookEntry (std::string entryText);
113 virtual void setSupervisorPropertyDefaults (
void)
override;
114 virtual void forceSupervisorPropertyValues (
void)
override;
118 unsigned int getNextRunNumber (
const std::string &fsmName =
"");
119 bool setNextRunNumber (
unsigned int runNumber,
const std::string &fsmName =
"");
120 static std::pair<std::string ,
ConfigurationGroupKey> loadGroupNameAndKey (
const std::string &fileName, std::string &returnedTimeString);
121 void saveGroupNameAndKey (
const std::pair<std::string /*group name*/, ConfigurationGroupKey> &theGroup,
const std::string &fileName);
122 static xoap::MessageReference lastConfigGroupRequestHandler (
const SOAPParameters ¶meters);
123 void launchStartOTSCommand (
const std::string& command);
126 std::string attemptStateMachineTransition (
HttpXmlDocument* xmldoc, std::ostringstream* out,
const std::string& command,
const std::string& fsmName,
const std::string& fsmWindowName,
const std::string& username,
const std::vector<std::string>& parameters);
127 bool broadcastMessage (xoap::MessageReference msg) ;
129 bool supervisorGuiHasBeenLoaded_ ;
140 toolbox::BSem stateMachineSemaphore_ ;
142 toolbox::BSem infoRequestSemaphore_ ;
147 std::string activeStateMachineName_ ;
148 std::string activeStateMachineWindowName_ ;
152 std::mutex stateMachineAccessMutex_ ;
153 std::string stateMachineLastCommandInput_ ;
160 char tmpStringForConversions_[100];
163 void wait(
int milliseconds, std::string who=
"")
const;
164 unsigned long long counterTest_ ;
165 std::vector<int> vectorTest_ ;
166 std::string securityType_;