1 #ifndef _Supervisor_Supervisor_h
2 #define _Supervisor_Supervisor_h
4 #include "otsdaq-core/SOAPUtilities/SOAPMessenger.h"
5 #include "otsdaq-core/WebUsersUtilities/WebUsers.h"
6 #include "otsdaq-core/SystemMessenger/SystemMessenger.h"
7 #include "otsdaq-core/WorkLoopManager/WorkLoopManager.h"
8 #include "otsdaq-core/FiniteStateMachine/RunControlStateMachine.h"
9 #include "otsdaq-core/Supervisor/SupervisorsInfo.h"
10 #include "otsdaq-core/Supervisor/Iterator.h"
11 #include "otsdaq-core/SupervisorDescriptorInfo/SupervisorDescriptorInfo.h"
12 #include "otsdaq-core/ConfigurationDataFormats/ConfigurationGroupKey.h"
14 #pragma GCC diagnostic push
15 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
16 #include <xdaq/Application.h>
17 #pragma GCC diagnostic pop
19 #include <toolbox/task/WorkLoop.h>
20 #include <xgi/Method.h>
21 #include <xdata/String.h>
27 #define FSM_LAST_CONFIGURED_GROUP_ALIAS_FILE std::string("FSMLastConfiguredGroupAlias.hist")
28 #define FSM_LAST_STARTED_GROUP_ALIAS_FILE std::string("FSMLastStartedGroupAlias.hist")
34 class ConfigurationManager;
35 class ConfigurationGroupKey;
36 class WorkLoopManager;
40 friend class OtsConfigurationWizardSupervisor;
47 Supervisor (xdaq::ApplicationStub * s)
throw (xdaq::exception::Exception);
52 void Default (xgi::Input* in, xgi::Output* out )
throw (xgi::exception::Exception);
55 void loginRequest (xgi::Input* in, xgi::Output* out )
throw (xgi::exception::Exception);
56 void request (xgi::Input* in, xgi::Output* out )
throw (xgi::exception::Exception);
57 void tooltipRequest (xgi::Input* in, xgi::Output* out )
throw (xgi::exception::Exception);
60 void stateMachineXgiHandler (xgi::Input* in, xgi::Output* out )
throw (xgi::exception::Exception);
61 void stateMachineResultXgiHandler (xgi::Input* in, xgi::Output* out )
throw (xgi::exception::Exception);
62 xoap::MessageReference stateMachineXoapHandler (xoap::MessageReference msg )
throw (xoap::exception::Exception);
63 xoap::MessageReference stateMachineResultXoapHandler (xoap::MessageReference msg )
throw (xoap::exception::Exception);
64 bool stateMachineThread (toolbox::task::WorkLoop* workLoop);
67 void infoRequestHandler (xgi::Input* in, xgi::Output* out )
throw (xgi::exception::Exception);
68 void infoRequestResultHandler (xgi::Input* in, xgi::Output* out )
throw (xgi::exception::Exception);
69 bool infoRequestThread (toolbox::task::WorkLoop* workLoop);
72 xoap::MessageReference supervisorCookieCheck (xoap::MessageReference msg)
throw (xoap::exception::Exception);
73 xoap::MessageReference supervisorGetActiveUsers (xoap::MessageReference msg)
throw (xoap::exception::Exception);
74 xoap::MessageReference supervisorSystemMessage (xoap::MessageReference msg)
throw (xoap::exception::Exception);
75 xoap::MessageReference supervisorGetUserInfo (xoap::MessageReference msg)
throw (xoap::exception::Exception);
76 xoap::MessageReference supervisorSystemLogbookEntry (xoap::MessageReference msg)
throw (xoap::exception::Exception);
77 xoap::MessageReference supervisorLastConfigGroupRequest(xoap::MessageReference msg)
throw (xoap::exception::Exception);
80 void stateInitial (toolbox::fsm::FiniteStateMachine& fsm)
throw (toolbox::fsm::exception::Exception);
81 void statePaused (toolbox::fsm::FiniteStateMachine& fsm)
throw (toolbox::fsm::exception::Exception);
82 void stateRunning (toolbox::fsm::FiniteStateMachine& fsm)
throw (toolbox::fsm::exception::Exception);
83 void stateHalted (toolbox::fsm::FiniteStateMachine& fsm)
throw (toolbox::fsm::exception::Exception);
84 void stateConfigured (toolbox::fsm::FiniteStateMachine& fsm)
throw (toolbox::fsm::exception::Exception);
85 void inError (toolbox::fsm::FiniteStateMachine& fsm)
throw (toolbox::fsm::exception::Exception);
87 void transitionConfiguring (toolbox::Event::Reference e)
throw (toolbox::fsm::exception::Exception);
88 void transitionHalting (toolbox::Event::Reference e)
throw (toolbox::fsm::exception::Exception);
89 void transitionInitializing (toolbox::Event::Reference e)
throw (toolbox::fsm::exception::Exception);
90 void transitionPausing (toolbox::Event::Reference e)
throw (toolbox::fsm::exception::Exception);
91 void transitionResuming (toolbox::Event::Reference e)
throw (toolbox::fsm::exception::Exception);
92 void transitionStarting (toolbox::Event::Reference e)
throw (toolbox::fsm::exception::Exception);
93 void transitionStopping (toolbox::Event::Reference e)
throw (toolbox::fsm::exception::Exception);
94 void enteringError (toolbox::Event::Reference e)
throw (toolbox::fsm::exception::Exception);
96 void getSupervisorsStatus (
void)
throw (toolbox::fsm::exception::Exception);
98 void makeSystemLogbookEntry (std::string entryText);
103 unsigned int getNextRunNumber(
const std::string &fsmName =
"");
104 bool setNextRunNumber(
unsigned int runNumber,
const std::string &fsmName =
"");
105 static std::pair<std::string ,
ConfigurationGroupKey> loadGroupNameAndKey(
const std::string &fileName, std::string &returnedTimeString);
106 void saveGroupNameAndKey(
const std::pair<std::string /*group name*/, ConfigurationGroupKey> &theGroup,
const std::string &fileName);
107 static xoap::MessageReference lastConfigGroupRequestHandler(
const SOAPParameters ¶meters);
109 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);
110 bool broadcastMessage(xoap::MessageReference msg)
throw (toolbox::fsm::exception::Exception);
112 bool supervisorGuiHasBeenLoaded_ ;
115 std::string outputDir_ ;
123 toolbox::BSem stateMachineSemaphore_ ;
125 toolbox::BSem infoRequestSemaphore_ ;
127 std::string supervisorContextUID_ ;
128 std::string supervisorApplicationUID_ ;
130 std::string activeStateMachineName_ ;
131 std::string activeStateMachineWindowName_ ;
135 std::mutex stateMachineAccessMutex_ ;
142 void wait(
int milliseconds, std::string who=
"")
const;
143 unsigned long long counterTest_ ;
144 std::vector<int> vectorTest_ ;
145 std::string securityType_;