1 #include "otsdaq/CoreSupervisors/FESupervisor.h"
2 #include "otsdaq/ConfigurationInterface/ConfigurationManager.h"
3 #include "otsdaq/FECore/FEVInterfacesManager.h"
5 #include "artdaq/DAQdata/Globals.hh"
7 #include "artdaq-core/Utilities/ExceptionHandler.hh"
9 #include "fhiclcpp/make_ParameterSet.h"
40 __SUP_COUT__ <<
"Constructing..." << __E__;
42 xoap::bind(
this, &FESupervisor::macroMakerSupervisorRequest,
"MacroMakerSupervisorRequest", XDAQ_NS_URI);
44 xoap::bind(
this, &FESupervisor::workLoopStatusRequest,
"WorkLoopStatusRequest", XDAQ_NS_URI);
46 xoap::bind(
this, &FESupervisor::frontEndCommunicationRequest,
"FECommunication", XDAQ_NS_URI);
50 CoreSupervisorBase::theStateMachineImplementation_.push_back(
51 new FEVInterfacesManager(CorePropertySupervisorBase::getContextTreeNode(), CorePropertySupervisorBase::getSupervisorConfigurationPath()));
55 if(CorePropertySupervisorBase::allSupervisorInfo_.isMacroMakerMode())
57 __SUP_COUT_WARN__ <<
"Error caught constructing FE Interface Manager. In "
58 "Macro Maker mode, the input fhicl defines the "
59 "configuration tree, make sure you specified a valid "
66 extractFEInterfacesManager();
68 __SUP_COUT__ <<
"Constructed." << __E__;
70 if(CorePropertySupervisorBase::allSupervisorInfo_.isMacroMakerMode())
72 __SUP_COUT_INFO__ <<
"Macro Maker mode, so configuring at startup!" << __E__;
73 if(!theFEInterfacesManager_)
75 __SUP_SS__ <<
"Missing FE Interface manager!" << __E__;
86 __SUP_COUT__ <<
"Configuring all state machine implementations..." << __E__;
87 preStateMachineExecutionLoop();
88 for(
unsigned int i = 0; i < theStateMachineImplementation_.size(); ++i)
91 if(subIterationWorkStateMachineIndex_ != (
unsigned int)-1 && i != subIterationWorkStateMachineIndex_)
94 if(stateMachinesIterationDone_[i])
97 preStateMachineExecution(i);
98 theStateMachineImplementation_[i]->parentSupervisor_ =
this;
100 theStateMachineImplementation_[i]->configure();
103 postStateMachineExecution(i);
105 postStateMachineExecutionLoop();
107 catch(
const std::runtime_error& e)
109 __SUP_SS__ <<
"Error was caught while configuring: " << e.what() << __E__;
110 __SUP_COUT_ERR__ <<
"\n" << ss.str();
111 theStateMachine_.setErrorMessage(ss.str());
115 __SUP_SS__ <<
"Unknown error was caught while configuring. Please checked the logs." << __E__;
116 __SUP_COUT_ERR__ <<
"\n" << ss.str();
117 theStateMachine_.setErrorMessage(ss.str());
123 FESupervisor::~FESupervisor(
void)
125 __SUP_COUT__ <<
"Destroying..." << __E__;
129 artdaq::Globals::CleanUpGlobals();
131 __SUP_COUT__ <<
"Destructed." << __E__;
135 xoap::MessageReference FESupervisor::frontEndCommunicationRequest(xoap::MessageReference message)
try
137 __SUP_COUT__ <<
"FE Request received: " << SOAPUtilities::translate(message) << __E__;
139 if(!theFEInterfacesManager_)
141 __SUP_SS__ <<
"No FE Interface Manager!" << __E__;
145 typeParameter.addParameter(
"type");
146 SOAPUtilities::receive(message, typeParameter);
148 std::string type = typeParameter.getValue(
"type");
158 rxParameters.addParameter(
"requester");
159 rxParameters.addParameter(
"targetInterfaceID");
165 rxParameters.addParameter(
"value");
166 SOAPUtilities::receive(message, rxParameters);
168 std::string requester = rxParameters.getValue(
"requester");
169 std::string targetInterfaceID = rxParameters.getValue(
"targetInterfaceID");
170 std::string value = rxParameters.getValue(
"value");
172 __SUP_COUTV__(requester);
173 __SUP_COUTV__(targetInterfaceID);
174 __SUP_COUTV__(value);
177 theFEInterfacesManager_->getFEInterface(targetInterfaceID);
181 std::lock_guard<std::mutex> lock(theFEInterfacesManager_->frontEndCommunicationReceiveMutex_);
183 theFEInterfacesManager_->frontEndCommunicationReceiveBuffer_[targetInterfaceID][requester].emplace(value);
185 __SUP_COUT__ <<
"Number of target interface ID '" << targetInterfaceID
186 <<
"' buffers: " << theFEInterfacesManager_->frontEndCommunicationReceiveBuffer_[targetInterfaceID].size() << __E__;
187 __SUP_COUT__ <<
"Number of source interface ID '" << requester
188 <<
"' values received: " << theFEInterfacesManager_->frontEndCommunicationReceiveBuffer_[targetInterfaceID][requester].size() << __E__;
190 return SOAPUtilities::makeSOAPMessageReference(
"Received");
192 else if(type ==
"feMacro")
196 rxParameters.addParameter(
"feMacroName");
197 rxParameters.addParameter(
"inputArgs");
199 SOAPUtilities::receive(message, rxParameters);
201 std::string requester = rxParameters.getValue(
"requester");
202 std::string targetInterfaceID = rxParameters.getValue(
"targetInterfaceID");
203 std::string feMacroName = rxParameters.getValue(
"feMacroName");
204 std::string inputArgs = rxParameters.getValue(
"inputArgs");
206 __SUP_COUTV__(requester);
207 __SUP_COUTV__(targetInterfaceID);
208 __SUP_COUTV__(feMacroName);
209 __SUP_COUTV__(inputArgs);
211 std::string outputArgs;
214 theFEInterfacesManager_->runFEMacroByFE(requester, targetInterfaceID, feMacroName, inputArgs, outputArgs);
216 catch(std::runtime_error& e)
218 __SUP_SS__ <<
"In Supervisor with LID=" << getApplicationDescriptor()->getLocalId() <<
" the FE Macro named '" << feMacroName
219 <<
"' with target FE '" << targetInterfaceID <<
"' failed. Here is the error:\n\n"
220 << e.what() << __E__;
225 __SUP_SS__ <<
"In Supervisor with LID=" << getApplicationDescriptor()->getLocalId() <<
" the FE Macro named '" << feMacroName
226 <<
"' with target FE '" << targetInterfaceID <<
"' failed due to an unknown error." << __E__;
230 __SUP_COUTV__(outputArgs);
232 xoap::MessageReference replyMessage = SOAPUtilities::makeSOAPMessageReference(
"feMacrosResponse");
234 txParameters.addParameter(
"requester", requester);
235 txParameters.addParameter(
"targetInterfaceID", targetInterfaceID);
236 txParameters.addParameter(
"feMacroName", feMacroName);
237 txParameters.addParameter(
"outputArgs", outputArgs);
238 SOAPUtilities::addParameters(replyMessage, txParameters);
240 __SUP_COUT__ <<
"Sending FE macro result: " << SOAPUtilities::translate(replyMessage) << __E__;
244 else if(type ==
"feMacroMultiDimensionalStart" ||
245 type ==
"macroMultiDimensionalStart")
251 rxParameters.addParameter(
"macroString");
252 rxParameters.addParameter(
"macroName");
255 rxParameters.addParameter(
"feMacroName");
257 rxParameters.addParameter(
"enableSavingOutput");
258 rxParameters.addParameter(
"outputFilePath");
259 rxParameters.addParameter(
"outputFileRadix");
260 rxParameters.addParameter(
"inputArgs");
262 SOAPUtilities::receive(message, rxParameters);
264 std::string requester = rxParameters.getValue(
"requester");
265 std::string targetInterfaceID = rxParameters.getValue(
"targetInterfaceID");
266 std::string macroName, macroString;
269 macroName = rxParameters.getValue(
"macroName");
270 macroString = rxParameters.getValue(
"macroString");
271 __SUP_COUTV__(macroString);
274 macroName = rxParameters.getValue(
"feMacroName");
275 bool enableSavingOutput = rxParameters.getValue(
"enableSavingOutput") ==
"1";
276 std::string outputFilePath = rxParameters.getValue(
"outputFilePath");
277 std::string outputFileRadix = rxParameters.getValue(
"outputFileRadix");
278 std::string inputArgs = rxParameters.getValue(
"inputArgs");
280 __SUP_COUTV__(requester);
281 __SUP_COUTV__(targetInterfaceID);
282 __SUP_COUTV__(macroName);
283 __SUP_COUTV__(enableSavingOutput);
284 __SUP_COUTV__(outputFilePath);
285 __SUP_COUTV__(outputFileRadix);
286 __SUP_COUTV__(inputArgs);
293 requester, targetInterfaceID, macroName, macroString, enableSavingOutput, outputFilePath, outputFileRadix, inputArgs);
295 catch(std::runtime_error& e)
297 __SUP_SS__ <<
"In Supervisor with LID=" << getApplicationDescriptor()->getLocalId() <<
" the Macro named '" << macroName <<
"' with target FE '"
298 << targetInterfaceID <<
"' failed to start multi-dimensional launch. "
299 <<
"Here is the error:\n\n"
300 << e.what() << __E__;
305 __SUP_SS__ <<
"In Supervisor with LID=" << getApplicationDescriptor()->getLocalId() <<
" the Macro named '" << macroName <<
"' with target FE '"
306 << targetInterfaceID <<
"' failed to start multi-dimensional launch "
307 <<
"due to an unknown error." << __E__;
315 theFEInterfacesManager_->startFEMacroMultiDimensional(
316 requester, targetInterfaceID, macroName, enableSavingOutput, outputFilePath, outputFileRadix, inputArgs);
318 catch(std::runtime_error& e)
320 __SUP_SS__ <<
"In Supervisor with LID=" << getApplicationDescriptor()->getLocalId() <<
" the FE Macro named '" << macroName
321 <<
"' with target FE '" << targetInterfaceID <<
"' failed to start multi-dimensional launch. "
322 <<
"Here is the error:\n\n"
323 << e.what() << __E__;
328 __SUP_SS__ <<
"In Supervisor with LID=" << getApplicationDescriptor()->getLocalId() <<
" the FE Macro named '" << macroName
329 <<
"' with target FE '" << targetInterfaceID <<
"' failed to start multi-dimensional launch "
330 <<
"due to an unknown error." << __E__;
335 xoap::MessageReference replyMessage = SOAPUtilities::makeSOAPMessageReference(type +
"Done");
338 SOAPUtilities::addParameters(replyMessage, txParameters);
340 __SUP_COUT__ <<
"Sending FE macro result: " << SOAPUtilities::translate(replyMessage) << __E__;
344 else if(type ==
"feMacroMultiDimensionalCheck" ||
345 type ==
"macroMultiDimensionalCheck")
349 rxParameters.addParameter(
"macroName");
351 rxParameters.addParameter(
"feMacroName");
352 rxParameters.addParameter(
"targetInterfaceID");
354 SOAPUtilities::receive(message, rxParameters);
356 std::string targetInterfaceID = rxParameters.getValue(
"targetInterfaceID");
357 std::string macroName;
359 macroName = rxParameters.getValue(
"macroName");
361 macroName = rxParameters.getValue(
"feMacroName");
363 __SUP_COUTV__(targetInterfaceID);
364 __SUP_COUTV__(macroName);
369 done = theFEInterfacesManager_->checkMacroMultiDimensional(targetInterfaceID, macroName);
371 catch(std::runtime_error& e)
373 __SUP_SS__ <<
"In Supervisor with LID=" << getApplicationDescriptor()->getLocalId() <<
" the FE Macro named '" << macroName <<
"' with target FE '"
374 << targetInterfaceID <<
"' failed to check multi-dimensional launch. "
375 <<
"Here is the error:\n\n"
376 << e.what() << __E__;
381 __SUP_SS__ <<
"In Supervisor with LID=" << getApplicationDescriptor()->getLocalId() <<
" the FE Macro named '" << macroName <<
"' with target FE '"
382 << targetInterfaceID <<
"' failed to check multi-dimensional launch "
383 <<
"due to an unknown error." << __E__;
387 xoap::MessageReference replyMessage = SOAPUtilities::makeSOAPMessageReference(type +
"Done");
389 txParameters.addParameter(
"Done", done ?
"1" :
"0");
390 SOAPUtilities::addParameters(replyMessage, txParameters);
392 __SUP_COUT__ <<
"Sending FE macro result: " << SOAPUtilities::translate(replyMessage) << __E__;
398 __SUP_SS__ <<
"Unrecognized FE Communication type: " << type << __E__;
402 catch(
const std::runtime_error& e)
404 __SUP_SS__ <<
"Error encountered processing FE communication request: " << e.what() << __E__;
405 __SUP_COUT_ERR__ << ss.str();
408 parameters.addParameter(
"Error", ss.str());
409 return SOAPUtilities::makeSOAPMessageReference(supervisorClassNoNamespace_ +
"FailFECommunicationRequest", parameters);
413 __SUP_SS__ <<
"Unknown error encountered processing FE communication request." << __E__;
414 __SUP_COUT_ERR__ << ss.str();
417 parameters.addParameter(
"Error", ss.str());
418 return SOAPUtilities::makeSOAPMessageReference(supervisorClassNoNamespace_ +
"FailFECommunicationRequest", parameters);
428 xoap::MessageReference FESupervisor::macroMakerSupervisorRequest(xoap::MessageReference message)
430 __SUP_COUT__ <<
"$$$$$$$$$$$$$$$$$" << __E__;
434 parameters.addParameter(
"Request");
436 __SUP_COUT__ <<
"Received Macro Maker message: " << SOAPUtilities::translate(message) << __E__;
438 SOAPUtilities::receive(message, parameters);
439 std::string request = parameters.getValue(
"Request");
441 __SUP_COUT__ <<
"request: " << request << __E__;
455 if(request ==
"GetInterfaces")
457 if(theFEInterfacesManager_)
458 retParameters.addParameter(
"FEList", theFEInterfacesManager_->getFEListString(std::to_string(getApplicationDescriptor()->getLocalId())));
460 retParameters.addParameter(
"FEList",
"");
463 if(theStateMachine_.getErrorMessage() !=
"")
464 retParameters.addParameter(
"frontEndError", theStateMachine_.getErrorMessage());
466 return SOAPUtilities::makeSOAPMessageReference(supervisorClassNoNamespace_ +
"Response", retParameters);
468 else if(request ==
"UniversalWrite")
470 if(!theFEInterfacesManager_)
472 __SUP_SS__ <<
"No FE Interface Manager! Are you configured?" << __E__;
477 requestParameters.addParameter(
"InterfaceID");
478 requestParameters.addParameter(
"Address");
479 requestParameters.addParameter(
"Data");
480 SOAPUtilities::receive(message, requestParameters);
481 std::string interfaceID = requestParameters.getValue(
"InterfaceID");
482 std::string addressStr = requestParameters.getValue(
"Address");
483 std::string dataStr = requestParameters.getValue(
"Data");
485 __SUP_COUT__ <<
"Address: " << addressStr <<
" Data: " << dataStr <<
" InterfaceID: " << interfaceID << __E__;
491 __SUP_COUT__ <<
"theFEInterfacesManager_->getInterfaceUniversalAddressSize(index) "
492 << theFEInterfacesManager_->getInterfaceUniversalAddressSize(interfaceID) << __E__;
493 __SUP_COUT__ <<
"theFEInterfacesManager_->getInterfaceUniversalDataSize(index) "
494 << theFEInterfacesManager_->getInterfaceUniversalDataSize(interfaceID) << __E__;
502 __SUP_COUT__ <<
"Translating address: ";
504 std::string addressTmp;
505 addressTmp.reserve(theFEInterfacesManager_->getInterfaceUniversalAddressSize(interfaceID));
506 char* address = &addressTmp[0];
508 if(addressStr.size() % 2)
509 addressStr =
"0" + addressStr;
511 for(; i < addressStr.size() && i / 2 < theFEInterfacesManager_->getInterfaceUniversalAddressSize(interfaceID); i += 2)
513 tmpHex[0] = addressStr[addressStr.size() - 1 - i - 1];
514 tmpHex[1] = addressStr[addressStr.size() - 1 - i];
515 sscanf(tmpHex,
"%hhX", (
unsigned char*)&address[i / 2]);
516 printf(
"%2.2X", (
unsigned char)address[i / 2]);
519 for(; i / 2 < theFEInterfacesManager_->getInterfaceUniversalAddressSize(interfaceID); i += 2)
522 printf(
"%2.2X", (
unsigned char)address[i / 2]);
527 __SUP_COUT__ <<
"Translating data: ";
530 dataTmp.reserve(theFEInterfacesManager_->getInterfaceUniversalDataSize(interfaceID));
531 char* data = &dataTmp[0];
533 if(dataStr.size() % 2)
534 dataStr =
"0" + dataStr;
537 for(; i < dataStr.size() && i / 2 < theFEInterfacesManager_->getInterfaceUniversalDataSize(interfaceID); i += 2)
539 tmpHex[0] = dataStr[dataStr.size() - 1 - i - 1];
540 tmpHex[1] = dataStr[dataStr.size() - 1 - i];
541 sscanf(tmpHex,
"%hhX", (
unsigned char*)&data[i / 2]);
542 printf(
"%2.2X", (
unsigned char)data[i / 2]);
545 for(; i / 2 < theFEInterfacesManager_->getInterfaceUniversalDataSize(interfaceID); i += 2)
548 printf(
"%2.2X", (
unsigned char)data[i / 2]);
560 theFEInterfacesManager_->universalWrite(interfaceID, address, data);
565 return SOAPUtilities::makeSOAPMessageReference(supervisorClassNoNamespace_ +
"DataWritten", retParameters);
567 else if(request ==
"UniversalRead")
569 if(!theFEInterfacesManager_)
571 __SUP_SS__ <<
"No FE Interface Manager! Are you configured?" << __E__;
577 requestParameters.addParameter(
"InterfaceID");
578 requestParameters.addParameter(
"Address");
579 SOAPUtilities::receive(message, requestParameters);
580 std::string interfaceID = requestParameters.getValue(
"InterfaceID");
581 std::string addressStr = requestParameters.getValue(
"Address");
583 __SUP_COUT__ <<
"Address: " << addressStr <<
" InterfaceID: " << interfaceID << __E__;
590 __SUP_COUT__ <<
"theFEInterfacesManager_->getInterfaceUniversalAddressSize(index) "
591 << theFEInterfacesManager_->getInterfaceUniversalAddressSize(interfaceID) << __E__;
592 __SUP_COUT__ <<
"theFEInterfacesManager_->getInterfaceUniversalDataSize(index) "
593 << theFEInterfacesManager_->getInterfaceUniversalDataSize(interfaceID) << __E__;
598 __SUP_COUT__ <<
"Translating address: ";
600 std::string addressTmp;
601 addressTmp.reserve(theFEInterfacesManager_->getInterfaceUniversalAddressSize(interfaceID));
602 char* address = &addressTmp[0];
604 if(addressStr.size() % 2)
605 addressStr =
"0" + addressStr;
608 for(; i < addressStr.size() && i / 2 < theFEInterfacesManager_->getInterfaceUniversalAddressSize(interfaceID); i += 2)
610 tmpHex[0] = addressStr[addressStr.size() - 1 - i - 1];
611 tmpHex[1] = addressStr[addressStr.size() - 1 - i];
612 sscanf(tmpHex,
"%hhX", (
unsigned char*)&address[i / 2]);
613 printf(
"%2.2X", (
unsigned char)address[i / 2]);
616 for(; i / 2 < theFEInterfacesManager_->getInterfaceUniversalAddressSize(interfaceID); i += 2)
619 printf(
"%2.2X", (
unsigned char)address[i / 2]);
624 unsigned int dataSz = theFEInterfacesManager_->getInterfaceUniversalDataSize(interfaceID);
626 dataStr.resize(dataSz);
627 char* data = &dataStr[0];
635 theFEInterfacesManager_->universalRead(interfaceID, address, data);
637 catch(
const std::runtime_error& e)
641 __MOUT_ERR__ <<
"Exception caught during read: " << e.what() << __E__;
642 __SUP_COUT_ERR__ <<
"Exception caught during read: " << e.what() << __E__;
643 retParameters.addParameter(
"dataResult",
"Time Out Error");
644 return SOAPUtilities::makeSOAPMessageReference(supervisorClassNoNamespace_ +
"aa", retParameters);
650 __MOUT_ERR__ <<
"Exception caught during read." << __E__;
651 __SUP_COUT_ERR__ <<
"Exception caught during read." << __E__;
652 retParameters.addParameter(
"dataResult",
"Time Out Error");
653 return SOAPUtilities::makeSOAPMessageReference(supervisorClassNoNamespace_ +
"aa", retParameters);
659 std::string str8(data);
661 __SUP_COUT__ <<
"decResult[" << dataSz <<
" bytes]: " << *((
unsigned long long*)(&str8[0])) << __E__;
664 std::string hexResultStr;
665 hexResultStr.reserve(dataSz * 2 + 1);
666 char* hexResult = &hexResultStr[0];
670 for(
unsigned int i = 0; i < dataSz; ++i)
672 sprintf(&hexResult[i * 2],
"%2.2X", (
unsigned char)data[dataSz - 1 - i]);
675 __SUP_COUT__ <<
"hexResult[" << strlen(hexResult) <<
" nibbles]: " << std::string(hexResult) << __E__;
677 retParameters.addParameter(
"dataResult", hexResult);
678 return SOAPUtilities::makeSOAPMessageReference(supervisorClassNoNamespace_ +
"aa", retParameters);
680 else if(request ==
"GetInterfaceMacros")
682 if(theFEInterfacesManager_)
683 retParameters.addParameter(
"FEMacros",
684 theFEInterfacesManager_->getFEMacrosString(CorePropertySupervisorBase::getSupervisorUID(),
685 std::to_string(CoreSupervisorBase::getSupervisorLID())));
687 retParameters.addParameter(
"FEMacros",
"");
689 return SOAPUtilities::makeSOAPMessageReference(supervisorClassNoNamespace_ +
"Response", retParameters);
691 else if(request ==
"RunInterfaceMacro")
693 if(!theFEInterfacesManager_)
695 __SUP_SS__ <<
"Missing FE Interface Manager! Are you configured?" << __E__;
701 requestParameters.addParameter(
"feMacroName");
702 requestParameters.addParameter(
"inputArgs");
703 requestParameters.addParameter(
"outputArgs");
704 requestParameters.addParameter(
"InterfaceID");
705 SOAPUtilities::receive(message, requestParameters);
706 std::string interfaceID = requestParameters.getValue(
"InterfaceID");
707 std::string feMacroName = requestParameters.getValue(
"feMacroName");
708 std::string inputArgs = requestParameters.getValue(
"inputArgs");
709 std::string outputArgs = requestParameters.getValue(
"outputArgs");
715 theFEInterfacesManager_->runFEMacro(interfaceID, feMacroName, inputArgs, outputArgs);
717 catch(std::runtime_error& e)
719 __SUP_SS__ <<
"In Supervisor with LID=" << getApplicationDescriptor()->getLocalId() <<
" the FE Macro named '" << feMacroName
720 <<
"' with target FE '" << interfaceID <<
"' failed. Here is the error:\n\n"
721 << e.what() << __E__;
726 __SUP_SS__ <<
"In Supervisor with LID=" << getApplicationDescriptor()->getLocalId() <<
" the FE Macro named '" << feMacroName
727 <<
"' with target FE '" << interfaceID <<
"' failed due to an unknown error." << __E__;
732 retParameters.addParameter(
"outputArgs", outputArgs);
734 return SOAPUtilities::makeSOAPMessageReference(supervisorClassNoNamespace_ +
"Response", retParameters);
736 else if(request ==
"RunMacroMakerMacro")
738 if(!theFEInterfacesManager_)
740 __SUP_SS__ <<
"Missing FE Interface Manager! Are you configured?" << __E__;
746 requestParameters.addParameter(
"macroName");
747 requestParameters.addParameter(
"macroString");
748 requestParameters.addParameter(
"inputArgs");
749 requestParameters.addParameter(
"outputArgs");
750 requestParameters.addParameter(
"InterfaceID");
751 SOAPUtilities::receive(message, requestParameters);
752 std::string interfaceID = requestParameters.getValue(
"InterfaceID");
753 std::string macroName = requestParameters.getValue(
"macroName");
754 std::string macroString = requestParameters.getValue(
"macroString");
755 std::string inputArgs = requestParameters.getValue(
"inputArgs");
756 std::string outputArgs = requestParameters.getValue(
"outputArgs");
762 theFEInterfacesManager_->runMacro(interfaceID, macroString, inputArgs, outputArgs);
764 catch(std::runtime_error& e)
766 __SUP_SS__ <<
"In Supervisor with LID=" << getApplicationDescriptor()->getLocalId() <<
" the MacroMaker Macro named '" << macroName
767 <<
"' with target FE '" << interfaceID <<
"' failed. Here is the error:\n\n"
768 << e.what() << __E__;
773 __SUP_SS__ <<
"In Supervisor with LID=" << getApplicationDescriptor()->getLocalId() <<
" the MacroMaker Macro named '" << macroName
774 <<
"' with target FE '" << interfaceID <<
"' failed due to an unknown error." << __E__;
778 retParameters.addParameter(
"outputArgs", outputArgs);
780 return SOAPUtilities::makeSOAPMessageReference(supervisorClassNoNamespace_ +
"Response", retParameters);
784 __SUP_SS__ <<
"Unrecognized request received! '" << request <<
"'" << __E__;
788 catch(
const std::runtime_error& e)
790 __SUP_SS__ <<
"Error occurred handling request: " << e.what() << __E__;
791 __SUP_COUT_ERR__ << ss.str();
792 retParameters.addParameter(
"Error", ss.str());
796 __SUP_SS__ <<
"Error occurred handling request." << __E__;
797 __SUP_COUT_ERR__ << ss.str();
798 retParameters.addParameter(
"Error", ss.str());
801 return SOAPUtilities::makeSOAPMessageReference(supervisorClassNoNamespace_ +
"FailRequest", retParameters);
806 xoap::MessageReference FESupervisor::workLoopStatusRequest(xoap::MessageReference )
808 if(!theFEInterfacesManager_)
810 __SUP_SS__ <<
"Invalid request for front-end workloop status from Supervisor "
811 "without a FEVInterfacesManager."
816 return SOAPUtilities::makeSOAPMessageReference(
817 (theFEInterfacesManager_->allFEWorkloopsAreDone() ? CoreSupervisorBase::WORK_LOOP_DONE : CoreSupervisorBase::WORK_LOOP_WORKING));
830 theFEInterfacesManager_ = 0;
832 for(
unsigned int i = 0; i < theStateMachineImplementation_.size(); ++i)
836 theFEInterfacesManager_ =
dynamic_cast<FEVInterfacesManager*
>(theStateMachineImplementation_[i]);
837 if(!theFEInterfacesManager_)
840 __SUP_SS__ <<
"Dynamic cast failure!" << __E__;
843 __SUP_COUT__ <<
"State Machine " << i <<
" WAS of type FEVInterfacesManager" << __E__;
849 __SUP_COUT__ <<
"State Machine " << i <<
" was NOT of type FEVInterfacesManager" << __E__;
853 __SUP_COUT__ <<
"theFEInterfacesManager pointer = " << theFEInterfacesManager_ << __E__;
855 return theFEInterfacesManager_;
859 void FESupervisor::transitionConfiguring(toolbox::Event::Reference )
861 __SUP_COUT__ <<
"transitionConfiguring" << __E__;
865 if(RunControlStateMachine::getIterationIndex() == 0 && RunControlStateMachine::getSubIterationIndex() == 0)
868 SOAPUtilities::translate(theStateMachine_.getCurrentMessage()).getParameters().getValue(
"ConfigurationTableGroupName"),
869 TableGroupKey(SOAPUtilities::translate(theStateMachine_.getCurrentMessage()).getParameters().getValue(
"ConfigurationTableGroupKey")));
871 __SUP_COUT__ <<
"Configuration table group name: " << theGroup.first <<
" key: " << theGroup.second << __E__;
873 theConfigurationManager_->loadTableGroup(theGroup.first, theGroup.second,
true );
882 __COUTV__(CorePropertySupervisorBase::getSupervisorConfigurationPath());
884 ConfigurationTree feSupervisorNode = CorePropertySupervisorBase::getSupervisorTableNode();
886 bool enableMetricManager =
false;
889 enableMetricManager = feSupervisorNode.getNode(
890 "/EnableSlowControlsMetricManager").getValue<
bool>();
895 if(enableMetricManager)
899 __SUP_COUT__ <<
"Metric manager is not instantiated! Attempting to fix." << __E__;
900 metricMan = std::make_unique<artdaq::MetricManager>();
902 std::string metricNamePreamble = feSupervisorNode.getNode(
903 "/SlowControlsMetricManagerChannelNamePreamble").getValue<std::string>();
904 __COUTV__(metricNamePreamble);
906 std::string metric_string =
"epics: {metricPluginType:epics level:3 channel_name_prefix:Mu2e}";
907 fhicl::ParameterSet metric_pset;
908 fhicl::make_ParameterSet(metric_string, metric_pset);
910 metricMan->initialize(metric_pset,metricNamePreamble);
912 __SUP_COUT__ <<
"transitionConfiguring metric manager(" << metricMan <<
913 ") initialized = " << metricMan->Initialized() << __E__;
916 __SUP_COUT__ <<
"Metric Manager disabled." << __E__;
918 catch(
const std::runtime_error& e)
920 __SS__ <<
"Error loading metrics in FESupervisor::transitionConfiguring(): " << e.what() << __E__;
921 __COUT_ERR__ << ss.str();
925 theStateMachine_.setErrorMessage(ss.str());
926 throw toolbox::fsm::exception::Exception(
"Transition Error" ,
928 "FESupervisor::transitionConfiguring" ,
935 __SS__ <<
"Error loading metrics in FESupervisor::transitionConfiguring()" << __E__;
936 __COUT_ERR__ << ss.str();
940 theStateMachine_.setErrorMessage(ss.str());
941 throw toolbox::fsm::exception::Exception(
"Transition Error" ,
943 "FESupervisor::transitionConfiguring" ,
949 CoreSupervisorBase::transitionConfiguringFSMs();
951 __SUP_COUT__ <<
"transitionConfiguring done." << __E__;
955 void FESupervisor::transitionHalting(toolbox::Event::Reference event)
957 __SUP_COUT__ <<
"transitionHalting" << __E__;
962 if(metricMan && metricMan->Initialized()) {
963 metricMan->shutdown();
964 metricMan.reset(
nullptr);
967 __SUP_COUT__ <<
"Metric manager(" << metricMan <<
") already shutdown." << __E__;
971 __SS__ <<
"Error shutting down metrics in FESupervisor::transitionHalting()" << __E__;
972 __COUT_ERR__ << ss.str();
976 theStateMachine_.setErrorMessage(ss.str());
977 throw toolbox::fsm::exception::Exception(
"Transition Error" ,
979 "FESupervisor::transitionHalting" ,
985 CoreSupervisorBase::transitionHalting(event);
986 __SUP_COUT__ <<
"transitionHalting done." << __E__;
void startMacroMultiDimensional(const std::string &requester, const std::string &interfaceID, const std::string ¯oName, const std::string ¯oString, const bool enableSavingOutput, const std::string &outputFilePath, const std::string &outputFileRadix, const std::string &inputArgs)