6 #include "Tests/SimpleSoap/include/SimpleSoap.h"
7 #include "Utilities/MacroUtilities/include/Macro.h"
8 #include "Utilities/SOAPUtilities/include/SOAPUtilities.h"
9 #include <xoap/Method.h>
10 #include <xdaq/NamespaceURI.h>
22 xgi::bind(
this,&SimpleSoap::Default,
"Default" );
23 xgi::bind(
this,&SimpleSoap::StateMachineXgiHandler,
"StateMachineXgiHandler");
25 xoap::bind(
this, &SimpleSoap::Start,
"Start", XDAQ_NS_URI );
26 fsm_.addState(
'I',
"Initial",
this, &SimpleSoap::stateInitial);
27 fsm_.addState(
'H',
"Halted",
this, &SimpleSoap::stateHalted);
28 fsm_.addStateTransition(
'I',
'H',
"Initialize");
33 void SimpleSoap::Default(xgi::Input * in,
36 std::string url=
"/"+getApplicationDescriptor()->getURN();
37 std::cout << __COUT_HDR_FL__ << url << std::endl;
39 *out << cgicc::HTMLDoctype(cgicc::HTMLDoctype::eStrict) << std::endl;
40 *out << cgicc::html().set(
"lang",
"en").set(
"dir",
"ltr") << std::endl;
41 *out << cgicc::title(
"Simple button page") << std::endl;
42 *out<<
"<body>"<<std::endl;
43 *out<<
" <form name=\"input\" method=\"get\" action=\""<<url<<
"/StateMachineXgiHandler"<<
"\" enctype=\"multipart/form-data\">" <<std::endl;
44 *out<<
" <p align=\"left\"><input type=\"submit\" name=\"StateInput\" value=\"PushStart\"/></p>" <<std::endl;
45 *out<<
" </form>" <<std::endl;
46 *out<<
" <form name=\"input\" method=\"get\" action=\""<<url<<
"/Start"<<
"\" enctype=\"multipart/form-data\">" <<std::endl;
47 *out<<
" <p align=\"left\"><input type=\"submit\" name=\"StateInput\" value=\"Start\"/></p>" <<std::endl;
48 *out<<
" </form>" <<std::endl;
49 *out<<
"</body>"<<std::endl;
53 void SimpleSoap::StateMachineXgiHandler(xgi::Input * in, xgi::Output * out )
57 std::string Command=cgi.getElement(
"StateInput")->getValue();
59 if (Command==
"PushStart")
61 std::cout << __COUT_HDR_FL__ <<
"Got start" << std::endl;
62 xoap::MessageReference msg = SOAPUtilities::makeSOAPMessageReference(
"Start");
63 xoap::MessageReference reply = Start(msg);
65 if (receive(reply) ==
"StartDone")
66 std::cout << __COUT_HDR_FL__ <<
"Everything started correctly!" <<std::endl << std::endl;
68 std::cout << __COUT_HDR_FL__ <<
"All underlying Supervisors could not be started by browser button!"<<std::endl << std::endl;
70 else if (Command ==
"Start")
73 std::set<xdaq::ApplicationDescriptor*> set_SimpleSoap = getApplicationContext()->getDefaultZone()->getApplicationGroup(
"daq")->getApplicationDescriptors(
"SimpleSoap::SimpleSoap");
75 for (std::set<xdaq::ApplicationDescriptor*>::iterator i_set_SimpleSoap=set_SimpleSoap.begin(); i_set_SimpleSoap!=set_SimpleSoap.end(); ++i_set_SimpleSoap)
79 std::string sReply=send(*i_set_SimpleSoap, Command.c_str());
81 if (sReply ==
"StartDone")
82 std::cout << __COUT_HDR_FL__ <<
"Everything started correctly!" <<std::endl << std::endl;
84 std::cout << __COUT_HDR_FL__ <<
"All underlying Supervisors could not be started by browser button!"<<std::endl << std::endl;
86 catch (xdaq::exception::Exception& e)
88 std::cout << __COUT_HDR_FL__
90 <<
" Couldn't start sending a msg" << std::endl;
96 std::cout << __COUT_HDR_FL__ <<
"Don't understand the command: " << Command << std::endl;
99 this->Default(in, out);
103 xoap::MessageReference SimpleSoap::Start (xoap::MessageReference msg)
105 std::cout << __COUT_HDR_FL__ <<
"Starting" << std::endl;
106 return SOAPUtilities::makeSOAPMessageReference(
"StartDone");
110 void SimpleSoap::stateInitial (toolbox::fsm::FiniteStateMachine & fsm)
112 std::cout << __COUT_HDR_FL__ <<
"--- SimpleWeb is in its Initial state ---" << std::endl;
113 state_ = fsm_.getStateName (fsm_.getCurrentState());
120 void SimpleSoap::stateHalted (toolbox::fsm::FiniteStateMachine & fsm)
122 std::cout << __COUT_HDR_FL__ <<
"--- SimpleWeb is in its Halted state ---" << std::endl;
123 state_ = fsm_.getStateName (fsm_.getCurrentState());