CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EPStateMachine.cc
Go to the documentation of this file.
2 #include "xoap/SOAPEnvelope.h"
3 #include "xoap/SOAPBody.h"
4 
5 namespace evf{
6 
7 
8  EPStateMachine::EPStateMachine(log4cplus::Logger &logger) : logger_(logger)
9  {
10  }
11 
12  xoap::MessageReference EPStateMachine::processFSMCommand(const std::string cmdName)
14  {
15  try
16  {
17  // Change state, calling the appropriate action method
18  toolbox::Event::Reference evtRef(new toolbox::Event(cmdName, this));
19  fireEvent(evtRef);
20  return createFSMReplyMsg(cmdName, stateName_);
21  }
22  catch(xcept::Exception e)
23  {
24  XCEPT_RETHROW(xoap::exception::Exception,
25  "Failed to process " + cmdName, e);
26  }
27  catch(...)
28  {
29  XCEPT_RAISE(xoap::exception::Exception,
30  "Failed to process " + cmdName + " - Unknown exception");
31  }
32  }
33  xoap::MessageReference EPStateMachine::createFSMReplyMsg(const std::string cmd,
34  const std::string state)
35  {
36  xoap::MessageReference msg = xoap::createMessage();
37  xoap::SOAPEnvelope env = msg->getSOAPPart().getEnvelope();
38  xoap::SOAPBody body = env.getBody();
39  std::string rStr = cmd + "Response";
40  xoap::SOAPName rName = env.createName(rStr,"xdaq",XDAQ_NS_URI);
41  xoap::SOAPBodyElement rElem = body.addBodyElement(rName);
42  xoap::SOAPName sName = env.createName("state","xdaq",XDAQ_NS_URI);
43  xoap::SOAPElement sElem = rElem.addChildElement(sName);
44  xoap::SOAPName aName = env.createName("stateName","xdaq",XDAQ_NS_URI);
45 
46 
47  sElem.addAttribute(aName, state);
48 
49  return msg;
50  }
51 } //end namespace evf
std::ostream & logger()
Definition: fwLog.cc:41
xoap::MessageReference createFSMReplyMsg(const std::string cmd, const std::string state)
string cmd
Definition: asciidump.py:19
xoap::MessageReference processFSMCommand(const std::string cmdName)
char state
Definition: procUtils.cc:75
EPStateMachine(log4cplus::Logger &logger)