tdaq-develop-2025-02-12
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  std::stringstream xmlDataSs;
186  try
187  {
188  // call derived class' request()
189  request(requestType, cgiIn, xmlOut, userInfo);
190  }
191  catch(const std::runtime_error& e)
192  {
193  __SUP_SS__ << "An error was encountered handling requestType '" << requestType
194  << "':" << e.what() << __E__;
195  __SUP_COUT_ERR__ << "\n" << ss.str();
196  xmlOut.addTextElementToData("Error", ss.str());
197  }
198  catch(...)
199  {
200  __SUP_SS__ << "An unknown error was encountered handling requestType '"
201  << requestType << ".' "
202  << "Please check the printouts to debug." << __E__;
203  try
204  {
205  throw;
206  } //one more try to printout extra info
207  catch(const std::exception& e)
208  {
209  ss << "Exception message: " << e.what();
210  }
211  catch(...)
212  {
213  }
214  __SUP_COUT_ERR__ << "\n" << ss.str();
215  xmlOut.addTextElementToData("Error", ss.str());
216  }
217  __SUP_COUTT__ << "Request '" << requestType
218  << "' time: " << artdaq::TimeUtils::GetElapsedTime(requestStart)
219  << __E__;
220 
221  // report any errors encountered
222  // but only if there are a reasonable number of children
223  size_t numberOfChildren = xmlOut.getRootDataElement()->getChildNodes()->getLength();
224  if(numberOfChildren &&
225  xmlOut.getRootDataElement()->getChildNodes()->item(0)->getNodeType() !=
226  xercesc::DOMNode::TEXT_NODE)
227  numberOfChildren += xmlOut.getRootDataElement()
228  ->getChildNodes()
229  ->item(0)
230  ->getChildNodes()
231  ->getLength();
232 
233  __SUP_COUTT__ << "Number of xml data element children: " << numberOfChildren << __E__;
234 
235  if(numberOfChildren < 1000)
236  {
237  unsigned int occurance = 0;
238  std::string err = xmlOut.getMatchingValue("Error", occurance++);
239  while(err != "")
240  {
241  __SUP_COUT_ERR__ << "'" << requestType << "' ERROR encountered: " << err
242  << __E__;
243  err = xmlOut.getMatchingValue("Error", occurance++);
244  }
245  __SUP_COUTT__ << "Elapsed time after error check: "
246  << artdaq::TimeUtils::GetElapsedTime(requestStart) << __E__;
247  }
248 
249  // __SUP_COUTV__(xmlDataSs.str());
250 
251  // return xml doc holding server response
252  xmlOut.outputXmlDocument((std::ostringstream*)out,
253  false /*print to cout*/,
254  !userInfo.NoXmlWhiteSpace_ /*allow whitespace*/);
255 
256  __SUP_COUTT__ << "Total xml request time: "
257  << artdaq::TimeUtils::GetElapsedTime(requestStart) << " = "
258  << time(0) - requestStartTime << __E__;
259 } // end requestWrapper()
260 catch(const std::runtime_error& e)
261 {
262  __SUP_SS__ << "An error was encountered handling HTTP request:" << e.what() << __E__;
263  __SUP_COUT_ERR__ << "\n" << ss.str();
264  throw;
265 }
266 catch(...)
267 {
268  __SUP_SS__ << "An unknown error was encountered HTTP request. "
269  << "Please check the printouts to debug." << __E__;
270  try
271  {
272  throw;
273  } //one more try to printout extra info
274  catch(const std::exception& e)
275  {
276  ss << "Exception message: " << e.what();
277  }
278  catch(...)
279  {
280  }
281  __SUP_COUT_ERR__ << "\n" << ss.str();
282  throw;
283 } // end requestWrapper() error handling
284 
285 //==============================================================================
291 void CoreSupervisorBase::request(const std::string& /*requestType*/,
292  cgicc::Cgicc& /*cgiIn*/,
293  HttpXmlDocument& xmlOut,
294  const WebUsers::RequestUserInfo& /*userInfo*/)
295 {
296  __SUP_SS__ << "This is the empty Core Supervisor request. Supervisors should "
297  "override this function."
298  << __E__;
299  __SUP_COUT__ << ss.str();
300  xmlOut.addTextElementToData("Error", ss.str());
301  return;
302 
303  // KEEP:
304  // here are some possibly interesting example lines of code for overriding
305  // supervisors
306  //
307  // try
308  //{
309  //
310  // if(requestType == "savePlanCommandSequence")
311  // {
312  // std::string planName = CgiDataUtilities::getData(cgiIn,"planName");
314  // CgiDataUtilities::postData(cgiIn,"commands");
316  //
317  // cgiIn.getFiles()
318  // __SUP_COUT__ << "planName: " << planName << __E__;
319  // __SUP_COUTV__(commands);
320  //
321  //
322  // }
323  // else
324  // {
325  // __SUP_SS__ << "requestType '" << requestType << "' request not recognized." <<
326  // __E__;
327  // __SUP_SS_THROW__;
328  // }
329  // xmlOut.addTextElementToData("Error",
330  // "request encountered an error!");
331  //}
332  // catch(const std::runtime_error& e)
333  // {
334  // __SUP_SS__ << "An error was encountered handling requestType '" << requestType
335  //<< "':" << e.what() << __E__;
336  // __SUP_COUT_ERR__ << "\n" << ss.str();
337  // xmlOut.addTextElementToData("Error", ss.str());
338  // }
339  // catch(...)
340  // {
341  // __SUP_SS__ << "An unknown error was encountered handling requestType '" <<
342  // requestType << ".' " << "Please check the printouts to debug." <<
343  //__E__;
344  // __SUP_COUT_ERR__ << "\n" << ss.str();
345  // xmlOut.addTextElementToData("Error", ss.str());
346  // }
347  // END KEEP.
348 
349 } // end request()
350 
351 //==============================================================================
357 void CoreSupervisorBase::nonXmlRequest(const std::string& /*requestType*/,
358  cgicc::Cgicc& /*cgiIn*/,
359  std::ostream& out,
360  const WebUsers::RequestUserInfo& /*userInfo*/)
361 {
362  __SUP_COUT__ << "This is the empty Core Supervisor non-xml request. Supervisors "
363  "should override this function."
364  << __E__;
365  out << "This is the empty Core Supervisor non-xml request. Supervisors should "
366  "override this function."
367  << __E__;
368 } // end nonXmlRequest()
369 
370 //==============================================================================
371 void CoreSupervisorBase::stateMachineXgiHandler(xgi::Input* /*in*/, xgi::Output* /*out*/)
372 {
373 }
374 
375 //==============================================================================
376 xoap::MessageReference CoreSupervisorBase::stateMachineXoapHandler(
377  xoap::MessageReference message)
378 {
379  __SUP_COUT__ << "Soap Handler!" << __E__;
380  stateMachineWorkLoopManager_.removeProcessedRequests();
381  stateMachineWorkLoopManager_.processRequest(message);
382  __SUP_COUT__ << "Done - Soap Handler!" << __E__;
383  return message;
384 } // end stateMachineXoapHandler()
385 
386 //==============================================================================
388 xoap::MessageReference CoreSupervisorBase::workLoopStatusRequestWrapper(
389  xoap::MessageReference message)
390 {
391  // this should have an override for monitoring work loops being done
392  return workLoopStatusRequest(message);
393 } // end workLoopStatusRequest()
394 
395 //==============================================================================
396 xoap::MessageReference CoreSupervisorBase::workLoopStatusRequest(
397  xoap::MessageReference /*message*/)
398 {
399  // this should have an override for monitoring work loops being done
400  return SOAPUtilities::makeSOAPMessageReference(CoreSupervisorBase::WORK_LOOP_DONE);
401 } // end workLoopStatusRequest()
402 
403 //==============================================================================
404 xoap::MessageReference CoreSupervisorBase::applicationStatusRequest(
405  xoap::MessageReference /*message*/)
406 {
407  // send back status and progress parameters
408 
409  __SUP_COUTVS__(20,
410  std::to_string(getpid()) + ":" + std::to_string(gettid()) + ":" +
411  theStateMachine_.getCurrentStateName());
412 
413  const std::string& err = theStateMachine_.getErrorMessage();
414  // std::string status = err == "" ? (theStateMachine_.isInTransition() ? theStateMachine_.getProvenanceStateName() : theStateMachine_.getCurrentStateName())
415  // : (theStateMachine_.getCurrentStateName() == "Paused" ? "Soft-Error:::" : "Error:::") + err;
416 
417  // __SUP_COUTV__(theStateMachine_.isInTransition());
418  // __SUP_COUTV__(theStateMachine_.getProvenanceStateName());
419  // __SUP_COUTV__(theStateMachine_.getCurrentStateName());
420  // __SUP_COUTV__(RunControlStateMachine::theProgressBar_.readPercentageString());
421 
422  SOAPParameters retParameters;
423  if(err == "")
424  {
425  if(theStateMachine_.isInTransition() ||
426  RunControlStateMachine::theProgressBar_.read() < 100)
427  {
428  // attempt to get transition name, otherwise give provenance state
429  try
430  {
431  retParameters.addParameter("Status",
432  theStateMachine_.getCurrentTransitionName());
433  }
434  catch(...)
435  {
436  retParameters.addParameter("Status",
437  theStateMachine_.getProvenanceStateName());
438  }
439  }
440  else
441  retParameters.addParameter("Status", theStateMachine_.getCurrentStateName());
442  }
443  else
444  retParameters.addParameter(
445  "Status",
446  (theStateMachine_.getCurrentStateName() == "Paused" ? "Soft-Error:::"
447  : "Error:::") +
448  err);
449 
450  retParameters.addParameter(
451  "Progress", RunControlStateMachine::theProgressBar_.readPercentageString());
452  retParameters.addParameter(
453  "Detail",
454  getStatusProgressDetail()); // call virtual progress detail string generation
455  auto subappInfo = getSubappInfo();
456  retParameters.addParameter("Subapps",
457  SupervisorInfo::serializeSubappInfos(subappInfo));
458 
459  return SOAPUtilities::makeSOAPMessageReference("applicationStatusRequestReply",
460  retParameters);
461 } // end applicationStatusRequest()
462 
463 //==============================================================================
469 {
470  std::string detail;
471  unsigned int cnt = 0;
472 
473  /*
474  //__SUP_COUT__ << "Checking..." << CoreSupervisorBase::theStateMachineImplementation_.size() << __E__;
475  for(const auto& fsm : CoreSupervisorBase::theStateMachineImplementation_)
476  {
477  //__SUP_COUT__ << "Checking..." << __E__;
478  try
479  {
480  VStateMachine* testFSM = dynamic_cast<VStateMachine*>(fsm);
481  }
482  catch(...)
483  {
484  __SUP_COUT__ << "getStatusProgressDetail() VStateMachine testFSM Failed..." << __E__;
485  throw;
486  }
487  }
488  */
489 
490  if(!theStateMachine_.isInTransition() &&
491  (theStateMachine_.getCurrentStateName() ==
492  RunControlStateMachine::HALTED_STATE_NAME ||
493  theStateMachine_.getCurrentStateName() ==
494  RunControlStateMachine::INITIAL_STATE_NAME))
495  {
496  detail = std::string("Uptime: ") +
497  StringMacros::encodeURIComponent(StringMacros::getTimeDurationString(
498  CorePropertySupervisorBase::getSupervisorUptime())) +
499  ", Time-in-state: " +
500  StringMacros::encodeURIComponent(StringMacros::getTimeDurationString(
501  theStateMachine_.getTimeInState()));
502  return detail;
503  }
504 
505  for(const auto& fsm : CoreSupervisorBase::theStateMachineImplementation_)
506  {
507  std::string fsmProgressDetail = fsm->getStatusProgressDetail();
508  if(fsmProgressDetail.size())
509  detail +=
510  ((cnt++) ? ":" : "") +
511  fsmProgressDetail; // StringMacros::encodeURIComponent(fsmProgressDetail);
512  }
513 
514  if(detail.size())
515  __SUP_COUTVS__(20, detail);
516 
517  // if empty detail, give last command
518  if(!detail.size() && RunControlStateMachine::getLastCommand() != "")
519  {
520  detail = "Last Command: " + RunControlStateMachine::getLastCommand();
521  if(RunControlStateMachine::getLastCommand() ==
522  RunControlStateMachine::CONFIGURE_TRANSITION_NAME)
523  detail += " w/" + RunControlStateMachine::getLastAttemptedConfigureGroup();
524  }
525 
526  return detail;
527 } // end getStatusProgressDetail()
528 
529 //==============================================================================
530 bool CoreSupervisorBase::stateMachineThread(toolbox::task::WorkLoop* workLoop)
531 {
532  stateMachineSemaphore_.take();
533  __SUP_COUT__ << "Re-sending message..."
534  << SOAPUtilities::translate(
535  stateMachineWorkLoopManager_.getMessage(workLoop))
536  .getCommand()
537  << __E__;
538  std::string reply = send(this->getApplicationDescriptor(),
539  stateMachineWorkLoopManager_.getMessage(workLoop));
540  stateMachineWorkLoopManager_.report(workLoop, reply, 100, true);
541  __SUP_COUT__ << "Done with message" << __E__;
542  stateMachineSemaphore_.give();
543  return false; // execute once and automatically remove the workloop so in
544  // WorkLoopManager the try workLoop->remove(job_) could be commented
545  // out return true;//go on and then you must do the
546  // workLoop->remove(job_) in WorkLoopManager
547 } // end stateMachineThread()
548 
549 //==============================================================================
550 xoap::MessageReference CoreSupervisorBase::stateMachineStateRequest(
551  xoap::MessageReference /*message*/)
552 {
553  __SUP_COUT__ << "theStateMachine_.getCurrentStateName() = "
554  << theStateMachine_.getCurrentStateName() << __E__;
555  return SOAPUtilities::makeSOAPMessageReference(
556  theStateMachine_.getCurrentStateName());
557 }
558 
559 //==============================================================================
560 xoap::MessageReference CoreSupervisorBase::stateMachineErrorMessageRequest(
561  xoap::MessageReference /*message*/)
562 
563 {
564  __SUP_COUT__ << "theStateMachine_.getErrorMessage() = "
565  << theStateMachine_.getErrorMessage() << __E__;
566 
567  SOAPParameters retParameters;
568  retParameters.addParameter("ErrorMessage", theStateMachine_.getErrorMessage());
569  return SOAPUtilities::makeSOAPMessageReference("stateMachineErrorMessageRequestReply",
570  retParameters);
571 } // end stateMachineErrorMessageRequest()
572 
573 //==============================================================================
574 void CoreSupervisorBase::stateInitial(toolbox::fsm::FiniteStateMachine& /*fsm*/)
575 {
576  __SUP_COUT__ << "CoreSupervisorBase::stateInitial" << __E__;
577 }
578 
579 //==============================================================================
580 void CoreSupervisorBase::stateHalted(toolbox::fsm::FiniteStateMachine& /*fsm*/)
581 {
582  __SUP_COUT__ << "CoreSupervisorBase::stateHalted" << __E__;
583 }
584 
585 //==============================================================================
586 void CoreSupervisorBase::stateRunning(toolbox::fsm::FiniteStateMachine& /*fsm*/)
587 {
588  __SUP_COUT__ << "CoreSupervisorBase::stateRunning" << __E__;
589 }
590 
591 //==============================================================================
592 void CoreSupervisorBase::stateConfigured(toolbox::fsm::FiniteStateMachine& /*fsm*/)
593 {
594  __SUP_COUT__ << "CoreSupervisorBase::stateConfigured" << __E__;
595 }
596 
597 //==============================================================================
598 void CoreSupervisorBase::statePaused(toolbox::fsm::FiniteStateMachine& /*fsm*/)
599 {
600  __SUP_COUT__ << "CoreSupervisorBase::statePaused" << __E__;
601 }
602 
603 //==============================================================================
604 void CoreSupervisorBase::inError(toolbox::fsm::FiniteStateMachine& /*fsm*/)
605 
606 {
607  __SUP_COUT__ << "Fsm current state: " << theStateMachine_.getCurrentStateName()
608  << __E__;
609  // rcmsStateNotifier_.stateChanged("Error", "");
610 }
611 
612 //==============================================================================
613 void CoreSupervisorBase::enteringError(toolbox::Event::Reference event)
614 
615 {
616  // __SUP_COUT__<< "Fsm current state: " << theStateMachine_.getCurrentStateName()
617  // << "\n\nError Message: " <<
618  // theStateMachine_.getErrorMessage() << __E__;
619  toolbox::fsm::FailedEvent& failedEvent =
620  dynamic_cast<toolbox::fsm::FailedEvent&>(*event);
621  std::ostringstream error;
622  error << "Failure performing transition from " << failedEvent.getFromState() << " to "
623  << failedEvent.getToState()
624  << " exception: " << failedEvent.getException().what();
625  __SUP_COUT_ERR__ << error.str() << __E__;
626  // diagService_->reportError(errstr.str(),DIAGERROR);
627 }
628 
629 //==============================================================================
630 void CoreSupervisorBase::preStateMachineExecutionLoop(void)
631 {
632  RunControlStateMachine::clearIterationWork();
633  RunControlStateMachine::clearSubIterationWork();
634 
635  stateMachinesIterationWorkCount_ = 0;
636 
637  if(RunControlStateMachine::getIterationIndex() == 0 &&
638  RunControlStateMachine::getSubIterationIndex() == 0)
639  {
640  // reset vector for iterations done on first iteration
641 
642  subIterationWorkStateMachineIndex_ = -1; // clear sub iteration work index
643 
644  stateMachinesIterationDone_.resize(theStateMachineImplementation_.size());
645  for(unsigned int i = 0; i < stateMachinesIterationDone_.size(); ++i)
646  stateMachinesIterationDone_[i] = false;
647  }
648  else
649  __SUP_COUT__ << "Iteration " << RunControlStateMachine::getIterationIndex() << "."
650  << RunControlStateMachine::getSubIterationIndex() << "("
651  << subIterationWorkStateMachineIndex_ << ")" << __E__;
652 }
653 
654 //==============================================================================
655 void CoreSupervisorBase::preStateMachineExecution(unsigned int i)
656 {
657  if(i >= theStateMachineImplementation_.size())
658  {
659  __SUP_SS__ << "State Machine " << i << " not found!" << __E__;
660  __SUP_SS_THROW__;
661  }
662 
663  theStateMachineImplementation_[i]->VStateMachine::setIterationIndex(
664  RunControlStateMachine::getIterationIndex());
665  theStateMachineImplementation_[i]->VStateMachine::setSubIterationIndex(
666  RunControlStateMachine::getSubIterationIndex());
667 
668  theStateMachineImplementation_[i]->VStateMachine::clearIterationWork();
669  theStateMachineImplementation_[i]->VStateMachine::clearSubIterationWork();
670 
671  __SUP_COUT__
672  << "theStateMachineImplementation Iteration "
673  << theStateMachineImplementation_[i]->VStateMachine::getIterationIndex() << "."
674  << theStateMachineImplementation_[i]->VStateMachine::getSubIterationIndex()
675  << __E__;
676 }
677 
678 //==============================================================================
679 void CoreSupervisorBase::postStateMachineExecution(unsigned int i)
680 {
681  if(i >= theStateMachineImplementation_.size())
682  {
683  __SUP_SS__ << "State Machine " << i << " not found!" << __E__;
684  __SUP_SS_THROW__;
685  }
686 
687  // sub-iteration has priority
688  if(theStateMachineImplementation_[i]->VStateMachine::getSubIterationWork())
689  {
690  subIterationWorkStateMachineIndex_ = i;
691  RunControlStateMachine::indicateSubIterationWork();
692 
693  __SUP_COUT__ << "State machine " << i
694  << " is flagged for another sub-iteration..." << __E__;
695  }
696  else
697  {
699  !theStateMachineImplementation_[i]->VStateMachine::getIterationWork();
700 
702  {
703  __SUP_COUT__ << "State machine " << i
704  << " is flagged for another iteration..." << __E__;
705  RunControlStateMachine::indicateIterationWork(); // mark not done at
706  // CoreSupervisorBase level
707  ++stateMachinesIterationWorkCount_; // increment still working count
708  }
709  }
710 } // end postStateMachineExecution()
711 
712 //==============================================================================
713 void CoreSupervisorBase::postStateMachineExecutionLoop(void)
714 {
715  if(RunControlStateMachine::subIterationWorkFlag_)
716  __SUP_COUT__ << "State machine implementation "
717  << subIterationWorkStateMachineIndex_
718  << " is flagged for another sub-iteration..." << __E__;
719  else if(RunControlStateMachine::iterationWorkFlag_)
720  __SUP_COUT__
721  << stateMachinesIterationWorkCount_
722  << " state machine implementation(s) flagged for another iteration..."
723  << __E__;
724  else
725  __SUP_COUT__ << "Done configuration all state machine implementations..."
726  << __E__;
727 } // end postStateMachineExecutionLoop()
728 
729 //==============================================================================
730 void CoreSupervisorBase::transitionConfiguring(toolbox::Event::Reference /*event*/)
731 {
732  __SUP_COUT__ << "transitionConfiguring" << __E__;
733 
734  // activate the configuration tree (the first iteration)
735  if(RunControlStateMachine::getIterationIndex() == 0 &&
736  RunControlStateMachine::getSubIterationIndex() == 0)
737  {
738  std::pair<std::string /*group name*/, TableGroupKey> theGroup(
739  SOAPUtilities::translate(theStateMachine_.getCurrentMessage())
740  .getParameters()
741  .getValue("ConfigurationTableGroupName"),
742  TableGroupKey(SOAPUtilities::translate(theStateMachine_.getCurrentMessage())
743  .getParameters()
744  .getValue("ConfigurationTableGroupKey")));
745 
746  __SUP_COUT__ << "Configuration table group name: " << theGroup.first
747  << " key: " << theGroup.second << __E__;
748 
749  try
750  {
751  //disable version tracking to accept untracked versions to be selected by the FSM transition source
752  theConfigurationManager_->loadTableGroup(
753  theGroup.first,
754  theGroup.second,
755  true /*doActivate*/,
756  0,
757  0,
758  0,
759  0,
760  0,
761  0,
762  false,
763  0,
764  0,
765  ConfigurationManager::LoadGroupType::ALL_TYPES,
766  true /*ignoreVersionTracking*/);
767  }
768  catch(const std::runtime_error& e)
769  {
770  __SS__ << "Error loading table group '" << theGroup.first << "("
771  << theGroup.second << ")! \n"
772  << e.what() << __E__;
773  __SUP_COUT_ERR__ << ss.str();
774  // ExceptionHandler(ExceptionHandlerRethrow::no, ss.str());
775 
776  //__SS_THROW_ONLY__;
777  theStateMachine_.setErrorMessage(ss.str());
778  throw toolbox::fsm::exception::Exception(
779  "Transition Error" /*name*/,
780  ss.str() /* message*/,
781  "CoreSupervisorBase::transitionConfiguring" /*module*/,
782  __LINE__ /*line*/,
783  __FUNCTION__ /*function*/
784  );
785  }
786  catch(...)
787  {
788  __SS__ << "Unknown error loading table group '" << theGroup.first << "("
789  << theGroup.second << ")!" << __E__;
790  try
791  {
792  throw;
793  } //one more try to printout extra info
794  catch(const std::exception& e)
795  {
796  ss << "Exception message: " << e.what();
797  }
798  catch(...)
799  {
800  }
801  __SUP_COUT_ERR__ << ss.str();
802  // ExceptionHandler(ExceptionHandlerRethrow::no, ss.str());
803 
804  //__SS_THROW_ONLY__;
805  theStateMachine_.setErrorMessage(ss.str());
806  throw toolbox::fsm::exception::Exception(
807  "Transition Error" /*name*/,
808  ss.str() /* message*/,
809  "CoreSupervisorBase::transitionConfiguring" /*module*/,
810  __LINE__ /*line*/,
811  __FUNCTION__ /*function*/
812  );
813  }
814  }
815 
816  CoreSupervisorBase::transitionConfiguringFSMs();
817 
818  __SUP_COUT__ << "Configured." << __E__;
819 } // end transitionConfiguring()
820 
821 //==============================================================================
822 void CoreSupervisorBase::transitionConfiguringFSMs()
823 {
824  // Now that the configuration manager has all the necessary configurations,
825  // create all objects that depend on the configuration (the first iteration)
826 
827  try
828  {
829  __SUP_COUT__ << "Configuring all state machine implementations..." << __E__;
830  preStateMachineExecutionLoop();
831  for(unsigned int i = 0; i < theStateMachineImplementation_.size(); ++i)
832  {
833  // if one state machine is doing a sub-iteration, then target that one
834  if(subIterationWorkStateMachineIndex_ != (unsigned int)-1 &&
835  i != subIterationWorkStateMachineIndex_)
836  continue; // skip those not in the sub-iteration
837 
839  continue; // skip state machines already done
840 
841  preStateMachineExecution(i);
842  theStateMachineImplementation_[i]->parentSupervisor_ =
843  this; // for backwards compatibility, kept out of configure parameters
844  theStateMachineImplementation_[i]->configure(); // e.g. for FESupervisor,
845  // this is configure of
846  // FEVInterfacesManager
847  postStateMachineExecution(i);
848  }
849  postStateMachineExecutionLoop();
850  }
851  catch(const std::runtime_error& e)
852  {
853  __SUP_SS__ << "Error was caught while configuring: " << e.what() << __E__;
854  __SUP_COUT_ERR__ << "\n" << ss.str();
855  theStateMachine_.setErrorMessage(ss.str());
856  throw toolbox::fsm::exception::Exception(
857  "Transition Error" /*name*/,
858  ss.str() /* message*/,
859  "CoreSupervisorBase::transitionConfiguring" /*module*/,
860  __LINE__ /*line*/,
861  __FUNCTION__ /*function*/
862  );
863  }
864  catch(...)
865  {
866  __SUP_SS__
867  << "Unknown error was caught while configuring. Please checked the logs."
868  << __E__;
869  try
870  {
871  throw;
872  } //one more try to printout extra info
873  catch(const std::exception& e)
874  {
875  ss << "Exception message: " << e.what();
876  }
877  catch(...)
878  {
879  }
880  __SUP_COUT_ERR__ << "\n" << ss.str();
881  theStateMachine_.setErrorMessage(ss.str());
882  throw toolbox::fsm::exception::Exception(
883  "Transition Error" /*name*/,
884  ss.str() /* message*/,
885  "CoreSupervisorBase::transitionConfiguring" /*module*/,
886  __LINE__ /*line*/,
887  __FUNCTION__ /*function*/
888  );
889  }
890 } // end transitionConfiguringFSMs()
891 
892 //==============================================================================
895 void CoreSupervisorBase::transitionHalting(toolbox::Event::Reference /*event*/)
896 {
897  const std::string transitionName = "Halting";
898  try
899  {
900  __SUP_COUT__ << transitionName << " all state machine implementations..."
901  << __E__;
902  preStateMachineExecutionLoop();
903  for(unsigned int i = 0; i < theStateMachineImplementation_.size(); ++i)
904  {
905  // if one state machine is doing a sub-iteration, then target that one
906  if(subIterationWorkStateMachineIndex_ != (unsigned int)-1 &&
907  i != subIterationWorkStateMachineIndex_)
908  continue; // skip those not in the sub-iteration
909 
911  continue; // skip state machines already done
912 
913  preStateMachineExecution(i);
914  theStateMachineImplementation_[i]->halt(); // e.g. for FESupervisor, this is
915  // transition of
916  // FEVInterfacesManager
917  postStateMachineExecution(i);
918  }
919  postStateMachineExecutionLoop();
920  }
921  catch(const std::runtime_error& e)
922  {
923  // if halting from Failed state, then ignore errors
924  if(theStateMachine_.getProvenanceStateName() ==
925  RunControlStateMachine::FAILED_STATE_NAME)
926  {
927  __SUP_COUT_INFO__ << "Error was caught while halting (but ignoring because "
928  "previous state was '"
929  << RunControlStateMachine::FAILED_STATE_NAME
930  << "'): " << e.what() << __E__;
931  }
932  else // if not previously in Failed state, then fail
933  {
934  __SUP_SS__ << "Error was caught while " << transitionName << ": " << e.what()
935  << __E__;
936  __SUP_COUT_ERR__ << "\n" << ss.str();
937  theStateMachine_.setErrorMessage(ss.str());
938  throw toolbox::fsm::exception::Exception(
939  "Transition Error" /*name*/,
940  ss.str() /* message*/,
941  "CoreSupervisorBase::transition" + transitionName /*module*/,
942  __LINE__ /*line*/,
943  __FUNCTION__ /*function*/
944  );
945  }
946  }
947  catch(...)
948  {
949  // if halting from Failed state, then ignore errors
950  if(theStateMachine_.getProvenanceStateName() ==
951  RunControlStateMachine::FAILED_STATE_NAME)
952  {
953  __SUP_COUT_INFO__ << "Unknown error was caught while halting (but ignoring "
954  "because previous state was '"
955  << RunControlStateMachine::FAILED_STATE_NAME << "')."
956  << __E__;
957  }
958  else // if not previously in Failed state, then fail
959  {
960  __SUP_SS__ << "Unknown error was caught while " << transitionName
961  << ". Please checked the logs." << __E__;
962  try
963  {
964  throw;
965  } //one more try to printout extra info
966  catch(const std::exception& e)
967  {
968  ss << "Exception message: " << e.what();
969  }
970  catch(...)
971  {
972  }
973  __SUP_COUT_ERR__ << "\n" << ss.str();
974  theStateMachine_.setErrorMessage(ss.str());
975  throw toolbox::fsm::exception::Exception(
976  "Transition Error" /*name*/,
977  ss.str() /* message*/,
978  "CoreSupervisorBase::transition" + transitionName /*module*/,
979  __LINE__ /*line*/,
980  __FUNCTION__ /*function*/
981  );
982  }
983  }
984 } // end transitionHalting()
985 
986 //==============================================================================
989 void CoreSupervisorBase::transitionInitializing(toolbox::Event::Reference /*event*/)
990 {
991  __SUP_COUT__ << "transitionInitializing" << __E__;
992 
993  CorePropertySupervisorBase::resetPropertiesAreSetup(); // indicate need to re-load
994  // user properties
995 
996  // Note: Do not initialize the state machine implementations...
997  // do any initializing in configure
998  // This allows re-instantiation at each configure time.
999  // for(auto& it: theStateMachineImplementation_)
1000  // it->initialize();
1001 } // end transitionInitializing()
1002 
1003 //==============================================================================
1004 void CoreSupervisorBase::transitionPausing(toolbox::Event::Reference /*event*/)
1005 {
1006  const std::string transitionName = "Pausing";
1007  try
1008  {
1009  __SUP_COUT__ << "Configuring all state machine implementations..." << __E__;
1010  preStateMachineExecutionLoop();
1011  for(unsigned int i = 0; i < theStateMachineImplementation_.size(); ++i)
1012  {
1013  // if one state machine is doing a sub-iteration, then target that one
1014  if(subIterationWorkStateMachineIndex_ != (unsigned int)-1 &&
1015  i != subIterationWorkStateMachineIndex_)
1016  continue; // skip those not in the sub-iteration
1017 
1019  continue; // skip state machines already done
1020 
1021  preStateMachineExecution(i);
1022  theStateMachineImplementation_[i]->pause(); // e.g. for FESupervisor, this is
1023  // transition of
1024  // FEVInterfacesManager
1025  postStateMachineExecution(i);
1026  }
1027  postStateMachineExecutionLoop();
1028  }
1029  catch(const std::runtime_error& e)
1030  {
1031  __SUP_SS__ << "Error was caught while " << transitionName << ": " << e.what()
1032  << __E__;
1033  __SUP_COUT_ERR__ << "\n" << ss.str();
1034  theStateMachine_.setErrorMessage(ss.str());
1035  throw toolbox::fsm::exception::Exception(
1036  "Transition Error" /*name*/,
1037  ss.str() /* message*/,
1038  "CoreSupervisorBase::transition" + transitionName /*module*/,
1039  __LINE__ /*line*/,
1040  __FUNCTION__ /*function*/
1041  );
1042  }
1043  catch(...)
1044  {
1045  __SUP_SS__ << "Unknown error was caught while " << transitionName
1046  << ". Please checked the logs." << __E__;
1047  try
1048  {
1049  throw;
1050  } //one more try to printout extra info
1051  catch(const std::exception& e)
1052  {
1053  ss << "Exception message: " << e.what();
1054  }
1055  catch(...)
1056  {
1057  }
1058  __SUP_COUT_ERR__ << "\n" << ss.str();
1059  theStateMachine_.setErrorMessage(ss.str());
1060  throw toolbox::fsm::exception::Exception(
1061  "Transition Error" /*name*/,
1062  ss.str() /* message*/,
1063  "CoreSupervisorBase::transition" + transitionName /*module*/,
1064  __LINE__ /*line*/,
1065  __FUNCTION__ /*function*/
1066  );
1067  }
1068 } // end transitionPausing()
1069 
1070 //==============================================================================
1071 void CoreSupervisorBase::transitionResuming(toolbox::Event::Reference /*event*/)
1072 {
1073  const std::string transitionName = "Resuming";
1074  try
1075  {
1076  __SUP_COUT__ << "Configuring all state machine implementations..." << __E__;
1077  preStateMachineExecutionLoop();
1078  for(unsigned int i = 0; i < theStateMachineImplementation_.size(); ++i)
1079  {
1080  // if one state machine is doing a sub-iteration, then target that one
1081  if(subIterationWorkStateMachineIndex_ != (unsigned int)-1 &&
1082  i != subIterationWorkStateMachineIndex_)
1083  continue; // skip those not in the sub-iteration
1084 
1086  continue; // skip state machines already done
1087 
1088  preStateMachineExecution(i);
1089  theStateMachineImplementation_[i]->resume(); // e.g. for FESupervisor, this
1090  // is transition of
1091  // FEVInterfacesManager
1092  postStateMachineExecution(i);
1093  }
1094  postStateMachineExecutionLoop();
1095  }
1096  catch(const std::runtime_error& e)
1097  {
1098  __SUP_SS__ << "Error was caught while " << transitionName << ": " << e.what()
1099  << __E__;
1100  __SUP_COUT_ERR__ << "\n" << ss.str();
1101  theStateMachine_.setErrorMessage(ss.str());
1102  throw toolbox::fsm::exception::Exception(
1103  "Transition Error" /*name*/,
1104  ss.str() /* message*/,
1105  "CoreSupervisorBase::transition" + transitionName /*module*/,
1106  __LINE__ /*line*/,
1107  __FUNCTION__ /*function*/
1108  );
1109  }
1110  catch(...)
1111  {
1112  __SUP_SS__ << "Unknown error was caught while " << transitionName
1113  << ". Please checked the logs." << __E__;
1114  try
1115  {
1116  throw;
1117  } //one more try to printout extra info
1118  catch(const std::exception& e)
1119  {
1120  ss << "Exception message: " << e.what();
1121  }
1122  catch(...)
1123  {
1124  }
1125  __SUP_COUT_ERR__ << "\n" << ss.str();
1126  theStateMachine_.setErrorMessage(ss.str());
1127  throw toolbox::fsm::exception::Exception(
1128  "Transition Error" /*name*/,
1129  ss.str() /* message*/,
1130  "CoreSupervisorBase::transition" + transitionName /*module*/,
1131  __LINE__ /*line*/,
1132  __FUNCTION__ /*function*/
1133  );
1134  }
1135 } // end transitionResuming()
1136 
1137 //==============================================================================
1138 void CoreSupervisorBase::transitionStarting(toolbox::Event::Reference /*event*/)
1139 {
1140  const std::string transitionName = "Starting";
1141  const std::string runNumber =
1142  SOAPUtilities::translate(theStateMachine_.getCurrentMessage())
1143  .getParameters()
1144  .getValue("RunNumber");
1145  try
1146  {
1147  __SUP_COUT__ << "Configuring all state machine implementations..." << __E__;
1148  preStateMachineExecutionLoop();
1149  for(unsigned int i = 0; i < theStateMachineImplementation_.size(); ++i)
1150  {
1151  // if one state machine is doing a sub-iteration, then target that one
1152  if(subIterationWorkStateMachineIndex_ != (unsigned int)-1 &&
1153  i != subIterationWorkStateMachineIndex_)
1154  continue; // skip those not in the sub-iteration
1155 
1157  continue; // skip state machines already done
1158 
1159  preStateMachineExecution(i);
1160  theStateMachineImplementation_[i]->start(runNumber); // e.g. for
1161  // FESupervisor, this is
1162  // transition of
1163  // FEVInterfacesManager
1164  postStateMachineExecution(i);
1165  }
1166  postStateMachineExecutionLoop();
1167  }
1168  catch(const std::runtime_error& e)
1169  {
1170  __SUP_SS__ << "Error was caught while " << transitionName << ": " << e.what()
1171  << __E__;
1172  __SUP_COUT_ERR__ << "\n" << ss.str();
1173  theStateMachine_.setErrorMessage(ss.str());
1174  throw toolbox::fsm::exception::Exception(
1175  "Transition Error" /*name*/,
1176  ss.str() /* message*/,
1177  "CoreSupervisorBase::transition" + transitionName /*module*/,
1178  __LINE__ /*line*/,
1179  __FUNCTION__ /*function*/
1180  );
1181  }
1182  catch(...)
1183  {
1184  __SUP_SS__ << "Unknown error was caught while " << transitionName
1185  << ". Please checked the logs." << __E__;
1186  try
1187  {
1188  throw;
1189  } //one more try to printout extra info
1190  catch(const std::exception& e)
1191  {
1192  ss << "Exception message: " << e.what();
1193  }
1194  catch(...)
1195  {
1196  }
1197  __SUP_COUT_ERR__ << "\n" << ss.str();
1198  theStateMachine_.setErrorMessage(ss.str());
1199  throw toolbox::fsm::exception::Exception(
1200  "Transition Error" /*name*/,
1201  ss.str() /* message*/,
1202  "CoreSupervisorBase::transition" + transitionName /*module*/,
1203  __LINE__ /*line*/,
1204  __FUNCTION__ /*function*/
1205  );
1206  }
1207 } // end transitionStarting()
1208 
1209 //==============================================================================
1210 void CoreSupervisorBase::transitionStopping(toolbox::Event::Reference /*event*/)
1211 {
1212  const std::string transitionName = "Stopping";
1213  try
1214  {
1215  __SUP_COUT__ << "Configuring all state machine implementations..." << __E__;
1216  preStateMachineExecutionLoop();
1217  for(unsigned int i = 0; i < theStateMachineImplementation_.size(); ++i)
1218  {
1219  // if one state machine is doing a sub-iteration, then target that one
1220  if(subIterationWorkStateMachineIndex_ != (unsigned int)-1 &&
1221  i != subIterationWorkStateMachineIndex_)
1222  continue; // skip those not in the sub-iteration
1223 
1225  continue; // skip state machines already done
1226 
1227  preStateMachineExecution(i);
1228  theStateMachineImplementation_[i]->stop(); // e.g. for FESupervisor, this is
1229  // transition of
1230  // FEVInterfacesManager
1231  postStateMachineExecution(i);
1232  }
1233  postStateMachineExecutionLoop();
1234  }
1235  catch(const std::runtime_error& e)
1236  {
1237  __SUP_SS__ << "Error was caught while " << transitionName << ": " << e.what()
1238  << __E__;
1239  __SUP_COUT_ERR__ << "\n" << ss.str();
1240  theStateMachine_.setErrorMessage(ss.str());
1241  throw toolbox::fsm::exception::Exception(
1242  "Transition Error" /*name*/,
1243  ss.str() /* message*/,
1244  "CoreSupervisorBase::transition" + transitionName /*module*/,
1245  __LINE__ /*line*/,
1246  __FUNCTION__ /*function*/
1247  );
1248  }
1249  catch(...)
1250  {
1251  __SUP_SS__ << "Unknown error was caught while " << transitionName
1252  << ". Please checked the logs." << __E__;
1253  try
1254  {
1255  throw;
1256  } //one more try to printout extra info
1257  catch(const std::exception& e)
1258  {
1259  ss << "Exception message: " << e.what();
1260  }
1261  catch(...)
1262  {
1263  }
1264  __SUP_COUT_ERR__ << "\n" << ss.str();
1265  theStateMachine_.setErrorMessage(ss.str());
1266  throw toolbox::fsm::exception::Exception(
1267  "Transition Error" /*name*/,
1268  ss.str() /* message*/,
1269  "CoreSupervisorBase::transition" + transitionName /*module*/,
1270  __LINE__ /*line*/,
1271  __FUNCTION__ /*function*/
1272  );
1273  }
1274 } // end transitionStopping()
1275 
1276 //==============================================================================
1281 void CoreSupervisorBase::sendAsyncExceptionToGateway(const std::string& errorMessage,
1282  bool isPauseException,
1283  bool isStopException)
1284 try
1285 {
1286  if(isStopException)
1287  __SUP_COUT_ERR__ << "Sending Supervisor Async STOP Running Exception... \n"
1288  << errorMessage << __E__;
1289  else if(isPauseException)
1290  __SUP_COUT_ERR__ << "Sending Supervisor Async SOFT Running Error... \n"
1291  << errorMessage << __E__;
1292  else
1293  __SUP_COUT_ERR__ << "Sending Supervisor Async Running Error... \n"
1294  << errorMessage << __E__;
1295 
1296  theStateMachine_.setErrorMessage(errorMessage);
1297 
1298  XDAQ_CONST_CALL xdaq::ApplicationDescriptor* gatewaySupervisor =
1299  allSupervisorInfo_.getGatewayInfo().getDescriptor();
1300 
1301  SOAPParameters parameters;
1302  parameters.addParameter("ErrorMessage", errorMessage);
1303 
1304  xoap::MessageReference replyMessage = SOAPMessenger::sendWithSOAPReply(
1305  gatewaySupervisor,
1306  isStopException ? "AsyncStopException"
1307  : (isPauseException ? "AsyncPauseException" : "AsyncError"),
1308  parameters);
1309 
1310  std::stringstream replyMessageSStream;
1311  replyMessageSStream << SOAPUtilities::translate(replyMessage);
1312  __SUP_COUT__ << "Received... " << replyMessageSStream.str() << std::endl;
1313 
1314  if(replyMessageSStream.str().find("Fault") != std::string::npos)
1315  {
1316  __SUP_COUT_ERR__ << "Failure to indicate fault to Gateway..." << __E__;
1317  throw;
1318  }
1319 }
1320 catch(const xdaq::exception::Exception& e)
1321 {
1322  if(isStopException)
1323  __SUP_COUT__
1324  << "SOAP message failure indicating Supervisor asynchronous running STOP "
1325  "exception back to Gateway: "
1326  << e.what() << __E__;
1327  else if(isPauseException)
1328  __SUP_COUT__
1329  << "SOAP message failure indicating Supervisor asynchronous running SOFT "
1330  "exception back to Gateway: "
1331  << e.what() << __E__;
1332  else
1333  __SUP_COUT__ << "SOAP message failure indicating Supervisor asynchronous running "
1334  "error back to Gateway: "
1335  << e.what() << __E__;
1336  throw; // rethrow and hope error is noticed
1337 }
1338 catch(...)
1339 {
1340  if(isStopException)
1341  __SUP_COUT__
1342  << "Unknown error encounter indicating Supervisor asynchronous running "
1343  "STOP exception back to Gateway."
1344  << __E__;
1345  else if(isPauseException)
1346  __SUP_COUT__
1347  << "Unknown error encounter indicating Supervisor asynchronous running "
1348  "SOFT error back to Gateway."
1349  << __E__;
1350  else
1351  __SUP_COUT__
1352  << "Unknown error encounter indicating Supervisor asynchronous running "
1353  "error back to Gateway."
1354  << __E__;
1355  throw; // rethrow and hope error is noticed
1356 } // end SendAsyncErrorToGateway()
1357 
1358 //==============================================================================
1359 xoap::MessageReference CoreSupervisorBase::TRACESupervisorRequest(
1360  xoap::MessageReference message)
1361 {
1362  return CorePropertySupervisorBase::TRACESupervisorRequest(message);
1363 } // 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)
std::string getMatchingValue(const std::string &field, const unsigned int occurance=0)
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))