1 #include "otsdaq-utilities/MacroMaker/MacroMakerSupervisor.h"
9 #include "otsdaq-core/ConfigurationInterface/ConfigurationManager.h"
12 #include "otsdaq-core/FECore/FEVInterface.h"
14 #include "otsdaq-core/CodeEditor/CodeEditor.h"
27 #include "otsdaq-core/TableCore/TableGroupKey.h"
29 #define MACROS_DB_PATH std::string(__ENV__("SERVICE_DATA_PATH")) + "/MacroData/"
30 #define MACROS_HIST_PATH std::string(__ENV__("SERVICE_DATA_PATH")) + "/MacroHistory/"
31 #define MACROS_EXPORT_PATH std::string(__ENV__("SERVICE_DATA_PATH")) + "/MacroExport/"
33 #define SEQUENCE_FILE_NAME \
34 std::string(__ENV__("SERVICE_DATA_PATH")) + "/OtsWizardData/sequence.dat"
35 #define SEQUENCE_OUT_FILE_NAME \
36 std::string(__ENV__("SERVICE_DATA_PATH")) + "/OtsWizardData/sequence.out"
41 #define __MF_SUBJECT__ "MacroMaker"
47 : CoreSupervisorBase(stub)
49 __SUP_COUT__ <<
"Constructing..." << __E__;
51 INIT_MF(
"MacroMaker");
54 mkdir(((std::string)MACROS_DB_PATH).c_str(), 0755);
55 mkdir(((std::string)MACROS_HIST_PATH).c_str(), 0755);
56 mkdir(((std::string)MACROS_EXPORT_PATH).c_str(), 0755);
59 &MacroMakerSupervisor::frontEndCommunicationRequest,
64 if(CorePropertySupervisorBase::allSupervisorInfo_.isMacroMakerMode())
66 __SUP_COUT__ <<
"Starting constructor for Macro Maker mode." << __E__;
68 xgi::bind(
this, &MacroMakerSupervisor::requestIcons,
"requestIcons");
69 xgi::bind(
this, &MacroMakerSupervisor::verification,
"Verify");
70 xgi::bind(
this, &MacroMakerSupervisor::tooltipRequest,
"TooltipRequest");
71 xgi::bind(
this, &MacroMakerSupervisor::requestWrapper,
"Request");
73 __SUP_COUT__ <<
"Completed constructor for Macro Maker mode." << __E__;
76 __SUP_COUT__ <<
"Not Macro Maker only mode." << __E__;
81 __SUP_COUT__ <<
"Constructed." << __E__;
85 MacroMakerSupervisor::~MacroMakerSupervisor(
void) { destroy(); }
88 void MacroMakerSupervisor::init(
void)
93 allFESupervisorInfo_ = allSupervisorInfo_.getAllFETypeSupervisorInfo();
98 void MacroMakerSupervisor::destroy(
void)
106 void MacroMakerSupervisor::forceSupervisorPropertyValues()
113 void MacroMakerSupervisor::tooltipRequest(xgi::Input* in, xgi::Output* out)
115 cgicc::Cgicc cgi(in);
117 std::string Command = CgiDataUtilities::getData(cgi,
"RequestType");
120 std::string submittedSequence = CgiDataUtilities::postData(cgi,
"sequence");
123 if(securityCode_.compare(submittedSequence) != 0)
125 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match!"
135 HttpXmlDocument xmldoc;
137 if(Command ==
"check")
139 WebUsers::tooltipCheckForUsername(WebUsers::DEFAULT_ADMIN_USERNAME,
141 CgiDataUtilities::getData(cgi,
"srcFile"),
142 CgiDataUtilities::getData(cgi,
"srcFunc"),
143 CgiDataUtilities::getData(cgi,
"srcId"));
145 else if(Command ==
"setNeverShow")
147 WebUsers::tooltipSetNeverShowForUsername(
148 WebUsers::DEFAULT_ADMIN_USERNAME,
150 CgiDataUtilities::getData(cgi,
"srcFile"),
151 CgiDataUtilities::getData(cgi,
"srcFunc"),
152 CgiDataUtilities::getData(cgi,
"srcId"),
153 CgiDataUtilities::getData(cgi,
"doNeverShow") ==
"1" ?
true :
false,
154 CgiDataUtilities::getData(cgi,
"temporarySilence") ==
"1" ?
true :
false);
157 __COUT__ <<
"Command Request, " << Command <<
", not recognized." << __E__;
159 xmldoc.outputXmlDocument((std::ostringstream*)out,
false,
true);
163 void MacroMakerSupervisor::verification(xgi::Input* in, xgi::Output* out)
165 cgicc::Cgicc cgi(in);
166 std::string submittedSequence = CgiDataUtilities::getData(cgi,
"code");
167 __COUT__ <<
"submittedSequence=" << submittedSequence <<
" " << time(0) << __E__;
169 std::string securityWarning =
"";
171 if(securityCode_.compare(submittedSequence) != 0)
173 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match!"
175 *out <<
"Invalid code.";
181 __COUT__ <<
"*** Successfully authenticated security sequence "
182 <<
"@ " << time(0) << __E__;
187 securityWarning =
"&secure=False";
191 *out <<
"<!DOCTYPE HTML><html lang='en'><head><title>ots wiz</title>" <<
194 "<link rel='apple-touch-icon' sizes='57x57' href='/WebPath/images/otsdaqIcons/apple-icon-57x57.png'>\
195 <link rel='apple-touch-icon' sizes='60x60' href='/WebPath/images/otsdaqIcons/apple-icon-60x60.png'>\
196 <link rel='apple-touch-icon' sizes='72x72' href='/WebPath/images/otsdaqIcons/apple-icon-72x72.png'>\
197 <link rel='apple-touch-icon' sizes='76x76' href='/WebPath/images/otsdaqIcons/apple-icon-76x76.png'>\
198 <link rel='apple-touch-icon' sizes='114x114' href='/WebPath/images/otsdaqIcons/apple-icon-114x114.png'>\
199 <link rel='apple-touch-icon' sizes='120x120' href='/WebPath/images/otsdaqIcons/apple-icon-120x120.png'>\
200 <link rel='apple-touch-icon' sizes='144x144' href='/WebPath/images/otsdaqIcons/apple-icon-144x144.png'>\
201 <link rel='apple-touch-icon' sizes='152x152' href='/WebPath/images/otsdaqIcons/apple-icon-152x152.png'>\
202 <link rel='apple-touch-icon' sizes='180x180' href='/WebPath/images/otsdaqIcons/apple-icon-180x180.png'>\
203 <link rel='icon' type='image/png' sizes='192x192' href='/WebPath/images/otsdaqIcons/android-icon-192x192.png'>\
204 <link rel='icon' type='image/png' sizes='32x32' href='/WebPath/images/otsdaqIcons/favicon-32x32.png'>\
205 <link rel='icon' type='image/png' sizes='96x96' href='/WebPath/images/otsdaqIcons/favicon-96x96.png'>\
206 <link rel='icon' type='image/png' sizes='16x16' href='/WebPath/images/otsdaqIcons/favicon-16x16.png'>\
207 <link rel='manifest' href='/WebPath/images/otsdaqIcons/manifest.json'>\
208 <meta name='msapplication-TileColor' content='#ffffff'>\
209 <meta name='msapplication-TileImage' content='/ms-icon-144x144.png'>\
210 <meta name='theme-color' content='#ffffff'>"
214 <<
"<frameset col='100%' row='100%'><frame "
215 "src='/WebPath/html/MacroMakerSupervisor.html?urn="
216 << this->getApplicationDescriptor()->getLocalId() << securityWarning
217 <<
"'></frameset></html>";
221 void MacroMakerSupervisor::generateURL()
223 defaultSequence_ =
true;
226 FILE* fp = fopen((SEQUENCE_FILE_NAME).c_str(),
"r");
229 __SUP_COUT_INFO__ <<
"Sequence length file found: " << SEQUENCE_FILE_NAME
232 fgets(line, 100, fp);
233 sscanf(line,
"%d", &length);
238 defaultSequence_ =
false;
244 <<
"(Reverting to default wiz security) Sequence length file NOT found: "
245 << SEQUENCE_FILE_NAME << __E__;
249 __SUP_COUT__ <<
"Sequence length = " << length << __E__;
253 const char alphanum[] =
255 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
256 "abcdefghijklmnopqrstuvwxyz";
258 for(
int i = 0; i < length; ++i)
260 securityCode_ += alphanum[rand() % (
sizeof(alphanum) - 1)];
263 __SUP_COUT__ << __ENV__(
"HOSTNAME") <<
":" << __ENV__(
"PORT")
264 <<
"/urn:xdaq-application:lid="
265 << this->getApplicationDescriptor()->getLocalId()
266 <<
"/Verify?code=" << securityCode_ << __E__;
272 fp = fopen((SEQUENCE_OUT_FILE_NAME).c_str(),
"w");
275 fprintf(fp,
"%s", securityCode_.c_str());
279 __SUP_COUT_ERR__ <<
"Sequence output file NOT found: " << SEQUENCE_OUT_FILE_NAME
285 void MacroMakerSupervisor::requestIcons(xgi::Input* in, xgi::Output* out)
287 cgicc::Cgicc cgi(in);
289 std::string submittedSequence = CgiDataUtilities::postData(cgi,
"sequence");
292 if(securityCode_.compare(submittedSequence) != 0)
294 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match! "
300 __COUT__ <<
"***Successfully authenticated security sequence. " << time(0)
313 *out <<
"Macro Maker "
314 ",MM,0,1,icon-MacroMaker.png,/WebPath/html/"
315 "MacroMaker.html?urn=290,/"
317 ",CFG,0,1,icon-Configure.png,/WebPath/html/"
318 "FEMacroTest.html?urn=290,/"
326 void MacroMakerSupervisor::requestWrapper(xgi::Input* in, xgi::Output* out)
329 if(!CorePropertySupervisorBase::allSupervisorInfo_.isMacroMakerMode())
332 return CoreSupervisorBase::requestWrapper(in, out);
340 cgicc::Cgicc cgiIn(in);
342 std::string submittedSequence = CgiDataUtilities::postData(cgiIn,
"sequence");
345 if(securityCode_.compare(submittedSequence) != 0)
347 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match! "
353 __COUT__ <<
"***Successfully authenticated security sequence. " << time(0)
358 std::string requestType = CgiDataUtilities::getData(cgiIn,
"RequestType");
363 HttpXmlDocument xmlOut;
364 WebUsers::RequestUserInfo userInfo(
365 requestType, CgiDataUtilities::getOrPostData(cgiIn,
"CookieCode"));
367 CorePropertySupervisorBase::getRequestUserInfo(userInfo);
370 userInfo.username_ =
"admin";
371 userInfo.displayName_ =
"Admin";
372 userInfo.usernameWithLock_ =
"admin";
373 userInfo.activeUserSessionIndex_ = 0;
375 if(1 || !userInfo.automatedCommand_)
376 __SUP_COUT__ <<
"requestType: " << requestType << __E__;
378 if(userInfo.NonXMLRequestType_)
382 nonXmlRequest(requestType, cgiIn, *out, userInfo);
384 catch(
const std::runtime_error& e)
386 __SUP_SS__ <<
"An error was encountered handling requestType '" << requestType
387 <<
"':" << e.what() << __E__;
388 __SUP_COUT_ERR__ <<
"\n" << ss.str();
389 __SUP_MOUT_ERR__ <<
"\n" << ss.str();
393 __SUP_SS__ <<
"An unknown error was encountered handling requestType '"
394 << requestType <<
".' "
395 <<
"Please check the printouts to debug." << __E__;
396 __SUP_COUT_ERR__ <<
"\n" << ss.str();
397 __SUP_MOUT_ERR__ <<
"\n" << ss.str();
406 request(requestType, cgiIn, xmlOut, userInfo);
408 catch(
const std::runtime_error& e)
410 __SUP_SS__ <<
"An error was encountered handling requestType '" << requestType
411 <<
"':" << e.what() << __E__;
412 __SUP_COUT_ERR__ <<
"\n" << ss.str();
413 xmlOut.addTextElementToData(
"Error", ss.str());
417 __SUP_SS__ <<
"An unknown error was encountered handling requestType '"
418 << requestType <<
".' "
419 <<
"Please check the printouts to debug." << __E__;
420 __SUP_COUT_ERR__ <<
"\n" << ss.str();
421 xmlOut.addTextElementToData(
"Error", ss.str());
426 unsigned int occurance = 0;
427 std::string err = xmlOut.getMatchingValue(
"Error", occurance++);
430 __SUP_COUT_ERR__ <<
"'" << requestType <<
"' ERROR encountered: " << err
432 __SUP_MOUT_ERR__ <<
"'" << requestType <<
"' ERROR encountered: " << err
434 err = xmlOut.getMatchingValue(
"Error", occurance++);
439 xmlOut.outputXmlDocument((std::ostringstream*)out,
441 !userInfo.NoXmlWhiteSpace_ );
445 void MacroMakerSupervisor::request(
const std::string& requestType,
447 HttpXmlDocument& xmlOut,
448 const WebUsers::RequestUserInfo& userInfo)
try
451 std::string username =
"";
452 for(
unsigned int i = 0; i < userInfo.username_.size(); ++i)
453 if((userInfo.username_[i] >=
'a' && userInfo.username_[i] <=
'z') ||
454 (userInfo.username_[i] >=
'A' && userInfo.username_[i] <=
'Z') ||
455 (userInfo.username_[i] >=
'0' && userInfo.username_[i] <=
'9') ||
456 userInfo.username_[i] >=
'-' || userInfo.username_[i] <=
'_')
457 username += userInfo.username_[i];
459 if(username.size() < 2)
461 __SUP_SS__ <<
"Illegal username '" << userInfo.username_ <<
"' received."
466 __SUP_COUT__ <<
"User name is " << userInfo.username_ <<
"." << __E__;
467 __SUP_COUT__ <<
"User permission level for request '" << requestType <<
"' is "
468 << unsigned(userInfo.permissionLevel_) <<
"." << __E__;
471 if(requestType ==
"getPermission")
473 xmlOut.addTextElementToData(
"Permission",
474 std::to_string(
unsigned(userInfo.permissionLevel_)));
478 std::string macroPath = (std::string)MACROS_DB_PATH + userInfo.username_ +
"/";
479 mkdir(macroPath.c_str(), 0755);
480 std::string histPath = (std::string)MACROS_HIST_PATH + userInfo.username_ +
"/";
481 mkdir(histPath.c_str(), 0755);
482 std::string publicPath = (std::string)MACROS_DB_PATH +
"publicMacros/";
483 mkdir(publicPath.c_str(), 0755);
484 std::string exportPath =
485 (std::string)MACROS_EXPORT_PATH + userInfo.username_ +
"/";
486 mkdir(exportPath.c_str(), 0755);
489 handleRequest(requestType, xmlOut, cgiIn, userInfo.username_);
491 catch(
const std::runtime_error& e)
493 __SS__ <<
"Error occurred handling request '" << requestType <<
"': " << e.what()
495 __SUP_COUT__ << ss.str();
496 xmlOut.addTextElementToData(
"Error", ss.str());
500 __SS__ <<
"Unknown error occurred handling request '" << requestType <<
"!'" << __E__;
501 __SUP_COUT__ << ss.str();
502 xmlOut.addTextElementToData(
"Error", ss.str());
506 void MacroMakerSupervisor::handleRequest(
const std::string Command,
507 HttpXmlDocument& xmldoc,
509 const std::string& username)
511 if(Command ==
"FElist")
513 else if(Command ==
"writeData")
514 writeData(xmldoc, cgi, username);
515 else if(Command ==
"readData")
516 readData(xmldoc, cgi, username);
517 else if(Command ==
"createMacro")
518 createMacro(xmldoc, cgi, username);
519 else if(Command ==
"loadMacros")
520 loadMacros(xmldoc, username);
521 else if(Command ==
"loadHistory")
522 loadHistory(xmldoc, username);
523 else if(Command ==
"deleteMacro")
524 deleteMacro(xmldoc, cgi, username);
525 else if(Command ==
"editMacro")
526 editMacro(xmldoc, cgi, username);
527 else if(Command ==
"clearHistory")
528 clearHistory(username);
529 else if(Command ==
"exportMacro")
530 exportMacro(xmldoc, cgi, username);
531 else if(Command ==
"exportFEMacro")
532 exportFEMacro(xmldoc, cgi, username);
533 else if(Command ==
"getFEMacroList")
535 getFEMacroList(xmldoc, username);
536 else if(Command ==
"runFEMacro")
538 runFEMacro(xmldoc, cgi, username);
540 xmldoc.addTextElementToData(
"Error",
"Unrecognized command '" + Command +
"'");
544 xoap::MessageReference MacroMakerSupervisor::frontEndCommunicationRequest(
545 xoap::MessageReference message)
try
547 __SUP_COUT__ <<
"FE Request received: " << SOAPUtilities::translate(message) << __E__;
549 SOAPParameters typeParameter, rxParameters;
550 typeParameter.addParameter(
"type");
551 SOAPUtilities::receive(message, typeParameter);
553 std::string type = typeParameter.getValue(
"type");
555 std::string error =
"";
557 if(type ==
"initFElist")
561 rxParameters.addParameter(
"groupName");
562 rxParameters.addParameter(
"groupKey");
563 SOAPUtilities::receive(message, rxParameters);
565 std::string groupName = rxParameters.getValue(
"groupName");
566 std::string groupKey = rxParameters.getValue(
"groupKey");
568 __SUP_COUTV__(groupName);
569 __SUP_COUTV__(groupKey);
571 ConfigurationManager cfgMgr;
572 cfgMgr.loadTableGroup(groupName, TableGroupKey(groupKey),
true);
577 const SupervisorInfoMap& feTypeSupervisors =
578 CorePropertySupervisorBase::allSupervisorInfo_.getAllFETypeSupervisorInfo();
580 ConfigurationTree appsNode =
581 cfgMgr.getNode(ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME);
583 __SUP_COUT__ <<
"Number of FE Supervisors found = " << feTypeSupervisors.size()
586 FEPluginTypetoFEsMap_.clear();
587 FEtoSupervisorMap_.clear();
588 FEtoPluginTypeMap_.clear();
589 for(
auto& feApp : feTypeSupervisors)
591 __SUP_COUT__ <<
"FEs for app " << feApp.first <<
":" << feApp.second.getName()
594 auto feChildren = appsNode.getNode(feApp.second.getName())
595 .getNode(
"LinkToSupervisorTable")
596 .getNode(
"LinkToFEInterfaceTable")
599 for(
auto& fe : feChildren)
601 __SUP_COUTV__(fe.first);
602 FEtoSupervisorMap_[fe.first] = feApp.first;
604 std::string pluginType =
605 fe.second.getNode(
"FEInterfacePluginName").getValue();
606 FEPluginTypetoFEsMap_[pluginType].emplace(fe.first);
607 FEtoPluginTypeMap_[fe.first] = pluginType;
611 __SUP_COUTV__(StringMacros::mapToString(FEtoSupervisorMap_));
612 __SUP_COUTV__(StringMacros::mapToString(FEPluginTypetoFEsMap_));
613 __SUP_COUTV__(StringMacros::mapToString(FEtoPluginTypeMap_));
615 else if(type ==
"feSend" ||
617 type ==
"feMacroMultiDimensionalStart" ||
618 type ==
"feMacroMultiDimensionalCheck" ||
619 type ==
"macroMultiDimensionalStart" ||
620 type ==
"macroMultiDimensionalCheck")
624 rxParameters.addParameter(
"targetInterfaceID");
625 SOAPUtilities::receive(message, rxParameters);
627 std::string targetInterfaceID = rxParameters.getValue(
"targetInterfaceID");
629 __SUP_COUTV__(targetInterfaceID);
631 auto feIt = FEtoSupervisorMap_.find(targetInterfaceID);
632 if(feIt == FEtoSupervisorMap_.end())
634 __SUP_SS__ <<
"Destination front end interface ID '" << targetInterfaceID
635 <<
"' was not found in the list of front ends." << __E__;
639 unsigned int FESupervisorIndex = feIt->second;
640 __SUP_COUT__ <<
"Found supervisor index: " << FESupervisorIndex << __E__;
642 SupervisorInfoMap::iterator it = allFESupervisorInfo_.find(FESupervisorIndex);
643 if(it == allFESupervisorInfo_.end())
645 __SUP_SS__ <<
"Error transmitting request to FE Supervisor '"
646 << targetInterfaceID <<
":" << FESupervisorIndex <<
".' \n\n"
647 <<
"The FE Supervisor Index does not exist. Have you configured "
648 "the state machine properly?"
653 if(type ==
"macroMultiDimensionalStart")
657 SOAPParameters rxParameters;
658 rxParameters.addParameter(
"macroName");
659 SOAPUtilities::receive(message, rxParameters);
660 std::string macroName = rxParameters.getValue(
"macroName");
661 __SUP_COUTV__(macroName);
663 std::string macroString;
664 loadMacro(macroName, macroString);
666 SOAPParameters parameters;
667 parameters.addParameter(
"macroString", macroString);
668 SOAPUtilities::addParameters(message, parameters);
673 __SUP_COUT__ <<
"Forwarding request: " << SOAPUtilities::translate(message)
676 xoap::MessageReference replyMessage =
677 SOAPMessenger::sendWithSOAPReply(it->second.getDescriptor(), message);
681 __SUP_COUT__ <<
"Forwarding FE Macro response: "
682 << SOAPUtilities::translate(replyMessage) << __E__;
687 catch(
const xdaq::exception::Exception& e)
689 __SUP_SS__ <<
"Error forwarding FE Communication request to FE Supervisor '"
690 << targetInterfaceID <<
":" << FESupervisorIndex <<
".' "
691 <<
"Have you configured the state machine properly?\n\n"
692 << e.what() << __E__;
698 __SUP_SS__ <<
"Unrecognized FE Communication type: " << type << __E__;
702 return SOAPUtilities::makeSOAPMessageReference(
"Received");
704 catch(
const std::runtime_error& e)
706 __SUP_SS__ <<
"Error processing FE communication request: " << e.what() << __E__;
707 __SUP_COUT_ERR__ << ss.str();
709 xoap::MessageReference returnMessage =
710 SOAPUtilities::makeSOAPMessageReference(
"Error");
712 SOAPParameters parameters;
713 parameters.addParameter(
"Error", ss.str());
714 SOAPUtilities::addParameters(returnMessage, parameters);
715 return returnMessage;
719 xoap::MessageReference returnMessage =
720 SOAPUtilities::makeSOAPMessageReference(
"Error");
722 __SUP_SS__ <<
"Unknown error processing FE communication request." << __E__;
723 __SUP_COUT_ERR__ << ss.str();
725 SOAPParameters parameters;
726 parameters.addParameter(
"Error", ss.str());
727 SOAPUtilities::addParameters(returnMessage, parameters);
728 return returnMessage;
732 void MacroMakerSupervisor::getFElist(HttpXmlDocument& xmldoc)
734 __SUP_COUT__ <<
"Getting FE list!!!!!!!!!" << __E__;
736 SOAPParameters txParameters;
737 txParameters.addParameter(
"Request",
"GetInterfaces");
739 SOAPParameters rxParameters;
740 rxParameters.addParameter(
"FEList");
741 rxParameters.addParameter(
"frontEndError");
745 SupervisorInfoMap::const_iterator it;
746 std::string oneInterface;
747 std::string rxFEList;
748 std::string rxFrontEndError;
750 size_t lastColonIndex;
754 for(
auto& appInfo : allFESupervisorInfo_)
762 __SUP_COUT__ <<
"FESupervisor LID = " << appInfo.second.getId()
763 <<
" name = " << appInfo.second.getName() << __E__;
767 xoap::MessageReference retMsg =
768 SOAPMessenger::sendWithSOAPReply(appInfo.second.getDescriptor(),
769 "MacroMakerSupervisorRequest",
771 SOAPUtilities::receive(retMsg, rxParameters);
773 catch(
const xdaq::exception::Exception& e)
775 __SUP_SS__ <<
"Error transmitting request to FE Supervisor LID = "
776 << appInfo.second.getId() <<
" name = " << appInfo.second.getName()
778 << e.what() << __E__;
782 rxFEList = rxParameters.getValue(
"FEList");
783 rxFrontEndError = rxParameters.getValue(
"frontEndError");
785 __SUP_COUT__ <<
"FE List received: \n" << rxFEList << __E__;
787 if(rxFrontEndError !=
"")
789 __SUP_SS__ <<
"FE Errors received: \n" << rxFrontEndError << __E__;
793 std::istringstream allInterfaces(rxFEList);
794 while(std::getline(allInterfaces, oneInterface))
796 __SUP_COUTV__(oneInterface);
797 xmldoc.addTextElementToData(
"FE", oneInterface);
799 lastColonIndex = oneInterface.rfind(
':');
800 if(lastColonIndex == std::string::npos)
802 __SUP_SS__ <<
"Last colon could not be found in " << oneInterface
806 oneInterface = oneInterface.substr(lastColonIndex);
808 __SUP_COUTV__(oneInterface);
816 void MacroMakerSupervisor::writeData(HttpXmlDocument& xmldoc,
818 const std::string& username)
820 __SUP_COUT__ <<
"MacroMaker writing..." << __E__;
822 std::string Address = CgiDataUtilities::getData(cgi,
"Address");
823 std::string Data = CgiDataUtilities::getData(cgi,
"Data");
824 std::string interfaceIndexArray = CgiDataUtilities::getData(cgi,
"interfaceIndex");
825 std::string supervisorIndexArray = CgiDataUtilities::getData(cgi,
"supervisorIndex");
827 CgiDataUtilities::decodeURIComponent(CgiDataUtilities::getData(cgi,
"time"));
828 std::string addressFormatStr = CgiDataUtilities::getData(cgi,
"addressFormatStr");
829 std::string dataFormatStr = CgiDataUtilities::getData(cgi,
"dataFormatStr");
831 std::string interfaces = CgiDataUtilities::postData(cgi,
"interfaces");
833 __SUP_COUT__ <<
"Write Address: " << Address <<
" Data: " << Data << __E__;
834 __SUP_COUTV__(interfaces);
836 std::string command =
"w:" + Address +
":" + Data;
837 std::string format = addressFormatStr +
":" + dataFormatStr;
838 appendCommandToHistory(command, format, time, interfaces, username);
840 SOAPParameters txParameters;
841 txParameters.addParameter(
"Request",
"UniversalWrite");
842 txParameters.addParameter(
"Address", Address);
843 txParameters.addParameter(
"Data", Data);
845 __SUP_COUT__ <<
"Here comes the array from multiselect box for WRITE, behold: \n"
846 << supervisorIndexArray <<
"\n"
847 << interfaceIndexArray << __E__;
851 std::vector<std::string> interfaceIndices;
852 std::istringstream f(interfaceIndexArray);
854 while(getline(f, s,
','))
855 interfaceIndices.push_back(s);
856 std::vector<int> supervisorIndices;
857 std::istringstream g(supervisorIndexArray);
859 while(getline(g, t,
','))
860 supervisorIndices.push_back(std::stoi(t));
862 for(
unsigned int i = 0; i < supervisorIndices.size(); i++)
864 unsigned int FESupervisorIndex = supervisorIndices[i];
865 std::string interfaceIndex = interfaceIndices[i];
867 txParameters.addParameter(
"InterfaceID", interfaceIndex);
869 __SUP_COUT__ <<
"The index of the supervisor instance is: " << FESupervisorIndex
871 __SUP_COUT__ <<
"...and the interface ID is: " << interfaceIndex << __E__;
873 SupervisorInfoMap::iterator it = allFESupervisorInfo_.find(FESupervisorIndex);
874 if(it == allFESupervisorInfo_.end())
876 __SUP_SS__ <<
"Error transmitting request to FE Supervisor '"
877 << interfaceIndex <<
":" << FESupervisorIndex <<
".' \n\n"
878 <<
"The FE Index doesn't exist. Have you configured the state "
886 xoap::MessageReference replyMessage = SOAPMessenger::sendWithSOAPReply(
887 it->second.getDescriptor(),
"MacroMakerSupervisorRequest", txParameters);
889 __SUP_COUT__ <<
"Response received: "
890 << SOAPUtilities::translate(replyMessage) << __E__;
892 SOAPParameters rxParameters;
893 rxParameters.addParameter(
"Error");
894 SOAPUtilities::receive(replyMessage, rxParameters);
896 std::string error = rxParameters.getValue(
"Error");
897 __SUP_COUTV__(error);
902 __SUP_SS__ <<
"Error transmitting request to FE Supervisor '"
903 << interfaceIndex <<
":" << FESupervisorIndex <<
".' "
904 <<
"Have you configured the state machine properly?\n\n"
909 catch(
const xdaq::exception::Exception& e)
911 __SUP_SS__ <<
"Error transmitting request to FE Supervisor '"
912 << interfaceIndex <<
":" << FESupervisorIndex <<
".' "
913 <<
"Have you configured the state machine properly?\n\n"
914 << e.what() << __E__;
922 void MacroMakerSupervisor::readData(HttpXmlDocument& xmldoc,
924 const std::string& username)
926 __SUP_COUT__ <<
"@@@@@@@ MacroMaker wants to read data @@@@@@@@" << __E__;
927 std::string Address = CgiDataUtilities::getData(cgi,
"Address");
928 std::string interfaceIndexArray = CgiDataUtilities::getData(cgi,
"interfaceIndex");
929 std::string supervisorIndexArray = CgiDataUtilities::getData(cgi,
"supervisorIndex");
931 CgiDataUtilities::decodeURIComponent(CgiDataUtilities::getData(cgi,
"time"));
932 std::string addressFormatStr = CgiDataUtilities::getData(cgi,
"addressFormatStr");
933 std::string dataFormatStr = CgiDataUtilities::getData(cgi,
"dataFormatStr");
935 std::string interfaces = CgiDataUtilities::postData(cgi,
"interfaces");
937 __SUP_COUT__ <<
"Read Address: " << Address << __E__;
938 __SUP_COUTV__(interfaces);
940 SOAPParameters txParameters;
941 txParameters.addParameter(
"Request",
"UniversalRead");
942 txParameters.addParameter(
"Address", Address);
944 SOAPParameters rxParameters;
945 rxParameters.addParameter(
"dataResult");
946 rxParameters.addParameter(
"Error");
947 __SUP_COUT__ <<
"Here comes the array from multiselect box for READ, behold: "
948 << supervisorIndexArray <<
"," << interfaceIndexArray << __E__;
952 std::vector<std::string> interfaceIndices;
953 std::istringstream f(interfaceIndexArray);
955 while(getline(f, s,
','))
956 interfaceIndices.push_back(s);
957 std::vector<int> supervisorIndices;
958 std::istringstream g(supervisorIndexArray);
960 while(getline(g, t,
','))
961 supervisorIndices.push_back(std::stoi(t));
963 for(
unsigned int i = 0; i < supervisorIndices.size(); i++)
965 unsigned int FESupervisorIndex = supervisorIndices[i];
966 std::string interfaceIndex = interfaceIndices[i];
968 txParameters.addParameter(
"InterfaceID", interfaceIndex);
970 __SUP_COUT__ <<
"The index of the supervisor instance is: " << FESupervisorIndex
972 __SUP_COUT__ <<
"...and the interface ID is: " << interfaceIndex << __E__;
974 SupervisorInfoMap::iterator it = allFESupervisorInfo_.find(FESupervisorIndex);
975 if(it == allFESupervisorInfo_.end())
977 __SUP_SS__ <<
"Error transmitting request to FE Supervisor '"
978 << interfaceIndex <<
":" << FESupervisorIndex <<
".' \n\n"
979 <<
"The FE Index doesn't exist. Have you configured the state "
987 xoap::MessageReference retMsg = SOAPMessenger::sendWithSOAPReply(
988 it->second.getDescriptor(),
"MacroMakerSupervisorRequest", txParameters);
990 __SUP_COUT__ <<
"Response received: " << SOAPUtilities::translate(retMsg)
995 SOAPUtilities::receive(retMsg, rxParameters);
997 std::string error = rxParameters.getValue(
"Error");
998 __SUP_COUTV__(error);
1003 __SUP_SS__ <<
"Error transmitting request to FE Supervisor '"
1004 << interfaceIndex <<
":" << FESupervisorIndex <<
".' "
1005 <<
"Have you configured the state machine properly?\n\n"
1010 catch(
const xdaq::exception::Exception& e)
1012 __SUP_SS__ <<
"Error transmitting request to FE Supervisor '"
1013 << interfaceIndex <<
":" << FESupervisorIndex <<
".' "
1014 <<
"Have you configured the state machine properly?\n\n"
1015 << e.what() << __E__;
1019 std::string dataReadResult = rxParameters.getValue(
"dataResult");
1020 __SUP_COUT__ <<
"Data reading result received: " << dataReadResult << __E__;
1021 xmldoc.addTextElementToData(
"readData", dataReadResult);
1022 std::string command =
"r:" + Address +
":" + dataReadResult;
1023 std::string format = addressFormatStr +
":" + dataFormatStr;
1024 appendCommandToHistory(command, format, time, interfaces, username);
1029 void MacroMakerSupervisor::createMacro(HttpXmlDocument& xmldoc,
1031 const std::string& username)
1033 __SUP_COUT__ <<
"MacroMaker wants to create a macro!!!!!!!!!" << __E__;
1034 std::string Name = CgiDataUtilities::postData(cgi,
"Name");
1035 std::string Sequence = CgiDataUtilities::postData(cgi,
"Sequence");
1036 std::string Time = CgiDataUtilities::postData(cgi,
"Time");
1038 CgiDataUtilities::decodeURIComponent(CgiDataUtilities::postData(cgi,
"Notes"));
1039 std::string isMacroPublic = CgiDataUtilities::getData(cgi,
"isPublic");
1040 std::string isMacroLSBF = CgiDataUtilities::getData(cgi,
"isLSBF");
1042 __SUP_COUTV__(Name);
1043 __SUP_COUTV__(Sequence);
1044 __SUP_COUTV__(Notes);
1045 __SUP_COUTV__(Time);
1046 __SUP_COUTV__(isMacroPublic);
1047 __SUP_COUTV__(isMacroLSBF);
1049 __SUP_COUTV__(MACROS_DB_PATH);
1051 std::string fileName = Name +
".dat";
1052 std::string fullPath;
1053 if(isMacroPublic ==
"true")
1054 fullPath = (std::string)MACROS_DB_PATH +
"publicMacros/" + fileName;
1056 fullPath = (std::string)MACROS_DB_PATH + username +
"/" + fileName;
1058 __SUP_COUTV__(fullPath);
1060 std::ofstream macrofile(fullPath.c_str());
1061 if(macrofile.is_open())
1064 macrofile <<
"\"name\":\"" << Name <<
"\",\n";
1065 macrofile <<
"\"sequence\":\"" << Sequence <<
"\",\n";
1066 macrofile <<
"\"time\":\"" << Time <<
"\",\n";
1067 macrofile <<
"\"notes\":\"" << Notes <<
"\",\n";
1068 macrofile <<
"\"LSBF\":\"" << isMacroLSBF <<
"\"\n";
1069 macrofile <<
"}@" << __E__;
1073 __SUP_COUT__ <<
"Unable to open file" << __E__;
1084 void MacroMakerSupervisor::loadMacro(
const std::string& macroName,
1085 std::string& macroString,
1086 const std::string& username )
1088 __SUP_COUTV__(macroName);
1091 std::string fullPath, line;
1093 for(
unsigned int i = 0; i < 2; ++i)
1096 fullPath = (std::string)MACROS_DB_PATH + username +
"/";
1098 fullPath = (std::string)MACROS_DB_PATH +
"publicMacros/";
1100 fullPath += macroName;
1101 if(macroName.find(
".dat") != macroName.size() - 4)
1103 __SUP_COUTV__(fullPath);
1105 std::ifstream read(fullPath.c_str());
1110 getline(read, line);
1111 macroString += line;
1118 __SUP_COUT__ <<
"Unable to open file: " << fullPath << __E__;
1122 if(macroString !=
"")
1126 if(macroString ==
"")
1128 __SUP_SS__ <<
"Unable to locate file for macro '" << macroName
1129 <<
"'... does it exist?" << __E__;
1131 ss <<
" Attempted username was '" << username <<
".'" << __E__;
1135 __SUP_COUTV__(macroString);
1139 void MacroMakerSupervisor::loadMacroNames(
1140 const std::string& username,
1141 std::pair<std::vector<std::string> ,
1142 std::vector<std::string> >& returnMacroNames)
1146 std::string fullPath = (std::string)MACROS_DB_PATH + username +
"/";
1147 if((dir = opendir(fullPath.c_str())) != NULL)
1150 while((ent = readdir(dir)) != NULL)
1153 if((
unsigned)strlen(ent->d_name) > 4)
1157 ((fullPath + (std::string)ent->d_name)).c_str());
1162 returnMacroNames.second.push_back(ent->d_name);
1165 __SUP_COUT__ <<
"Unable to open file" << __E__;
1172 __SUP_COUT__ <<
"Looping through privateMacros folder failed! Wrong directory"
1175 fullPath = (std::string)MACROS_DB_PATH +
"publicMacros/";
1176 if((dir = opendir(fullPath.c_str())) != NULL)
1179 while((ent = readdir(dir)) != NULL)
1182 if((
unsigned)strlen(ent->d_name) > 4)
1186 ((fullPath + (std::string)ent->d_name)).c_str());
1190 returnMacroNames.first.push_back(ent->d_name);
1194 __SUP_COUT__ <<
"Unable to open file" << __E__;
1201 __SUP_COUT__ << fullPath << __E__;
1202 __SUP_COUT__ <<
"Looping through MacroData folder failed! Wrong directory"
1209 void MacroMakerSupervisor::loadMacros(HttpXmlDocument& xmldoc,
1210 const std::string& username)
1214 std::string returnStr =
"";
1215 std::string fullPath = (std::string)MACROS_DB_PATH + username +
"/";
1216 if((dir = opendir(fullPath.c_str())) != NULL)
1219 while((ent = readdir(dir)) != NULL)
1222 if((
unsigned)strlen(ent->d_name) > 4)
1226 ((fullPath + (std::string)ent->d_name)).c_str());
1229 std::stringstream buffer;
1232 getline(read, line);
1236 returnStr += buffer.str();
1241 __SUP_COUT__ <<
"Unable to open file" << __E__;
1244 std::string returnMacroStr = returnStr.substr(0, returnStr.size() - 1);
1246 __SUP_COUT__ <<
"Loading existing macros! " << returnMacroStr << __E__;
1249 xmldoc.addTextElementToData(
"returnMacroStr", returnMacroStr);
1253 __SUP_COUT__ <<
"Looping through privateMacros folder failed! Wrong directory"
1256 fullPath = (std::string)MACROS_DB_PATH +
"publicMacros/";
1258 if((dir = opendir(fullPath.c_str())) != NULL)
1261 while((ent = readdir(dir)) != NULL)
1264 if((
unsigned)strlen(ent->d_name) > 4)
1268 ((fullPath + (std::string)ent->d_name)).c_str());
1271 std::stringstream buffer;
1274 getline(read, line);
1278 returnStr += buffer.str();
1282 __SUP_COUT__ <<
"Unable to open file" << __E__;
1285 std::string returnPublicStr = returnStr.substr(0, returnStr.size() - 1);
1286 __SUP_COUT__ <<
"Loading existing public macros: " << returnPublicStr << __E__;
1288 xmldoc.addTextElementToData(
"returnPublicStr", returnPublicStr);
1292 __SUP_COUT__ << fullPath << __E__;
1293 __SUP_COUT__ <<
"Looping through MacroData folder failed! Wrong directory"
1299 void MacroMakerSupervisor::appendCommandToHistory(std::string Command,
1302 std::string Interfaces,
1303 const std::string& username)
1305 std::string fileName =
"history.hist";
1306 std::string fullPath = (std::string)MACROS_HIST_PATH + username +
"/" + fileName;
1307 __SUP_COUT__ << fullPath << __E__;
1308 std::ofstream histfile(fullPath.c_str(), std::ios::app);
1309 if(histfile.is_open())
1312 histfile <<
"\"Command\":\"" << Command <<
"\",\n";
1313 histfile <<
"\"Format\":\"" << Format <<
"\",\n";
1314 histfile <<
"\"Time\":\"" << Time <<
"\",\n";
1315 histfile <<
"\"Interfaces\":\"" << Interfaces <<
"\"\n";
1316 histfile <<
"}#" << __E__;
1320 __SUP_COUT__ <<
"Unable to open history.hist" << __E__;
1324 void MacroMakerSupervisor::loadHistory(HttpXmlDocument& xmldoc,
1325 const std::string& username)
1327 std::string fileName = MACROS_HIST_PATH + username +
"/" +
"history.hist";
1329 std::ifstream read(fileName.c_str());
1330 __SUP_COUT__ << fileName << __E__;
1336 unsigned long long fileSz, i = 0, MAX_HISTORY_SIZE = 100000;
1340 read.seekg(0, std::ios::end);
1341 fileSz = read.tellg();
1342 returnStr =
new char[fileSz + 1];
1343 returnStr[fileSz] =
'\0';
1344 read.seekg(0, std::ios::beg);
1347 read.read(returnStr, fileSz);
1351 if(fileSz > MAX_HISTORY_SIZE)
1353 i = fileSz - MAX_HISTORY_SIZE;
1354 for(; i < fileSz; ++i)
1355 if(returnStr[i] ==
'#')
1364 FILE* fp = fopen(fileName.c_str(),
"w");
1367 __SS__ <<
"Big problem with macromaker history file: " << fileName
1371 fwrite(&returnStr[i], fileSz - i, 1, fp);
1375 __SUP_COUT__ <<
"Loading user history! " << __E__;
1378 returnStr[fileSz - 2] =
'\0';
1380 xmldoc.addTextElementToData(
"returnHistStr", &returnStr[i]);
1386 __SUP_COUT__ <<
"Unable to open history.hist" << __E__;
1390 void MacroMakerSupervisor::deleteMacro(HttpXmlDocument& xmldoc,
1392 const std::string& username)
1394 std::string MacroName = CgiDataUtilities::getData(cgi,
"MacroName");
1395 std::string isMacroPublic = CgiDataUtilities::getData(cgi,
"isPublic");
1397 std::string fileName = MacroName +
".dat";
1398 std::string fullPath;
1399 if(isMacroPublic ==
"true")
1400 fullPath = (std::string)MACROS_DB_PATH +
"publicMacros/" + fileName;
1402 fullPath = (std::string)MACROS_DB_PATH + username +
"/" + fileName;
1404 __SUP_COUT__ << fullPath << __E__;
1406 std::remove(fullPath.c_str());
1407 __SUP_COUT__ <<
"Successfully deleted " << MacroName;
1408 xmldoc.addTextElementToData(
"deletedMacroName", MacroName);
1412 void MacroMakerSupervisor::editMacro(HttpXmlDocument& xmldoc,
1414 const std::string& username)
1416 std::string oldMacroName = CgiDataUtilities::postData(cgi,
"oldMacroName");
1417 std::string newMacroName = CgiDataUtilities::postData(cgi,
"newMacroName");
1418 std::string Sequence = CgiDataUtilities::postData(cgi,
"Sequence");
1419 std::string Time = CgiDataUtilities::postData(cgi,
"Time");
1421 CgiDataUtilities::decodeURIComponent(CgiDataUtilities::postData(cgi,
"Notes"));
1423 std::string isMacroPublic = CgiDataUtilities::getData(cgi,
"isPublic");
1424 std::string isMacroLSBF = CgiDataUtilities::getData(cgi,
"isLSBF");
1426 __SUP_COUTV__(oldMacroName);
1427 __SUP_COUTV__(newMacroName);
1428 __SUP_COUTV__(Sequence);
1429 __SUP_COUTV__(Notes);
1430 __SUP_COUTV__(Time);
1431 __SUP_COUTV__(isMacroPublic);
1432 __SUP_COUTV__(isMacroLSBF);
1434 __SUP_COUTV__(MACROS_DB_PATH);
1436 std::string fileName = oldMacroName +
".dat";
1437 std::string fullPath;
1438 if(isMacroPublic ==
"true")
1439 fullPath = (std::string)MACROS_DB_PATH +
"publicMacros/" + fileName;
1441 fullPath = (std::string)MACROS_DB_PATH + username +
"/" + fileName;
1443 __SUP_COUTV__(fullPath);
1445 std::ofstream macrofile(fullPath.c_str());
1446 if(macrofile.is_open())
1449 macrofile <<
"\"name\":\"" << newMacroName <<
"\",\n";
1450 macrofile <<
"\"sequence\":\"" << Sequence <<
"\",\n";
1451 macrofile <<
"\"time\":\"" << Time <<
"\",\n";
1452 macrofile <<
"\"notes\":\"" << Notes <<
"\",\n";
1453 macrofile <<
"\"LSBF\":\"" << isMacroLSBF <<
"\"\n";
1454 macrofile <<
"}@" << __E__;
1458 __SUP_COUT__ <<
"Unable to open file" << __E__;
1460 if(oldMacroName != newMacroName)
1464 rename((MACROS_DB_PATH + username +
"/" + oldMacroName +
".dat").c_str(),
1465 (MACROS_DB_PATH + username +
"/" + newMacroName +
".dat").c_str());
1467 xmldoc.addTextElementToData(
"newMacroName", newMacroName);
1469 xmldoc.addTextElementToData(
"newMacroName",
"ERROR");
1474 void MacroMakerSupervisor::clearHistory(
const std::string& username)
1476 std::string fileName =
"history.hist";
1477 std::string fullPath = (std::string)MACROS_HIST_PATH + username +
"/" + fileName;
1479 std::remove(fullPath.c_str());
1480 __SUP_COUT__ <<
"Successfully deleted " << fullPath;
1484 void MacroMakerSupervisor::exportFEMacro(HttpXmlDocument& xmldoc,
1486 const std::string& username)
1488 std::string macroName = CgiDataUtilities::getData(cgi,
"MacroName");
1489 std::string pluginName = CgiDataUtilities::getData(cgi,
"PluginName");
1490 std::string macroSequence = CgiDataUtilities::postData(cgi,
"MacroSequence");
1491 std::string macroNotes = CgiDataUtilities::decodeURIComponent(
1492 CgiDataUtilities::postData(cgi,
"MacroNotes"));
1494 __SUP_COUTV__(pluginName);
1495 __SUP_COUTV__(macroName);
1496 __SUP_COUTV__(macroSequence);
1499 for(
unsigned int i = 0; i < macroNotes.length(); ++i)
1500 if(macroNotes[i] ==
'\r' || macroNotes[i] ==
'\n')
1501 macroNotes[i] =
' ';
1502 __SUP_COUTV__(macroNotes);
1504 std::stringstream ss(macroSequence);
1505 std::string command;
1506 std::vector<std::string> commands;
1508 while(getline(ss, command,
','))
1509 commands.push_back(command);
1511 __SUP_COUTV__(StringMacros::vectorToString(commands));
1513 std::map<std::string , std::set<std::string> >
1514 specialsCodeMap = CodeEditor::getSpecialsMap();
1517 auto specialsCodeMapIt = specialsCodeMap.find(CodeEditor::SPECIAL_TYPE_FEInterface);
1518 if(specialsCodeMapIt == specialsCodeMap.end())
1521 <<
"Could not find any FE Interface plugins in source code. Does MacroMaker "
1522 <<
"have access to the source code? Check that the Supervisor context places "
1524 <<
"location with access to the source code." << __E__;
1529 std::string headerFile = pluginName +
".h";
1530 std::string sourceFile = pluginName +
"_interface.cc";
1531 bool foundHeaderFile =
false;
1532 bool foundSourceFile =
false;
1533 for(
const auto& filePath : specialsCodeMapIt->second)
1535 if(!foundHeaderFile && filePath.find(headerFile) != std::string::npos)
1537 foundHeaderFile =
true;
1538 headerFile = filePath;
1539 __SUP_COUT__ <<
"found headerFile=" << filePath << __E__;
1541 if(!foundSourceFile && filePath.find(sourceFile) != std::string::npos)
1543 foundSourceFile =
true;
1544 sourceFile = filePath;
1545 __SUP_COUT__ <<
"found sourceFile=" << filePath << __E__;
1548 if(foundSourceFile && foundHeaderFile)
1552 if(!foundHeaderFile)
1554 __SS__ <<
"Could not find the header file for the FE Interface plugins at '"
1555 << headerFile <<
".' Does MacroMaker "
1556 <<
"have access to the source code? Check that the Supervisor context "
1557 "places MacroMaker in a "
1558 <<
"location with access to the source code." << __E__;
1561 if(!foundSourceFile)
1563 __SS__ <<
"Could not find the source file for the FE Interface plugins at '"
1564 << sourceFile <<
".' Does MacroMaker "
1565 <<
"have access to the source code? Check that the Supervisor context "
1566 "places MacroMaker in a "
1567 <<
"location with access to the source code." << __E__;
1580 char timeBuffer[100];
1583 struct tm* timeinfo;
1586 timeinfo = localtime(&rawtime);
1588 strftime(timeBuffer, 100,
"%b-%d-%Y %I:%M:%S", timeinfo);
1591 std::string contents;
1596 CodeEditor::readFile(CodeEditor::SOURCE_BASE_PATH, sourceFile, contents);
1600 xmldoc.addTextElementToData(
"sourceFile", sourceFile);
1601 xmldoc.addTextElementToData(
"headerFile", headerFile);
1604 if(contents.find(pluginName +
"::" + macroName) != std::string::npos)
1606 __SS__ <<
"The function definition '" << (pluginName +
"::" + macroName)
1607 <<
"(...)' already exists in the source file '" << sourceFile
1608 <<
".' Duplicate functions are not allowed - please rename the macro or "
1609 "modify the source file."
1614 std::stringstream codess;
1615 std::set<std::string> inArgNames, outArgNames;
1622 __SUP_COUTV__(StringMacros::setToString(inArgNames));
1623 __SUP_COUTV__(StringMacros::setToString(outArgNames));
1627 auto insertPos = contents.find(pluginName +
"::" + pluginName);
1628 if(insertPos == std::string::npos)
1630 __SS__ <<
"Could not find the code insert position in the source file '"
1631 << sourceFile <<
".' The FE plugin class constructor must be '"
1632 << pluginName <<
":" << pluginName <<
"' - is this the case?" << __E__;
1635 __SUP_COUTV__(insertPos);
1637 insertPos = contents.find(
"{", insertPos);
1638 if(insertPos == std::string::npos)
1640 __SS__ <<
"Could not find the code insert position in the source file '"
1642 <<
".' The FE plugin class constructor must begin with '{"
1643 <<
"' - is this the case?" << __E__;
1647 __SUP_COUTV__(insertPos);
1649 insert =
"\n\t//registration of FEMacro '" + macroName +
"' generated, " +
1650 timeBuffer +
", by '" + username +
"' using MacroMaker.\n\t" +
1651 "FEVInterface::registerFEMacroFunction(\"" + macroName +
1652 "\",//feMacroName \n\t\t" +
1653 "static_cast<FEVInterface::frontEndMacroFunction_t>(&" + pluginName +
1654 "::" + macroName +
"), //feMacroFunction \n\t\t" +
1655 "std::vector<std::string>{";
1658 for(
const auto& inArg : inArgNames)
1664 insert +=
"\"" + inArg +
"\"";
1667 insert +=
"}, //namesOfInputArgs \n\t\t";
1668 insert +=
"std::vector<std::string>{";
1671 for(
const auto& outArg : outArgNames)
1677 insert +=
"\"" + outArg +
"\"";
1680 insert +=
"}, //namesOfOutputArgs \n\t\t";
1681 insert +=
"1); //requiredUserPermissions \n\n";
1683 __SUP_COUTV__(insert);
1684 contents = contents.substr(0, insertPos) + insert + contents.substr(insertPos);
1689 auto insertPos = contents.rfind(
"DEFINE_OTS_INTERFACE");
1690 if(insertPos == std::string::npos)
1692 __SS__ <<
"Could not find the code insert position in the source file '"
1694 <<
".' The FE plugin class must end with a 'DEFINE_OTS_INTERFACE("
1695 << pluginName <<
")' - is this the case?" << __E__;
1698 __SUP_COUTV__(insertPos);
1702 "============================================================================"
1703 "============================================\n//" +
1704 macroName +
"\n" +
"//\tFEMacro '" + macroName +
"' generated, " +
1705 timeBuffer +
", by '" + username +
"' using MacroMaker.\n" +
1706 "//\tMacro Notes: " + macroNotes +
"\n" +
"void " + pluginName +
1707 "::" + macroName +
"(__ARGS__)\n{\n\t" +
1708 "__CFG_COUT__ << \"# of input args = \" << argsIn.size() << __E__; \n\t" +
1709 "__CFG_COUT__ << \"# of output args = \" << argsOut.size() << __E__; \n\t" +
1710 "for(auto &argIn:argsIn) \n\t\t" +
1711 "__CFG_COUT__ << argIn.first << \": \" << argIn.second << __E__; \n\n\t" +
1712 "//macro commands section \n" + codess.str() +
"\n\n\t" +
1713 "for(auto &argOut:argsOut) \n\t\t" +
1714 "__CFG_COUT__ << argOut.first << \": \" << argOut.second << __E__; \n\n" +
1715 "} //end " + macroName +
"()\n\n";
1718 CodeEditor::writeFile(CodeEditor::SOURCE_BASE_PATH,
1721 "MacroMaker-" + username,
1728 CodeEditor::readFile(CodeEditor::SOURCE_BASE_PATH, headerFile, contents);
1733 auto insertPos = contents.rfind(
"};");
1734 if(insertPos == std::string::npos)
1736 __SS__ <<
"Could not find the code insert position in the header file '"
1738 <<
".' The FE plugin class must end with a '};' - is this the case?"
1743 __SUP_COUTV__(insertPos);
1745 insert =
"\npublic: // FEMacro '" + macroName +
"' generated, " + timeBuffer +
1746 ", by '" + username +
"' using MacroMaker.\n\t" +
"void " + macroName +
1749 __SUP_COUTV__(insert);
1750 CodeEditor::writeFile(CodeEditor::SOURCE_BASE_PATH,
1753 "MacroMaker-" + username,
1761 void MacroMakerSupervisor::exportMacro(HttpXmlDocument& xmldoc,
1763 const std::string& username)
1765 std::string macroName = CgiDataUtilities::getData(cgi,
"MacroName");
1766 std::string macroSequence = CgiDataUtilities::postData(cgi,
"MacroSequence");
1767 std::string macroNotes = CgiDataUtilities::decodeURIComponent(
1768 CgiDataUtilities::postData(cgi,
"MacroNotes"));
1770 __SUP_COUTV__(macroName);
1771 __SUP_COUTV__(macroSequence);
1774 for(
unsigned int i = 0; i < macroNotes.length(); ++i)
1775 if(macroNotes[i] ==
'\r' || macroNotes[i] ==
'\n')
1776 macroNotes[i] =
' ';
1777 __SUP_COUTV__(macroNotes);
1779 std::stringstream ss(macroSequence);
1780 std::string command;
1781 std::vector<std::string> commands;
1783 while(getline(ss, command,
','))
1784 commands.push_back(command);
1786 std::string fileName = macroName +
".cc";
1788 std::string fullPath = (std::string)MACROS_EXPORT_PATH + username +
"/" + fileName;
1789 __SUP_COUT__ << fullPath << __E__;
1790 std::ofstream exportFile(fullPath.c_str(), std::ios::trunc);
1791 if(exportFile.is_open())
1793 exportFile <<
"//Generated Macro Name:\t" << macroName <<
"\n";
1794 exportFile <<
"//Macro Notes: " << macroNotes <<
"\n";
1798 struct tm* timeinfo;
1802 timeinfo = localtime(&rawtime);
1804 strftime(buffer, 100,
"%b-%d-%Y %I:%M:%S", timeinfo);
1805 exportFile <<
"//Generated Time: \t\t" << buffer <<
"\n";
1808 exportFile <<
"//Paste this whole file into an interface to transfer Macro "
1811 createCode(exportFile, commands);
1815 xmldoc.addTextElementToData(
"ExportFile", fullPath);
1818 __SUP_COUT__ <<
"Unable to open file" << __E__;
1823 void MacroMakerSupervisor::createCode(std::ostream& out,
1824 const std::vector<std::string>& commands,
1825 const std::string& tabOffset,
1827 std::set<std::string>* inArgNames,
1828 std::set<std::string>* outArgNames)
1831 std::set<std::string > argInHasBeenInitializedSet;
1832 bool addressIsVariable, dataIsVariable;
1834 out << tabOffset <<
"{";
1837 << tabOffset <<
"\t"
1838 <<
"char *address \t= new char[universalAddressSize_]{0}; //create address "
1839 "buffer of interface size and init to all 0";
1841 << tabOffset <<
"\t"
1842 <<
"char *data \t\t= new char[universalDataSize_]{0}; //create data buffer "
1843 "of interface size and init to all 0";
1846 << tabOffset <<
"\t"
1847 <<
"uint64_t macroAddress; //create macro address buffer (size 8 bytes)";
1849 << tabOffset <<
"\t"
1850 <<
"uint64_t macroData; //create macro address buffer (size 8 bytes)";
1853 << tabOffset <<
"\t"
1854 <<
"std::map<std::string /*arg name*/,uint64_t /*arg val*/> macroArgs; //create "
1855 "map from arg name to 64-bit number";
1858 for(
unsigned int i = 0; i < commands.size(); i++)
1860 std::stringstream sst(commands[i]);
1862 std::vector<std::string>
1864 while(getline(sst, tokens,
':'))
1865 oneCommand.push_back(tokens);
1866 while(oneCommand.size() < 4)
1867 oneCommand.push_back(
"");
1869 __SUP_COUTV__(StringMacros::vectorToString(oneCommand));
1895 addressIsVariable = isArgumentVariable(oneCommand[2]);
1896 dataIsVariable = isArgumentVariable(oneCommand[3]);
1898 __SUP_COUTV__(addressIsVariable);
1899 __SUP_COUTV__(dataIsVariable);
1901 out <<
"\n\n" << tabOffset <<
"\t// command-#" << i <<
": ";
1903 if(oneCommand[1][0] ==
'w' || oneCommand[1][0] ==
'r')
1905 if(oneCommand[1][0] ==
'w')
1907 else if(oneCommand[1][0] ==
'r')
1910 if(addressIsVariable)
1911 out << oneCommand[2];
1913 out <<
"0x" << oneCommand[2];
1914 out <<
" /*address*/,";
1918 out << oneCommand[3] <<
" /*data*/";
1919 else if(oneCommand[1][0] ==
'w')
1920 out <<
"0x" << oneCommand[3] <<
" /*data*/";
1921 else if(oneCommand[1][0] ==
'r')
1925 else if(oneCommand[1][0] ==
'd')
1927 out <<
"delay(" << oneCommand[2] <<
");\n";
1928 out << tabOffset <<
"\t"
1929 <<
"__CFG_COUT__ << \"Sleeping for... \" << " << oneCommand[2]
1930 <<
" << \" milliseconds \" << __E__;\n";
1931 out << tabOffset <<
"\t"
1932 <<
"usleep(" << oneCommand[2] <<
"*1000 /* microseconds */);\n";
1937 __SS__ <<
"FATAL ERROR: Unknown command '" << oneCommand[1]
1938 <<
"'... command is not w, r or d" << __E__;
1944 if(addressIsVariable)
1946 if(argInHasBeenInitializedSet.find(oneCommand[2]) ==
1947 argInHasBeenInitializedSet.end())
1949 argInHasBeenInitializedSet.emplace(oneCommand[2]);
1954 out << tabOffset <<
"\t"
1955 <<
"macroArgs[\"" << oneCommand[2]
1957 "theXDAQContextConfigTree_.getNode(theConfigurationPath_)."
1960 << tabOffset <<
"\t\t\"" << oneCommand[2]
1961 <<
"\").getValue<uint64_t>();";
1966 inArgNames->emplace(oneCommand[2]);
1969 out << tabOffset <<
"\t"
1970 <<
"macroArgs[\"" << oneCommand[2] <<
"\"] = __GET_ARG_IN__(\""
1971 << oneCommand[2] <<
"\", uint64_t);";
1974 out <<
"\t//get macro address argument";
1976 << tabOffset <<
"\tmemcpy(address,¯oArgs[\"" << oneCommand[2]
1977 <<
"\"],8); //copy macro address argument to buffer";
1981 out << tabOffset <<
"\t"
1982 <<
"macroAddress = 0x" << oneCommand[2]
1983 <<
"; memcpy(address,¯oAddress,8);"
1984 <<
"\t//copy macro address to buffer";
1989 if(oneCommand[1] ==
"w")
1993 if(argInHasBeenInitializedSet.find(oneCommand[3]) ==
1994 argInHasBeenInitializedSet
1997 argInHasBeenInitializedSet.emplace(oneCommand[3]);
2002 inArgNames->emplace(oneCommand[3]);
2006 << tabOffset <<
"\t"
2007 <<
"macroArgs[\"" << oneCommand[3]
2008 <<
"\"] = __GET_ARG_IN__(\"" << oneCommand[3]
2009 <<
"\", uint64_t); //initialize from input arguments";
2015 << tabOffset <<
"\t"
2016 <<
"macroArgs[\"" << oneCommand[3]
2018 "theXDAQContextConfigTree_.getNode(theConfigurationPath_)."
2021 << tabOffset <<
"\t\t\"" << oneCommand[3]
2022 <<
"\").getValue<uint64_t>(); //initialize from "
2023 "configuration tree";
2026 out <<
"\t//get macro data argument";
2028 << tabOffset <<
"\tmemcpy(data,¯oArgs[\"" << oneCommand[3]
2029 <<
"\"],8); //copy macro data argument to buffer";
2034 << tabOffset <<
"\t"
2035 <<
"macroData = 0x" << oneCommand[3] <<
"; memcpy(data,¯oData,8);"
2036 <<
"\t//copy macro data to buffer";
2039 << tabOffset <<
"\t"
2040 <<
"universalWrite(address,data);";
2045 << tabOffset <<
"\t"
2046 <<
"universalRead(address,data);";
2048 std::string outputArgName;
2051 outputArgName = oneCommand[3];
2055 sprintf(str,
"outArg%d", i);
2056 outputArgName = str;
2058 __SUP_COUTV__(outputArgName);
2060 out << tabOffset <<
"\t"
2061 <<
"memcpy(¯oArgs[\"" << outputArgName
2062 <<
"\"],data,8); //copy buffer to argument map";
2067 << tabOffset <<
"\t"
2068 <<
"__SET_ARG_OUT__(\"" << outputArgName <<
"\",macroArgs[\""
2069 << outputArgName <<
"\"]); //update output argument result";
2072 outArgNames->emplace(outputArgName);
2073 argInHasBeenInitializedSet.emplace(
2078 out <<
"\n\n" << tabOffset <<
"\tdelete[] address; //free the memory";
2079 out <<
"\n" << tabOffset <<
"\tdelete[] data; //free the memory";
2080 out <<
"\n" << tabOffset <<
"}";
2082 __SUP_COUT__ <<
"Done with code generation." << __E__;
2088 bool MacroMakerSupervisor::isArgumentVariable(
const std::string& argumentString)
2090 for(
unsigned int i = 0; i < argumentString.length(); ++i)
2093 if(!((argumentString[i] >=
'0' && argumentString[i] <=
'9') ||
2094 (argumentString[i] >=
'a' && argumentString[i] <=
'f') ||
2095 (argumentString[i] >=
'A' && argumentString[i] <=
'F')))
2110 std::string MacroMakerSupervisor::generateHexArray(
const std::string& sourceHexString,
2113 std::stringstream retSs;
2115 std::string srcHexStr = sourceHexString;
2116 __SUP_COUT__ <<
"Translating: \n";
2117 __SUP_COUT__ << srcHexStr << __E__;
2119 if(srcHexStr.size() % 2)
2120 srcHexStr =
"0" + srcHexStr;
2122 numOfBytes = srcHexStr.size() / 2;
2123 retSs <<
"[" << numOfBytes <<
"] = {";
2125 for(
int i = 0; i < numOfBytes * 2; i += 2)
2128 if(!((srcHexStr[i] >=
'0' && srcHexStr[i] <=
'9') ||
2129 (srcHexStr[i] >=
'a' && srcHexStr[i] <=
'f') ||
2130 (srcHexStr[i] >=
'A' && srcHexStr[i] <=
'F')) ||
2131 !((srcHexStr[i + 1] >=
'0' && srcHexStr[i + 1] <=
'9') ||
2132 (srcHexStr[i + 1] >=
'a' && srcHexStr[i + 1] <=
'f') ||
2133 (srcHexStr[i + 1] >=
'A' && srcHexStr[i + 1] <=
'F')))
2141 retSs <<
"0x" << srcHexStr[srcHexStr.size() - 1 - i - 1]
2142 << srcHexStr[srcHexStr.size() - 1 - i];
2146 __SUP_COUT__ << retSs.str() << __E__;
2152 void MacroMakerSupervisor::runFEMacro(HttpXmlDocument& xmldoc,
2154 const std::string& username)
try
2156 __SUP_COUT__ << __E__;
2160 std::string feClassSelected = CgiDataUtilities::getData(cgi,
"feClassSelected");
2161 std::string feUIDSelected = CgiDataUtilities::getData(cgi,
"feUIDSelected");
2162 std::string macroType = CgiDataUtilities::getData(cgi,
"macroType");
2163 std::string macroName = CgiDataUtilities::getData(cgi,
"macroName");
2164 std::string inputArgs = CgiDataUtilities::postData(cgi,
"inputArgs");
2165 std::string outputArgs = CgiDataUtilities::postData(cgi,
"outputArgs");
2166 bool saveOutputs = CgiDataUtilities::getDataAsInt(cgi,
"saveOutputs") == 1;
2169 __SUP_COUTV__(feClassSelected);
2170 __SUP_COUTV__(feUIDSelected);
2171 __SUP_COUTV__(macroType);
2172 __SUP_COUTV__(macroName);
2173 __SUP_COUTV__(inputArgs);
2174 __SUP_COUTV__(outputArgs);
2175 __SUP_COUTV__(saveOutputs);
2177 std::set<std::string > feUIDs;
2179 if(feUIDSelected ==
"")
2180 feUIDSelected =
"*";
2181 if(feClassSelected ==
"")
2182 feClassSelected =
"*";
2184 if(feClassSelected ==
"" || feUIDSelected ==
"" || macroType ==
"" || macroName ==
"")
2186 __SUP_SS__ <<
"Illegal empty front-end parameter." << __E__;
2189 else if(feUIDSelected !=
"*")
2190 feUIDs.emplace(feUIDSelected);
2194 if(feClassSelected ==
"*")
2196 for(
auto& feTypePair : FEPluginTypetoFEsMap_)
2197 for(
auto& feUID : feTypePair.second)
2198 feUIDs.emplace(feUID);
2202 auto typeIt = FEPluginTypetoFEsMap_.find(feClassSelected);
2203 if(typeIt == FEPluginTypetoFEsMap_.end())
2205 __SUP_SS__ <<
"Illegal front-end type parameter '" << feClassSelected
2206 <<
"' not in list of types." << __E__;
2210 for(
auto& feUID : typeIt->second)
2211 feUIDs.emplace(feUID);
2215 __SUP_COUTV__(StringMacros::setToString(feUIDs));
2217 std::string macroString;
2218 if(macroType ==
"public")
2219 loadMacro(macroName, macroString);
2220 else if(macroType ==
"private")
2221 loadMacro(macroName, macroString, username);
2223 __SUP_COUTV__(macroString);
2230 std::string filename =
"/macroOutput_" + std::to_string(time(0)) +
"_" +
2231 std::to_string(clock()) +
".txt";
2233 __SUP_COUTV__(filename);
2234 fp = fopen((CodeEditor::OTSDAQ_DATA_PATH + filename).c_str(),
"w");
2237 __SUP_SS__ <<
"Failed to open file to save macro output '"
2238 << CodeEditor::OTSDAQ_DATA_PATH << filename <<
"'..." << __E__;
2242 fprintf(fp,
"############################\n");
2244 "### Running '%s' at time %s\n",
2246 StringMacros::getTimestampString().c_str());
2248 "### \t Target front-ends (count=%lu): %s\n",
2250 StringMacros::setToString(feUIDs).c_str());
2251 fprintf(fp,
"### \t\t Inputs: %s\n", inputArgs.c_str());
2252 fprintf(fp,
"############################\n\n\n");
2254 xmldoc.addTextElementToData(
"outputArgs_name",
"Filename");
2255 xmldoc.addTextElementToData(
"outputArgs_value",
"$OTSDAQ_DATA/" + filename);
2259 for(
auto& feUID : feUIDs)
2261 auto feIt = FEtoSupervisorMap_.find(feUID);
2262 if(feIt == FEtoSupervisorMap_.end())
2264 __SUP_SS__ <<
"Destination front end interface ID '" << feUID
2265 <<
"' was not found in the list of front ends." << __E__;
2266 ss <<
"\n\nHere is the map:\n\n"
2267 << StringMacros::mapToString(FEtoSupervisorMap_) << __E__;
2271 unsigned int FESupervisorIndex = feIt->second;
2272 __SUP_COUT__ <<
"Found supervisor index: " << FESupervisorIndex << __E__;
2274 SupervisorInfoMap::iterator it = allFESupervisorInfo_.find(FESupervisorIndex);
2275 if(it == allFESupervisorInfo_.end())
2278 <<
"Error transmitting request to FE Supervisor '" << feUID <<
":"
2279 << FESupervisorIndex <<
".' \n\n"
2280 <<
"The FE Supervisor Index does not exist. Have you configured "
2281 "the state machine properly?"
2287 SOAPParameters txParameters;
2288 if(macroType ==
"fe")
2289 txParameters.addParameter(
"Request",
"RunInterfaceMacro");
2291 txParameters.addParameter(
"Request",
"RunMacroMakerMacro");
2292 txParameters.addParameter(
"InterfaceID", feUID);
2293 if(macroType ==
"fe")
2294 txParameters.addParameter(
"feMacroName", macroName);
2297 txParameters.addParameter(
"macroName", macroName);
2298 txParameters.addParameter(
"macroString", macroString);
2300 txParameters.addParameter(
"inputArgs", inputArgs);
2301 txParameters.addParameter(
"outputArgs", outputArgs);
2303 SOAPParameters rxParameters;
2305 rxParameters.addParameter(
"outputArgs");
2306 rxParameters.addParameter(
"Error");
2311 "Running '%s' at time %s\n",
2313 StringMacros::getTimestampString().c_str());
2315 "\t Target front-end: '%s::%s'\n",
2316 FEtoPluginTypeMap_[feUID].c_str(),
2318 fprintf(fp,
"\t\t Inputs: %s\n", inputArgs.c_str());
2322 xoap::MessageReference retMsg = SOAPMessenger::sendWithSOAPReply(
2323 it->second.getDescriptor(),
2324 "MacroMakerSupervisorRequest",
2327 __SUP_COUT__ <<
"Received response message: "
2328 << SOAPUtilities::translate(retMsg) << __E__;
2330 SOAPUtilities::receive(retMsg, rxParameters);
2332 __SUP_COUT__ <<
"Received it " << __E__;
2335 std::string outputResults = rxParameters.getValue(
"outputArgs");
2336 std::string error = rxParameters.getValue(
"Error");
2339 __SUP_COUT__ <<
"outputArgs = " << outputResults << __E__;
2343 __SS__ <<
"Attempted FE Macro Failed. Attempted target "
2344 <<
"was UID=" << feUID
2345 <<
" at feSupervisorID=" << FESupervisorIndex <<
"." << __E__;
2346 ss <<
"\n\n The error was:\n\n" << error << __E__;
2347 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2348 xmldoc.addTextElementToData(
"Error", ss.str());
2356 std::istringstream inputStream(outputResults);
2357 std::string splitVal, argName, argValue;
2358 while(getline(inputStream, splitVal,
';'))
2360 std::istringstream pairInputStream(splitVal);
2361 getline(pairInputStream, argName,
',');
2362 getline(pairInputStream, argValue,
',');
2367 "\t\t Output '%s' = %s\n",
2373 xmldoc.addTextElementToData(
"outputArgs_name", argName);
2374 xmldoc.addTextElementToData(
"outputArgs_value", argValue);
2376 __SUP_COUT__ << argName <<
": " << argValue << __E__;
2392 catch(
const std::runtime_error& e)
2394 __SUP_SS__ <<
"Error processing FE communication request: " << e.what() << __E__;
2395 __SUP_COUT_ERR__ << ss.str();
2396 xmldoc.addTextElementToData(
"Error", ss.str());
2400 __SUP_SS__ <<
"Unknown error processing FE communication request." << __E__;
2401 __SUP_COUT_ERR__ << ss.str();
2403 xmldoc.addTextElementToData(
"Error", ss.str());
2407 void MacroMakerSupervisor::getFEMacroList(HttpXmlDocument& xmldoc,
2408 const std::string& username)
2410 __SUP_COUT__ <<
"Getting FE Macro list" << __E__;
2412 SOAPParameters txParameters;
2413 txParameters.addParameter(
"Request",
"GetInterfaceMacros");
2415 SOAPParameters rxParameters;
2416 rxParameters.addParameter(
"FEMacros");
2418 std::string oneInterface;
2419 std::string rxFEMacros;
2423 for(
auto& appInfo : allFESupervisorInfo_)
2425 __SUP_COUT__ <<
"FESupervisor LID = " << appInfo.second.getId()
2426 <<
" name = " << appInfo.second.getName() << __E__;
2428 xoap::MessageReference retMsg = SOAPMessenger::sendWithSOAPReply(
2429 appInfo.second.getDescriptor(),
"MacroMakerSupervisorRequest", txParameters);
2430 SOAPUtilities::receive(retMsg, rxParameters);
2432 rxFEMacros = rxParameters.getValue(
"FEMacros");
2434 __SUP_COUT__ <<
"FE Macros received: \n" << rxFEMacros << __E__;
2436 std::istringstream allInterfaces(rxFEMacros);
2437 while(std::getline(allInterfaces, oneInterface))
2441 xmldoc.addTextElementToData(
"FEMacros", oneInterface);
2447 std::pair<std::vector<std::string> ,
2448 std::vector<std::string> >
2450 loadMacroNames(username, macroNames);
2452 __SUP_COUT__ <<
"Public macro count: " << macroNames.first.size() << __E__;
2453 __SUP_COUT__ <<
"Private macro count: " << macroNames.second.size() << __E__;
2455 std::string macroString;
2464 for(
int i = 0; i < 2; ++i)
2465 for(
auto& macroName : (i ? macroNames.second : macroNames.first))
2468 loadMacro(macroName, macroString, username);
2471 FEVInterface::macroStruct_t macro(macroString);
2473 std::stringstream xmlMacroStream;
2474 xmlMacroStream << macro.macroName_;
2475 xmlMacroStream <<
":"
2477 xmlMacroStream <<
":" << macro.namesOfInputArguments_.size();
2478 for(
auto& inputArg : macro.namesOfInputArguments_)
2479 xmlMacroStream <<
":" << inputArg;
2480 xmlMacroStream <<
":" << macro.namesOfOutputArguments_.size();
2481 for(
auto& inputArg : macro.namesOfOutputArguments_)
2482 xmlMacroStream <<
":" << inputArg;
2484 xmldoc.addTextElementToData(i ?
"PrivateMacro" :
"PublicMacro",
2485 xmlMacroStream.str());