1 #include "otsdaq/CoreSupervisors/FESupervisor.h"
2 #include "otsdaq/ConfigurationInterface/ConfigurationManager.h"
3 #include "otsdaq/FECore/FEVInterfacesManager.h"
4 #include "otsdaq/TablePlugins/ARTDAQTableBase/ARTDAQTableBase.h"
6 #include "artdaq/DAQdata/Globals.hh"
8 #include "artdaq-core/Utilities/ExceptionHandler.hh"
39 __SUP_COUT__ <<
"Constructing..." << __E__;
42 &FESupervisor::macroMakerSupervisorRequest,
43 "MacroMakerSupervisorRequest",
47 this, &FESupervisor::workLoopStatusRequest,
"WorkLoopStatusRequest", XDAQ_NS_URI);
50 &FESupervisor::frontEndCommunicationRequest,
56 CoreSupervisorBase::theStateMachineImplementation_.push_back(
58 CorePropertySupervisorBase::getContextTreeNode(),
59 CorePropertySupervisorBase::getSupervisorConfigurationPath()));
63 if(CorePropertySupervisorBase::allSupervisorInfo_.isMacroMakerMode())
65 __SUP_COUT_WARN__ <<
"Error caught constructing FE Interface Manager. In "
66 "Macro Maker mode, the input fhicl defines the "
67 "configuration tree, make sure you specified a valid "
74 catch(
const std::runtime_error& e)
76 __SUP_COUT_WARN__ << e.what() << __E__;
83 extractFEInterfacesManager();
85 __SUP_COUT__ <<
"Constructed." << __E__;
87 if(CorePropertySupervisorBase::allSupervisorInfo_.isMacroMakerMode())
89 __SUP_COUT_INFO__ <<
"Macro Maker mode, so configuring at startup!" << __E__;
90 if(!theFEInterfacesManager_)
92 __SUP_SS__ <<
"Missing FE Interface manager!" << __E__;
103 __SUP_COUT__ <<
"Configuring all state machine implementations..." << __E__;
104 __SUP_COUTV__(stateMachinesIterationDone_.size());
105 preStateMachineExecutionLoop();
106 __SUP_COUTV__(stateMachinesIterationDone_.size());
107 for(
unsigned int i = 0; i < theStateMachineImplementation_.size(); ++i)
109 __SUP_COUT__ <<
"Configuring state machine i " << i << __E__;
112 if(subIterationWorkStateMachineIndex_ != (
unsigned int)-1 &&
113 i != subIterationWorkStateMachineIndex_)
116 if(stateMachinesIterationDone_[i])
119 preStateMachineExecution(i);
120 theStateMachineImplementation_[i]->parentSupervisor_ =
123 theStateMachineImplementation_[i]->configure();
126 postStateMachineExecution(i);
128 postStateMachineExecutionLoop();
131 CorePropertySupervisorBase::indicateOtsAlive(0);
133 catch(
const std::runtime_error& e)
135 __SUP_SS__ <<
"Error was caught while configuring: " << e.what() << __E__;
136 __SUP_COUT_ERR__ <<
"\n" << ss.str();
142 <<
"Unknown error was caught while configuring. Please checked the logs."
148 catch(
const std::exception& e)
150 ss <<
"Exception message: " << e.what();
155 __SUP_COUT_ERR__ <<
"\n" << ss.str();
162 FESupervisor::~FESupervisor(
void)
164 __SUP_COUT__ <<
"Destroying..." << __E__;
168 artdaq::Globals::CleanUpGlobals();
170 __SUP_COUT__ <<
"Destructed." << __E__;
174 xoap::MessageReference FESupervisor::frontEndCommunicationRequest(
175 xoap::MessageReference message)
180 if(!theFEInterfacesManager_)
182 __SUP_SS__ <<
"No FE Interface Manager!" << __E__;
186 typeParameter.addParameter(
"type");
187 SOAPUtilities::receive(message, typeParameter);
189 std::string type = typeParameter.getValue(
"type");
199 rxParameters.addParameter(
"requester");
200 rxParameters.addParameter(
"targetInterfaceID");
206 rxParameters.addParameter(
"value");
207 SOAPUtilities::receive(message, rxParameters);
209 std::string requester = rxParameters.getValue(
"requester");
210 std::string targetInterfaceID = rxParameters.getValue(
"targetInterfaceID");
211 std::string value = rxParameters.getValue(
"value");
213 __SUP_COUTV__(requester);
214 __SUP_COUTV__(targetInterfaceID);
215 __SUP_COUTV__(value);
222 std::lock_guard<std::mutex> lock(
225 theFEInterfacesManager_
226 ->frontEndCommunicationReceiveBuffer_[targetInterfaceID][requester]
229 __SUP_COUT__ <<
"Number of target interface ID '" << targetInterfaceID
231 << theFEInterfacesManager_
232 ->frontEndCommunicationReceiveBuffer_[targetInterfaceID]
236 <<
"Number of source interface ID '" << requester <<
"' values received: "
237 << theFEInterfacesManager_
238 ->frontEndCommunicationReceiveBuffer_[targetInterfaceID][requester]
242 return SOAPUtilities::makeSOAPMessageReference(
"Received");
244 else if(type ==
"feMacro")
248 rxParameters.addParameter(
"feMacroName");
249 rxParameters.addParameter(
"inputArgs");
251 SOAPUtilities::receive(message, rxParameters);
253 std::string requester = rxParameters.getValue(
"requester");
254 std::string targetInterfaceID = rxParameters.getValue(
"targetInterfaceID");
255 std::string feMacroName = rxParameters.getValue(
"feMacroName");
256 std::string inputArgs = rxParameters.getValue(
"inputArgs");
258 __SUP_COUTV__(requester);
259 __SUP_COUTV__(targetInterfaceID);
260 __SUP_COUTV__(feMacroName);
261 __SUP_COUTV__(inputArgs);
263 std::string outputArgs;
267 requester, targetInterfaceID, feMacroName, inputArgs, outputArgs);
269 catch(std::runtime_error& e)
271 __SUP_SS__ <<
"In Supervisor with LID="
272 << getApplicationDescriptor()->getLocalId()
273 <<
" the FE Macro named '" << feMacroName <<
"' with target FE '"
274 << targetInterfaceID <<
"' failed. Here is the error:\n\n"
275 << e.what() << __E__;
280 __SUP_SS__ <<
"In Supervisor with LID="
281 << getApplicationDescriptor()->getLocalId()
282 <<
" the FE Macro named '" << feMacroName <<
"' with target FE '"
283 << targetInterfaceID <<
"' failed due to an unknown error."
289 catch(
const std::exception& e)
291 ss <<
"Exception message: " << e.what();
299 __SUP_COUTV__(outputArgs);
301 xoap::MessageReference replyMessage =
302 SOAPUtilities::makeSOAPMessageReference(
"feMacrosResponse");
304 txParameters.addParameter(
"requester", requester);
305 txParameters.addParameter(
"targetInterfaceID", targetInterfaceID);
306 txParameters.addParameter(
"feMacroName", feMacroName);
307 txParameters.addParameter(
"outputArgs", outputArgs);
308 SOAPUtilities::addParameters(replyMessage, txParameters);
310 __SUP_COUT__ <<
"Sending FE macro result: "
311 << SOAPUtilities::translate(replyMessage) << __E__;
315 else if(type ==
"feMacroMultiDimensionalStart" ||
316 type ==
"macroMultiDimensionalStart")
322 rxParameters.addParameter(
"macroString");
323 rxParameters.addParameter(
"macroName");
326 rxParameters.addParameter(
"feMacroName");
328 rxParameters.addParameter(
"enableSavingOutput");
329 rxParameters.addParameter(
"outputFilePath");
330 rxParameters.addParameter(
"outputFileRadix");
331 rxParameters.addParameter(
"inputArgs");
333 SOAPUtilities::receive(message, rxParameters);
335 std::string requester = rxParameters.getValue(
"requester");
336 std::string targetInterfaceID = rxParameters.getValue(
"targetInterfaceID");
337 std::string macroName, macroString;
340 macroName = rxParameters.getValue(
"macroName");
341 macroString = rxParameters.getValue(
"macroString");
342 __SUP_COUTV__(macroString);
345 macroName = rxParameters.getValue(
"feMacroName");
346 bool enableSavingOutput = rxParameters.getValue(
"enableSavingOutput") ==
"1";
347 std::string outputFilePath = rxParameters.getValue(
"outputFilePath");
348 std::string outputFileRadix = rxParameters.getValue(
"outputFileRadix");
349 std::string inputArgs = rxParameters.getValue(
"inputArgs");
351 __SUP_COUTV__(requester);
352 __SUP_COUTV__(targetInterfaceID);
353 __SUP_COUTV__(macroName);
354 __SUP_COUTV__(enableSavingOutput);
355 __SUP_COUTV__(outputFilePath);
356 __SUP_COUTV__(outputFileRadix);
357 __SUP_COUTV__(inputArgs);
372 catch(std::runtime_error& e)
374 __SUP_SS__ <<
"In Supervisor with LID="
375 << getApplicationDescriptor()->getLocalId()
376 <<
" the Macro named '" << macroName <<
"' with target FE '"
378 <<
"' failed to start multi-dimensional launch. "
379 <<
"Here is the error:\n\n"
380 << e.what() << __E__;
385 __SUP_SS__ <<
"In Supervisor with LID="
386 << getApplicationDescriptor()->getLocalId()
387 <<
" the Macro named '" << macroName <<
"' with target FE '"
389 <<
"' failed to start multi-dimensional launch "
390 <<
"due to an unknown error." << __E__;
395 catch(
const std::exception& e)
397 ss <<
"Exception message: " << e.what();
417 catch(std::runtime_error& e)
419 __SUP_SS__ <<
"In Supervisor with LID="
420 << getApplicationDescriptor()->getLocalId()
421 <<
" the FE Macro named '" << macroName <<
"' with target FE '"
423 <<
"' failed to start multi-dimensional launch. "
424 <<
"Here is the error:\n\n"
425 << e.what() << __E__;
430 __SUP_SS__ <<
"In Supervisor with LID="
431 << getApplicationDescriptor()->getLocalId()
432 <<
" the FE Macro named '" << macroName <<
"' with target FE '"
434 <<
"' failed to start multi-dimensional launch "
435 <<
"due to an unknown error." << __E__;
440 catch(
const std::exception& e)
442 ss <<
"Exception message: " << e.what();
451 xoap::MessageReference replyMessage =
452 SOAPUtilities::makeSOAPMessageReference(type +
"Done");
455 SOAPUtilities::addParameters(replyMessage, txParameters);
457 __SUP_COUT__ <<
"Sending FE macro result: "
458 << SOAPUtilities::translate(replyMessage) << __E__;
462 else if(type ==
"feMacroMultiDimensionalCheck" ||
463 type ==
"macroMultiDimensionalCheck")
467 rxParameters.addParameter(
"macroName");
469 rxParameters.addParameter(
"feMacroName");
470 rxParameters.addParameter(
"targetInterfaceID");
472 SOAPUtilities::receive(message, rxParameters);
474 std::string targetInterfaceID = rxParameters.getValue(
"targetInterfaceID");
475 std::string macroName;
477 macroName = rxParameters.getValue(
"macroName");
479 macroName = rxParameters.getValue(
"feMacroName");
490 catch(std::runtime_error& e)
492 __SUP_SS__ <<
"In Supervisor with LID="
493 << getApplicationDescriptor()->getLocalId()
494 <<
" the FE Macro named '" << macroName <<
"' with target FE '"
496 <<
"' failed to check multi-dimensional launch. "
497 <<
"Here is the error:\n\n"
498 << e.what() << __E__;
503 __SUP_SS__ <<
"In Supervisor with LID="
504 << getApplicationDescriptor()->getLocalId()
505 <<
" the FE Macro named '" << macroName <<
"' with target FE '"
507 <<
"' failed to check multi-dimensional launch "
508 <<
"due to an unknown error." << __E__;
513 catch(
const std::exception& e)
515 ss <<
"Exception message: " << e.what();
523 xoap::MessageReference replyMessage =
524 SOAPUtilities::makeSOAPMessageReference(type +
"Done");
526 txParameters.addParameter(
"Done", done ?
"1" :
"0");
527 SOAPUtilities::addParameters(replyMessage, txParameters);
535 __SUP_SS__ <<
"Unrecognized FE Communication type: " << type << __E__;
539 catch(
const std::runtime_error& e)
541 __SUP_SS__ <<
"Error encountered processing FE communication request: " << e.what()
543 __SUP_COUT_ERR__ << ss.str();
546 parameters.addParameter(
"Error", ss.str());
547 return SOAPUtilities::makeSOAPMessageReference(
548 supervisorClassNoNamespace_ +
"FailFECommunicationRequest", parameters);
552 __SUP_SS__ <<
"Unknown error encountered processing FE communication request."
558 catch(
const std::exception& e)
560 ss <<
"Exception message: " << e.what();
565 __SUP_COUT_ERR__ << ss.str();
568 parameters.addParameter(
"Error", ss.str());
569 return SOAPUtilities::makeSOAPMessageReference(
570 supervisorClassNoNamespace_ +
"FailFECommunicationRequest", parameters);
581 xoap::MessageReference message)
583 __SUP_COUT__ <<
"$$$$$$$$$$$$$$$$$" << __E__;
587 parameters.addParameter(
"Request");
589 __SUP_COUT__ <<
"Received Macro Maker message: " << SOAPUtilities::translate(message)
592 SOAPUtilities::receive(message, parameters);
593 std::string
request = parameters.getValue(
"Request");
595 __SUP_COUT__ <<
"request: " <<
request << __E__;
611 if(theFEInterfacesManager_)
612 retParameters.addParameter(
615 std::to_string(getApplicationDescriptor()->getLocalId())));
617 retParameters.addParameter(
"FEList",
"");
620 if(theStateMachine_.getErrorMessage() !=
"")
621 retParameters.addParameter(
"frontEndError",
622 theStateMachine_.getErrorMessage());
624 return SOAPUtilities::makeSOAPMessageReference(
625 supervisorClassNoNamespace_ +
"Response", retParameters);
627 else if(
request ==
"UniversalWrite")
629 if(!theFEInterfacesManager_)
631 __SUP_SS__ <<
"No FE Interface Manager! Are you configured?" << __E__;
636 requestParameters.addParameter(
"InterfaceID");
637 requestParameters.addParameter(
"Address");
638 requestParameters.addParameter(
"Data");
639 SOAPUtilities::receive(message, requestParameters);
640 std::string interfaceID = requestParameters.getValue(
"InterfaceID");
641 std::string addressStr = requestParameters.getValue(
"Address");
642 std::string dataStr = requestParameters.getValue(
"Data");
644 __SUP_COUT__ <<
"Address: " << addressStr <<
" Data: " << dataStr
645 <<
" InterfaceID: " << interfaceID << __E__;
652 <<
"theFEInterfacesManager_->getInterfaceUniversalAddressSize(index) "
656 <<
"theFEInterfacesManager_->getInterfaceUniversalDataSize(index) "
666 __SUP_COUT__ <<
"Translating address: ";
668 std::string addressTmp;
671 char* address = &addressTmp[0];
673 if(addressStr.size() % 2)
674 addressStr =
"0" + addressStr;
676 for(; i < addressStr.size() &&
681 tmpHex[0] = addressStr[addressStr.size() - 1 - i - 1];
682 tmpHex[1] = addressStr[addressStr.size() - 1 - i];
683 sscanf(tmpHex,
"%hhX", (
unsigned char*)&address[i / 2]);
684 printf(
"%2.2X", (
unsigned char)address[i / 2]);
692 printf(
"%2.2X", (
unsigned char)address[i / 2]);
697 __SUP_COUT__ <<
"Translating data: ";
702 char* data = &dataTmp[0];
704 if(dataStr.size() % 2)
705 dataStr =
"0" + dataStr;
708 for(; i < dataStr.size() &&
713 tmpHex[0] = dataStr[dataStr.size() - 1 - i - 1];
714 tmpHex[1] = dataStr[dataStr.size() - 1 - i];
715 sscanf(tmpHex,
"%hhX", (
unsigned char*)&data[i / 2]);
716 printf(
"%2.2X", (
unsigned char)data[i / 2]);
724 printf(
"%2.2X", (
unsigned char)data[i / 2]);
736 theFEInterfacesManager_->
universalWrite(interfaceID, address, data);
741 return SOAPUtilities::makeSOAPMessageReference(
742 supervisorClassNoNamespace_ +
"DataWritten", retParameters);
744 else if(
request ==
"UniversalRead")
746 if(!theFEInterfacesManager_)
748 __SUP_SS__ <<
"No FE Interface Manager! Are you configured?" << __E__;
754 requestParameters.addParameter(
"InterfaceID");
755 requestParameters.addParameter(
"Address");
756 SOAPUtilities::receive(message, requestParameters);
757 std::string interfaceID = requestParameters.getValue(
"InterfaceID");
758 std::string addressStr = requestParameters.getValue(
"Address");
760 __SUP_COUT__ <<
"Address: " << addressStr <<
" InterfaceID: " << interfaceID
769 <<
"theFEInterfacesManager_->getInterfaceUniversalAddressSize(index) "
773 <<
"theFEInterfacesManager_->getInterfaceUniversalDataSize(index) "
780 __SUP_COUT__ <<
"Translating address: ";
782 std::string addressTmp;
785 char* address = &addressTmp[0];
787 if(addressStr.size() % 2)
788 addressStr =
"0" + addressStr;
791 for(; i < addressStr.size() &&
796 tmpHex[0] = addressStr[addressStr.size() - 1 - i - 1];
797 tmpHex[1] = addressStr[addressStr.size() - 1 - i];
798 sscanf(tmpHex,
"%hhX", (
unsigned char*)&address[i / 2]);
799 printf(
"%2.2X", (
unsigned char)address[i / 2]);
807 printf(
"%2.2X", (
unsigned char)address[i / 2]);
812 unsigned int dataSz =
815 dataStr.resize(dataSz);
816 char* data = &dataStr[0];
824 theFEInterfacesManager_->
universalRead(interfaceID, address, data);
826 catch(
const std::runtime_error& e)
830 __SUP_COUT_ERR__ <<
"Exception caught during read: " << e.what() << __E__;
831 retParameters.addParameter(
"dataResult",
"Time Out Error");
832 return SOAPUtilities::makeSOAPMessageReference(
833 supervisorClassNoNamespace_ +
"aa", retParameters);
839 __SUP_COUT_ERR__ <<
"Exception caught during read." << __E__;
840 retParameters.addParameter(
"dataResult",
"Time Out Error");
841 return SOAPUtilities::makeSOAPMessageReference(
842 supervisorClassNoNamespace_ +
"aa", retParameters);
848 std::string str8(data);
850 __SUP_COUT__ <<
"decResult[" << dataSz
851 <<
" bytes]: " << *((
unsigned long long*)(&str8[0]))
855 std::string hexResultStr;
856 hexResultStr.reserve(dataSz * 2 + 1);
857 char* hexResult = &hexResultStr[0];
861 for(
unsigned int i = 0; i < dataSz; ++i)
863 sprintf(&hexResult[i * 2],
"%2.2X", (
unsigned char)data[dataSz - 1 - i]);
866 __SUP_COUT__ <<
"hexResult[" << strlen(hexResult)
867 <<
" nibbles]: " << std::string(hexResult) << __E__;
869 retParameters.addParameter(
"dataResult", hexResult);
870 return SOAPUtilities::makeSOAPMessageReference(
871 supervisorClassNoNamespace_ +
"aa", retParameters);
873 else if(
request ==
"GetInterfaceMacros")
875 if(theFEInterfacesManager_)
877 __SUP_COUT__ <<
"Getting FE Macros from FE Interface Manager..." << __E__;
878 retParameters.addParameter(
881 CorePropertySupervisorBase::getSupervisorUID(),
882 std::to_string(CoreSupervisorBase::getSupervisorLID())));
886 __SUP_COUT__ <<
"No FE Macros because there is no FE Interface Manager..."
888 retParameters.addParameter(
"FEMacros",
"");
891 return SOAPUtilities::makeSOAPMessageReference(
892 supervisorClassNoNamespace_ +
"Response", retParameters);
894 else if(
request ==
"RunInterfaceMacro")
896 if(!theFEInterfacesManager_)
898 __SUP_SS__ <<
"Missing FE Interface Manager! Are you configured?"
905 requestParameters.addParameter(
"feMacroName");
906 requestParameters.addParameter(
"inputArgs");
907 requestParameters.addParameter(
"outputArgs");
908 requestParameters.addParameter(
"InterfaceID");
909 requestParameters.addParameter(
"userPermissions");
910 SOAPUtilities::receive(message, requestParameters);
911 std::string interfaceID = requestParameters.getValue(
"InterfaceID");
912 std::string feMacroName = requestParameters.getValue(
"feMacroName");
913 std::string inputArgs = requestParameters.getValue(
"inputArgs");
914 std::string outputArgs = requestParameters.getValue(
"outputArgs");
915 std::string userPermissions = requestParameters.getValue(
"userPermissions");
920 __COUTV__(userPermissions);
921 std::map<std::string, WebUsers::permissionLevel_t> userPermissionLevelsMap;
923 userPermissions, userPermissionLevelsMap);
934 auto FEMacroIt = fe->getMapOfFEMacroFunctions().find(feMacroName);
935 if(FEMacroIt == fe->getMapOfFEMacroFunctions().end())
937 __SUP_SS__ <<
"FE Macro '" << feMacroName <<
"' of interfaceID '"
938 << interfaceID <<
"' was not found!" << __E__;
943 __COUTV__(FEMacro.requiredUserPermissions_);
944 std::map<std::string, WebUsers::permissionLevel_t>
945 FERequiredUserPermissionsMap;
947 FEMacro.requiredUserPermissions_, FERequiredUserPermissionsMap);
951 userPermissionLevelsMap, FERequiredUserPermissionsMap))
953 __SUP_SS__ <<
"Invalid user permission for FE Macro '" << feMacroName
954 <<
"' of interfaceID '" << interfaceID <<
"'!\n\n"
955 <<
"Must have access level of at least '"
957 <<
".' Users permissions level is only '"
958 << userPermissions <<
".'" << __E__;
963 interfaceID, FEMacro, inputArgs, outputArgs);
967 catch(std::runtime_error& e)
969 __SUP_SS__ <<
"In Supervisor with LID="
970 << getApplicationDescriptor()->getLocalId()
971 <<
" the FE Macro named '" << feMacroName
972 <<
"' with target FE '" << interfaceID
973 <<
"' failed. Here is the error:\n\n"
974 << e.what() << __E__;
977 catch(std::exception& e)
979 __SUP_SS__ <<
"In Supervisor with LID="
980 << getApplicationDescriptor()->getLocalId()
981 <<
" the FE Macro named '" << feMacroName
982 <<
"' with target FE '" << interfaceID
983 <<
"' failed. Here is the error:\n\n"
984 << e.what() << __E__;
989 __SUP_SS__ <<
"In Supervisor with LID="
990 << getApplicationDescriptor()->getLocalId()
991 <<
" the FE Macro named '" << feMacroName
992 <<
"' with target FE '" << interfaceID
993 <<
"' failed due to an unknown error." << __E__;
998 catch(
const std::exception& e)
1000 ss <<
"Exception message: " << e.what();
1009 retParameters.addParameter(
"outputArgs", outputArgs);
1011 return SOAPUtilities::makeSOAPMessageReference(
1012 supervisorClassNoNamespace_ +
"Response", retParameters);
1014 else if(
request ==
"RunMacroMakerMacro")
1016 if(!theFEInterfacesManager_)
1018 __SUP_SS__ <<
"Missing FE Interface Manager! Are you configured?"
1025 requestParameters.addParameter(
"macroName");
1026 requestParameters.addParameter(
"macroString");
1027 requestParameters.addParameter(
"inputArgs");
1028 requestParameters.addParameter(
"outputArgs");
1029 requestParameters.addParameter(
"InterfaceID");
1030 SOAPUtilities::receive(message, requestParameters);
1031 std::string interfaceID = requestParameters.getValue(
"InterfaceID");
1032 std::string macroName = requestParameters.getValue(
"macroName");
1033 std::string macroString = requestParameters.getValue(
"macroString");
1034 std::string inputArgs = requestParameters.getValue(
"inputArgs");
1035 std::string outputArgs = requestParameters.getValue(
"outputArgs");
1042 interfaceID, macroString, inputArgs, outputArgs);
1044 catch(std::runtime_error& e)
1046 __SUP_SS__ <<
"In Supervisor with LID="
1047 << getApplicationDescriptor()->getLocalId()
1048 <<
" the MacroMaker Macro named '" << macroName
1049 <<
"' with target FE '" << interfaceID
1050 <<
"' failed. Here is the error:\n\n"
1051 << e.what() << __E__;
1056 __SUP_SS__ <<
"In Supervisor with LID="
1057 << getApplicationDescriptor()->getLocalId()
1058 <<
" the MacroMaker Macro named '" << macroName
1059 <<
"' with target FE '" << interfaceID
1060 <<
"' failed due to an unknown error." << __E__;
1065 catch(
const std::exception& e)
1067 ss <<
"Exception message: " << e.what();
1075 retParameters.addParameter(
"outputArgs", outputArgs);
1077 return SOAPUtilities::makeSOAPMessageReference(
1078 supervisorClassNoNamespace_ +
"Response", retParameters);
1082 __SUP_SS__ <<
"Unrecognized request received! '" <<
request <<
"'" << __E__;
1086 catch(
const std::runtime_error& e)
1088 __SUP_SS__ <<
"Error occurred handling request: " << e.what() << __E__;
1089 __SUP_COUT_ERR__ << ss.str();
1090 retParameters.addParameter(
"Error", ss.str());
1094 __SUP_SS__ <<
"Error occurred handling request." << __E__;
1099 catch(
const std::exception& e)
1101 ss <<
"Exception message: " << e.what();
1106 __SUP_COUT_ERR__ << ss.str();
1107 retParameters.addParameter(
"Error", ss.str());
1110 return SOAPUtilities::makeSOAPMessageReference(
1111 supervisorClassNoNamespace_ +
"FailRequest", retParameters);
1116 xoap::MessageReference FESupervisor::workLoopStatusRequest(
1117 xoap::MessageReference )
1119 if(!theFEInterfacesManager_)
1121 __SUP_SS__ <<
"Invalid request for front-end workloop status from Supervisor "
1122 "without a FEVInterfacesManager."
1127 return SOAPUtilities::makeSOAPMessageReference(
1129 ? CoreSupervisorBase::WORK_LOOP_DONE
1130 : CoreSupervisorBase::WORK_LOOP_WORKING));
1143 theFEInterfacesManager_ = 0;
1145 for(
unsigned int i = 0; i < theStateMachineImplementation_.size(); ++i)
1149 theFEInterfacesManager_ =
1151 if(!theFEInterfacesManager_)
1154 __SUP_SS__ <<
"Dynamic cast failure!" << __E__;
1157 __SUP_COUT__ <<
"State Machine " << i <<
" WAS of type FEVInterfacesManager"
1164 __SUP_COUT__ <<
"State Machine " << i
1165 <<
" was NOT of type FEVInterfacesManager" << __E__;
1169 __SUP_COUT__ <<
"theFEInterfacesManager pointer = " << theFEInterfacesManager_
1172 return theFEInterfacesManager_;
1176 void FESupervisor::transitionConfiguring(toolbox::Event::Reference )
1178 __SUP_COUT__ <<
"transitionConfiguring" << __E__;
1182 if(RunControlStateMachine::getIterationIndex() == 0 &&
1183 RunControlStateMachine::getSubIterationIndex() == 0)
1186 SOAPUtilities::translate(theStateMachine_.getCurrentMessage())
1188 .getValue(
"ConfigurationTableGroupName"),
1190 SOAPUtilities::translate(theStateMachine_.getCurrentMessage())
1192 .getValue(
"ConfigurationTableGroupKey")));
1194 __SUP_COUT__ <<
"Configuration table group name: " << theGroup.first
1195 <<
" key: " << theGroup.second << __E__;
1213 ConfigurationManager::LoadGroupType::ALL_TYPES,
1216 catch(
const std::runtime_error& e)
1218 __SS__ <<
"Error loading table group '" << theGroup.first <<
"("
1219 << theGroup.second <<
")! \n"
1220 << e.what() << __E__;
1221 __SUP_COUT_ERR__ << ss.str();
1225 theStateMachine_.setErrorMessage(ss.str());
1226 throw toolbox::fsm::exception::Exception(
1227 "Transition Error" ,
1229 "FESupervisor::transitionConfiguring" ,
1236 __SS__ <<
"Unknown error loading table group '" << theGroup.first <<
"("
1237 << theGroup.second <<
")!" << __E__;
1242 catch(
const std::exception& e)
1244 ss <<
"Exception message: " << e.what();
1249 __SUP_COUT_ERR__ << ss.str();
1253 theStateMachine_.setErrorMessage(ss.str());
1254 throw toolbox::fsm::exception::Exception(
1255 "Transition Error" ,
1257 "FESupervisor::transitionConfiguring" ,
1268 __COUTV__(CorePropertySupervisorBase::getSupervisorConfigurationPath());
1271 CorePropertySupervisorBase::getSupervisorTableNode();
1273 std::string metric_string =
"";
1274 bool metricStringSetup =
true;
1277 std::ostringstream oss;
1278 std::string tabString =
"";
1279 std::string commentsString =
"";
1281 oss, tabString, commentsString, feSupervisorNode);
1282 metric_string = oss.str();
1286 metricStringSetup =
false;
1292 __SUP_COUT__ <<
"Metric manager is not instantiated! Attempting to fix."
1294 metricMan = std::make_unique<artdaq::MetricManager>();
1296 std::string metricNamePreamble =
1297 feSupervisorNode.
getNode(
"/SlowControlsMetricManagerChannelNamePreamble")
1299 __SUP_COUTV__(metricNamePreamble);
1300 if(metricNamePreamble == TableViewColumnInfo::DATATYPE_STRING_DEFAULT)
1301 metricNamePreamble =
"";
1304 fhicl::ParameterSet metric_pset = fhicl::ParameterSet::make(metric_string);
1306 __SUP_COUTV__(metricNamePreamble);
1309 metricMan->initialize(metric_pset.get<fhicl::ParameterSet>(
"metrics"),
1310 metricNamePreamble);
1314 if(metricStringSetup)
1317 __SUP_COUT__ <<
"Ignore metric manager initialize error because metric "
1318 "string is not setup."
1321 __SUP_COUT__ <<
"transitionConfiguring metric manager(" << metricMan
1322 <<
") initialized = " << metricMan->Initialized() << __E__;
1324 catch(
const std::runtime_error& e)
1326 __SS__ <<
"Error loading metrics in FESupervisor::transitionConfiguring(): "
1327 << e.what() << __E__;
1328 __SUP_COUT_ERR__ << ss.str();
1332 theStateMachine_.setErrorMessage(ss.str());
1333 throw toolbox::fsm::exception::Exception(
1334 "Transition Error" ,
1336 "FESupervisor::transitionConfiguring" ,
1343 __SS__ <<
"Error loading metrics in FESupervisor::transitionConfiguring()"
1349 catch(
const std::exception& e)
1351 ss <<
"Exception message: " << e.what();
1356 __SUP_COUT_ERR__ << ss.str();
1360 theStateMachine_.setErrorMessage(ss.str());
1361 throw toolbox::fsm::exception::Exception(
1362 "Transition Error" ,
1364 "FESupervisor::transitionConfiguring" ,
1370 CoreSupervisorBase::transitionConfiguringFSMs();
1372 __SUP_COUT__ <<
"transitionConfiguring done." << __E__;
1378 __SUP_COUT__ <<
"transitionHalting" << __E__;
1379 TLOG_DEBUG(7) <<
"transitionHalting";
1386 if(metricMan && metricMan->Initialized())
1388 TLOG_DEBUG(7) <<
"Metric manager(" << metricMan <<
") shutting down..."
1392 TLOG_DEBUG(7) <<
"Metric manager shutdown." << __E__;
1395 __SUP_COUT__ <<
"Metric manager(" << metricMan <<
") already shutdown."
1398 metricMan.reset(
nullptr);
1402 __SS__ <<
"Error shutting down metrics in FESupervisor::transitionHalting()"
1408 catch(
const std::exception& e)
1410 ss <<
"Exception message: " << e.what();
1415 __SUP_COUT_ERR__ << ss.str();
1419 theStateMachine_.setErrorMessage(ss.str());
1420 throw toolbox::fsm::exception::Exception(
1421 "Transition Error" ,
1423 "FESupervisor::transitionHalting" ,
1429 __SUP_COUT__ <<
"transitionHalting done." << __E__;
static void insertMetricsBlock(std::ostream &out, std::string &tabStr, std::string &commentStr, ConfigurationTree daqNode)
insertMetricsBlock
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)
ConfigurationTree getNode(const std::string &nodeName, bool doNotThrowOnBrokenUIDLinks=false) const
navigating between nodes
void getValue(T &value) const
static void extractPermissionsMapFromString(const std::string &permissionsString, std::map< std::string, WebUsers::permissionLevel_t > &permissionsMap)
static bool doPermissionsGrantAccess(std::map< std::string, WebUsers::permissionLevel_t > &permissionLevelsMap, std::map< std::string, WebUsers::permissionLevel_t > &permissionThresholdsMap)
virtual void transitionHalting(toolbox::Event::Reference event)
virtual void request(const std::string &requestType, cgicc::Cgicc &cgiIn, HttpXmlDocument &xmlOut, const WebUsers::RequestUserInfo &userInfo)
virtual void transitionHalting(toolbox::Event::Reference event) override
xoap::MessageReference macroMakerSupervisorRequest(xoap::MessageReference message)
const FEVInterface & getFEInterface(const std::string &interfaceID) const
getFEInterface
std::string getFEMacrosString(const std::string &supervisorName, const std::string &supervisorLid)
used by MacroMaker
FEVInterface * getFEInterfaceP(const std::string &interfaceID)
getFEInterfaceP
void runFEMacro(const std::string &interfaceID, const FEVInterface::frontEndMacroStruct_t &feMacro, const std::string &inputArgs, std::string &outputArgs)
used by MacroMaker and FE calling indirectly
unsigned int getInterfaceUniversalAddressSize(const std::string &interfaceID)
used by MacroMaker
void startFEMacroMultiDimensional(const std::string &requester, const std::string &interfaceID, const std::string &feMacroName, const bool enableSavingOutput, const std::string &outputFilePath, const std::string &outputFileRadix, const std::string &inputArgs)
used by iterator calling (i.e. FESupervisor)
void universalWrite(const std::string &interfaceID, char *address, char *writeValue)
used by MacroMaker
bool allFEWorkloopsAreDone(void)
used by Iterator, e.g.
void runFEMacroByFE(const std::string &callingInterfaceID, const std::string &interfaceID, const std::string &feMacroName, const std::string &inputArgs, std::string &outputArgs)
used by FE calling (i.e. FESupervisor)
unsigned int getInterfaceUniversalDataSize(const std::string &interfaceID)
used by MacroMaker
void universalRead(const std::string &interfaceID, char *address, char *returnValue)
used by MacroMaker
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)
used by iterator calling (i.e. FESupervisor)
bool checkMacroMultiDimensional(const std::string &interfaceID, const std::string ¯oName)
used by iterator calling (i.e. FESupervisor)
std::mutex frontEndCommunicationReceiveMutex_
FE communication helpers.
void runMacro(const std::string &interfaceID, const std::string ¯oObjectString, const std::string &inputArgs, std::string &outputArgs)
used by MacroMaker
std::string getFEListString(const std::string &supervisorLid)
used by MacroMaker
< members fully define a front-end macro function
static std::string mapToString(const std::map< std::string, T > &mapToReturn, const std::string &primaryDelimeter=", ", const std::string &secondaryDelimeter=": ")