00001 #ifndef _ots_CoreSupervisorBase_h_
00002 #define _ots_CoreSupervisorBase_h_
00003
00004 #include "otsdaq-core/SupervisorInfo/AllSupervisorInfo.h"
00005 #include "otsdaq-core/WorkLoopManager/WorkLoopManager.h"
00006 #include "otsdaq-core/FiniteStateMachine/RunControlStateMachine.h"
00007 #include "otsdaq-core/SupervisorInfo/AllSupervisorInfo.h"
00008 #include "otsdaq-core/SOAPUtilities/SOAPMessenger.h"
00009
00010 #include "otsdaq-core/XmlUtilities/HttpXmlDocument.h"
00011 #include "otsdaq-core/SOAPUtilities/SOAPUtilities.h"
00012 #include "otsdaq-core/SOAPUtilities/SOAPCommand.h"
00013 #include "otsdaq-core/CgiDataUtilities/CgiDataUtilities.h"
00014
00015 #include "otsdaq-core/ConfigurationDataFormats/ConfigurationGroupKey.h"
00016 #include "otsdaq-core/ConfigurationInterface/ConfigurationManager.h"
00017 #include "otsdaq-core/ConfigurationInterface/ConfigurationTree.h"
00018 #include "otsdaq-core/ConfigurationPluginDataFormats/XDAQContextConfiguration.h"
00019 #include "otsdaq-core/MessageFacility/MessageFacility.h"
00020 #include "otsdaq-core/Macros/CoutHeaderMacros.h"
00021 #include "otsdaq-core/FiniteStateMachine/VStateMachine.h"
00022
00023 #include "otsdaq-core/WebUsersUtilities/RemoteWebUsers.h"
00024
00025 #pragma GCC diagnostic push
00026 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
00027 #include <xdaq/Application.h>
00028 #pragma GCC diagnostic pop
00029 #include "xgi/Method.h"
00030
00031 #include <toolbox/fsm/FailedEvent.h>
00032
00033 #include <xdaq/NamespaceURI.h>
00034 #include <xoap/Method.h>
00035
00036 #include <string>
00037 #include <vector>
00038 #include <map>
00039 #include <memory>
00040
00041
00042
00043 namespace ots
00044 {
00045
00046 class CoreSupervisorBase: public xdaq::Application, public SOAPMessenger, public RunControlStateMachine
00047 {
00048
00049 public:
00050
00051 CoreSupervisorBase (xdaq::ApplicationStub * s) throw (xdaq::exception::Exception);
00052 virtual ~CoreSupervisorBase(void);
00053
00054 virtual void setSupervisorPropertyDefaults (void);
00055 void destroy (void);
00056
00057 private:
00058 xoap::MessageReference workLoopStatusRequestWrapper (xoap::MessageReference message ) throw (xoap::exception::Exception);
00059 void DefaultWrapper (xgi::Input* in, xgi::Output* out) throw (xgi::exception::Exception);
00060 void requestWrapper (xgi::Input* in, xgi::Output* out) throw (xgi::exception::Exception);
00061
00062 public:
00063
00064 virtual void Default (xgi::Input* in, xgi::Output* out) throw (xgi::exception::Exception);
00065 virtual void request (xgi::Input* in, xgi::Output* out) throw (xgi::exception::Exception);
00066
00067
00068
00069
00070 void stateMachineXgiHandler (xgi::Input* in, xgi::Output* out ) throw (xgi::exception::Exception);
00071 void stateMachineResultXgiHandler (xgi::Input* in, xgi::Output* out ) throw (xgi::exception::Exception);
00072 xoap::MessageReference stateMachineXoapHandler (xoap::MessageReference message ) throw (xoap::exception::Exception);
00073 xoap::MessageReference stateMachineResultXoapHandler (xoap::MessageReference message ) throw (xoap::exception::Exception);
00074
00075 xoap::MessageReference stateMachineStateRequest (xoap::MessageReference message ) throw (xoap::exception::Exception);
00076 xoap::MessageReference stateMachineErrorMessageRequest (xoap::MessageReference message ) throw (xoap::exception::Exception);
00077
00078 virtual xoap::MessageReference workLoopStatusRequest (xoap::MessageReference message ) throw (xoap::exception::Exception);
00079
00080 bool stateMachineThread (toolbox::task::WorkLoop* workLoop);
00081
00082 virtual void stateInitial (toolbox::fsm::FiniteStateMachine& fsm) throw (toolbox::fsm::exception::Exception);
00083 virtual void statePaused (toolbox::fsm::FiniteStateMachine& fsm) throw (toolbox::fsm::exception::Exception);
00084 virtual void stateRunning (toolbox::fsm::FiniteStateMachine& fsm) throw (toolbox::fsm::exception::Exception);
00085 virtual void stateHalted (toolbox::fsm::FiniteStateMachine& fsm) throw (toolbox::fsm::exception::Exception);
00086 virtual void stateConfigured (toolbox::fsm::FiniteStateMachine& fsm) throw (toolbox::fsm::exception::Exception);
00087 virtual void inError (toolbox::fsm::FiniteStateMachine& fsm) throw (toolbox::fsm::exception::Exception);
00088
00089 virtual void transitionConfiguring (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception);
00090 virtual void transitionHalting (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception);
00091 virtual void transitionInitializing (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception);
00092 virtual void transitionPausing (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception);
00093 virtual void transitionResuming (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception);
00094 virtual void transitionStarting (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception);
00095 virtual void transitionStopping (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception);
00096 virtual void enteringError (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception);
00097
00098
00099 static const std::string WORK_LOOP_DONE, WORK_LOOP_WORKING;
00100 protected:
00101
00102
00103 WorkLoopManager stateMachineWorkLoopManager_;
00104 toolbox::BSem stateMachineSemaphore_;
00105
00106 ConfigurationManager* theConfigurationManager_;
00107
00108 std::string XDAQContextConfigurationName_;
00109 std::string supervisorConfigurationPath_;
00110
00111 std::string supervisorContextUID_;
00112 std::string supervisorApplicationUID_;
00113 std::string supervisorClass_;
00114 std::string supervisorClassNoNamespace_;
00115
00116 AllSupervisorInfo allSupervisorInfo_;
00117 RemoteWebUsers theRemoteWebUsers_;
00118 std::vector<VStateMachine*> theStateMachineImplementation_;
00119
00120 bool LOCK_REQUIRED_;
00121 uint8_t USER_PERMISSIONS_THRESHOLD_;
00122 std::string USER_GROUPS_ALLOWED_;
00123 std::string USER_GROUPS_DISALLOWED_;
00124
00125
00126 struct SupervisorProperties
00127 {
00128 std::string const fieldRequireLock = "RequireUserHasLock";
00129 std::string const fieldUserPermissionsThreshold = "UserPermissionsThreshold";
00130 std::string const fieldUserGroupsAllowed = "UserGroupsAllowed";
00131 std::string const fieldUserGroupsDisallowed = "UserGroupsDisallowed";
00132 } supervisorProperties_;
00133 };
00134
00135 }
00136
00137 #endif