1 #include "otsdaq/CoreSupervisors/CoreSupervisorBase.h"
9 const std::string CoreSupervisorBase::WORK_LOOP_DONE =
"Done";
10 const std::string CoreSupervisorBase::WORK_LOOP_WORKING =
"Working";
13 CoreSupervisorBase::CoreSupervisorBase(xdaq::ApplicationStub* stub)
14 : xdaq::Application(stub)
21 , stateMachineWorkLoopManager_(toolbox::task::bind(this, &
CoreSupervisorBase::stateMachineThread,
"StateMachine"))
22 , stateMachineSemaphore_(toolbox::BSem::FULL)
25 __SUP_COUT__ <<
"Constructor." << __E__;
29 xgi::bind(
this, &CoreSupervisorBase::defaultPageWrapper,
"Default");
30 xgi::bind(
this, &CoreSupervisorBase::requestWrapper,
"Request");
32 xgi::bind(
this, &CoreSupervisorBase::stateMachineXgiHandler,
"StateMachineXgiHandler");
34 xoap::bind(
this, &CoreSupervisorBase::stateMachineStateRequest,
"StateMachineStateRequest", XDAQ_NS_URI);
35 xoap::bind(
this, &CoreSupervisorBase::stateMachineErrorMessageRequest,
"StateMachineErrorMessageRequest", XDAQ_NS_URI);
36 xoap::bind(
this, &CoreSupervisorBase::workLoopStatusRequestWrapper,
"WorkLoopStatusRequest", XDAQ_NS_URI);
37 xoap::bind(
this, &CoreSupervisorBase::applicationStatusRequest,
"ApplicationStatusRequest", XDAQ_NS_URI);
40 __SUP_COUT__ <<
"Constructed." << __E__;
44 CoreSupervisorBase::~CoreSupervisorBase(
void)
46 __SUP_COUT__ <<
"Destructor." << __E__;
48 __SUP_COUT__ <<
"Destructed." << __E__;
52 void CoreSupervisorBase::destroy(
void)
54 __SUP_COUT__ <<
"Destroying..." << __E__;
55 for(
auto& it : theStateMachineImplementation_)
57 theStateMachineImplementation_.clear();
62 void CoreSupervisorBase::defaultPageWrapper(xgi::Input* in, xgi::Output* out) {
return defaultPage(in, out); }
65 void CoreSupervisorBase::defaultPage(xgi::Input* , xgi::Output* out)
67 __SUP_COUT__ <<
"Supervisor class " << supervisorClass_ << __E__;
69 std::stringstream pagess;
70 pagess <<
"/WebPath/html/" << supervisorClassNoNamespace_ <<
".html?urn=" << this->getApplicationDescriptor()->getLocalId();
72 __SUP_COUT__ <<
"Default page = " << pagess.str() << __E__;
74 *out <<
"<!DOCTYPE HTML><html lang='en'><frameset col='100%' row='100%'><frame src='" << pagess.str() <<
"'></frameset></html>";
80 void CoreSupervisorBase::requestWrapper(xgi::Input* in, xgi::Output* out)
82 cgicc::Cgicc cgiIn(in);
83 std::string requestType = CgiDataUtilities::getData(cgiIn,
"RequestType");
91 CorePropertySupervisorBase::getRequestUserInfo(userInfo);
93 if(!theRemoteWebUsers_.xmlRequestToGateway(cgiIn, out, &xmlOut, CorePropertySupervisorBase::allSupervisorInfo_, userInfo))
96 if(requestType ==
"GetUserDisplayName")
98 __COUTV__(userInfo.displayName_);
99 xmlOut.addTextElementToData(
"DisplayName", userInfo.displayName_);
100 xmlOut.outputXmlDocument((std::ostringstream*)out,
false , !userInfo.NoXmlWhiteSpace_ );
108 if(!userInfo.automatedCommand_)
109 __SUP_COUT__ <<
"requestType: " << requestType << __E__;
111 if(userInfo.NonXMLRequestType_)
115 nonXmlRequest(requestType, cgiIn, *out, userInfo);
117 catch(
const std::runtime_error& e)
119 __SUP_SS__ <<
"An error was encountered handling requestType '" << requestType <<
"':" << e.what() << __E__;
120 __SUP_COUT_ERR__ <<
"\n" << ss.str();
121 __SUP_MOUT_ERR__ <<
"\n" << ss.str();
125 __SUP_SS__ <<
"An unknown error was encountered handling requestType '" << requestType <<
".' "
126 <<
"Please check the printouts to debug." << __E__;
127 __SUP_COUT_ERR__ <<
"\n" << ss.str();
128 __SUP_MOUT_ERR__ <<
"\n" << ss.str();
137 request(requestType, cgiIn, xmlOut, userInfo);
139 catch(
const std::runtime_error& e)
141 __SUP_SS__ <<
"An error was encountered handling requestType '" << requestType <<
"':" << e.what() << __E__;
142 __SUP_COUT_ERR__ <<
"\n" << ss.str();
143 xmlOut.addTextElementToData(
"Error", ss.str());
147 __SUP_SS__ <<
"An unknown error was encountered handling requestType '" << requestType <<
".' "
148 <<
"Please check the printouts to debug." << __E__;
149 __SUP_COUT_ERR__ <<
"\n" << ss.str();
150 xmlOut.addTextElementToData(
"Error", ss.str());
155 unsigned int occurance = 0;
156 std::string err = xmlOut.getMatchingValue(
"Error", occurance++);
159 __SUP_COUT_ERR__ <<
"'" << requestType <<
"' ERROR encountered: " << err << __E__;
160 err = xmlOut.getMatchingValue(
"Error", occurance++);
165 xmlOut.outputXmlDocument((std::ostringstream*)out,
false , !userInfo.NoXmlWhiteSpace_ );
176 __SUP_SS__ <<
"This is the empty Core Supervisor request. Supervisors should "
177 "override this function."
179 __SUP_COUT__ << ss.str();
180 xmlOut.addTextElementToData(
"Error", ss.str());
237 void CoreSupervisorBase::nonXmlRequest(
const std::string& , cgicc::Cgicc& , std::ostream& out,
const WebUsers::RequestUserInfo& )
239 __SUP_COUT__ <<
"This is the empty Core Supervisor non-xml request. Supervisors "
240 "should override this function."
242 out <<
"This is the empty Core Supervisor non-xml request. Supervisors should "
243 "override this function."
248 void CoreSupervisorBase::stateMachineXgiHandler(xgi::Input* , xgi::Output* ) {}
251 xoap::MessageReference CoreSupervisorBase::stateMachineXoapHandler(xoap::MessageReference message)
253 __SUP_COUT__ <<
"Soap Handler!" << __E__;
254 stateMachineWorkLoopManager_.removeProcessedRequests();
255 stateMachineWorkLoopManager_.processRequest(message);
256 __SUP_COUT__ <<
"Done - Soap Handler!" << __E__;
262 xoap::MessageReference CoreSupervisorBase::workLoopStatusRequestWrapper(xoap::MessageReference message)
265 return workLoopStatusRequest(message);
269 xoap::MessageReference CoreSupervisorBase::workLoopStatusRequest(xoap::MessageReference )
272 return SOAPUtilities::makeSOAPMessageReference(CoreSupervisorBase::WORK_LOOP_DONE);
276 xoap::MessageReference CoreSupervisorBase::applicationStatusRequest(xoap::MessageReference )
280 const std::string& err = theStateMachine_.getErrorMessage();
281 std::string status = err ==
"" ? (theStateMachine_.isInTransition() ? theStateMachine_.getProvenanceStateName() : theStateMachine_.getCurrentStateName())
282 : (theStateMachine_.getCurrentStateName() ==
"Paused" ?
"Soft-Error:::" :
"Error:::") + err;
285 retParameters.addParameter(
"Status", status);
286 retParameters.addParameter(
"Progress", RunControlStateMachine::theProgressBar_.readPercentageString());
287 retParameters.addParameter(
"Detail", getStatusProgressDetail());
289 return SOAPUtilities::makeSOAPMessageReference(
"applicationStatusRequestReply", retParameters);
297 std::string CoreSupervisorBase::getStatusProgressDetail(
void)
300 unsigned int cnt = 0;
320 if(theStateMachine_.getCurrentStateName() ==
"Halted")
return detail;
322 for(
const auto& fsm : CoreSupervisorBase::theStateMachineImplementation_)
324 std::string fsmProgressDetail = fsm->getStatusProgressDetail();
325 if(fsmProgressDetail.size())
326 detail += ((cnt++) ?
":" :
"") + fsmProgressDetail;
330 __SUP_COUTV__(detail);
336 bool CoreSupervisorBase::stateMachineThread(toolbox::task::WorkLoop* workLoop)
338 stateMachineSemaphore_.take();
339 __SUP_COUT__ <<
"Re-sending message..." << SOAPUtilities::translate(stateMachineWorkLoopManager_.getMessage(workLoop)).getCommand() << __E__;
340 std::string reply = send(this->getApplicationDescriptor(), stateMachineWorkLoopManager_.getMessage(workLoop));
341 stateMachineWorkLoopManager_.report(workLoop, reply, 100,
true);
342 __SUP_COUT__ <<
"Done with message" << __E__;
343 stateMachineSemaphore_.give();
351 xoap::MessageReference CoreSupervisorBase::stateMachineStateRequest(xoap::MessageReference )
353 __SUP_COUT__ <<
"theStateMachine_.getCurrentStateName() = " << theStateMachine_.getCurrentStateName() << __E__;
354 return SOAPUtilities::makeSOAPMessageReference(theStateMachine_.getCurrentStateName());
358 xoap::MessageReference CoreSupervisorBase::stateMachineErrorMessageRequest(xoap::MessageReference )
361 __SUP_COUT__ <<
"theStateMachine_.getErrorMessage() = " << theStateMachine_.getErrorMessage() << __E__;
364 retParameters.addParameter(
"ErrorMessage", theStateMachine_.getErrorMessage());
365 return SOAPUtilities::makeSOAPMessageReference(
"stateMachineErrorMessageRequestReply", retParameters);
369 void CoreSupervisorBase::stateInitial(toolbox::fsm::FiniteStateMachine& ) { __SUP_COUT__ <<
"CoreSupervisorBase::stateInitial" << __E__; }
372 void CoreSupervisorBase::stateHalted(toolbox::fsm::FiniteStateMachine& ) { __SUP_COUT__ <<
"CoreSupervisorBase::stateHalted" << __E__; }
375 void CoreSupervisorBase::stateRunning(toolbox::fsm::FiniteStateMachine& ) { __SUP_COUT__ <<
"CoreSupervisorBase::stateRunning" << __E__; }
378 void CoreSupervisorBase::stateConfigured(toolbox::fsm::FiniteStateMachine& ) { __SUP_COUT__ <<
"CoreSupervisorBase::stateConfigured" << __E__; }
381 void CoreSupervisorBase::statePaused(toolbox::fsm::FiniteStateMachine& ) { __SUP_COUT__ <<
"CoreSupervisorBase::statePaused" << __E__; }
384 void CoreSupervisorBase::inError(toolbox::fsm::FiniteStateMachine& )
387 __SUP_COUT__ <<
"Fsm current state: " << theStateMachine_.getCurrentStateName() << __E__;
392 void CoreSupervisorBase::enteringError(toolbox::Event::Reference event)
398 toolbox::fsm::FailedEvent& failedEvent =
dynamic_cast<toolbox::fsm::FailedEvent&
>(*event);
399 std::ostringstream error;
400 error <<
"Failure performing transition from " << failedEvent.getFromState() <<
" to " << failedEvent.getToState()
401 <<
" exception: " << failedEvent.getException().what();
402 __SUP_COUT_ERR__ << error.str() << __E__;
407 void CoreSupervisorBase::preStateMachineExecutionLoop(
void)
409 RunControlStateMachine::clearIterationWork();
410 RunControlStateMachine::clearSubIterationWork();
412 stateMachinesIterationWorkCount_ = 0;
414 if(RunControlStateMachine::getIterationIndex() == 0 && RunControlStateMachine::getSubIterationIndex() == 0)
418 subIterationWorkStateMachineIndex_ = -1;
420 stateMachinesIterationDone_.resize(theStateMachineImplementation_.size());
421 for(
unsigned int i = 0; i < stateMachinesIterationDone_.size(); ++i)
422 stateMachinesIterationDone_[i] =
false;
425 __SUP_COUT__ <<
"Iteration " << RunControlStateMachine::getIterationIndex() <<
"." << RunControlStateMachine::getSubIterationIndex() <<
"("
426 << subIterationWorkStateMachineIndex_ <<
")" << __E__;
430 void CoreSupervisorBase::preStateMachineExecution(
unsigned int i)
432 if(i >= theStateMachineImplementation_.size())
434 __SUP_SS__ <<
"State Machine " << i <<
" not found!" << __E__;
438 theStateMachineImplementation_[i]->VStateMachine::setIterationIndex(RunControlStateMachine::getIterationIndex());
439 theStateMachineImplementation_[i]->VStateMachine::setSubIterationIndex(RunControlStateMachine::getSubIterationIndex());
441 theStateMachineImplementation_[i]->VStateMachine::clearIterationWork();
442 theStateMachineImplementation_[i]->VStateMachine::clearSubIterationWork();
444 __SUP_COUT__ <<
"theStateMachineImplementation Iteration " << theStateMachineImplementation_[i]->VStateMachine::getIterationIndex() <<
"."
445 << theStateMachineImplementation_[i]->VStateMachine::getSubIterationIndex() << __E__;
449 void CoreSupervisorBase::postStateMachineExecution(
unsigned int i)
451 if(i >= theStateMachineImplementation_.size())
453 __SUP_SS__ <<
"State Machine " << i <<
" not found!" << __E__;
458 if(theStateMachineImplementation_[i]->VStateMachine::getSubIterationWork())
460 subIterationWorkStateMachineIndex_ = i;
461 RunControlStateMachine::indicateSubIterationWork();
463 __SUP_COUT__ <<
"State machine " << i <<
" is flagged for another sub-iteration..." << __E__;
467 stateMachinesIterationDone_[i] = !theStateMachineImplementation_[i]->VStateMachine::getIterationWork();
469 if(!stateMachinesIterationDone_[i])
471 __SUP_COUT__ <<
"State machine " << i <<
" is flagged for another iteration..." << __E__;
472 RunControlStateMachine::indicateIterationWork();
474 ++stateMachinesIterationWorkCount_;
480 void CoreSupervisorBase::postStateMachineExecutionLoop(
void)
482 if(RunControlStateMachine::subIterationWorkFlag_)
483 __SUP_COUT__ <<
"State machine implementation " << subIterationWorkStateMachineIndex_ <<
" is flagged for another sub-iteration..." << __E__;
484 else if(RunControlStateMachine::iterationWorkFlag_)
485 __SUP_COUT__ << stateMachinesIterationWorkCount_ <<
" state machine implementation(s) flagged for another iteration..." << __E__;
487 __SUP_COUT__ <<
"Done configuration all state machine implementations..." << __E__;
491 void CoreSupervisorBase::transitionConfiguring(toolbox::Event::Reference )
493 __SUP_COUT__ <<
"transitionConfiguring" << __E__;
496 if(RunControlStateMachine::getIterationIndex() == 0 && RunControlStateMachine::getSubIterationIndex() == 0)
499 SOAPUtilities::translate(theStateMachine_.getCurrentMessage()).getParameters().getValue(
"ConfigurationTableGroupName"),
500 TableGroupKey(SOAPUtilities::translate(theStateMachine_.getCurrentMessage()).getParameters().getValue(
"ConfigurationTableGroupKey")));
502 __SUP_COUT__ <<
"Configuration table group name: " << theGroup.first <<
" key: " << theGroup.second << __E__;
504 theConfigurationManager_->loadTableGroup(theGroup.first, theGroup.second,
true );
507 CoreSupervisorBase::transitionConfiguringFSMs();
509 __SUP_COUT__ <<
"Configured." << __E__;
513 void CoreSupervisorBase::transitionConfiguringFSMs()
520 __SUP_COUT__ <<
"Configuring all state machine implementations..." << __E__;
521 preStateMachineExecutionLoop();
522 for(
unsigned int i = 0; i < theStateMachineImplementation_.size(); ++i)
525 if(subIterationWorkStateMachineIndex_ != (
unsigned int)-1 && i != subIterationWorkStateMachineIndex_)
528 if(stateMachinesIterationDone_[i])
531 preStateMachineExecution(i);
532 theStateMachineImplementation_[i]->parentSupervisor_ =
this;
533 theStateMachineImplementation_[i]->configure();
536 postStateMachineExecution(i);
538 postStateMachineExecutionLoop();
540 catch(
const std::runtime_error& e)
542 __SUP_SS__ <<
"Error was caught while configuring: " << e.what() << __E__;
543 __SUP_COUT_ERR__ <<
"\n" << ss.str();
544 theStateMachine_.setErrorMessage(ss.str());
545 throw toolbox::fsm::exception::Exception(
"Transition Error" ,
547 "CoreSupervisorBase::transitionConfiguring" ,
554 __SUP_SS__ <<
"Unknown error was caught while configuring. Please checked the logs." << __E__;
555 __SUP_COUT_ERR__ <<
"\n" << ss.str();
556 theStateMachine_.setErrorMessage(ss.str());
557 throw toolbox::fsm::exception::Exception(
"Transition Error" ,
559 "CoreSupervisorBase::transitionConfiguring" ,
569 void CoreSupervisorBase::transitionHalting(toolbox::Event::Reference )
571 const std::string transitionName =
"Halting";
574 __SUP_COUT__ << transitionName <<
" all state machine implementations..." << __E__;
575 preStateMachineExecutionLoop();
576 for(
unsigned int i = 0; i < theStateMachineImplementation_.size(); ++i)
579 if(subIterationWorkStateMachineIndex_ != (
unsigned int)-1 && i != subIterationWorkStateMachineIndex_)
582 if(stateMachinesIterationDone_[i])
585 preStateMachineExecution(i);
586 theStateMachineImplementation_[i]->halt();
589 postStateMachineExecution(i);
591 postStateMachineExecutionLoop();
593 catch(
const std::runtime_error& e)
596 if(theStateMachine_.getProvenanceStateName() == RunControlStateMachine::FAILED_STATE_NAME)
598 __SUP_COUT_INFO__ <<
"Error was caught while halting (but ignoring because "
599 "previous state was '"
600 << RunControlStateMachine::FAILED_STATE_NAME <<
"'): " << e.what() << __E__;
604 __SUP_SS__ <<
"Error was caught while " << transitionName <<
": " << e.what() << __E__;
605 __SUP_COUT_ERR__ <<
"\n" << ss.str();
606 theStateMachine_.setErrorMessage(ss.str());
607 throw toolbox::fsm::exception::Exception(
"Transition Error" ,
609 "CoreSupervisorBase::transition" + transitionName ,
618 if(theStateMachine_.getProvenanceStateName() == RunControlStateMachine::FAILED_STATE_NAME)
620 __SUP_COUT_INFO__ <<
"Unknown error was caught while halting (but ignoring "
621 "because previous state was '"
622 << RunControlStateMachine::FAILED_STATE_NAME <<
"')." << __E__;
626 __SUP_SS__ <<
"Unknown error was caught while " << transitionName <<
". Please checked the logs." << __E__;
627 __SUP_COUT_ERR__ <<
"\n" << ss.str();
628 theStateMachine_.setErrorMessage(ss.str());
629 throw toolbox::fsm::exception::Exception(
"Transition Error" ,
631 "CoreSupervisorBase::transition" + transitionName ,
642 void CoreSupervisorBase::transitionInitializing(toolbox::Event::Reference )
644 __SUP_COUT__ <<
"transitionInitializing" << __E__;
646 CorePropertySupervisorBase::resetPropertiesAreSetup();
657 void CoreSupervisorBase::transitionPausing(toolbox::Event::Reference )
659 const std::string transitionName =
"Pausing";
662 __SUP_COUT__ <<
"Configuring all state machine implementations..." << __E__;
663 preStateMachineExecutionLoop();
664 for(
unsigned int i = 0; i < theStateMachineImplementation_.size(); ++i)
667 if(subIterationWorkStateMachineIndex_ != (
unsigned int)-1 && i != subIterationWorkStateMachineIndex_)
670 if(stateMachinesIterationDone_[i])
673 preStateMachineExecution(i);
674 theStateMachineImplementation_[i]->pause();
677 postStateMachineExecution(i);
679 postStateMachineExecutionLoop();
681 catch(
const std::runtime_error& e)
683 __SUP_SS__ <<
"Error was caught while " << transitionName <<
": " << e.what() << __E__;
684 __SUP_COUT_ERR__ <<
"\n" << ss.str();
685 theStateMachine_.setErrorMessage(ss.str());
686 throw toolbox::fsm::exception::Exception(
"Transition Error" ,
688 "CoreSupervisorBase::transition" + transitionName ,
695 __SUP_SS__ <<
"Unknown error was caught while " << transitionName <<
". Please checked the logs." << __E__;
696 __SUP_COUT_ERR__ <<
"\n" << ss.str();
697 theStateMachine_.setErrorMessage(ss.str());
698 throw toolbox::fsm::exception::Exception(
"Transition Error" ,
700 "CoreSupervisorBase::transition" + transitionName ,
708 void CoreSupervisorBase::transitionResuming(toolbox::Event::Reference )
710 const std::string transitionName =
"Resuming";
713 __SUP_COUT__ <<
"Configuring all state machine implementations..." << __E__;
714 preStateMachineExecutionLoop();
715 for(
unsigned int i = 0; i < theStateMachineImplementation_.size(); ++i)
718 if(subIterationWorkStateMachineIndex_ != (
unsigned int)-1 && i != subIterationWorkStateMachineIndex_)
721 if(stateMachinesIterationDone_[i])
724 preStateMachineExecution(i);
725 theStateMachineImplementation_[i]->resume();
728 postStateMachineExecution(i);
730 postStateMachineExecutionLoop();
732 catch(
const std::runtime_error& e)
734 __SUP_SS__ <<
"Error was caught while " << transitionName <<
": " << e.what() << __E__;
735 __SUP_COUT_ERR__ <<
"\n" << ss.str();
736 theStateMachine_.setErrorMessage(ss.str());
737 throw toolbox::fsm::exception::Exception(
"Transition Error" ,
739 "CoreSupervisorBase::transition" + transitionName ,
746 __SUP_SS__ <<
"Unknown error was caught while " << transitionName <<
". Please checked the logs." << __E__;
747 __SUP_COUT_ERR__ <<
"\n" << ss.str();
748 theStateMachine_.setErrorMessage(ss.str());
749 throw toolbox::fsm::exception::Exception(
"Transition Error" ,
751 "CoreSupervisorBase::transition" + transitionName ,
759 void CoreSupervisorBase::transitionStarting(toolbox::Event::Reference )
761 const std::string transitionName =
"Starting";
762 const std::string runNumber = SOAPUtilities::translate(theStateMachine_.getCurrentMessage()).getParameters().getValue(
"RunNumber");
765 __SUP_COUT__ <<
"Configuring all state machine implementations..." << __E__;
766 preStateMachineExecutionLoop();
767 for(
unsigned int i = 0; i < theStateMachineImplementation_.size(); ++i)
770 if(subIterationWorkStateMachineIndex_ != (
unsigned int)-1 && i != subIterationWorkStateMachineIndex_)
773 if(stateMachinesIterationDone_[i])
776 preStateMachineExecution(i);
777 theStateMachineImplementation_[i]->start(runNumber);
781 postStateMachineExecution(i);
783 postStateMachineExecutionLoop();
785 catch(
const std::runtime_error& e)
787 __SUP_SS__ <<
"Error was caught while " << transitionName <<
": " << e.what() << __E__;
788 __SUP_COUT_ERR__ <<
"\n" << ss.str();
789 theStateMachine_.setErrorMessage(ss.str());
790 throw toolbox::fsm::exception::Exception(
"Transition Error" ,
792 "CoreSupervisorBase::transition" + transitionName ,
799 __SUP_SS__ <<
"Unknown error was caught while " << transitionName <<
". Please checked the logs." << __E__;
800 __SUP_COUT_ERR__ <<
"\n" << ss.str();
801 theStateMachine_.setErrorMessage(ss.str());
802 throw toolbox::fsm::exception::Exception(
"Transition Error" ,
804 "CoreSupervisorBase::transition" + transitionName ,
812 void CoreSupervisorBase::transitionStopping(toolbox::Event::Reference )
814 const std::string transitionName =
"Stopping";
817 __SUP_COUT__ <<
"Configuring all state machine implementations..." << __E__;
818 preStateMachineExecutionLoop();
819 for(
unsigned int i = 0; i < theStateMachineImplementation_.size(); ++i)
822 if(subIterationWorkStateMachineIndex_ != (
unsigned int)-1 && i != subIterationWorkStateMachineIndex_)
825 if(stateMachinesIterationDone_[i])
828 preStateMachineExecution(i);
829 theStateMachineImplementation_[i]->stop();
832 postStateMachineExecution(i);
834 postStateMachineExecutionLoop();
836 catch(
const std::runtime_error& e)
838 __SUP_SS__ <<
"Error was caught while " << transitionName <<
": " << e.what() << __E__;
839 __SUP_COUT_ERR__ <<
"\n" << ss.str();
840 theStateMachine_.setErrorMessage(ss.str());
841 throw toolbox::fsm::exception::Exception(
"Transition Error" ,
843 "CoreSupervisorBase::transition" + transitionName ,
850 __SUP_SS__ <<
"Unknown error was caught while " << transitionName <<
". Please checked the logs." << __E__;
851 __SUP_COUT_ERR__ <<
"\n" << ss.str();
852 theStateMachine_.setErrorMessage(ss.str());
853 throw toolbox::fsm::exception::Exception(
"Transition Error" ,
855 "CoreSupervisorBase::transition" + transitionName ,
867 void CoreSupervisorBase::sendAsyncErrorToGateway(
const std::string& errorMessage,
bool isSoftError)
try
870 __SUP_COUT_ERR__ <<
"Sending Supervisor Async SOFT Running Error... \n" << errorMessage << __E__;
872 __SUP_COUT_ERR__ <<
"Sending Supervisor Async Running Error... \n" << errorMessage << __E__;
874 theStateMachine_.setErrorMessage(errorMessage);
876 XDAQ_CONST_CALL xdaq::ApplicationDescriptor* gatewaySupervisor = allSupervisorInfo_.getGatewayInfo().getDescriptor();
879 parameters.addParameter(
"ErrorMessage", errorMessage);
881 xoap::MessageReference replyMessage = SOAPMessenger::sendWithSOAPReply(gatewaySupervisor, isSoftError ?
"AsyncSoftError" :
"AsyncError", parameters);
883 std::stringstream replyMessageSStream;
884 replyMessageSStream << SOAPUtilities::translate(replyMessage);
885 __SUP_COUT__ <<
"Received... " << replyMessageSStream.str() << std::endl;
887 if(replyMessageSStream.str().find(
"Fault") != std::string::npos)
889 __SUP_COUT_ERR__ <<
"Failure to indicate fault to Gateway..." << __E__;
893 catch(
const xdaq::exception::Exception& e)
896 __SUP_COUT__ <<
"SOAP message failure indicating Supervisor asynchronous running SOFT "
897 "error back to Gateway: "
898 << e.what() << __E__;
900 __SUP_COUT__ <<
"SOAP message failure indicating Supervisor asynchronous running "
901 "error back to Gateway: "
902 << e.what() << __E__;
908 __SUP_COUT__ <<
"Unknown error encounter indicating Supervisor asynchronous running "
909 "SOFT error back to Gateway."
912 __SUP_COUT__ <<
"Unknown error encounter indicating Supervisor asynchronous running "
913 "error back to Gateway."