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"
18 SimpleSoap::SimpleSoap(xdaq::ApplicationStub* s)
21 xgi::bind(
this, &SimpleSoap::Default,
"Default");
22 xgi::bind(
this, &SimpleSoap::StateMachineXgiHandler,
"StateMachineXgiHandler");
26 RunControlStateMachine::START_TRANSITION_NAME,
29 'I', RunControlStateMachine::INITIAL_STATE_NAME,
this, &SimpleSoap::stateInitial);
31 'H', RunControlStateMachine::HALTED_STATE_NAME,
this, &SimpleSoap::stateHalted);
32 fsm_.addStateTransition(
'I',
'H', RunControlStateMachine::INIT_TRANSITION_NAME);
36 void SimpleSoap::Default(xgi::Input* in, xgi::Output* out)
38 std::string url =
"/" + getApplicationDescriptor()->getURN();
39 std::cout << __COUT_HDR_FL__ << url << std::endl;
41 *out << cgicc::HTMLDoctype(cgicc::HTMLDoctype::eStrict) << std::endl;
42 *out << cgicc::html().set(
"lang",
"en").set(
"dir",
"ltr") << std::endl;
43 *out << cgicc::title(
"Simple button page") << std::endl;
44 *out <<
"<body>" << std::endl;
45 *out <<
" <form name=\"input\" method=\"get\" action=\"" << url
46 <<
"/StateMachineXgiHandler"
47 <<
"\" enctype=\"multipart/form-data\">" << std::endl;
48 *out <<
" <p align=\"left\"><input type=\"submit\" name=\"StateInput\" "
49 "value=\"PushStart\"/></p>"
51 *out <<
" </form>" << std::endl;
52 *out <<
" <form name=\"input\" method=\"get\" action=\"" << url <<
"/Start"
53 <<
"\" enctype=\"multipart/form-data\">" << std::endl;
54 *out <<
" <p align=\"left\"><input type=\"submit\" name=\"StateInput\" "
55 "value=\"Start\"/></p>"
57 *out <<
" </form>" << std::endl;
58 *out <<
"</body>" << std::endl;
62 void SimpleSoap::StateMachineXgiHandler(xgi::Input* in, xgi::Output* out)
65 std::string Command = cgi.getElement(
"StateInput")->getValue();
67 if(Command ==
"PushStart")
69 std::cout << __COUT_HDR_FL__ <<
"Got start" << std::endl;
70 xoap::MessageReference msg = SOAPUtilities::makeSOAPMessageReference(
"Start");
71 xoap::MessageReference reply = Start(msg);
73 if(receive(reply) ==
"StartDone")
74 std::cout << __COUT_HDR_FL__ <<
"Everything started correctly!" << std::endl
79 <<
"All underlying Supervisors could not be started by browser button!"
83 else if(Command ==
"Start")
87 std::set<xdaq::ApplicationDescriptor*> set_SimpleSoap =
88 getApplicationContext()
90 ->getApplicationGroup(
"daq")
91 ->getApplicationDescriptors(
"SimpleSoap::SimpleSoap");
93 for(std::set<xdaq::ApplicationDescriptor*>::iterator i_set_SimpleSoap =
94 set_SimpleSoap.begin();
95 i_set_SimpleSoap != set_SimpleSoap.end();
100 std::string sReply =
send(*i_set_SimpleSoap, Command.c_str());
102 if(sReply ==
"StartDone")
103 std::cout << __COUT_HDR_FL__ <<
"Everything started correctly!"
107 std::cout << __COUT_HDR_FL__
108 <<
"All underlying Supervisors could not be started by "
113 catch(xdaq::exception::Exception& e)
115 std::cout << __COUT_HDR_FL__
117 <<
" Couldn't start sending a msg" << std::endl;
123 std::cout << __COUT_HDR_FL__ <<
"Don't understand the command: " << Command
127 this->Default(in, out);
131 xoap::MessageReference SimpleSoap::Start(xoap::MessageReference msg)
133 std::cout << __COUT_HDR_FL__ <<
"Starting" << std::endl;
134 return SOAPUtilities::makeSOAPMessageReference(
"StartDone");
138 void SimpleSoap::stateInitial(toolbox::fsm::FiniteStateMachine& fsm)
140 std::cout << __COUT_HDR_FL__ <<
"--- SimpleWeb is in its Initial state ---"
142 state_ = fsm_.getStateName(fsm_.getCurrentState());
150 void SimpleSoap::stateHalted(toolbox::fsm::FiniteStateMachine& fsm)
152 std::cout << __COUT_HDR_FL__ <<
"--- SimpleWeb is in its Halted state ---"
154 state_ = fsm_.getStateName(fsm_.getCurrentState());
std::string send(XDAQ_CONST_CALL xdaq::ApplicationDescriptor *d, xoap::MessageReference message)