CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
dqm::StateMachine Class Referenceabstract

#include <StateMachine.h>

Inheritance diagram for dqm::StateMachine:

Public Member Functions

virtual void configureAction (toolbox::Event::Reference e)=0 throw (toolbox::fsm::exception::Exception)
 transition methods to be implemented by the application More...
 
virtual void enableAction (toolbox::Event::Reference e)=0 throw (toolbox::fsm::exception::Exception)
 
xoap::MessageReference fireEvent (xoap::MessageReference msg) throw (xoap::exception::Exception)
 
virtual void haltAction (toolbox::Event::Reference e)=0 throw (toolbox::fsm::exception::Exception)
 
virtual void nullAction (toolbox::Event::Reference e)=0 throw (toolbox::fsm::exception::Exception)
 
virtual void resumeAction (toolbox::Event::Reference e)=0 throw (toolbox::fsm::exception::Exception)
 
 StateMachine (xdaq::ApplicationStub *s)
 
virtual void stopAction (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception)
 
virtual void suspendAction (toolbox::Event::Reference e)=0 throw (toolbox::fsm::exception::Exception)
 
virtual ~StateMachine ()
 

Protected Member Functions

void bind (std::string)
 
void Default (xgi::Input *in, xgi::Output *out) throw (xgi::exception::Exception)
 
void dispatch (xgi::Input *in, xgi::Output *out) throw (xgi::exception::Exception)
 
xdata::String * stateName ()
 

Private Member Functions

void failurePage (xgi::Output *out, xgi::exception::Exception &e) throw (xgi::exception::Exception)
 
void statePage (xgi::Output *out) throw (xgi::exception::Exception)
 
void webConfigure (xgi::Input *in) throw (xgi::exception::Exception)
 
void webEnable (xgi::Input *in) throw (xgi::exception::Exception)
 
void webHalt (xgi::Input *in) throw (xgi::exception::Exception)
 
void webResume (xgi::Input *in) throw (xgi::exception::Exception)
 
void webSuspend (xgi::Input *in) throw (xgi::exception::Exception)
 

Private Attributes

evf::EPStateMachine fsm_
 
std::string page_
 
xgi::WSM wsm_
 

Detailed Description

Definition at line 18 of file StateMachine.h.

Constructor & Destructor Documentation

StateMachine::StateMachine ( xdaq::ApplicationStub *  s)

Definition at line 15 of file StateMachine.cc.

References dispatch(), failurePage(), fsm_, evf::EPStateMachine::init(), statePage(), webConfigure(), webEnable(), webHalt(), webResume(), webSuspend(), and wsm_.

15  :
16  xdaq::Application(s),
17  fsm_(getApplicationLogger())
18 {
19  wsm_.addState('H', "Halted" , this, &StateMachine::statePage);
20  wsm_.addState('R', "Ready" , this, &StateMachine::statePage);
21  wsm_.addState('E', "Enabled" , this, &StateMachine::statePage);
22  wsm_.addState('S', "Suspended", this, &StateMachine::statePage);
23 
24  // Define FSM transitions
25  wsm_.addStateTransition('H', 'R', "Configure", this,
27  wsm_.addStateTransition('R', 'E', "Enable", this,
29  wsm_.addStateTransition('E', 'S', "Suspend", this,
31  wsm_.addStateTransition('S', 'E', "Resume", this,
33  wsm_.addStateTransition('H', 'H', "Halt", this,
35  wsm_.addStateTransition('R', 'H', "Halt", this,
37  wsm_.addStateTransition('E', 'H', "Halt", this,
39  wsm_.addStateTransition('S', 'H', "Halt", this,
41 
42  wsm_.setInitialState('H');
43 
45  xgi::bind(this, &StateMachine::dispatch, "dispatch");
46 }
void failurePage(xgi::Output *out, xgi::exception::Exception &e)
void webResume(xgi::Input *in)
Definition: StateMachine.h:86
void statePage(xgi::Output *out)
Definition: StateMachine.cc:83
void webSuspend(xgi::Input *in)
Definition: StateMachine.h:81
void webEnable(xgi::Input *in)
Definition: StateMachine.h:76
void webHalt(xgi::Input *in)
Definition: StateMachine.h:91
void dispatch(xgi::Input *in, xgi::Output *out)
Definition: StateMachine.h:48
evf::EPStateMachine fsm_
Definition: StateMachine.h:100
void webConfigure(xgi::Input *in)
Definition: StateMachine.h:71
virtual dqm::StateMachine::~StateMachine ( )
inlinevirtual

Definition at line 24 of file StateMachine.h.

24 {}

Member Function Documentation

void StateMachine::bind ( std::string  page)
protected

Definition at line 48 of file StateMachine.cc.

References Default(), MainPageGenerator::page, and page_.

49 {
50  page_ = page;
51  xgi::bind(this, &StateMachine::Default, page);
52 }
void Default(xgi::Input *in, xgi::Output *out)
Definition: StateMachine.h:43
std::string page_
Definition: StateMachine.h:101
virtual void dqm::StateMachine::configureAction ( toolbox::Event::Reference  e)
throw (toolbox::fsm::exception::Exception
)
pure virtual

transition methods to be implemented by the application

void dqm::StateMachine::Default ( xgi::Input in,
xgi::Output out 
)
throw (xgi::exception::Exception
)
inlineprotected

Definition at line 43 of file StateMachine.h.

References dbtoconf::out, and wsm_.

Referenced by bind().

44  {
45  wsm_.displayPage(out);
46  }
tuple out
Definition: dbtoconf.py:99
void dqm::StateMachine::dispatch ( xgi::Input in,
xgi::Output out 
)
throw (xgi::exception::Exception
)
inlineprotected

Definition at line 48 of file StateMachine.h.

References fsm_, recoMuon::in, dbtoconf::out, evf::EPStateMachine::processFSMCommand(), and wsm_.

Referenced by StateMachine().

49  {
50  cgicc::Cgicc cgi(in);
51  cgi.getEnvironment();
52  cgicc::const_form_iterator stateInputElement = cgi.getElement("StateInput");
53  std::string stateInput = (*stateInputElement).getValue();
54  wsm_.fireEvent(stateInput,in,out);
55  fsm_.processFSMCommand(stateInput);
56  }
tuple out
Definition: dbtoconf.py:99
xoap::MessageReference processFSMCommand(const std::string cmdName)
evf::EPStateMachine fsm_
Definition: StateMachine.h:100
virtual void dqm::StateMachine::enableAction ( toolbox::Event::Reference  e)
throw (toolbox::fsm::exception::Exception
)
pure virtual
void StateMachine::failurePage ( xgi::Output out,
xgi::exception::Exception &  e 
)
throw (xgi::exception::Exception
)
private

Definition at line 151 of file StateMachine.cc.

References scaleCards::br, alignCSCRings::e, cmsCodeRulesChecker::html, dbtoconf::out, and relmon_authenticated_wget::url.

Referenced by StateMachine().

153 {
154  if(out)
155  {
156  *out << cgicc::HTMLDoctype(cgicc::HTMLDoctype::eStrict) << std::endl;
157  *out << cgicc::html().set("lang", "en").set("dir","ltr") << std::endl;
158 
159  xgi::Utils::getPageHeader(*out, "WebStateMachine Home", "Failure");
160 
161 
162  *out << cgicc::br() << e.what() << cgicc::br() << std::endl;
163  std::string url = "/";
164  url += getApplicationDescriptor()->getURN();
165 
166  *out << cgicc::br() << "<a href=\"" << url << "\">" << "retry" << "</a>" << cgicc::br() << std::endl;
167 
168  xgi::Utils::getPageFooter(*out);
169 
170  }
171 }
tuple br
Definition: scaleCards.py:54
tuple out
Definition: dbtoconf.py:99
xoap::MessageReference StateMachine::fireEvent ( xoap::MessageReference  msg)
throw (xoap::exception::Exception
)

Definition at line 54 of file StateMachine.cc.

References edmPickEvents::command, web.browse_db::env, edm::hlt::Exception, i, lumiQueryAPI::msg, and python.Node::node.

56 {
57  xoap::SOAPPart part = msg->getSOAPPart();
58  xoap::SOAPEnvelope env = part.getEnvelope();
59  xoap::SOAPBody body = env.getBody();
60  DOMNode *node = body.getDOMNode();
61  DOMNodeList *bodyList = node->getChildNodes();
62  DOMNode *command = 0;
63  std::string commandName;
64 
65  for (unsigned int i = 0; i < bodyList->getLength(); i++)
66  {
67  command = bodyList->item(i);
68 
69  if(command->getNodeType() == DOMNode::ELEMENT_NODE)
70  {
71  commandName = xoap::XMLCh2String(command->getLocalName());
72  wsm_.fireEvent(commandName,0,0);
73  return fsm_.processFSMCommand(commandName);
74  }
75  }
76 
77  XCEPT_RAISE(xoap::exception::Exception, "Command not found");
78 }
int i
Definition: DBlmapReader.cc:9
tuple node
Definition: Node.py:50
xoap::MessageReference processFSMCommand(const std::string cmdName)
part
Definition: HCALResponse.h:21
evf::EPStateMachine fsm_
Definition: StateMachine.h:100
virtual void dqm::StateMachine::haltAction ( toolbox::Event::Reference  e)
throw (toolbox::fsm::exception::Exception
)
pure virtual
virtual void dqm::StateMachine::nullAction ( toolbox::Event::Reference  e)
throw (toolbox::fsm::exception::Exception
)
pure virtual
virtual void dqm::StateMachine::resumeAction ( toolbox::Event::Reference  e)
throw (toolbox::fsm::exception::Exception
)
pure virtual
xdata::String* dqm::StateMachine::stateName ( )
inlineprotected

Definition at line 58 of file StateMachine.h.

References fsm_, and evf::EPStateMachine::stateName_.

58 {return &fsm_.stateName_;}
xdata::String stateName_
evf::EPStateMachine fsm_
Definition: StateMachine.h:100
void StateMachine::statePage ( xgi::Output out)
throw (xgi::exception::Exception
)
private

Definition at line 83 of file StateMachine.cc.

References cmsCodeRulesChecker::html, i, LaserDQM_cfg::input, dbtoconf::out, and relmon_authenticated_wget::url.

Referenced by StateMachine().

85 {
86  if(out)
87  {
88  std::string url = "/";
89  url += getApplicationDescriptor()->getURN();
90  std::string purl = url + "/" + page_;
91 
92  *out << cgicc::HTMLDoctype(cgicc::HTMLDoctype::eStrict) << std::endl;
93  *out << cgicc::html().set("lang", "en").set("dir","ltr") << std::endl;
94  *out << "<head>" << std::endl;
95  *out << "<META HTTP-EQUIV=refresh CONTENT=\"30; URL=";
96  *out << purl << "\">" << std::endl;
97  *out << "<META HTTP-EQUIV=Window-target CONTENT=\"_self\">" << std::endl;
98  *out << "<title> " << "fsm" << "</title>" << std::endl;
99  *out << "</head>" << std::endl;
100  *out << "<body>" << std::endl;
101  // xgi::Utils::getPageHeader(*out, "StateMachine", wsm_.getStateName(wsm_.getCurrentState()));
102 
103  url += "/dispatch";
104 
105  // display FSM
106  // cout << "current state " << wsm_.getCurrentState() << endl;
107  // cout << "possible commands" << endl;
108  std::set<std::string>::iterator i;
109  std::set<std::string> possibleInputs = wsm_.getInputs(wsm_.getCurrentState());
110  std::set<std::string> allInputs = wsm_.getInputs();
111 
112  // for ( i = possibleInputs.begin(); i != possibleInputs.end(); i++)
113  // cout << (*i) << endl;
114 
115  *out << cgicc::h3("Finite State Machine").set("style", "font-family: arial") << std::endl;
116  *out << "<table border cellpadding=10 cellspacing=0>" << std::endl;
117  *out << "<tr>" << std::endl;
118  *out << "<th>" << wsm_.getStateName(wsm_.getCurrentState()) << "</th>" << std::endl;
119  *out << "</tr>" << std::endl;
120  *out << "<tr>" << std::endl;
121 
122  for ( i = allInputs.begin(); i != allInputs.end(); i++)
123  {
124  *out << "<td>";
125  *out << cgicc::form().set("method","post").set("target","_self").set("action", url).set("enctype","multipart/form-data") << std::endl;
126 
127  if ( possibleInputs.find(*i) != possibleInputs.end() )
128  {
129  *out << cgicc::input().set("type", "submit").set("name", "StateInput").set("value", (*i) );
130  }
131  else
132  {
133  *out << cgicc::input() .set("type", "submit").set("name", "StateInput").set("value", (*i) ).set("disabled", "true");
134  }
135 
136  *out << cgicc::form();
137  *out << "</td>" << std::endl;
138  }
139 
140  *out << "</tr>" << std::endl;
141  *out << "</table>" << std::endl;
142  *out << cgicc::html();
143  //
144  // xgi::Utils::getPageFooter(*out);
145  }
146 }
int i
Definition: DBlmapReader.cc:9
std::string page_
Definition: StateMachine.h:101
tuple out
Definition: dbtoconf.py:99
virtual void dqm::StateMachine::stopAction ( toolbox::Event::Reference  e)
throw (toolbox::fsm::exception::Exception
)
inlinevirtual

Definition at line 31 of file StateMachine.h.

31 {}; //just a noop to keep the compiler happy for the moment
virtual void dqm::StateMachine::suspendAction ( toolbox::Event::Reference  e)
throw (toolbox::fsm::exception::Exception
)
pure virtual
void dqm::StateMachine::webConfigure ( xgi::Input in)
throw (xgi::exception::Exception
)
inlineprivate

Web Events that trigger state changes

Definition at line 71 of file StateMachine.h.

Referenced by StateMachine().

72  {
73 
74  }
void dqm::StateMachine::webEnable ( xgi::Input in)
throw (xgi::exception::Exception
)
inlineprivate

Definition at line 76 of file StateMachine.h.

Referenced by StateMachine().

77  {
78 
79 
80  }
void dqm::StateMachine::webHalt ( xgi::Input in)
throw (xgi::exception::Exception
)
inlineprivate

Definition at line 91 of file StateMachine.h.

Referenced by StateMachine().

92  {
93 
94 
95  }
void dqm::StateMachine::webResume ( xgi::Input in)
throw (xgi::exception::Exception
)
inlineprivate

Definition at line 86 of file StateMachine.h.

Referenced by StateMachine().

87  {
88 
89 
90  }
void dqm::StateMachine::webSuspend ( xgi::Input in)
throw (xgi::exception::Exception
)
inlineprivate

Definition at line 81 of file StateMachine.h.

Referenced by StateMachine().

82  {
83 
84 
85  }

Member Data Documentation

evf::EPStateMachine dqm::StateMachine::fsm_
private

Definition at line 100 of file StateMachine.h.

Referenced by dispatch(), StateMachine(), and stateName().

std::string dqm::StateMachine::page_
private

Definition at line 101 of file StateMachine.h.

Referenced by bind().

xgi::WSM dqm::StateMachine::wsm_
private

Definition at line 99 of file StateMachine.h.

Referenced by Default(), dispatch(), and StateMachine().