CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/src/EventFilter/Utilities/src/EPStateMachine.cc

Go to the documentation of this file.
00001 #include "EventFilter/Utilities/interface/EPStateMachine.h"
00002 #include "xoap/SOAPEnvelope.h"
00003 #include "xoap/SOAPBody.h"
00004 
00005 namespace evf{
00006 
00007 
00008   EPStateMachine::EPStateMachine(log4cplus::Logger &logger) : logger_(logger)
00009   {
00010   }
00011 
00012   xoap::MessageReference EPStateMachine::processFSMCommand(const std::string cmdName)
00013     throw (xoap::exception::Exception)
00014   {
00015     try
00016       {
00017         // Change state, calling the appropriate action method
00018         toolbox::Event::Reference evtRef(new toolbox::Event(cmdName, this));
00019         fireEvent(evtRef);
00020         return createFSMReplyMsg(cmdName, stateName_);
00021       }
00022     catch(xcept::Exception e)
00023       {
00024         XCEPT_RETHROW(xoap::exception::Exception,
00025                       "Failed to process " + cmdName, e);
00026       }
00027     catch(...)
00028       {
00029         XCEPT_RAISE(xoap::exception::Exception,
00030                     "Failed to process " + cmdName + " - Unknown exception");
00031       }
00032   }
00033   xoap::MessageReference EPStateMachine::createFSMReplyMsg(const std::string cmd, 
00034                                                            const std::string state)
00035   {
00036     xoap::MessageReference msg = xoap::createMessage();
00037     xoap::SOAPEnvelope     env   = msg->getSOAPPart().getEnvelope();
00038     xoap::SOAPBody         body  = env.getBody();
00039     std::string            rStr  = cmd + "Response";
00040     xoap::SOAPName         rName = env.createName(rStr,"xdaq",XDAQ_NS_URI);
00041     xoap::SOAPBodyElement  rElem = body.addBodyElement(rName);
00042     xoap::SOAPName       sName = env.createName("state","xdaq",XDAQ_NS_URI);
00043     xoap::SOAPElement      sElem = rElem.addChildElement(sName);
00044     xoap::SOAPName   aName = env.createName("stateName","xdaq",XDAQ_NS_URI);
00045   
00046   
00047     sElem.addAttribute(aName, state);
00048   
00049     return msg;
00050   }
00051 } //end namespace evf