00001 #ifndef _Supervisor_Supervisor_h
00002 #define _Supervisor_Supervisor_h
00003
00004 #include "otsdaq-core/SOAPUtilities/SOAPMessenger.h"
00005 #include "otsdaq-core/WebUsersUtilities/WebUsers.h"
00006 #include "otsdaq-core/SystemMessenger/SystemMessenger.h"
00007 #include "otsdaq-core/WorkLoopManager/WorkLoopManager.h"
00008 #include "otsdaq-core/FiniteStateMachine/RunControlStateMachine.h"
00009 #include "otsdaq-core/Supervisor/SupervisorsInfo.h"
00010 #include "otsdaq-core/SupervisorDescriptorInfo/SupervisorDescriptorInfo.h"
00011 #include "otsdaq-core/ConfigurationDataFormats/ConfigurationGroupKey.h"
00012
00013 #pragma GCC diagnostic push
00014 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
00015 #include <xdaq/Application.h>
00016 #pragma GCC diagnostic pop
00017
00018 #include <toolbox/task/WorkLoop.h>
00019 #include <xgi/Method.h>
00020 #include <xdata/String.h>
00021
00022 #include <string>
00023 #include <set>
00024
00025
00026 #define FSM_LAST_CONFIGURED_GROUP_ALIAS_FILE std::string("FSMLastConfiguredGroupAlias.hist")
00027 #define FSM_LAST_STARTED_GROUP_ALIAS_FILE std::string("FSMLastStartedGroupAlias.hist")
00028
00029
00030 namespace ots
00031 {
00032
00033 class ConfigurationManager;
00034 class ConfigurationGroupKey;
00035 class WorkLoopManager;
00036
00037 class Supervisor: public xdaq::Application, public SOAPMessenger, public RunControlStateMachine
00038 {
00039 friend class OtsConfigurationWizardSupervisor;
00040
00041 public:
00042
00043 XDAQ_INSTANTIATOR();
00044
00045 Supervisor (xdaq::ApplicationStub * s) throw (xdaq::exception::Exception);
00046 virtual ~Supervisor(void);
00047
00048 void init (void);
00049 static void URLDisplayThread (Supervisor *);
00050 void Default (xgi::Input* in, xgi::Output* out ) throw (xgi::exception::Exception);
00051
00052
00053 void loginRequest (xgi::Input* in, xgi::Output* out ) throw (xgi::exception::Exception);
00054 void request (xgi::Input* in, xgi::Output* out ) throw (xgi::exception::Exception);
00055 void tooltipRequest (xgi::Input* in, xgi::Output* out ) throw (xgi::exception::Exception);
00056
00057
00058 void stateMachineXgiHandler (xgi::Input* in, xgi::Output* out ) throw (xgi::exception::Exception);
00059 void stateMachineResultXgiHandler (xgi::Input* in, xgi::Output* out ) throw (xgi::exception::Exception);
00060 xoap::MessageReference stateMachineXoapHandler (xoap::MessageReference msg ) throw (xoap::exception::Exception);
00061 xoap::MessageReference stateMachineResultXoapHandler (xoap::MessageReference msg ) throw (xoap::exception::Exception);
00062 bool stateMachineThread (toolbox::task::WorkLoop* workLoop);
00063
00064
00065 void infoRequestHandler (xgi::Input* in, xgi::Output* out ) throw (xgi::exception::Exception);
00066 void infoRequestResultHandler (xgi::Input* in, xgi::Output* out ) throw (xgi::exception::Exception);
00067 bool infoRequestThread (toolbox::task::WorkLoop* workLoop);
00068
00069
00070 xoap::MessageReference supervisorCookieCheck (xoap::MessageReference msg) throw (xoap::exception::Exception);
00071 xoap::MessageReference supervisorGetActiveUsers (xoap::MessageReference msg) throw (xoap::exception::Exception);
00072 xoap::MessageReference supervisorSystemMessage (xoap::MessageReference msg) throw (xoap::exception::Exception);
00073 xoap::MessageReference supervisorGetUserInfo (xoap::MessageReference msg) throw (xoap::exception::Exception);
00074 xoap::MessageReference supervisorSystemLogbookEntry (xoap::MessageReference msg) throw (xoap::exception::Exception);
00075 xoap::MessageReference supervisorLastConfigGroupRequest(xoap::MessageReference msg) throw (xoap::exception::Exception);
00076
00077
00078 void stateInitial (toolbox::fsm::FiniteStateMachine& fsm) throw (toolbox::fsm::exception::Exception);
00079 void statePaused (toolbox::fsm::FiniteStateMachine& fsm) throw (toolbox::fsm::exception::Exception);
00080 void stateRunning (toolbox::fsm::FiniteStateMachine& fsm) throw (toolbox::fsm::exception::Exception);
00081 void stateHalted (toolbox::fsm::FiniteStateMachine& fsm) throw (toolbox::fsm::exception::Exception);
00082 void stateConfigured (toolbox::fsm::FiniteStateMachine& fsm) throw (toolbox::fsm::exception::Exception);
00083 void inError (toolbox::fsm::FiniteStateMachine& fsm) throw (toolbox::fsm::exception::Exception);
00084
00085 void transitionConfiguring (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception);
00086 void transitionHalting (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception);
00087 void transitionInitializing (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception);
00088 void transitionPausing (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception);
00089 void transitionResuming (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception);
00090 void transitionStarting (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception);
00091 void transitionStopping (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception);
00092 void enteringError (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception);
00093
00094 void getSupervisorsStatus (void) throw (toolbox::fsm::exception::Exception);
00095
00096 void makeSystemLogbookEntry (std::string entryText);
00097
00098
00099
00100 private:
00101 unsigned int getNextRunNumber(const std::string &fsmName = "");
00102 bool setNextRunNumber(unsigned int runNumber, const std::string &fsmName = "");
00103 static std::pair<std::string , ConfigurationGroupKey> loadGroupNameAndKey(const std::string &fileName, std::string &returnedTimeString);
00104 void saveGroupNameAndKey(const std::pair<std::string /*group name*/, ConfigurationGroupKey> &theGroup, const std::string &fileName);
00105 static xoap::MessageReference lastConfigGroupRequestHandler(const SOAPParameters ¶meters);
00106
00107 bool broadcastMessage(xoap::MessageReference msg);
00108
00109 bool supervisorGuiHasBeenLoaded_ ;
00110
00111
00112 std::string outputDir_ ;
00113 SupervisorDescriptorInfo theSupervisorDescriptorInfo_;
00114 SupervisorsInfo theSupervisorsInfo_ ;
00115 ConfigurationManager* theConfigurationManager_ ;
00116 WebUsers theWebUsers_ ;
00117 SystemMessenger theSysMessenger_ ;
00118
00119 WorkLoopManager stateMachineWorkLoopManager_;
00120 toolbox::BSem stateMachineSemaphore_ ;
00121 WorkLoopManager infoRequestWorkLoopManager_ ;
00122 toolbox::BSem infoRequestSemaphore_ ;
00123
00124 std::string supervisorContextUID_ ;
00125 std::string supervisorApplicationUID_ ;
00126
00127 std::string activeStateMachineName_;
00128 std::string activeStateMachineWindowName_;
00129 std::pair<std::string , ConfigurationGroupKey> theConfigurationGroup_;
00130
00131
00132 void wait(int milliseconds, std::string who="") const;
00133 unsigned long long counterTest_ ;
00134 std::vector<int> vectorTest_ ;
00135 std::string securityType_;
00136
00137 };
00138
00139 }
00140
00141 #endif
00142