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(
746 SupervisorInfoMap::const_iterator it;
747 std::string oneInterface;
748 std::string rxFEList;
749 std::string rxFrontEndError;
751 size_t lastColonIndex;
755 for(
auto& appInfo : allFESupervisorInfo_)
763 __SUP_COUT__ <<
"FESupervisor LID = " << appInfo.second.getId()
764 <<
" name = " << appInfo.second.getName() << __E__;
768 xoap::MessageReference retMsg =
769 SOAPMessenger::sendWithSOAPReply(appInfo.second.getDescriptor(),
770 "MacroMakerSupervisorRequest",
772 SOAPUtilities::receive(retMsg, rxParameters);
774 catch(
const xdaq::exception::Exception& e)
776 __SUP_SS__ <<
"Error transmitting request to FE Supervisor LID = "
777 << appInfo.second.getId() <<
" name = " << appInfo.second.getName()
779 << e.what() << __E__;
783 rxFEList = rxParameters.getValue(
"FEList");
784 rxFrontEndError = rxParameters.getValue(
"frontEndError");
786 __SUP_COUT__ <<
"FE List received: \n" << rxFEList << __E__;
788 if(rxFrontEndError !=
"")
790 __SUP_SS__ <<
"FE Errors received: \n" << rxFrontEndError << __E__;
794 std::istringstream allInterfaces(rxFEList);
795 while(std::getline(allInterfaces, oneInterface))
797 __SUP_COUTV__(oneInterface);
798 xmldoc.addTextElementToData(
"FE", oneInterface);
800 lastColonIndex = oneInterface.rfind(
':');
801 if(lastColonIndex == std::string::npos)
803 __SUP_SS__ <<
"Last colon could not be found in " << oneInterface
807 oneInterface = oneInterface.substr(lastColonIndex);
809 __SUP_COUTV__(oneInterface);
817 void MacroMakerSupervisor::writeData(HttpXmlDocument& xmldoc,
819 const std::string& username)
821 __SUP_COUT__ <<
"MacroMaker writing..." << __E__;
823 std::string Address = CgiDataUtilities::getData(cgi,
"Address");
824 std::string Data = CgiDataUtilities::getData(cgi,
"Data");
825 std::string interfaceIndexArray = CgiDataUtilities::getData(cgi,
"interfaceIndex");
826 std::string supervisorIndexArray = CgiDataUtilities::getData(cgi,
"supervisorIndex");
828 CgiDataUtilities::decodeURIComponent(CgiDataUtilities::getData(cgi,
"time"));
829 std::string addressFormatStr = CgiDataUtilities::getData(cgi,
"addressFormatStr");
830 std::string dataFormatStr = CgiDataUtilities::getData(cgi,
"dataFormatStr");
832 std::string interfaces = CgiDataUtilities::postData(cgi,
"interfaces");
834 __SUP_COUT__ <<
"Write Address: " << Address <<
" Data: " << Data << __E__;
835 __SUP_COUTV__(interfaces);
837 std::string command =
"w:" + Address +
":" + Data;
838 std::string format = addressFormatStr +
":" + dataFormatStr;
839 appendCommandToHistory(command, format, time, interfaces, username);
841 SOAPParameters txParameters;
842 txParameters.addParameter(
"Request",
"UniversalWrite");
843 txParameters.addParameter(
"Address", Address);
844 txParameters.addParameter(
"Data", Data);
846 __SUP_COUT__ <<
"Here comes the array from multiselect box for WRITE, behold: \n"
847 << supervisorIndexArray <<
"\n"
848 << interfaceIndexArray << __E__;
852 std::vector<std::string> interfaceIndices;
853 std::istringstream f(interfaceIndexArray);
855 while(getline(f, s,
','))
856 interfaceIndices.push_back(s);
857 std::vector<int> supervisorIndices;
858 std::istringstream g(supervisorIndexArray);
860 while(getline(g, t,
','))
861 supervisorIndices.push_back(std::stoi(t));
863 for(
unsigned int i = 0; i < supervisorIndices.size(); i++)
865 unsigned int FESupervisorIndex = supervisorIndices[i];
866 std::string interfaceIndex = interfaceIndices[i];
868 txParameters.addParameter(
"InterfaceID", interfaceIndex);
870 __SUP_COUT__ <<
"The index of the supervisor instance is: " << FESupervisorIndex
872 __SUP_COUT__ <<
"...and the interface ID is: " << interfaceIndex << __E__;
874 SupervisorInfoMap::iterator it = allFESupervisorInfo_.find(FESupervisorIndex);
875 if(it == allFESupervisorInfo_.end())
877 __SUP_SS__ <<
"Error transmitting request to FE Supervisor '"
878 << interfaceIndex <<
":" << FESupervisorIndex <<
".' \n\n"
879 <<
"The FE Index doesn't exist. Have you configured the state "
887 xoap::MessageReference replyMessage = SOAPMessenger::sendWithSOAPReply(
888 it->second.getDescriptor(),
"MacroMakerSupervisorRequest", txParameters);
890 __SUP_COUT__ <<
"Response received: "
891 << SOAPUtilities::translate(replyMessage) << __E__;
893 SOAPParameters rxParameters;
894 rxParameters.addParameter(
"Error");
895 SOAPUtilities::receive(replyMessage, rxParameters);
897 std::string error = rxParameters.getValue(
"Error");
898 __SUP_COUTV__(error);
903 __SUP_SS__ <<
"Error transmitting request to FE Supervisor '"
904 << interfaceIndex <<
":" << FESupervisorIndex <<
".' "
905 <<
"Have you configured the state machine properly?\n\n"
910 catch(
const xdaq::exception::Exception& e)
912 __SUP_SS__ <<
"Error transmitting request to FE Supervisor '"
913 << interfaceIndex <<
":" << FESupervisorIndex <<
".' "
914 <<
"Have you configured the state machine properly?\n\n"
915 << e.what() << __E__;
923 void MacroMakerSupervisor::readData(HttpXmlDocument& xmldoc,
925 const std::string& username)
927 __SUP_COUT__ <<
"@@@@@@@ MacroMaker wants to read data @@@@@@@@" << __E__;
928 std::string Address = CgiDataUtilities::getData(cgi,
"Address");
929 std::string interfaceIndexArray = CgiDataUtilities::getData(cgi,
"interfaceIndex");
930 std::string supervisorIndexArray = CgiDataUtilities::getData(cgi,
"supervisorIndex");
932 CgiDataUtilities::decodeURIComponent(CgiDataUtilities::getData(cgi,
"time"));
933 std::string addressFormatStr = CgiDataUtilities::getData(cgi,
"addressFormatStr");
934 std::string dataFormatStr = CgiDataUtilities::getData(cgi,
"dataFormatStr");
936 std::string interfaces = CgiDataUtilities::postData(cgi,
"interfaces");
938 __SUP_COUT__ <<
"Read Address: " << Address << __E__;
939 __SUP_COUTV__(interfaces);
941 SOAPParameters txParameters;
942 txParameters.addParameter(
"Request",
"UniversalRead");
943 txParameters.addParameter(
"Address", Address);
945 SOAPParameters rxParameters;
946 rxParameters.addParameter(
"dataResult");
947 rxParameters.addParameter(
"Error");
948 __SUP_COUT__ <<
"Here comes the array from multiselect box for READ, behold: "
949 << supervisorIndexArray <<
"," << interfaceIndexArray << __E__;
953 std::vector<std::string> interfaceIndices;
954 std::istringstream f(interfaceIndexArray);
956 while(getline(f, s,
','))
957 interfaceIndices.push_back(s);
958 std::vector<int> supervisorIndices;
959 std::istringstream g(supervisorIndexArray);
961 while(getline(g, t,
','))
962 supervisorIndices.push_back(std::stoi(t));
964 for(
unsigned int i = 0; i < supervisorIndices.size(); i++)
966 unsigned int FESupervisorIndex = supervisorIndices[i];
967 std::string interfaceIndex = interfaceIndices[i];
969 txParameters.addParameter(
"InterfaceID", interfaceIndex);
971 __SUP_COUT__ <<
"The index of the supervisor instance is: " << FESupervisorIndex
973 __SUP_COUT__ <<
"...and the interface ID is: " << interfaceIndex << __E__;
975 SupervisorInfoMap::iterator it = allFESupervisorInfo_.find(FESupervisorIndex);
976 if(it == allFESupervisorInfo_.end())
978 __SUP_SS__ <<
"Error transmitting request to FE Supervisor '"
979 << interfaceIndex <<
":" << FESupervisorIndex <<
".' \n\n"
980 <<
"The FE Index doesn't exist. Have you configured the state "
988 xoap::MessageReference retMsg = SOAPMessenger::sendWithSOAPReply(
989 it->second.getDescriptor(),
"MacroMakerSupervisorRequest", txParameters);
991 __SUP_COUT__ <<
"Response received: " << SOAPUtilities::translate(retMsg)
996 SOAPUtilities::receive(retMsg, rxParameters);
998 std::string error = rxParameters.getValue(
"Error");
999 __SUP_COUTV__(error);
1004 __SUP_SS__ <<
"Error transmitting request to FE Supervisor '"
1005 << interfaceIndex <<
":" << FESupervisorIndex <<
".' "
1006 <<
"Have you configured the state machine properly?\n\n"
1011 catch(
const xdaq::exception::Exception& e)
1013 __SUP_SS__ <<
"Error transmitting request to FE Supervisor '"
1014 << interfaceIndex <<
":" << FESupervisorIndex <<
".' "
1015 <<
"Have you configured the state machine properly?\n\n"
1016 << e.what() << __E__;
1020 std::string dataReadResult = rxParameters.getValue(
"dataResult");
1021 __SUP_COUT__ <<
"Data reading result received: " << dataReadResult << __E__;
1022 xmldoc.addTextElementToData(
"readData", dataReadResult);
1023 std::string command =
"r:" + Address +
":" + dataReadResult;
1024 std::string format = addressFormatStr +
":" + dataFormatStr;
1025 appendCommandToHistory(command, format, time, interfaces, username);
1030 void MacroMakerSupervisor::createMacro(HttpXmlDocument& xmldoc,
1032 const std::string& username)
1034 __SUP_COUT__ <<
"MacroMaker wants to create a macro!!!!!!!!!" << __E__;
1035 std::string Name = CgiDataUtilities::postData(cgi,
"Name");
1036 std::string Sequence = CgiDataUtilities::postData(cgi,
"Sequence");
1037 std::string Time = CgiDataUtilities::postData(cgi,
"Time");
1039 CgiDataUtilities::decodeURIComponent(CgiDataUtilities::postData(cgi,
"Notes"));
1040 std::string isMacroPublic = CgiDataUtilities::getData(cgi,
"isPublic");
1041 std::string isMacroLSBF = CgiDataUtilities::getData(cgi,
"isLSBF");
1043 __SUP_COUTV__(Name);
1044 __SUP_COUTV__(Sequence);
1045 __SUP_COUTV__(Notes);
1046 __SUP_COUTV__(Time);
1047 __SUP_COUTV__(isMacroPublic);
1048 __SUP_COUTV__(isMacroLSBF);
1050 __SUP_COUTV__(MACROS_DB_PATH);
1052 std::string fileName = Name +
".dat";
1053 std::string fullPath;
1054 if(isMacroPublic ==
"true")
1055 fullPath = (std::string)MACROS_DB_PATH +
"publicMacros/" + fileName;
1057 fullPath = (std::string)MACROS_DB_PATH + username +
"/" + fileName;
1059 __SUP_COUTV__(fullPath);
1061 std::ofstream macrofile(fullPath.c_str());
1062 if(macrofile.is_open())
1065 macrofile <<
"\"name\":\"" << Name <<
"\",\n";
1066 macrofile <<
"\"sequence\":\"" << Sequence <<
"\",\n";
1067 macrofile <<
"\"time\":\"" << Time <<
"\",\n";
1068 macrofile <<
"\"notes\":\"" << Notes <<
"\",\n";
1069 macrofile <<
"\"LSBF\":\"" << isMacroLSBF <<
"\"\n";
1070 macrofile <<
"}@" << __E__;
1074 __SUP_COUT__ <<
"Unable to open file" << __E__;
1085 void MacroMakerSupervisor::loadMacro(
const std::string& macroName,
1086 std::string& macroString,
1087 const std::string& username )
1089 __SUP_COUTV__(macroName);
1092 std::string fullPath, line;
1094 for(
unsigned int i = 0; i < 2; ++i)
1097 fullPath = (std::string)MACROS_DB_PATH + username +
"/";
1099 fullPath = (std::string)MACROS_DB_PATH +
"publicMacros/";
1101 fullPath += macroName;
1102 if(macroName.find(
".dat") != macroName.size() - 4)
1104 __SUP_COUTV__(fullPath);
1106 std::ifstream read(fullPath.c_str());
1111 getline(read, line);
1112 macroString += line;
1119 __SUP_COUT__ <<
"Unable to open file: " << fullPath << __E__;
1123 if(macroString !=
"")
1127 if(macroString ==
"")
1129 __SUP_SS__ <<
"Unable to locate file for macro '" << macroName
1130 <<
"'... does it exist?" << __E__;
1132 ss <<
" Attempted username was '" << username <<
".'" << __E__;
1136 __SUP_COUTV__(macroString);
1140 void MacroMakerSupervisor::loadMacroNames(
1141 const std::string& username,
1142 std::pair<std::vector<std::string> ,
1143 std::vector<std::string> >& returnMacroNames)
1147 std::string fullPath = (std::string)MACROS_DB_PATH + username +
"/";
1148 if((dir = opendir(fullPath.c_str())) != NULL)
1151 while((ent = readdir(dir)) != NULL)
1154 if((
unsigned)strlen(ent->d_name) > 4)
1158 ((fullPath + (std::string)ent->d_name)).c_str());
1163 returnMacroNames.second.push_back(ent->d_name);
1166 __SUP_COUT__ <<
"Unable to open file" << __E__;
1173 __SUP_COUT__ <<
"Looping through privateMacros folder failed! Wrong directory"
1176 fullPath = (std::string)MACROS_DB_PATH +
"publicMacros/";
1177 if((dir = opendir(fullPath.c_str())) != NULL)
1180 while((ent = readdir(dir)) != NULL)
1183 if((
unsigned)strlen(ent->d_name) > 4)
1187 ((fullPath + (std::string)ent->d_name)).c_str());
1191 returnMacroNames.first.push_back(ent->d_name);
1195 __SUP_COUT__ <<
"Unable to open file" << __E__;
1202 __SUP_COUT__ << fullPath << __E__;
1203 __SUP_COUT__ <<
"Looping through MacroData folder failed! Wrong directory"
1210 void MacroMakerSupervisor::loadMacros(HttpXmlDocument& xmldoc,
1211 const std::string& username)
1215 std::string returnStr =
"";
1216 std::string fullPath = (std::string)MACROS_DB_PATH + username +
"/";
1217 if((dir = opendir(fullPath.c_str())) != NULL)
1220 while((ent = readdir(dir)) != NULL)
1223 if((
unsigned)strlen(ent->d_name) > 4)
1227 ((fullPath + (std::string)ent->d_name)).c_str());
1230 std::stringstream buffer;
1233 getline(read, line);
1237 returnStr += buffer.str();
1242 __SUP_COUT__ <<
"Unable to open file" << __E__;
1245 std::string returnMacroStr = returnStr.substr(0, returnStr.size() - 1);
1247 __SUP_COUT__ <<
"Loading existing macros! " << returnMacroStr << __E__;
1250 xmldoc.addTextElementToData(
"returnMacroStr", returnMacroStr);
1254 __SUP_COUT__ <<
"Looping through privateMacros folder failed! Wrong directory"
1257 fullPath = (std::string)MACROS_DB_PATH +
"publicMacros/";
1259 if((dir = opendir(fullPath.c_str())) != NULL)
1262 while((ent = readdir(dir)) != NULL)
1265 if((
unsigned)strlen(ent->d_name) > 4)
1269 ((fullPath + (std::string)ent->d_name)).c_str());
1272 std::stringstream buffer;
1275 getline(read, line);
1279 returnStr += buffer.str();
1283 __SUP_COUT__ <<
"Unable to open file" << __E__;
1286 std::string returnPublicStr = returnStr.substr(0, returnStr.size() - 1);
1287 __SUP_COUT__ <<
"Loading existing public macros: " << returnPublicStr << __E__;
1289 xmldoc.addTextElementToData(
"returnPublicStr", returnPublicStr);
1293 __SUP_COUT__ << fullPath << __E__;
1294 __SUP_COUT__ <<
"Looping through MacroData folder failed! Wrong directory"
1300 void MacroMakerSupervisor::appendCommandToHistory(std::string Command,
1303 std::string Interfaces,
1304 const std::string& username)
1306 std::string fileName =
"history.hist";
1307 std::string fullPath = (std::string)MACROS_HIST_PATH + username +
"/" + fileName;
1308 __SUP_COUT__ << fullPath << __E__;
1309 std::ofstream histfile(fullPath.c_str(), std::ios::app);
1310 if(histfile.is_open())
1313 histfile <<
"\"Command\":\"" << Command <<
"\",\n";
1314 histfile <<
"\"Format\":\"" << Format <<
"\",\n";
1315 histfile <<
"\"Time\":\"" << Time <<
"\",\n";
1316 histfile <<
"\"Interfaces\":\"" << Interfaces <<
"\"\n";
1317 histfile <<
"}#" << __E__;
1321 __SUP_COUT__ <<
"Unable to open history.hist" << __E__;
1325 void MacroMakerSupervisor::loadHistory(HttpXmlDocument& xmldoc,
1326 const std::string& username)
1328 std::string fileName = MACROS_HIST_PATH + username +
"/" +
"history.hist";
1330 std::ifstream read(fileName.c_str());
1331 __SUP_COUT__ << fileName << __E__;
1337 unsigned long long fileSz, i = 0, MAX_HISTORY_SIZE = 100000;
1341 read.seekg(0, std::ios::end);
1342 fileSz = read.tellg();
1343 returnStr =
new char[fileSz + 1];
1344 returnStr[fileSz] =
'\0';
1345 read.seekg(0, std::ios::beg);
1348 read.read(returnStr, fileSz);
1352 if(fileSz > MAX_HISTORY_SIZE)
1354 i = fileSz - MAX_HISTORY_SIZE;
1355 for(; i < fileSz; ++i)
1356 if(returnStr[i] ==
'#')
1365 FILE* fp = fopen(fileName.c_str(),
"w");
1368 __SS__ <<
"Big problem with macromaker history file: " << fileName
1372 fwrite(&returnStr[i], fileSz - i, 1, fp);
1376 __SUP_COUT__ <<
"Loading user history! " << __E__;
1379 returnStr[fileSz - 2] =
'\0';
1381 xmldoc.addTextElementToData(
"returnHistStr", &returnStr[i]);
1387 __SUP_COUT__ <<
"Unable to open history.hist" << __E__;
1391 void MacroMakerSupervisor::deleteMacro(HttpXmlDocument& xmldoc,
1393 const std::string& username)
1395 std::string MacroName = CgiDataUtilities::getData(cgi,
"MacroName");
1396 std::string isMacroPublic = CgiDataUtilities::getData(cgi,
"isPublic");
1398 std::string fileName = MacroName +
".dat";
1399 std::string fullPath;
1400 if(isMacroPublic ==
"true")
1401 fullPath = (std::string)MACROS_DB_PATH +
"publicMacros/" + fileName;
1403 fullPath = (std::string)MACROS_DB_PATH + username +
"/" + fileName;
1405 __SUP_COUT__ << fullPath << __E__;
1407 std::remove(fullPath.c_str());
1408 __SUP_COUT__ <<
"Successfully deleted " << MacroName;
1409 xmldoc.addTextElementToData(
"deletedMacroName", MacroName);
1413 void MacroMakerSupervisor::editMacro(HttpXmlDocument& xmldoc,
1415 const std::string& username)
1417 std::string oldMacroName = CgiDataUtilities::postData(cgi,
"oldMacroName");
1418 std::string newMacroName = CgiDataUtilities::postData(cgi,
"newMacroName");
1419 std::string Sequence = CgiDataUtilities::postData(cgi,
"Sequence");
1420 std::string Time = CgiDataUtilities::postData(cgi,
"Time");
1422 CgiDataUtilities::decodeURIComponent(CgiDataUtilities::postData(cgi,
"Notes"));
1424 std::string isMacroPublic = CgiDataUtilities::getData(cgi,
"isPublic");
1425 std::string isMacroLSBF = CgiDataUtilities::getData(cgi,
"isLSBF");
1427 __SUP_COUTV__(oldMacroName);
1428 __SUP_COUTV__(newMacroName);
1429 __SUP_COUTV__(Sequence);
1430 __SUP_COUTV__(Notes);
1431 __SUP_COUTV__(Time);
1432 __SUP_COUTV__(isMacroPublic);
1433 __SUP_COUTV__(isMacroLSBF);
1435 __SUP_COUTV__(MACROS_DB_PATH);
1437 std::string fileName = oldMacroName +
".dat";
1438 std::string fullPath;
1439 if(isMacroPublic ==
"true")
1440 fullPath = (std::string)MACROS_DB_PATH +
"publicMacros/" + fileName;
1442 fullPath = (std::string)MACROS_DB_PATH + username +
"/" + fileName;
1444 __SUP_COUTV__(fullPath);
1446 std::ofstream macrofile(fullPath.c_str());
1447 if(macrofile.is_open())
1450 macrofile <<
"\"name\":\"" << newMacroName <<
"\",\n";
1451 macrofile <<
"\"sequence\":\"" << Sequence <<
"\",\n";
1452 macrofile <<
"\"time\":\"" << Time <<
"\",\n";
1453 macrofile <<
"\"notes\":\"" << Notes <<
"\",\n";
1454 macrofile <<
"\"LSBF\":\"" << isMacroLSBF <<
"\"\n";
1455 macrofile <<
"}@" << __E__;
1459 __SUP_COUT__ <<
"Unable to open file" << __E__;
1461 if(oldMacroName != newMacroName)
1465 rename((MACROS_DB_PATH + username +
"/" + oldMacroName +
".dat").c_str(),
1466 (MACROS_DB_PATH + username +
"/" + newMacroName +
".dat").c_str());
1468 xmldoc.addTextElementToData(
"newMacroName", newMacroName);
1470 xmldoc.addTextElementToData(
"newMacroName",
"ERROR");
1475 void MacroMakerSupervisor::clearHistory(
const std::string& username)
1477 std::string fileName =
"history.hist";
1478 std::string fullPath = (std::string)MACROS_HIST_PATH + username +
"/" + fileName;
1480 std::remove(fullPath.c_str());
1481 __SUP_COUT__ <<
"Successfully deleted " << fullPath;
1485 void MacroMakerSupervisor::exportFEMacro(HttpXmlDocument& xmldoc,
1487 const std::string& username)
1489 std::string macroName = CgiDataUtilities::getData(cgi,
"MacroName");
1490 std::string pluginName = CgiDataUtilities::getData(cgi,
"PluginName");
1491 std::string macroSequence = CgiDataUtilities::postData(cgi,
"MacroSequence");
1492 std::string macroNotes = CgiDataUtilities::decodeURIComponent(
1493 CgiDataUtilities::postData(cgi,
"MacroNotes"));
1495 __SUP_COUTV__(pluginName);
1496 __SUP_COUTV__(macroName);
1497 __SUP_COUTV__(macroSequence);
1500 for(
unsigned int i = 0; i < macroNotes.length(); ++i)
1501 if(macroNotes[i] ==
'\r' || macroNotes[i] ==
'\n')
1502 macroNotes[i] =
' ';
1503 __SUP_COUTV__(macroNotes);
1505 std::stringstream ss(macroSequence);
1506 std::string command;
1507 std::vector<std::string> commands;
1509 while(getline(ss, command,
','))
1510 commands.push_back(command);
1512 __SUP_COUTV__(StringMacros::vectorToString(commands));
1514 std::map<std::string , std::set<std::string> >
1515 specialsCodeMap = CodeEditor::getSpecialsMap();
1518 auto specialsCodeMapIt = specialsCodeMap.find(CodeEditor::SPECIAL_TYPE_FEInterface);
1519 if(specialsCodeMapIt == specialsCodeMap.end())
1522 <<
"Could not find any FE Interface plugins in source code. Does MacroMaker "
1523 <<
"have access to the source code? Check that the Supervisor context places "
1525 <<
"location with access to the source code." << __E__;
1530 std::string headerFile = pluginName +
".h";
1531 std::string sourceFile = pluginName +
"_interface.cc";
1532 bool foundHeaderFile =
false;
1533 bool foundSourceFile =
false;
1534 for(
const auto& filePath : specialsCodeMapIt->second)
1536 if(!foundHeaderFile && filePath.find(headerFile) != std::string::npos)
1538 foundHeaderFile =
true;
1539 headerFile = filePath;
1540 __SUP_COUT__ <<
"found headerFile=" << filePath << __E__;
1542 if(!foundSourceFile && filePath.find(sourceFile) != std::string::npos)
1544 foundSourceFile =
true;
1545 sourceFile = filePath;
1546 __SUP_COUT__ <<
"found sourceFile=" << filePath << __E__;
1549 if(foundSourceFile && foundHeaderFile)
1553 if(!foundHeaderFile)
1555 __SS__ <<
"Could not find the header file for the FE Interface plugins at '"
1556 << headerFile <<
".' Does MacroMaker "
1557 <<
"have access to the source code? Check that the Supervisor context "
1558 "places MacroMaker in a "
1559 <<
"location with access to the source code." << __E__;
1562 if(!foundSourceFile)
1564 __SS__ <<
"Could not find the source file for the FE Interface plugins at '"
1565 << sourceFile <<
".' Does MacroMaker "
1566 <<
"have access to the source code? Check that the Supervisor context "
1567 "places MacroMaker in a "
1568 <<
"location with access to the source code." << __E__;
1581 char timeBuffer[100];
1584 struct tm* timeinfo;
1587 timeinfo = localtime(&rawtime);
1589 strftime(timeBuffer, 100,
"%b-%d-%Y %I:%M:%S", timeinfo);
1592 std::string contents;
1597 CodeEditor::readFile(CodeEditor::SOURCE_BASE_PATH, sourceFile, contents);
1601 xmldoc.addTextElementToData(
"sourceFile", sourceFile);
1602 xmldoc.addTextElementToData(
"headerFile", headerFile);
1605 if(contents.find(pluginName +
"::" + macroName) != std::string::npos)
1607 __SS__ <<
"The function definition '" << (pluginName +
"::" + macroName)
1608 <<
"(...)' already exists in the source file '" << sourceFile
1609 <<
".' Duplicate functions are not allowed - please rename the macro or "
1610 "modify the source file."
1615 std::stringstream codess;
1616 std::set<std::string> inArgNames, outArgNames;
1623 __SUP_COUTV__(StringMacros::setToString(inArgNames));
1624 __SUP_COUTV__(StringMacros::setToString(outArgNames));
1628 auto insertPos = contents.find(pluginName +
"::" + pluginName);
1629 if(insertPos == std::string::npos)
1631 __SS__ <<
"Could not find the code insert position in the source file '"
1632 << sourceFile <<
".' The FE plugin class constructor must be '"
1633 << pluginName <<
":" << pluginName <<
"' - is this the case?" << __E__;
1636 __SUP_COUTV__(insertPos);
1638 insertPos = contents.find(
"{", insertPos);
1639 if(insertPos == std::string::npos)
1641 __SS__ <<
"Could not find the code insert position in the source file '"
1643 <<
".' The FE plugin class constructor must begin with '{"
1644 <<
"' - is this the case?" << __E__;
1648 __SUP_COUTV__(insertPos);
1650 insert =
"\n\t//registration of FEMacro '" + macroName +
"' generated, " +
1651 timeBuffer +
", by '" + username +
"' using MacroMaker.\n\t" +
1652 "FEVInterface::registerFEMacroFunction(\"" + macroName +
1653 "\",//feMacroName \n\t\t" +
1654 "static_cast<FEVInterface::frontEndMacroFunction_t>(&" + pluginName +
1655 "::" + macroName +
"), //feMacroFunction \n\t\t" +
1656 "std::vector<std::string>{";
1659 for(
const auto& inArg : inArgNames)
1665 insert +=
"\"" + inArg +
"\"";
1668 insert +=
"}, //namesOfInputArgs \n\t\t";
1669 insert +=
"std::vector<std::string>{";
1672 for(
const auto& outArg : outArgNames)
1678 insert +=
"\"" + outArg +
"\"";
1681 insert +=
"}, //namesOfOutputArgs \n\t\t";
1682 insert +=
"1); //requiredUserPermissions \n\n";
1684 __SUP_COUTV__(insert);
1685 contents = contents.substr(0, insertPos) + insert + contents.substr(insertPos);
1690 auto insertPos = contents.rfind(
"DEFINE_OTS_INTERFACE");
1691 if(insertPos == std::string::npos)
1693 __SS__ <<
"Could not find the code insert position in the source file '"
1695 <<
".' The FE plugin class must end with a 'DEFINE_OTS_INTERFACE("
1696 << pluginName <<
")' - is this the case?" << __E__;
1699 __SUP_COUTV__(insertPos);
1703 "============================================================================"
1704 "============================================\n//" +
1705 macroName +
"\n" +
"//\tFEMacro '" + macroName +
"' generated, " +
1706 timeBuffer +
", by '" + username +
"' using MacroMaker.\n" +
1707 "//\tMacro Notes: " + macroNotes +
"\n" +
"void " + pluginName +
1708 "::" + macroName +
"(__ARGS__)\n{\n\t" +
1709 "__CFG_COUT__ << \"# of input args = \" << argsIn.size() << __E__; \n\t" +
1710 "__CFG_COUT__ << \"# of output args = \" << argsOut.size() << __E__; \n\t" +
1711 "for(auto &argIn:argsIn) \n\t\t" +
1712 "__CFG_COUT__ << argIn.first << \": \" << argIn.second << __E__; \n\n\t" +
1713 "//macro commands section \n" + codess.str() +
"\n\n\t" +
1714 "for(auto &argOut:argsOut) \n\t\t" +
1715 "__CFG_COUT__ << argOut.first << \": \" << argOut.second << __E__; \n\n" +
1716 "} //end " + macroName +
"()\n\n";
1719 CodeEditor::writeFile(CodeEditor::SOURCE_BASE_PATH,
1722 "MacroMaker-" + username,
1729 CodeEditor::readFile(CodeEditor::SOURCE_BASE_PATH, headerFile, contents);
1734 auto insertPos = contents.rfind(
"};");
1735 if(insertPos == std::string::npos)
1737 __SS__ <<
"Could not find the code insert position in the header file '"
1739 <<
".' The FE plugin class must end with a '};' - is this the case?"
1744 __SUP_COUTV__(insertPos);
1746 insert =
"\npublic: // FEMacro '" + macroName +
"' generated, " + timeBuffer +
1747 ", by '" + username +
"' using MacroMaker.\n\t" +
"void " + macroName +
1750 __SUP_COUTV__(insert);
1751 CodeEditor::writeFile(CodeEditor::SOURCE_BASE_PATH,
1754 "MacroMaker-" + username,
1762 void MacroMakerSupervisor::exportMacro(HttpXmlDocument& xmldoc,
1764 const std::string& username)
1766 std::string macroName = CgiDataUtilities::getData(cgi,
"MacroName");
1767 std::string macroSequence = CgiDataUtilities::postData(cgi,
"MacroSequence");
1768 std::string macroNotes = CgiDataUtilities::decodeURIComponent(
1769 CgiDataUtilities::postData(cgi,
"MacroNotes"));
1771 __SUP_COUTV__(macroName);
1772 __SUP_COUTV__(macroSequence);
1775 for(
unsigned int i = 0; i < macroNotes.length(); ++i)
1776 if(macroNotes[i] ==
'\r' || macroNotes[i] ==
'\n')
1777 macroNotes[i] =
' ';
1778 __SUP_COUTV__(macroNotes);
1780 std::stringstream ss(macroSequence);
1781 std::string command;
1782 std::vector<std::string> commands;
1784 while(getline(ss, command,
','))
1785 commands.push_back(command);
1787 std::string fileName = macroName +
".cc";
1789 std::string fullPath = (std::string)MACROS_EXPORT_PATH + username +
"/" + fileName;
1790 __SUP_COUT__ << fullPath << __E__;
1791 std::ofstream exportFile(fullPath.c_str(), std::ios::trunc);
1792 if(exportFile.is_open())
1794 exportFile <<
"//Generated Macro Name:\t" << macroName <<
"\n";
1795 exportFile <<
"//Macro Notes: " << macroNotes <<
"\n";
1799 struct tm* timeinfo;
1803 timeinfo = localtime(&rawtime);
1805 strftime(buffer, 100,
"%b-%d-%Y %I:%M:%S", timeinfo);
1806 exportFile <<
"//Generated Time: \t\t" << buffer <<
"\n";
1809 exportFile <<
"//Paste this whole file into an interface to transfer Macro "
1812 createCode(exportFile, commands);
1816 xmldoc.addTextElementToData(
"ExportFile", fullPath);
1819 __SUP_COUT__ <<
"Unable to open file" << __E__;
1824 void MacroMakerSupervisor::createCode(std::ostream& out,
1825 const std::vector<std::string>& commands,
1826 const std::string& tabOffset,
1828 std::set<std::string>* inArgNames,
1829 std::set<std::string>* outArgNames)
1832 std::set<std::string > argInHasBeenInitializedSet;
1833 bool addressIsVariable, dataIsVariable;
1835 out << tabOffset <<
"{";
1838 << tabOffset <<
"\t"
1839 <<
"char *address \t= new char[universalAddressSize_]{0}; //create address "
1840 "buffer of interface size and init to all 0";
1842 << tabOffset <<
"\t"
1843 <<
"char *data \t\t= new char[universalDataSize_]{0}; //create data buffer "
1844 "of interface size and init to all 0";
1847 << tabOffset <<
"\t"
1848 <<
"uint64_t macroAddress; //create macro address buffer (size 8 bytes)";
1850 << tabOffset <<
"\t"
1851 <<
"uint64_t macroData; //create macro address buffer (size 8 bytes)";
1854 << tabOffset <<
"\t"
1855 <<
"std::map<std::string /*arg name*/,uint64_t /*arg val*/> macroArgs; //create "
1856 "map from arg name to 64-bit number";
1859 for(
unsigned int i = 0; i < commands.size(); i++)
1861 std::stringstream sst(commands[i]);
1863 std::vector<std::string>
1865 while(getline(sst, tokens,
':'))
1866 oneCommand.push_back(tokens);
1867 while(oneCommand.size() < 4)
1868 oneCommand.push_back(
"");
1870 __SUP_COUTV__(StringMacros::vectorToString(oneCommand));
1896 addressIsVariable = isArgumentVariable(oneCommand[2]);
1897 dataIsVariable = isArgumentVariable(oneCommand[3]);
1899 __SUP_COUTV__(addressIsVariable);
1900 __SUP_COUTV__(dataIsVariable);
1902 out <<
"\n\n" << tabOffset <<
"\t// command-#" << i <<
": ";
1904 if(oneCommand[1][0] ==
'w' || oneCommand[1][0] ==
'r')
1906 if(oneCommand[1][0] ==
'w')
1908 else if(oneCommand[1][0] ==
'r')
1911 if(addressIsVariable)
1912 out << oneCommand[2];
1914 out <<
"0x" << oneCommand[2];
1915 out <<
" /*address*/,";
1919 out << oneCommand[3] <<
" /*data*/";
1920 else if(oneCommand[1][0] ==
'w')
1921 out <<
"0x" << oneCommand[3] <<
" /*data*/";
1922 else if(oneCommand[1][0] ==
'r')
1926 else if(oneCommand[1][0] ==
'd')
1928 out <<
"delay(" << oneCommand[2] <<
");\n";
1929 out << tabOffset <<
"\t"
1930 <<
"__CFG_COUT__ << \"Sleeping for... \" << " << oneCommand[2]
1931 <<
" << \" milliseconds \" << __E__;\n";
1932 out << tabOffset <<
"\t"
1933 <<
"usleep(" << oneCommand[2] <<
"*1000 /* microseconds */);\n";
1938 __SS__ <<
"FATAL ERROR: Unknown command '" << oneCommand[1]
1939 <<
"'... command is not w, r or d" << __E__;
1945 if(addressIsVariable)
1947 if(argInHasBeenInitializedSet.find(oneCommand[2]) ==
1948 argInHasBeenInitializedSet.end())
1950 argInHasBeenInitializedSet.emplace(oneCommand[2]);
1955 out << tabOffset <<
"\t"
1956 <<
"macroArgs[\"" << oneCommand[2]
1958 "theXDAQContextConfigTree_.getNode(theConfigurationPath_)."
1961 << tabOffset <<
"\t\t\"" << oneCommand[2]
1962 <<
"\").getValue<uint64_t>();";
1967 inArgNames->emplace(oneCommand[2]);
1970 out << tabOffset <<
"\t"
1971 <<
"macroArgs[\"" << oneCommand[2] <<
"\"] = __GET_ARG_IN__(\""
1972 << oneCommand[2] <<
"\", uint64_t);";
1975 out <<
"\t//get macro address argument";
1977 << tabOffset <<
"\tmemcpy(address,¯oArgs[\"" << oneCommand[2]
1978 <<
"\"],8); //copy macro address argument to buffer";
1982 out << tabOffset <<
"\t"
1983 <<
"macroAddress = 0x" << oneCommand[2]
1984 <<
"; memcpy(address,¯oAddress,8);"
1985 <<
"\t//copy macro address to buffer";
1990 if(oneCommand[1] ==
"w")
1994 if(argInHasBeenInitializedSet.find(oneCommand[3]) ==
1995 argInHasBeenInitializedSet
1998 argInHasBeenInitializedSet.emplace(oneCommand[3]);
2003 inArgNames->emplace(oneCommand[3]);
2007 << tabOffset <<
"\t"
2008 <<
"macroArgs[\"" << oneCommand[3]
2009 <<
"\"] = __GET_ARG_IN__(\"" << oneCommand[3]
2010 <<
"\", uint64_t); //initialize from input arguments";
2016 << tabOffset <<
"\t"
2017 <<
"macroArgs[\"" << oneCommand[3]
2019 "theXDAQContextConfigTree_.getNode(theConfigurationPath_)."
2022 << tabOffset <<
"\t\t\"" << oneCommand[3]
2023 <<
"\").getValue<uint64_t>(); //initialize from "
2024 "configuration tree";
2027 out <<
"\t//get macro data argument";
2029 << tabOffset <<
"\tmemcpy(data,¯oArgs[\"" << oneCommand[3]
2030 <<
"\"],8); //copy macro data argument to buffer";
2035 << tabOffset <<
"\t"
2036 <<
"macroData = 0x" << oneCommand[3] <<
"; memcpy(data,¯oData,8);"
2037 <<
"\t//copy macro data to buffer";
2040 << tabOffset <<
"\t"
2041 <<
"universalWrite(address,data);";
2046 << tabOffset <<
"\t"
2047 <<
"universalRead(address,data);";
2049 std::string outputArgName;
2052 outputArgName = oneCommand[3];
2056 sprintf(str,
"outArg%d", i);
2057 outputArgName = str;
2059 __SUP_COUTV__(outputArgName);
2061 out << tabOffset <<
"\t"
2062 <<
"memcpy(¯oArgs[\"" << outputArgName
2063 <<
"\"],data,8); //copy buffer to argument map";
2068 << tabOffset <<
"\t"
2069 <<
"__SET_ARG_OUT__(\"" << outputArgName <<
"\",macroArgs[\""
2070 << outputArgName <<
"\"]); //update output argument result";
2073 outArgNames->emplace(outputArgName);
2074 argInHasBeenInitializedSet.emplace(
2079 out <<
"\n\n" << tabOffset <<
"\tdelete[] address; //free the memory";
2080 out <<
"\n" << tabOffset <<
"\tdelete[] data; //free the memory";
2081 out <<
"\n" << tabOffset <<
"}";
2083 __SUP_COUT__ <<
"Done with code generation." << __E__;
2089 bool MacroMakerSupervisor::isArgumentVariable(
const std::string& argumentString)
2091 for(
unsigned int i = 0; i < argumentString.length(); ++i)
2094 if(!((argumentString[i] >=
'0' && argumentString[i] <=
'9') ||
2095 (argumentString[i] >=
'a' && argumentString[i] <=
'f') ||
2096 (argumentString[i] >=
'A' && argumentString[i] <=
'F')))
2111 std::string MacroMakerSupervisor::generateHexArray(
const std::string& sourceHexString,
2114 std::stringstream retSs;
2116 std::string srcHexStr = sourceHexString;
2117 __SUP_COUT__ <<
"Translating: \n";
2118 __SUP_COUT__ << srcHexStr << __E__;
2120 if(srcHexStr.size() % 2)
2121 srcHexStr =
"0" + srcHexStr;
2123 numOfBytes = srcHexStr.size() / 2;
2124 retSs <<
"[" << numOfBytes <<
"] = {";
2126 for(
int i = 0; i < numOfBytes * 2; i += 2)
2129 if(!((srcHexStr[i] >=
'0' && srcHexStr[i] <=
'9') ||
2130 (srcHexStr[i] >=
'a' && srcHexStr[i] <=
'f') ||
2131 (srcHexStr[i] >=
'A' && srcHexStr[i] <=
'F')) ||
2132 !((srcHexStr[i + 1] >=
'0' && srcHexStr[i + 1] <=
'9') ||
2133 (srcHexStr[i + 1] >=
'a' && srcHexStr[i + 1] <=
'f') ||
2134 (srcHexStr[i + 1] >=
'A' && srcHexStr[i + 1] <=
'F')))
2142 retSs <<
"0x" << srcHexStr[srcHexStr.size() - 1 - i - 1]
2143 << srcHexStr[srcHexStr.size() - 1 - i];
2147 __SUP_COUT__ << retSs.str() << __E__;
2153 void MacroMakerSupervisor::runFEMacro(HttpXmlDocument& xmldoc,
2155 const std::string& username)
try
2157 __SUP_COUT__ << __E__;
2161 std::string feClassSelected = CgiDataUtilities::getData(cgi,
"feClassSelected");
2162 std::string feUIDSelected = CgiDataUtilities::getData(cgi,
"feUIDSelected");
2163 std::string macroType = CgiDataUtilities::getData(cgi,
"macroType");
2164 std::string macroName = CgiDataUtilities::getData(cgi,
"macroName");
2165 std::string inputArgs = CgiDataUtilities::postData(cgi,
"inputArgs");
2166 std::string outputArgs = CgiDataUtilities::postData(cgi,
"outputArgs");
2167 bool saveOutputs = CgiDataUtilities::getDataAsInt(cgi,
"saveOutputs") == 1;
2170 __SUP_COUTV__(feClassSelected);
2171 __SUP_COUTV__(feUIDSelected);
2172 __SUP_COUTV__(macroType);
2173 __SUP_COUTV__(macroName);
2174 __SUP_COUTV__(inputArgs);
2175 __SUP_COUTV__(outputArgs);
2176 __SUP_COUTV__(saveOutputs);
2178 std::set<std::string > feUIDs;
2180 if(feUIDSelected ==
"")
2181 feUIDSelected =
"*";
2182 if(feClassSelected ==
"")
2183 feClassSelected =
"*";
2185 if(feClassSelected ==
"" || feUIDSelected ==
"" || macroType ==
"" || macroName ==
"")
2187 __SUP_SS__ <<
"Illegal empty front-end parameter." << __E__;
2190 else if(feUIDSelected !=
"*")
2191 feUIDs.emplace(feUIDSelected);
2195 if(feClassSelected ==
"*")
2197 for(
auto& feTypePair : FEPluginTypetoFEsMap_)
2198 for(
auto& feUID : feTypePair.second)
2199 feUIDs.emplace(feUID);
2203 auto typeIt = FEPluginTypetoFEsMap_.find(feClassSelected);
2204 if(typeIt == FEPluginTypetoFEsMap_.end())
2206 __SUP_SS__ <<
"Illegal front-end type parameter '" << feClassSelected
2207 <<
"' not in list of types." << __E__;
2211 for(
auto& feUID : typeIt->second)
2212 feUIDs.emplace(feUID);
2216 __SUP_COUTV__(StringMacros::setToString(feUIDs));
2218 std::string macroString;
2219 if(macroType ==
"public")
2220 loadMacro(macroName, macroString);
2221 else if(macroType ==
"private")
2222 loadMacro(macroName, macroString, username);
2224 __SUP_COUTV__(macroString);
2231 std::string filename =
"/macroOutput_" + std::to_string(time(0)) +
"_" +
2232 std::to_string(clock()) +
".txt";
2234 __SUP_COUTV__(filename);
2235 fp = fopen((CodeEditor::OTSDAQ_DATA_PATH + filename).c_str(),
"w");
2238 __SUP_SS__ <<
"Failed to open file to save macro output '"
2239 << CodeEditor::OTSDAQ_DATA_PATH << filename <<
"'..." << __E__;
2243 fprintf(fp,
"############################\n");
2245 "### Running '%s' at time %s\n",
2247 StringMacros::getTimestampString().c_str());
2249 "### \t Target front-ends (count=%lu): %s\n",
2251 StringMacros::setToString(feUIDs).c_str());
2252 fprintf(fp,
"### \t\t Inputs: %s\n", inputArgs.c_str());
2253 fprintf(fp,
"############################\n\n\n");
2255 xmldoc.addTextElementToData(
"outputArgs_name",
"Filename");
2256 xmldoc.addTextElementToData(
"outputArgs_value",
"$OTSDAQ_DATA/" + filename);
2260 for(
auto& feUID : feUIDs)
2262 auto feIt = FEtoSupervisorMap_.find(feUID);
2263 if(feIt == FEtoSupervisorMap_.end())
2265 __SUP_SS__ <<
"Destination front end interface ID '" << feUID
2266 <<
"' was not found in the list of front ends." << __E__;
2267 ss <<
"\n\nHere is the map:\n\n"
2268 << StringMacros::mapToString(FEtoSupervisorMap_) << __E__;
2272 unsigned int FESupervisorIndex = feIt->second;
2273 __SUP_COUT__ <<
"Found supervisor index: " << FESupervisorIndex << __E__;
2275 SupervisorInfoMap::iterator it = allFESupervisorInfo_.find(FESupervisorIndex);
2276 if(it == allFESupervisorInfo_.end())
2279 <<
"Error transmitting request to FE Supervisor '" << feUID <<
":"
2280 << FESupervisorIndex <<
".' \n\n"
2281 <<
"The FE Supervisor Index does not exist. Have you configured "
2282 "the state machine properly?"
2288 SOAPParameters txParameters;
2289 if(macroType ==
"fe")
2290 txParameters.addParameter(
"Request",
"RunInterfaceMacro");
2292 txParameters.addParameter(
"Request",
"RunMacroMakerMacro");
2293 txParameters.addParameter(
"InterfaceID", feUID);
2294 if(macroType ==
"fe")
2295 txParameters.addParameter(
"feMacroName", macroName);
2298 txParameters.addParameter(
"macroName", macroName);
2299 txParameters.addParameter(
"macroString", macroString);
2301 txParameters.addParameter(
"inputArgs", inputArgs);
2302 txParameters.addParameter(
"outputArgs", outputArgs);
2304 SOAPParameters rxParameters;
2306 rxParameters.addParameter(
"outputArgs");
2307 rxParameters.addParameter(
"Error");
2312 "Running '%s' at time %s\n",
2314 StringMacros::getTimestampString().c_str());
2316 "\t Target front-end: '%s::%s'\n",
2317 FEtoPluginTypeMap_[feUID].c_str(),
2319 fprintf(fp,
"\t\t Inputs: %s\n", inputArgs.c_str());
2323 xoap::MessageReference retMsg = SOAPMessenger::sendWithSOAPReply(
2324 it->second.getDescriptor(),
2325 "MacroMakerSupervisorRequest",
2328 __SUP_COUT__ <<
"Received response message: "
2329 << SOAPUtilities::translate(retMsg) << __E__;
2331 SOAPUtilities::receive(retMsg, rxParameters);
2333 __SUP_COUT__ <<
"Received it " << __E__;
2336 std::string outputResults = rxParameters.getValue(
"outputArgs");
2337 std::string error = rxParameters.getValue(
"Error");
2340 __SUP_COUT__ <<
"outputArgs = " << outputResults << __E__;
2344 __SS__ <<
"Attempted FE Macro Failed. Attempted target "
2345 <<
"was UID=" << feUID
2346 <<
" at feSupervisorID=" << FESupervisorIndex <<
"." << __E__;
2347 ss <<
"\n\n The error was:\n\n" << error << __E__;
2348 __SUP_COUT_ERR__ <<
"\n" << ss.str();
2349 xmldoc.addTextElementToData(
"Error", ss.str());
2357 std::istringstream inputStream(outputResults);
2358 std::string splitVal, argName, argValue;
2359 while(getline(inputStream, splitVal,
';'))
2361 std::istringstream pairInputStream(splitVal);
2362 getline(pairInputStream, argName,
',');
2363 getline(pairInputStream, argValue,
',');
2368 "\t\t Output '%s' = %s\n",
2374 xmldoc.addTextElementToData(
"outputArgs_name", argName);
2375 xmldoc.addTextElementToData(
"outputArgs_value", argValue);
2377 __SUP_COUT__ << argName <<
": " << argValue << __E__;
2393 catch(
const std::runtime_error& e)
2395 __SUP_SS__ <<
"Error processing FE communication request: " << e.what() << __E__;
2396 __SUP_COUT_ERR__ << ss.str();
2397 xmldoc.addTextElementToData(
"Error", ss.str());
2401 __SUP_SS__ <<
"Unknown error processing FE communication request." << __E__;
2402 __SUP_COUT_ERR__ << ss.str();
2404 xmldoc.addTextElementToData(
"Error", ss.str());
2408 void MacroMakerSupervisor::getFEMacroList(HttpXmlDocument& xmldoc,
2409 const std::string& username)
2411 __SUP_COUT__ <<
"Getting FE Macro list" << __E__;
2413 SOAPParameters txParameters;
2414 txParameters.addParameter(
"Request",
"GetInterfaceMacros");
2416 SOAPParameters rxParameters;
2417 rxParameters.addParameter(
"FEMacros");
2419 std::string oneInterface;
2420 std::string rxFEMacros;
2424 for(
auto& appInfo : allFESupervisorInfo_)
2426 __SUP_COUT__ <<
"FESupervisor LID = " << appInfo.second.getId()
2427 <<
" name = " << appInfo.second.getName() << __E__;
2429 xoap::MessageReference retMsg = SOAPMessenger::sendWithSOAPReply(
2430 appInfo.second.getDescriptor(),
"MacroMakerSupervisorRequest", txParameters);
2431 SOAPUtilities::receive(retMsg, rxParameters);
2433 rxFEMacros = rxParameters.getValue(
"FEMacros");
2435 __SUP_COUT__ <<
"FE Macros received: \n" << rxFEMacros << __E__;
2437 std::istringstream allInterfaces(rxFEMacros);
2438 while(std::getline(allInterfaces, oneInterface))
2442 xmldoc.addTextElementToData(
"FEMacros", oneInterface);
2448 std::pair<std::vector<std::string> ,
2449 std::vector<std::string> >
2451 loadMacroNames(username, macroNames);
2453 __SUP_COUT__ <<
"Public macro count: " << macroNames.first.size() << __E__;
2454 __SUP_COUT__ <<
"Private macro count: " << macroNames.second.size() << __E__;
2456 std::string macroString;
2465 for(
int i = 0; i < 2; ++i)
2466 for(
auto& macroName : (i ? macroNames.second : macroNames.first))
2469 loadMacro(macroName, macroString, username);
2472 FEVInterface::macroStruct_t macro(macroString);
2474 std::stringstream xmlMacroStream;
2475 xmlMacroStream << macro.macroName_;
2476 xmlMacroStream <<
":"
2478 xmlMacroStream <<
":" << macro.namesOfInputArguments_.size();
2479 for(
auto& inputArg : macro.namesOfInputArguments_)
2480 xmlMacroStream <<
":" << inputArg;
2481 xmlMacroStream <<
":" << macro.namesOfOutputArguments_.size();
2482 for(
auto& inputArg : macro.namesOfOutputArguments_)
2483 xmlMacroStream <<
":" << inputArg;
2485 xmldoc.addTextElementToData(i ?
"PrivateMacro" :
"PublicMacro",
2486 xmlMacroStream.str());