otsdaq  3.03.00
CoreSupervisorBase.cc
1 #include "otsdaq/CoreSupervisors/CoreSupervisorBase.h"
2 
3 #include <iostream>
4 
5 using namespace ots;
6 
7 // XDAQ_INSTANTIATOR_IMPL(CoreSupervisorBase)
8 
9 const std::string CoreSupervisorBase::WORK_LOOP_DONE = "Done";
10 const std::string CoreSupervisorBase::WORK_LOOP_WORKING = "Working";
11 
12 //==============================================================================
13 CoreSupervisorBase::CoreSupervisorBase(xdaq::ApplicationStub* stub)
14  : xdaq::Application(stub)
15  , SOAPMessenger(this)
18  CorePropertySupervisorBase::allSupervisorInfo_.isWizardMode()
19  ? // set state machine name
20  CorePropertySupervisorBase::supervisorClassNoNamespace_
21  : CorePropertySupervisorBase::supervisorClassNoNamespace_ + ":" +
22  CorePropertySupervisorBase::getSupervisorUID())
23  , stateMachineWorkLoopManager_(toolbox::task::bind(
24  this, &CoreSupervisorBase::stateMachineThread, "StateMachine"))
25  , stateMachineSemaphore_(toolbox::BSem::FULL)
26  , theRemoteWebUsers_(this,
27  CorePropertySupervisorBase::getGatewaySupervisorDescriptor())
28 {
29  __SUP_COUT__ << "Constructor." << __E__;
30 
31  INIT_MF("." /*directory used is USER_DATA/LOG/.*/);
32 
33  xgi::bind(this, &CoreSupervisorBase::defaultPageWrapper, "Default");
34  xgi::bind(this, &CoreSupervisorBase::requestWrapper, "Request");
35 
36  xgi::bind(
37  this, &CoreSupervisorBase::stateMachineXgiHandler, "StateMachineXgiHandler");
38 
39  xoap::bind(this,
40  &CoreSupervisorBase::stateMachineStateRequest,
41  "StateMachineStateRequest",
42  XDAQ_NS_URI);
43  xoap::bind(this,
44  &CoreSupervisorBase::stateMachineErrorMessageRequest,
45  "StateMachineErrorMessageRequest",
46  XDAQ_NS_URI);
47  xoap::bind(this,
48  &CoreSupervisorBase::workLoopStatusRequestWrapper,
49  "WorkLoopStatusRequest",
50  XDAQ_NS_URI);
51  xoap::bind(this,
52  &CoreSupervisorBase::applicationStatusRequest,
53  "ApplicationStatusRequest",
54  XDAQ_NS_URI);
55  xoap::bind(this,
56  &CoreSupervisorBase::TRACESupervisorRequest,
57  "TRACESupervisorRequest",
58  XDAQ_NS_URI);
59 
60  __SUP_COUT__ << "Constructed. getpid()=" << getpid() << " gettid()=" << gettid()
61  << __E__;
62 } // end constructor
63 
64 //==============================================================================
65 CoreSupervisorBase::~CoreSupervisorBase(void)
66 {
67  __SUP_COUT__ << "Destructor." << __E__;
68  destroy();
69  __SUP_COUT__ << "Destructed." << __E__;
70 } // end destructor()
71 
72 //==============================================================================
73 void CoreSupervisorBase::destroy(void)
74 {
75  __SUP_COUT__ << "Destroying..." << __E__;
76  for(auto& it : theStateMachineImplementation_)
77  delete it;
78 
79  theStateMachineImplementation_.clear();
80 } // end destroy()
81 
82 //==============================================================================
84 void CoreSupervisorBase::defaultPageWrapper(xgi::Input* in, xgi::Output* out)
85 {
86  return defaultPage(in, out);
87 }
88 
89 //==============================================================================
90 void CoreSupervisorBase::defaultPage(xgi::Input* /*in*/, xgi::Output* out)
91 {
92  __SUP_COUT__ << "Supervisor class " << supervisorClass_ << __E__;
93 
94  std::stringstream pagess;
95  pagess << "/WebPath/html/" << supervisorClassNoNamespace_
96  << ".html?urn=" << this->getApplicationDescriptor()->getLocalId();
97 
98  __SUP_COUT__ << "Default page = " << pagess.str() << __E__;
99 
100  *out << "<!DOCTYPE HTML><html lang='en'><frameset col='100%' row='100%'><frame src='"
101  << pagess.str() << "'></frameset></html>";
102 } // end defaultPage()
103 
104 //==============================================================================
107 void CoreSupervisorBase::requestWrapper(xgi::Input* in, xgi::Output* out)
108 try
109 {
110  out->getHTTPResponseHeader().addHeader(
111  "Access-Control-Allow-Origin",
112  "*"); // to avoid block by blocked by CORS policy of browser
113  out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
114 
115  cgicc::Cgicc cgiIn(in);
116  std::string requestType = CgiDataUtilities::getData(cgiIn, "RequestType");
117 
118  __SUP_COUTT__ << "requestType " << requestType
119  << " files: " << cgiIn.getFiles().size() << __E__;
120 
121  HttpXmlDocument xmlOut;
122  WebUsers::RequestUserInfo userInfo(
123  requestType, CgiDataUtilities::getOrPostData(cgiIn, "CookieCode"));
124 
126 
127  if(!theRemoteWebUsers_.xmlRequestToGateway(
128  cgiIn, out, &xmlOut, CorePropertySupervisorBase::allSupervisorInfo_, userInfo))
129  return; // access failed
130 
131  if(requestType == "GetUserDisplayName")
132  {
133  __COUTV__(userInfo.displayName_);
134  xmlOut.addTextElementToData("DisplayName", userInfo.displayName_);
135  xmlOut.outputXmlDocument((std::ostringstream*)out,
136  false /*print to cout*/,
137  !userInfo.NoXmlWhiteSpace_ /*allow whitespace*/);
138  return;
139  }
140 
141  // done checking cookieCode, sequence, userWithLock, and permissions access all in one
142  // shot!
143  //**** end LOGIN GATEWAY CODE ***//
144 
145  if(!userInfo.automatedCommand_)
146  __SUP_COUT__ << "requestType: " << requestType << __E__;
147 
148  if(userInfo.NonXMLRequestType_)
149  {
150  try
151  {
152  nonXmlRequest(requestType, cgiIn, *out, userInfo);
153  }
154  catch(const std::runtime_error& e)
155  {
156  __SUP_SS__ << "An error was encountered handling requestType '" << requestType
157  << "':" << e.what() << __E__;
158  __SUP_COUT_ERR__ << "\n" << ss.str();
159  }
160  catch(...)
161  {
162  __SUP_SS__ << "An unknown error was encountered handling requestType '"
163  << requestType << ".' "
164  << "Please check the printouts to debug." << __E__;
165  try
166  {
167  throw;
168  } //one more try to printout extra info
169  catch(const std::exception& e)
170  {
171  ss << "Exception message: " << e.what();
172  }
173  catch(...)
174  {
175  }
176  __SUP_COUT_ERR__ << "\n" << ss.str();
177  }
178  return;
179  }
180  // else xml request type
181 
182  std::chrono::steady_clock::time_point requestStart = std::chrono::steady_clock::now();
183  time_t requestStartTime = time(0);
184 
185  try
186  {
187  // call derived class' request()
188  request(requestType, cgiIn, xmlOut, userInfo);
189  }
190  catch(const std::runtime_error& e)
191  {
192  __SUP_SS__ << "An error was encountered handling requestType '" << requestType
193  << "':" << e.what() << __E__;
194  __SUP_COUT_ERR__ << "\n" << ss.str();
195  xmlOut.addTextElementToData("Error", ss.str());
196  }
197  catch(...)
198  {
199  __SUP_SS__ << "An unknown error was encountered handling requestType '"
200  << requestType << ".' "
201  << "Please check the printouts to debug." << __E__;
202  try
203  {
204  throw;
205  } //one more try to printout extra info
206  catch(const std::exception& e)
207  {
208  ss << "Exception message: " << e.what();
209  }
210  catch(...)
211  {
212  }
213  __SUP_COUT_ERR__ << "\n" << ss.str();
214  xmlOut.addTextElementToData("Error", ss.str());
215  }
216  __SUP_COUTT__ << "Request '" << requestType
217  << "' time: " << artdaq::TimeUtils::GetElapsedTime(requestStart)
218  << __E__;
219 
220  // used to print xml errors only if there are a reasonable number of children
221  if(TTEST(1)) //now just check child size if debugging
222  {
223  size_t numberOfChildren =
224  xmlOut.getRootDataElement()->getChildNodes()->getLength();
225  if(numberOfChildren &&
226  xmlOut.getRootDataElement()->getChildNodes()->item(0)->getNodeType() !=
227  xercesc::DOMNode::TEXT_NODE)
228  numberOfChildren += xmlOut.getRootDataElement()
229  ->getChildNodes()
230  ->item(0)
231  ->getChildNodes()
232  ->getLength();
233 
234  __SUP_COUTT__ << "Number of '" << requestType
235  << "' xml data element children: " << numberOfChildren << __E__;
236 
237  __SUP_COUTT__ << "Request '" << requestType
238  << "' time: " << artdaq::TimeUtils::GetElapsedTime(requestStart)
239  << __E__;
240  }
241  //Note: the above XML-children-count only looks at depth 1, if there are too many nodes (including deeper nodes) then outputing the xml will be slow (4K nodes takes ~2 seconds)
242 
243  // return xml doc holding server response to request
244  xmlOut.outputXmlDocument((std::ostringstream*)out,
245  false /*print to cout*/,
246  !userInfo.NoXmlWhiteSpace_ /*allow whitespace*/,
247  true /* printErrors */); // report any errors encountered
248 
249  // __SUP_COUTT__ << "Request '" << requestType
250  // << "' time: " << artdaq::TimeUtils::GetElapsedTime(requestStart)
251  // << __E__;
252  // std::stringstream oss;
253  // xmlOut.outputXmlDocument((std::ostringstream*)&oss,
254  // false /*print to cout*/,
255  // !userInfo.NoXmlWhiteSpace_ /*allow whitespace*/,
256  // true /* printErrors */);
257  // __SUP_COUTT__ << "Request '" << requestType
258  // << "' time: " << artdaq::TimeUtils::GetElapsedTime(requestStart)
259  // << __E__;
260  // __SUP_COUTV__(oss.str());
261 
262  __SUP_COUTT__ << "Total '" << requestType << "' xml request time: "
263  << artdaq::TimeUtils::GetElapsedTime(requestStart) << " = "
264  << time(0) - requestStartTime << __E__;
265 } // end requestWrapper()
266 catch(const std::runtime_error& e)
267 {
268  __SUP_SS__ << "An error was encountered handling HTTP request:" << e.what() << __E__;
269  __SUP_COUT_ERR__ << "\n" << ss.str();
270  throw;
271 }
272 catch(...)
273 {
274  __SUP_SS__ << "An unknown error was encountered HTTP request. "
275  << "Please check the printouts to debug." << __E__;
276  try
277  {
278  throw;
279  } //one more try to printout extra info
280  catch(const std::exception& e)
281  {
282  ss << "Exception message: " << e.what();
283  }
284  catch(...)
285  {
286  }
287  __SUP_COUT_ERR__ << "\n" << ss.str();
288  throw;
289 } // end requestWrapper() error handling
290 
291 //==============================================================================
297 void CoreSupervisorBase::request(const std::string& /*requestType*/,
298  cgicc::Cgicc& /*cgiIn*/,
299  HttpXmlDocument& xmlOut,
300  const WebUsers::RequestUserInfo& /*userInfo*/)
301 {
302  __SUP_SS__ << "This is the empty Core Supervisor request. Supervisors should "
303  "override this function."
304  << __E__;
305  __SUP_COUT__ << ss.str();
306  xmlOut.addTextElementToData("Error", ss.str());
307  return;
308 
309  // KEEP:
310  // here are some possibly interesting example lines of code for overriding
311  // supervisors
312  //
313  // try
314  //{
315  //
316  // if(requestType == "savePlanCommandSequence")
317  // {
318  // std::string planName = CgiDataUtilities::getData(cgiIn,"planName");
320  // CgiDataUtilities::postData(cgiIn,"commands");
322  //
323  // cgiIn.getFiles()
324  // __SUP_COUT__ << "planName: " << planName << __E__;
325  // __SUP_COUTV__(commands);
326  //
327  //
328  // }
329  // else
330  // {
331  // __SUP_SS__ << "requestType '" << requestType << "' request not recognized." <<
332  // __E__;
333  // __SUP_SS_THROW__;
334  // }
335  // xmlOut.addTextElementToData("Error",
336  // "request encountered an error!");
337  //}
338  // catch(const std::runtime_error& e)
339  // {
340  // __SUP_SS__ << "An error was encountered handling requestType '" << requestType
341  //<< "':" << e.what() << __E__;
342  // __SUP_COUT_ERR__ << "\n" << ss.str();
343  // xmlOut.addTextElementToData("Error", ss.str());
344  // }
345  // catch(...)
346  // {
347  // __SUP_SS__ << "An unknown error was encountered handling requestType '" <<
348  // requestType << ".' " << "Please check the printouts to debug." <<
349  //__E__;
350  // __SUP_COUT_ERR__ << "\n" << ss.str();
351  // xmlOut.addTextElementToData("Error", ss.str());
352  // }
353  // END KEEP.
354 
355 } // end request()
356 
357 //==============================================================================
363 void CoreSupervisorBase::nonXmlRequest(const std::string& /*requestType*/,
364  cgicc::Cgicc& /*cgiIn*/,
365  std::ostream& out,
366  const WebUsers::RequestUserInfo& /*userInfo*/)
367 {
368  __SUP_COUT__ << "This is the empty Core Supervisor non-xml request. Supervisors "
369  "should override this function."
370  << __E__;
371  out << "This is the empty Core Supervisor non-xml request. Supervisors should "
372  "override this function."
373  << __E__;
374 } // end nonXmlRequest()
375 
376 //==============================================================================
377 void CoreSupervisorBase::stateMachineXgiHandler(xgi::Input* /*in*/, xgi::Output* /*out*/)
378 {
379 }
380 
381 //==============================================================================
382 xoap::MessageReference CoreSupervisorBase::stateMachineXoapHandler(
383  xoap::MessageReference message)
384 {
385  __SUP_COUT__ << "Soap Handler!" << __E__;
386  stateMachineWorkLoopManager_.removeProcessedRequests();
387  stateMachineWorkLoopManager_.processRequest(message);
388  __SUP_COUT__ << "Done - Soap Handler!" << __E__;
389  return message;
390 } // end stateMachineXoapHandler()
391 
392 //==============================================================================
394 xoap::MessageReference CoreSupervisorBase::workLoopStatusRequestWrapper(
395  xoap::MessageReference message)
396 {
397  // this should have an override for monitoring work loops being done
398  return workLoopStatusRequest(message);
399 } // end workLoopStatusRequest()
400 
401 //==============================================================================
402 xoap::MessageReference CoreSupervisorBase::workLoopStatusRequest(
403  xoap::MessageReference /*message*/)
404 {
405  // this should have an override for monitoring work loops being done
406  return SOAPUtilities::makeSOAPMessageReference(CoreSupervisorBase::WORK_LOOP_DONE);
407 } // end workLoopStatusRequest()
408 
409 //==============================================================================
410 xoap::MessageReference CoreSupervisorBase::applicationStatusRequest(
411  xoap::MessageReference /*message*/)
412 {
413  // send back status and progress parameters
414 
415  __SUP_COUTVS__(20,
416  std::to_string(getpid()) + ":" + std::to_string(gettid()) + ":" +
417  theStateMachine_.getCurrentStateName());
418 
419  const std::string& err = theStateMachine_.getErrorMessage();
420  // std::string status = err == "" ? (theStateMachine_.isInTransition() ? theStateMachine_.getProvenanceStateName() : theStateMachine_.getCurrentStateName())
421  // : (theStateMachine_.getCurrentStateName() == "Paused" ? "Soft-Error:::" : "Error:::") + err;
422 
423  // __SUP_COUTV__(theStateMachine_.isInTransition());
424  // __SUP_COUTV__(theStateMachine_.getProvenanceStateName());
425  // __SUP_COUTV__(theStateMachine_.getCurrentStateName());
426  // __SUP_COUTV__(RunControlStateMachine::theProgressBar_.readPercentageString());
427 
428  SOAPParameters retParameters;
429  if(err == "")
430  {
431  if(theStateMachine_.isInTransition() ||
432  RunControlStateMachine::theProgressBar_.read() < 100)
433  {
434  // attempt to get transition name, otherwise give provenance state
435  try
436  {
437  retParameters.addParameter("Status",
438  theStateMachine_.getCurrentTransitionName());
439  }
440  catch(...)
441  {
442  retParameters.addParameter("Status",
443  theStateMachine_.getProvenanceStateName());
444  }
445  }
446  else
447  retParameters.addParameter("Status", theStateMachine_.getCurrentStateName());
448  }
449  else
450  retParameters.addParameter(
451  "Status",
452  (theStateMachine_.getCurrentStateName() == "Paused" ? "Soft-Error:::"
453  : "Error:::") +
454  err);
455 
456  retParameters.addParameter(
457  "Progress", RunControlStateMachine::theProgressBar_.readPercentageString());
458  retParameters.addParameter(
459  "Detail",
460  getStatusProgressDetail()); // call virtual progress detail string generation
461  auto subappInfo = getSubappInfo();
462  retParameters.addParameter("Subapps",
463  SupervisorInfo::serializeSubappInfos(subappInfo));
464 
465  return SOAPUtilities::makeSOAPMessageReference("applicationStatusRequestReply",
466  retParameters);
467 } // end applicationStatusRequest()
468 
469 //==============================================================================
475 {
476  std::string detail;
477  unsigned int cnt = 0;
478 
479  /*
480  //__SUP_COUT__ << "Checking..." << CoreSupervisorBase::theStateMachineImplementation_.size() << __E__;
481  for(const auto& fsm : CoreSupervisorBase::theStateMachineImplementation_)
482  {
483  //__SUP_COUT__ << "Checking..." << __E__;
484  try
485  {
486  VStateMachine* testFSM = dynamic_cast<VStateMachine*>(fsm);
487  }
488  catch(...)
489  {
490  __SUP_COUT__ << "getStatusProgressDetail() VStateMachine testFSM Failed..." << __E__;
491  throw;
492  }
493  }
494  */
495 
496  if(!theStateMachine_.isInTransition() &&
497  (theStateMachine_.getCurrentStateName() ==
498  RunControlStateMachine::HALTED_STATE_NAME ||
499  theStateMachine_.getCurrentStateName() ==
500  RunControlStateMachine::INITIAL_STATE_NAME))
501  {
502  detail = std::string("Uptime: ") +
503  StringMacros::encodeURIComponent(StringMacros::getTimeDurationString(
504  CorePropertySupervisorBase::getSupervisorUptime())) +
505  ", Time-in-state: " +
506  StringMacros::encodeURIComponent(StringMacros::getTimeDurationString(
507  theStateMachine_.getTimeInState()));
508  return detail;
509  }
510 
511  for(const auto& fsm : CoreSupervisorBase::theStateMachineImplementation_)
512  {
513  std::string fsmProgressDetail = fsm->getStatusProgressDetail();
514  if(fsmProgressDetail.size())
515  detail +=
516  ((cnt++) ? ":" : "") +
517  fsmProgressDetail; // StringMacros::encodeURIComponent(fsmProgressDetail);
518  }
519 
520  if(detail.size())
521  __SUP_COUTVS__(20, detail);
522 
523  // if empty detail, give last command
524  if(!detail.size() && RunControlStateMachine::getLastCommand() != "")
525  {
526  detail = "Last Command: " + RunControlStateMachine::getLastCommand();
527  if(RunControlStateMachine::getLastCommand() ==
528  RunControlStateMachine::CONFIGURE_TRANSITION_NAME)
529  detail += " w/" + RunControlStateMachine::getLastAttemptedConfigureGroup();
530  }
531 
532  return detail;
533 } // end getStatusProgressDetail()
534 
535 //==============================================================================
536 bool CoreSupervisorBase::stateMachineThread(toolbox::task::WorkLoop* workLoop)
537 {
538  stateMachineSemaphore_.take();
539  __SUP_COUT__ << "Re-sending message..."
540  << SOAPUtilities::translate(
541  stateMachineWorkLoopManager_.getMessage(workLoop))
542  .getCommand()
543  << __E__;
544  std::string reply = send(this->getApplicationDescriptor(),
545  stateMachineWorkLoopManager_.getMessage(workLoop));
546  stateMachineWorkLoopManager_.report(workLoop, reply, 100, true);
547  __SUP_COUT__ << "Done with message" << __E__;
548  stateMachineSemaphore_.give();
549  return false; // execute once and automatically remove the workloop so in
550  // WorkLoopManager the try workLoop->remove(job_) could be commented
551  // out return true;//go on and then you must do the
552  // workLoop->remove(job_) in WorkLoopManager
553 } // end stateMachineThread()
554 
555 //==============================================================================
556 xoap::MessageReference CoreSupervisorBase::stateMachineStateRequest(
557  xoap::MessageReference /*message*/)
558 {
559  __SUP_COUT__ << "theStateMachine_.getCurrentStateName() = "
560  << theStateMachine_.getCurrentStateName() << __E__;
561  return SOAPUtilities::makeSOAPMessageReference(
562  theStateMachine_.getCurrentStateName());
563 }
564 
565 //==============================================================================
566 xoap::MessageReference CoreSupervisorBase::stateMachineErrorMessageRequest(
567  xoap::MessageReference /*message*/)
568 
569 {
570  __SUP_COUT__ << "theStateMachine_.getErrorMessage() = "
571  << theStateMachine_.getErrorMessage() << __E__;
572 
573  SOAPParameters retParameters;
574  retParameters.addParameter("ErrorMessage", theStateMachine_.getErrorMessage());
575  return SOAPUtilities::makeSOAPMessageReference("stateMachineErrorMessageRequestReply",
576  retParameters);
577 } // end stateMachineErrorMessageRequest()
578 
579 //==============================================================================
580 void CoreSupervisorBase::stateInitial(toolbox::fsm::FiniteStateMachine& /*fsm*/)
581 {
582  __SUP_COUT__ << "CoreSupervisorBase::stateInitial" << __E__;
583 }
584 
585 //==============================================================================
586 void CoreSupervisorBase::stateHalted(toolbox::fsm::FiniteStateMachine& /*fsm*/)
587 {
588  __SUP_COUT__ << "CoreSupervisorBase::stateHalted" << __E__;
589 }
590 
591 //==============================================================================
592 void CoreSupervisorBase::stateRunning(toolbox::fsm::FiniteStateMachine& /*fsm*/)
593 {
594  __SUP_COUT__ << "CoreSupervisorBase::stateRunning" << __E__;
595 }
596 
597 //==============================================================================
598 void CoreSupervisorBase::stateConfigured(toolbox::fsm::FiniteStateMachine& /*fsm*/)
599 {
600  __SUP_COUT__ << "CoreSupervisorBase::stateConfigured" << __E__;
601 }
602 
603 //==============================================================================
604 void CoreSupervisorBase::statePaused(toolbox::fsm::FiniteStateMachine& /*fsm*/)
605 {
606  __SUP_COUT__ << "CoreSupervisorBase::statePaused" << __E__;
607 }
608 
609 //==============================================================================
610 void CoreSupervisorBase::inError(toolbox::fsm::FiniteStateMachine& /*fsm*/)
611 
612 {
613  __SUP_COUT__ << "Fsm current state: " << theStateMachine_.getCurrentStateName()
614  << __E__;
615  // rcmsStateNotifier_.stateChanged("Error", "");
616 }
617 
618 //==============================================================================
619 void CoreSupervisorBase::enteringError(toolbox::Event::Reference event)
620 
621 {
622  // __SUP_COUT__<< "Fsm current state: " << theStateMachine_.getCurrentStateName()
623  // << "\n\nError Message: " <<
624  // theStateMachine_.getErrorMessage() << __E__;
625  toolbox::fsm::FailedEvent& failedEvent =
626  dynamic_cast<toolbox::fsm::FailedEvent&>(*event);
627  std::ostringstream error;
628  error << "Failure performing transition from " << failedEvent.getFromState() << " to "
629  << failedEvent.getToState()
630  << " exception: " << failedEvent.getException().what();
631  __SUP_COUT_ERR__ << error.str() << __E__;
632  // diagService_->reportError(errstr.str(),DIAGERROR);
633 }
634 
635 //==============================================================================
636 void CoreSupervisorBase::preStateMachineExecutionLoop(void)
637 {
638  RunControlStateMachine::clearIterationWork();
639  RunControlStateMachine::clearSubIterationWork();
640 
641  stateMachinesIterationWorkCount_ = 0;
642 
643  if(RunControlStateMachine::getIterationIndex() == 0 &&
644  RunControlStateMachine::getSubIterationIndex() == 0)
645  {
646  // reset vector for iterations done on first iteration
647 
648  subIterationWorkStateMachineIndex_ = -1; // clear sub iteration work index
649 
650  stateMachinesIterationDone_.resize(theStateMachineImplementation_.size());
651  for(unsigned int i = 0; i < stateMachinesIterationDone_.size(); ++i)
652  stateMachinesIterationDone_[i] = false;
653  }
654  else
655  __SUP_COUT__ << "Iteration " << RunControlStateMachine::getIterationIndex() << "."
656  << RunControlStateMachine::getSubIterationIndex() << "("
657  << subIterationWorkStateMachineIndex_ << ")" << __E__;
658 }
659 
660 //==============================================================================
661 void CoreSupervisorBase::preStateMachineExecution(unsigned int i)
662 {
663  if(i >= theStateMachineImplementation_.size())
664  {
665  __SUP_SS__ << "State Machine " << i << " not found!" << __E__;
666  __SUP_SS_THROW__;
667  }
668 
669  theStateMachineImplementation_[i]->VStateMachine::setIterationIndex(
670  RunControlStateMachine::getIterationIndex());
671  theStateMachineImplementation_[i]->VStateMachine::setSubIterationIndex(
672  RunControlStateMachine::getSubIterationIndex());
673 
674  theStateMachineImplementation_[i]->VStateMachine::clearIterationWork();
675  theStateMachineImplementation_[i]->VStateMachine::clearSubIterationWork();
676 
677  __SUP_COUT__
678  << "theStateMachineImplementation Iteration "
679  << theStateMachineImplementation_[i]->VStateMachine::getIterationIndex() << "."
680  << theStateMachineImplementation_[i]->VStateMachine::getSubIterationIndex()
681  << __E__;
682 }
683 
684 //==============================================================================
685 void CoreSupervisorBase::postStateMachineExecution(unsigned int i)
686 {
687  if(i >= theStateMachineImplementation_.size())
688  {
689  __SUP_SS__ << "State Machine " << i << " not found!" << __E__;
690  __SUP_SS_THROW__;
691  }
692 
693  // sub-iteration has priority
694  if(theStateMachineImplementation_[i]->VStateMachine::getSubIterationWork())
695  {
696  subIterationWorkStateMachineIndex_ = i;
697  RunControlStateMachine::indicateSubIterationWork();
698 
699  __SUP_COUT__ << "State machine " << i
700  << " is flagged for another sub-iteration..." << __E__;
701  }
702  else
703  {
705  !theStateMachineImplementation_[i]->VStateMachine::getIterationWork();
706 
708  {
709  __SUP_COUT__ << "State machine " << i
710  << " is flagged for another iteration..." << __E__;
711  RunControlStateMachine::indicateIterationWork(); // mark not done at
712  // CoreSupervisorBase level
713  ++stateMachinesIterationWorkCount_; // increment still working count
714  }
715  }
716 } // end postStateMachineExecution()
717 
718 //==============================================================================
719 void CoreSupervisorBase::postStateMachineExecutionLoop(void)
720 {
721  if(RunControlStateMachine::subIterationWorkFlag_)
722  __SUP_COUT__ << "State machine implementation "
723  << subIterationWorkStateMachineIndex_
724  << " is flagged for another sub-iteration..." << __E__;
725  else if(RunControlStateMachine::iterationWorkFlag_)
726  __SUP_COUT__
727  << stateMachinesIterationWorkCount_
728  << " state machine implementation(s) flagged for another iteration..."
729  << __E__;
730  else
731  __SUP_COUT__ << "Done configuration all state machine implementations..."
732  << __E__;
733 } // end postStateMachineExecutionLoop()
734 
735 //==============================================================================
736 void CoreSupervisorBase::transitionConfiguring(toolbox::Event::Reference /*event*/)
737 {
738  __SUP_COUT__ << "transitionConfiguring" << __E__;
739 
740  // activate the configuration tree (the first iteration)
741  if(RunControlStateMachine::getIterationIndex() == 0 &&
742  RunControlStateMachine::getSubIterationIndex() == 0)
743  {
744  std::pair<std::string /*group name*/, TableGroupKey> theGroup(
745  SOAPUtilities::translate(theStateMachine_.getCurrentMessage())
746  .getParameters()
747  .getValue("ConfigurationTableGroupName"),
748  TableGroupKey(SOAPUtilities::translate(theStateMachine_.getCurrentMessage())
749  .getParameters()
750  .getValue("ConfigurationTableGroupKey")));
751 
752  __SUP_COUT__ << "Configuration table group name: " << theGroup.first
753  << " key: " << theGroup.second << __E__;
754 
755  try
756  {
757  //disable version tracking to accept untracked versions to be selected by the FSM transition source
758  theConfigurationManager_->loadTableGroup(
759  theGroup.first,
760  theGroup.second,
761  true /*doActivate*/,
762  0,
763  0,
764  0,
765  0,
766  0,
767  0,
768  false,
769  0,
770  0,
771  ConfigurationManager::LoadGroupType::ALL_TYPES,
772  true /*ignoreVersionTracking*/);
773  }
774  catch(const std::runtime_error& e)
775  {
776  __SS__ << "Error loading table group '" << theGroup.first << "("
777  << theGroup.second << ")! \n"
778  << e.what() << __E__;
779  __SUP_COUT_ERR__ << ss.str();
780  // ExceptionHandler(ExceptionHandlerRethrow::no, ss.str());
781 
782  //__SS_THROW_ONLY__;
783  theStateMachine_.setErrorMessage(ss.str());
784  throw toolbox::fsm::exception::Exception(
785  "Transition Error" /*name*/,
786  ss.str() /* message*/,
787  "CoreSupervisorBase::transitionConfiguring" /*module*/,
788  __LINE__ /*line*/,
789  __FUNCTION__ /*function*/
790  );
791  }
792  catch(...)
793  {
794  __SS__ << "Unknown error loading table group '" << theGroup.first << "("
795  << theGroup.second << ")!" << __E__;
796  try
797  {
798  throw;
799  } //one more try to printout extra info
800  catch(const std::exception& e)
801  {
802  ss << "Exception message: " << e.what();
803  }
804  catch(...)
805  {
806  }
807  __SUP_COUT_ERR__ << ss.str();
808  // ExceptionHandler(ExceptionHandlerRethrow::no, ss.str());
809 
810  //__SS_THROW_ONLY__;
811  theStateMachine_.setErrorMessage(ss.str());
812  throw toolbox::fsm::exception::Exception(
813  "Transition Error" /*name*/,
814  ss.str() /* message*/,
815  "CoreSupervisorBase::transitionConfiguring" /*module*/,
816  __LINE__ /*line*/,
817  __FUNCTION__ /*function*/
818  );
819  }
820  }
821 
822  CoreSupervisorBase::transitionConfiguringFSMs();
823 
824  __SUP_COUT__ << "Configured." << __E__;
825 } // end transitionConfiguring()
826 
827 //==============================================================================
828 void CoreSupervisorBase::transitionConfiguringFSMs()
829 {
830  // Now that the configuration manager has all the necessary configurations,
831  // create all objects that depend on the configuration (the first iteration)
832 
833  try
834  {
835  __SUP_COUT__ << "Configuring all state machine implementations..." << __E__;
836  preStateMachineExecutionLoop();
837  for(unsigned int i = 0; i < theStateMachineImplementation_.size(); ++i)
838  {
839  // if one state machine is doing a sub-iteration, then target that one
840  if(subIterationWorkStateMachineIndex_ != (unsigned int)-1 &&
841  i != subIterationWorkStateMachineIndex_)
842  continue; // skip those not in the sub-iteration
843 
845  continue; // skip state machines already done
846 
847  preStateMachineExecution(i);
848  theStateMachineImplementation_[i]->parentSupervisor_ =
849  this; // for backwards compatibility, kept out of configure parameters
850  theStateMachineImplementation_[i]->configure(); // e.g. for FESupervisor,
851  // this is configure of
852  // FEVInterfacesManager
853  postStateMachineExecution(i);
854  }
855  postStateMachineExecutionLoop();
856  }
857  catch(const std::runtime_error& e)
858  {
859  __SUP_SS__ << "Error was caught while configuring: " << e.what() << __E__;
860  __SUP_COUT_ERR__ << "\n" << ss.str();
861  theStateMachine_.setErrorMessage(ss.str());
862  throw toolbox::fsm::exception::Exception(
863  "Transition Error" /*name*/,
864  ss.str() /* message*/,
865  "CoreSupervisorBase::transitionConfiguring" /*module*/,
866  __LINE__ /*line*/,
867  __FUNCTION__ /*function*/
868  );
869  }
870  catch(...)
871  {
872  __SUP_SS__
873  << "Unknown error was caught while configuring. Please checked the logs."
874  << __E__;
875  try
876  {
877  throw;
878  } //one more try to printout extra info
879  catch(const std::exception& e)
880  {
881  ss << "Exception message: " << e.what();
882  }
883  catch(...)
884  {
885  }
886  __SUP_COUT_ERR__ << "\n" << ss.str();
887  theStateMachine_.setErrorMessage(ss.str());
888  throw toolbox::fsm::exception::Exception(
889  "Transition Error" /*name*/,
890  ss.str() /* message*/,
891  "CoreSupervisorBase::transitionConfiguring" /*module*/,
892  __LINE__ /*line*/,
893  __FUNCTION__ /*function*/
894  );
895  }
896 } // end transitionConfiguringFSMs()
897 
898 //==============================================================================
901 void CoreSupervisorBase::transitionHalting(toolbox::Event::Reference /*event*/)
902 {
903  const std::string transitionName = "Halting";
904  try
905  {
906  __SUP_COUT__ << transitionName << " all state machine implementations..."
907  << __E__;
908  preStateMachineExecutionLoop();
909  for(unsigned int i = 0; i < theStateMachineImplementation_.size(); ++i)
910  {
911  // if one state machine is doing a sub-iteration, then target that one
912  if(subIterationWorkStateMachineIndex_ != (unsigned int)-1 &&
913  i != subIterationWorkStateMachineIndex_)
914  continue; // skip those not in the sub-iteration
915 
917  continue; // skip state machines already done
918 
919  preStateMachineExecution(i);
920  theStateMachineImplementation_[i]->halt(); // e.g. for FESupervisor, this is
921  // transition of
922  // FEVInterfacesManager
923  postStateMachineExecution(i);
924  }
925  postStateMachineExecutionLoop();
926  }
927  catch(const std::runtime_error& e)
928  {
929  // if halting from Failed state, then ignore errors
930  if(theStateMachine_.getProvenanceStateName() ==
931  RunControlStateMachine::FAILED_STATE_NAME)
932  {
933  __SUP_COUT_INFO__ << "Error was caught while halting (but ignoring because "
934  "previous state was '"
935  << RunControlStateMachine::FAILED_STATE_NAME
936  << "'): " << e.what() << __E__;
937  }
938  else // if not previously in Failed state, then fail
939  {
940  __SUP_SS__ << "Error was caught while " << transitionName << ": " << e.what()
941  << __E__;
942  __SUP_COUT_ERR__ << "\n" << ss.str();
943  theStateMachine_.setErrorMessage(ss.str());
944  throw toolbox::fsm::exception::Exception(
945  "Transition Error" /*name*/,
946  ss.str() /* message*/,
947  "CoreSupervisorBase::transition" + transitionName /*module*/,
948  __LINE__ /*line*/,
949  __FUNCTION__ /*function*/
950  );
951  }
952  }
953  catch(...)
954  {
955  // if halting from Failed state, then ignore errors
956  if(theStateMachine_.getProvenanceStateName() ==
957  RunControlStateMachine::FAILED_STATE_NAME)
958  {
959  __SUP_COUT_INFO__ << "Unknown error was caught while halting (but ignoring "
960  "because previous state was '"
961  << RunControlStateMachine::FAILED_STATE_NAME << "')."
962  << __E__;
963  }
964  else // if not previously in Failed state, then fail
965  {
966  __SUP_SS__ << "Unknown error was caught while " << transitionName
967  << ". Please checked the logs." << __E__;
968  try
969  {
970  throw;
971  } //one more try to printout extra info
972  catch(const std::exception& e)
973  {
974  ss << "Exception message: " << e.what();
975  }
976  catch(...)
977  {
978  }
979  __SUP_COUT_ERR__ << "\n" << ss.str();
980  theStateMachine_.setErrorMessage(ss.str());
981  throw toolbox::fsm::exception::Exception(
982  "Transition Error" /*name*/,
983  ss.str() /* message*/,
984  "CoreSupervisorBase::transition" + transitionName /*module*/,
985  __LINE__ /*line*/,
986  __FUNCTION__ /*function*/
987  );
988  }
989  }
990 } // end transitionHalting()
991 
992 //==============================================================================
995 void CoreSupervisorBase::transitionInitializing(toolbox::Event::Reference /*event*/)
996 {
997  __SUP_COUT__ << "transitionInitializing" << __E__;
998 
999  CorePropertySupervisorBase::resetPropertiesAreSetup(); // indicate need to re-load
1000  // user properties
1001 
1002  // Note: Do not initialize the state machine implementations...
1003  // do any initializing in configure
1004  // This allows re-instantiation at each configure time.
1005  // for(auto& it: theStateMachineImplementation_)
1006  // it->initialize();
1007 } // end transitionInitializing()
1008 
1009 //==============================================================================
1010 void CoreSupervisorBase::transitionPausing(toolbox::Event::Reference /*event*/)
1011 {
1012  const std::string transitionName = "Pausing";
1013  try
1014  {
1015  __SUP_COUT__ << "Configuring all state machine implementations..." << __E__;
1016  preStateMachineExecutionLoop();
1017  for(unsigned int i = 0; i < theStateMachineImplementation_.size(); ++i)
1018  {
1019  // if one state machine is doing a sub-iteration, then target that one
1020  if(subIterationWorkStateMachineIndex_ != (unsigned int)-1 &&
1021  i != subIterationWorkStateMachineIndex_)
1022  continue; // skip those not in the sub-iteration
1023 
1025  continue; // skip state machines already done
1026 
1027  preStateMachineExecution(i);
1028  theStateMachineImplementation_[i]->pause(); // e.g. for FESupervisor, this is
1029  // transition of
1030  // FEVInterfacesManager
1031  postStateMachineExecution(i);
1032  }
1033  postStateMachineExecutionLoop();
1034  }
1035  catch(const std::runtime_error& e)
1036  {
1037  __SUP_SS__ << "Error was caught while " << transitionName << ": " << e.what()
1038  << __E__;
1039  __SUP_COUT_ERR__ << "\n" << ss.str();
1040  theStateMachine_.setErrorMessage(ss.str());
1041  throw toolbox::fsm::exception::Exception(
1042  "Transition Error" /*name*/,
1043  ss.str() /* message*/,
1044  "CoreSupervisorBase::transition" + transitionName /*module*/,
1045  __LINE__ /*line*/,
1046  __FUNCTION__ /*function*/
1047  );
1048  }
1049  catch(...)
1050  {
1051  __SUP_SS__ << "Unknown error was caught while " << transitionName
1052  << ". Please checked the logs." << __E__;
1053  try
1054  {
1055  throw;
1056  } //one more try to printout extra info
1057  catch(const std::exception& e)
1058  {
1059  ss << "Exception message: " << e.what();
1060  }
1061  catch(...)
1062  {
1063  }
1064  __SUP_COUT_ERR__ << "\n" << ss.str();
1065  theStateMachine_.setErrorMessage(ss.str());
1066  throw toolbox::fsm::exception::Exception(
1067  "Transition Error" /*name*/,
1068  ss.str() /* message*/,
1069  "CoreSupervisorBase::transition" + transitionName /*module*/,
1070  __LINE__ /*line*/,
1071  __FUNCTION__ /*function*/
1072  );
1073  }
1074 } // end transitionPausing()
1075 
1076 //==============================================================================
1077 void CoreSupervisorBase::transitionResuming(toolbox::Event::Reference /*event*/)
1078 {
1079  const std::string transitionName = "Resuming";
1080  try
1081  {
1082  __SUP_COUT__ << "Configuring all state machine implementations..." << __E__;
1083  preStateMachineExecutionLoop();
1084  for(unsigned int i = 0; i < theStateMachineImplementation_.size(); ++i)
1085  {
1086  // if one state machine is doing a sub-iteration, then target that one
1087  if(subIterationWorkStateMachineIndex_ != (unsigned int)-1 &&
1088  i != subIterationWorkStateMachineIndex_)
1089  continue; // skip those not in the sub-iteration
1090 
1092  continue; // skip state machines already done
1093 
1094  preStateMachineExecution(i);
1095  theStateMachineImplementation_[i]->resume(); // e.g. for FESupervisor, this
1096  // is transition of
1097  // FEVInterfacesManager
1098  postStateMachineExecution(i);
1099  }
1100  postStateMachineExecutionLoop();
1101  }
1102  catch(const std::runtime_error& e)
1103  {
1104  __SUP_SS__ << "Error was caught while " << transitionName << ": " << e.what()
1105  << __E__;
1106  __SUP_COUT_ERR__ << "\n" << ss.str();
1107  theStateMachine_.setErrorMessage(ss.str());
1108  throw toolbox::fsm::exception::Exception(
1109  "Transition Error" /*name*/,
1110  ss.str() /* message*/,
1111  "CoreSupervisorBase::transition" + transitionName /*module*/,
1112  __LINE__ /*line*/,
1113  __FUNCTION__ /*function*/
1114  );
1115  }
1116  catch(...)
1117  {
1118  __SUP_SS__ << "Unknown error was caught while " << transitionName
1119  << ". Please checked the logs." << __E__;
1120  try
1121  {
1122  throw;
1123  } //one more try to printout extra info
1124  catch(const std::exception& e)
1125  {
1126  ss << "Exception message: " << e.what();
1127  }
1128  catch(...)
1129  {
1130  }
1131  __SUP_COUT_ERR__ << "\n" << ss.str();
1132  theStateMachine_.setErrorMessage(ss.str());
1133  throw toolbox::fsm::exception::Exception(
1134  "Transition Error" /*name*/,
1135  ss.str() /* message*/,
1136  "CoreSupervisorBase::transition" + transitionName /*module*/,
1137  __LINE__ /*line*/,
1138  __FUNCTION__ /*function*/
1139  );
1140  }
1141 } // end transitionResuming()
1142 
1143 //==============================================================================
1144 void CoreSupervisorBase::transitionStarting(toolbox::Event::Reference /*event*/)
1145 {
1146  const std::string transitionName = "Starting";
1147  const std::string runNumber =
1148  SOAPUtilities::translate(theStateMachine_.getCurrentMessage())
1149  .getParameters()
1150  .getValue("RunNumber");
1151  try
1152  {
1153  __SUP_COUT__ << "Configuring all state machine implementations..." << __E__;
1154  preStateMachineExecutionLoop();
1155  for(unsigned int i = 0; i < theStateMachineImplementation_.size(); ++i)
1156  {
1157  // if one state machine is doing a sub-iteration, then target that one
1158  if(subIterationWorkStateMachineIndex_ != (unsigned int)-1 &&
1159  i != subIterationWorkStateMachineIndex_)
1160  continue; // skip those not in the sub-iteration
1161 
1163  continue; // skip state machines already done
1164 
1165  preStateMachineExecution(i);
1166  theStateMachineImplementation_[i]->start(runNumber); // e.g. for
1167  // FESupervisor, this is
1168  // transition of
1169  // FEVInterfacesManager
1170  postStateMachineExecution(i);
1171  }
1172  postStateMachineExecutionLoop();
1173  }
1174  catch(const std::runtime_error& e)
1175  {
1176  __SUP_SS__ << "Error was caught while " << transitionName << ": " << e.what()
1177  << __E__;
1178  __SUP_COUT_ERR__ << "\n" << ss.str();
1179  theStateMachine_.setErrorMessage(ss.str());
1180  throw toolbox::fsm::exception::Exception(
1181  "Transition Error" /*name*/,
1182  ss.str() /* message*/,
1183  "CoreSupervisorBase::transition" + transitionName /*module*/,
1184  __LINE__ /*line*/,
1185  __FUNCTION__ /*function*/
1186  );
1187  }
1188  catch(...)
1189  {
1190  __SUP_SS__ << "Unknown error was caught while " << transitionName
1191  << ". Please checked the logs." << __E__;
1192  try
1193  {
1194  throw;
1195  } //one more try to printout extra info
1196  catch(const std::exception& e)
1197  {
1198  ss << "Exception message: " << e.what();
1199  }
1200  catch(...)
1201  {
1202  }
1203  __SUP_COUT_ERR__ << "\n" << ss.str();
1204  theStateMachine_.setErrorMessage(ss.str());
1205  throw toolbox::fsm::exception::Exception(
1206  "Transition Error" /*name*/,
1207  ss.str() /* message*/,
1208  "CoreSupervisorBase::transition" + transitionName /*module*/,
1209  __LINE__ /*line*/,
1210  __FUNCTION__ /*function*/
1211  );
1212  }
1213 } // end transitionStarting()
1214 
1215 //==============================================================================
1216 void CoreSupervisorBase::transitionStopping(toolbox::Event::Reference /*event*/)
1217 {
1218  const std::string transitionName = "Stopping";
1219  try
1220  {
1221  __SUP_COUT__ << "Configuring all state machine implementations..." << __E__;
1222  preStateMachineExecutionLoop();
1223  for(unsigned int i = 0; i < theStateMachineImplementation_.size(); ++i)
1224  {
1225  // if one state machine is doing a sub-iteration, then target that one
1226  if(subIterationWorkStateMachineIndex_ != (unsigned int)-1 &&
1227  i != subIterationWorkStateMachineIndex_)
1228  continue; // skip those not in the sub-iteration
1229 
1231  continue; // skip state machines already done
1232 
1233  preStateMachineExecution(i);
1234  theStateMachineImplementation_[i]->stop(); // e.g. for FESupervisor, this is
1235  // transition of
1236  // FEVInterfacesManager
1237  postStateMachineExecution(i);
1238  }
1239  postStateMachineExecutionLoop();
1240  }
1241  catch(const std::runtime_error& e)
1242  {
1243  __SUP_SS__ << "Error was caught while " << transitionName << ": " << e.what()
1244  << __E__;
1245  __SUP_COUT_ERR__ << "\n" << ss.str();
1246  theStateMachine_.setErrorMessage(ss.str());
1247  throw toolbox::fsm::exception::Exception(
1248  "Transition Error" /*name*/,
1249  ss.str() /* message*/,
1250  "CoreSupervisorBase::transition" + transitionName /*module*/,
1251  __LINE__ /*line*/,
1252  __FUNCTION__ /*function*/
1253  );
1254  }
1255  catch(...)
1256  {
1257  __SUP_SS__ << "Unknown error was caught while " << transitionName
1258  << ". Please checked the logs." << __E__;
1259  try
1260  {
1261  throw;
1262  } //one more try to printout extra info
1263  catch(const std::exception& e)
1264  {
1265  ss << "Exception message: " << e.what();
1266  }
1267  catch(...)
1268  {
1269  }
1270  __SUP_COUT_ERR__ << "\n" << ss.str();
1271  theStateMachine_.setErrorMessage(ss.str());
1272  throw toolbox::fsm::exception::Exception(
1273  "Transition Error" /*name*/,
1274  ss.str() /* message*/,
1275  "CoreSupervisorBase::transition" + transitionName /*module*/,
1276  __LINE__ /*line*/,
1277  __FUNCTION__ /*function*/
1278  );
1279  }
1280 } // end transitionStopping()
1281 
1282 //==============================================================================
1287 void CoreSupervisorBase::sendAsyncExceptionToGateway(const std::string& errorMessage,
1288  bool isPauseException,
1289  bool isStopException)
1290 try
1291 {
1292  if(isStopException)
1293  __SUP_COUT_ERR__ << "Sending Supervisor Async STOP Running Exception... \n"
1294  << errorMessage << __E__;
1295  else if(isPauseException)
1296  __SUP_COUT_ERR__ << "Sending Supervisor Async SOFT Running Error... \n"
1297  << errorMessage << __E__;
1298  else
1299  __SUP_COUT_ERR__ << "Sending Supervisor Async Running Error... \n"
1300  << errorMessage << __E__;
1301 
1302  theStateMachine_.setErrorMessage(errorMessage);
1303 
1304  XDAQ_CONST_CALL xdaq::ApplicationDescriptor* gatewaySupervisor =
1305  allSupervisorInfo_.getGatewayInfo().getDescriptor();
1306 
1307  SOAPParameters parameters;
1308  parameters.addParameter("ErrorMessage", errorMessage);
1309 
1310  xoap::MessageReference replyMessage = SOAPMessenger::sendWithSOAPReply(
1311  gatewaySupervisor,
1312  isStopException ? "AsyncStopException"
1313  : (isPauseException ? "AsyncPauseException" : "AsyncError"),
1314  parameters);
1315 
1316  std::stringstream replyMessageSStream;
1317  replyMessageSStream << SOAPUtilities::translate(replyMessage);
1318  __SUP_COUT__ << "Received... " << replyMessageSStream.str() << std::endl;
1319 
1320  if(replyMessageSStream.str().find("Fault") != std::string::npos)
1321  {
1322  __SUP_COUT_ERR__ << "Failure to indicate fault to Gateway..." << __E__;
1323  throw;
1324  }
1325 }
1326 catch(const xdaq::exception::Exception& e)
1327 {
1328  if(isStopException)
1329  __SUP_COUT__
1330  << "SOAP message failure indicating Supervisor asynchronous running STOP "
1331  "exception back to Gateway: "
1332  << e.what() << __E__;
1333  else if(isPauseException)
1334  __SUP_COUT__
1335  << "SOAP message failure indicating Supervisor asynchronous running SOFT "
1336  "exception back to Gateway: "
1337  << e.what() << __E__;
1338  else
1339  __SUP_COUT__ << "SOAP message failure indicating Supervisor asynchronous running "
1340  "error back to Gateway: "
1341  << e.what() << __E__;
1342  throw; // rethrow and hope error is noticed
1343 }
1344 catch(...)
1345 {
1346  if(isStopException)
1347  __SUP_COUT__
1348  << "Unknown error encounter indicating Supervisor asynchronous running "
1349  "STOP exception back to Gateway."
1350  << __E__;
1351  else if(isPauseException)
1352  __SUP_COUT__
1353  << "Unknown error encounter indicating Supervisor asynchronous running "
1354  "SOFT error back to Gateway."
1355  << __E__;
1356  else
1357  __SUP_COUT__
1358  << "Unknown error encounter indicating Supervisor asynchronous running "
1359  "error back to Gateway."
1360  << __E__;
1361  throw; // rethrow and hope error is noticed
1362 } // end SendAsyncErrorToGateway()
1363 
1364 //==============================================================================
1365 xoap::MessageReference CoreSupervisorBase::TRACESupervisorRequest(
1366  xoap::MessageReference message)
1367 {
1368  return CorePropertySupervisorBase::TRACESupervisorRequest(message);
1369 } // end TRACESupervisorRequest()
static std::string getOrPostData(cgicc::Cgicc &cgi, const std::string &needle)
static std::string getData(cgicc::Cgicc &cgi, const std::string &needle)
void loadTableGroup(const std::string &tableGroupName, const TableGroupKey &tableGroupKey, bool doActivate=false, std::map< std::string, TableVersion > *groupMembers=0, ProgressBar *progressBar=0, std::string *accumulateWarnings=0, std::string *groupComment=0, std::string *groupAuthor=0, std::string *groupCreateTime=0, bool doNotLoadMember=false, std::string *groupTypeString=0, std::map< std::string, std::string > *groupAliases=0, ConfigurationManager::LoadGroupType onlyLoadIfBackboneOrContext=ConfigurationManager::LoadGroupType::ALL_TYPES, bool ignoreVersionTracking=false)
void getRequestUserInfo(WebUsers::RequestUserInfo &requestUserInfo)
virtual void transitionHalting(toolbox::Event::Reference event)
virtual void stateInitial(toolbox::fsm::FiniteStateMachine &fsm)
void stateMachineXgiHandler(xgi::Input *in, xgi::Output *out)
State Machine request handlers.
virtual void request(const std::string &requestType, cgicc::Cgicc &cgiIn, HttpXmlDocument &xmlOut, const WebUsers::RequestUserInfo &userInfo)
virtual void stateConfigured(toolbox::fsm::FiniteStateMachine &fsm)
virtual std::string getStatusProgressDetail(void)
virtual void statePaused(toolbox::fsm::FiniteStateMachine &fsm)
virtual void stateRunning(toolbox::fsm::FiniteStateMachine &fsm)
virtual void transitionInitializing(toolbox::Event::Reference event)
virtual void defaultPage(xgi::Input *in, xgi::Output *out)
virtual void nonXmlRequest(const std::string &requestType, cgicc::Cgicc &cgiIn, std::ostream &out, const WebUsers::RequestUserInfo &userInfo)
std::vector< bool > stateMachinesIterationDone_
for managing transition iterations
void sendAsyncExceptionToGateway(const std::string &errMsg, bool isPauseException, bool isStopException)
virtual void stateHalted(toolbox::fsm::FiniteStateMachine &fsm)
time_t getTimeInState(void) const
void outputXmlDocument(std::ostringstream *out, bool dispStdOut=false, bool allowWhiteSpace=false, bool printErrors=false)
bool xmlRequestToGateway(cgicc::Cgicc &cgi, std::ostringstream *out, HttpXmlDocument *xmldoc, const AllSupervisorInfo &allSupervisorInfo, WebUsers::RequestUserInfo &userInfo)
std::string send(XDAQ_CONST_CALL xdaq::ApplicationDescriptor *d, xoap::MessageReference message)
XDAQ_CONST_CALL xdaq::ApplicationDescriptor * getDescriptor(void) const
Getters ----------------—.
HttpXmlDocument processRequest(cgicc::Cgicc &cgi)
void INIT_MF(const char *name)
static std::string getTimeDurationString(const time_t durationInSeconds=time(0))