6 #include "Tests/SimpleSoap/include/SimpleSoap.h"
7 #include <xdaq/NamespaceURI.h>
8 #include <xoap/Method.h>
10 #include "Utilities/MacroUtilities/include/Macro.h"
11 #include "Utilities/SOAPUtilities/include/SOAPUtilities.h"
21 xgi::bind(
this, &SimpleSoap::Default,
"Default");
22 xgi::bind(
this, &SimpleSoap::StateMachineXgiHandler,
"StateMachineXgiHandler");
24 xoap::bind(
this, &SimpleSoap::Start,
"Start", XDAQ_NS_URI);
25 fsm_.addState(
'I',
"Initial",
this, &SimpleSoap::stateInitial);
26 fsm_.addState(
'H',
"Halted",
this, &SimpleSoap::stateHalted);
27 fsm_.addStateTransition(
'I',
'H',
"Initialize");
31 void SimpleSoap::Default(xgi::Input* in, xgi::Output* out)
33 std::string url =
"/" + getApplicationDescriptor()->getURN();
34 std::cout << __COUT_HDR_FL__ << url << std::endl;
36 *out << cgicc::HTMLDoctype(cgicc::HTMLDoctype::eStrict) << std::endl;
37 *out << cgicc::html().set(
"lang",
"en").set(
"dir",
"ltr") << std::endl;
38 *out << cgicc::title(
"Simple button page") << std::endl;
39 *out <<
"<body>" << std::endl;
40 *out <<
" <form name=\"input\" method=\"get\" action=\"" << url
41 <<
"/StateMachineXgiHandler"
42 <<
"\" enctype=\"multipart/form-data\">" << std::endl;
43 *out <<
" <p align=\"left\"><input type=\"submit\" name=\"StateInput\" "
44 "value=\"PushStart\"/></p>"
46 *out <<
" </form>" << std::endl;
47 *out <<
" <form name=\"input\" method=\"get\" action=\"" << url <<
"/Start"
48 <<
"\" enctype=\"multipart/form-data\">" << std::endl;
49 *out <<
" <p align=\"left\"><input type=\"submit\" name=\"StateInput\" "
50 "value=\"Start\"/></p>"
52 *out <<
" </form>" << std::endl;
53 *out <<
"</body>" << std::endl;
57 void SimpleSoap::StateMachineXgiHandler(xgi::Input* in, xgi::Output* out)
60 std::string Command = cgi.getElement(
"StateInput")->getValue();
62 if(Command ==
"PushStart")
64 std::cout << __COUT_HDR_FL__ <<
"Got start" << std::endl;
65 xoap::MessageReference msg = SOAPUtilities::makeSOAPMessageReference(
"Start");
66 xoap::MessageReference reply = Start(msg);
68 if(receive(reply) ==
"StartDone")
69 std::cout << __COUT_HDR_FL__ <<
"Everything started correctly!" << std::endl
74 <<
"All underlying Supervisors could not be started by browser button!"
78 else if(Command ==
"Start")
82 std::set<xdaq::ApplicationDescriptor*> set_SimpleSoap =
83 getApplicationContext()
85 ->getApplicationGroup(
"daq")
86 ->getApplicationDescriptors(
"SimpleSoap::SimpleSoap");
88 for(std::set<xdaq::ApplicationDescriptor*>::iterator i_set_SimpleSoap =
89 set_SimpleSoap.begin();
90 i_set_SimpleSoap != set_SimpleSoap.end();
95 std::string sReply = send(*i_set_SimpleSoap, Command.c_str());
97 if(sReply ==
"StartDone")
98 std::cout << __COUT_HDR_FL__ <<
"Everything started correctly!"
102 std::cout << __COUT_HDR_FL__
103 <<
"All underlying Supervisors could not be started by "
108 catch(xdaq::exception::Exception& e)
110 std::cout << __COUT_HDR_FL__
112 <<
" Couldn't start sending a msg" << std::endl;
118 std::cout << __COUT_HDR_FL__ <<
"Don't understand the command: " << Command
122 this->Default(in, out);
126 xoap::MessageReference SimpleSoap::Start(xoap::MessageReference msg)
128 std::cout << __COUT_HDR_FL__ <<
"Starting" << std::endl;
129 return SOAPUtilities::makeSOAPMessageReference(
"StartDone");
133 void SimpleSoap::stateInitial(toolbox::fsm::FiniteStateMachine& fsm)
135 std::cout << __COUT_HDR_FL__ <<
"--- SimpleWeb is in its Initial state ---"
137 state_ = fsm_.getStateName(fsm_.getCurrentState());
145 void SimpleSoap::stateHalted(toolbox::fsm::FiniteStateMachine& fsm)
147 std::cout << __COUT_HDR_FL__ <<
"--- SimpleWeb is in its Halted state ---"
149 state_ = fsm_.getStateName(fsm_.getCurrentState());