1 #ifndef EPSTATEMACHINE_H
2 #define EPSTATEMACHINE_H
4 #include "toolbox/fsm/FiniteStateMachine.h"
5 #include "toolbox/fsm/FailedEvent.h"
6 #include "xcept/tools.h"
7 #include "xoap/MessageFactory.h"
8 #include "xoap/Method.h"
9 #include "log4cplus/logger.h"
10 #include "xdata/String.h"
11 #include "xdaq/NamespaceURI.h"
32 template<
class T>
void init(
T*me)
41 addStateTransition(
'H',
'R',
"Configure", me, &T::configureAction);
42 addStateTransition(
'R',
'E',
"Enable", me, &T::enableAction);
43 addStateTransition(
'E',
'R',
"Stop", me, &T::stopAction);
44 addStateTransition(
'E',
'S',
"Suspend", me, &T::suspendAction);
45 addStateTransition(
'S',
'E',
"Resume", me, &T::resumeAction);
46 addStateTransition(
'H',
'H',
"Halt", me, &T::nullAction);
47 addStateTransition(
'R',
'H',
"Halt", me, &T::haltAction);
48 addStateTransition(
'E',
'H',
"Halt", me, &T::haltAction);
49 addStateTransition(
'S',
'H',
"Halt", me, &T::haltAction);
57 xoap::bind(me,&T::fireEvent,
"Configure", XDAQ_NS_URI);
58 xoap::bind(me,&T::fireEvent,
"Stop" , XDAQ_NS_URI);
59 xoap::bind(me,&T::fireEvent,
"Enable" , XDAQ_NS_URI);
60 xoap::bind(me,&T::fireEvent,
"Suspend" , XDAQ_NS_URI);
61 xoap::bind(me,&T::fireEvent,
"Resume" , XDAQ_NS_URI);
62 xoap::bind(me,&T::fireEvent,
"Halt" , XDAQ_NS_URI);
63 xoap::bind(me,&T::fireEvent,
"Disable" , XDAQ_NS_URI);
64 xoap::bind(me,&T::fireEvent,
"Fail" , XDAQ_NS_URI);
71 toolbox::fsm::FailedEvent &fe =
72 dynamic_cast<toolbox::fsm::FailedEvent&
>(*e);
75 "Failure occurred when performing transition from: "
76 << fe.getFromState() <<
" to: " << fe.getToState()
77 <<
" exception: " << fe.getException().what());
85 << getStateName(getCurrentState()));
97 state_ = FiniteStateMachine::getCurrentState();
110 FiniteStateMachine::fireEvent(
e);
114 LOG4CPLUS_ERROR(
logger_,
"EPStateMachine fireEvent failed "
119 LOG4CPLUS_ERROR(
logger_,
"EPStateMachine fireEvent failed "
120 <<
" Unknown Exception " <<
" state is "
121 << FiniteStateMachine::getCurrentState());
125 state_ = FiniteStateMachine::getCurrentState();
void fireEvent(toolbox::Event::Reference e)
xoap::MessageReference createFSMReplyMsg(const std::string cmd, const std::string state)
toolbox::fsm::State state_
void failedTransition(toolbox::Event::Reference e)
xoap::MessageReference processFSMCommand(const std::string cmdName)
void stateChanged(toolbox::fsm::FiniteStateMachine &fsm)
EPStateMachine(log4cplus::Logger &logger)
void reset(double vett[256])
log4cplus::Logger & logger_