1 #include "otsdaq-utilities/Visualization/VisualSupervisor.h"
2 #include "otsdaq/DataManager/DataManagerSingleton.h"
3 #include "otsdaq/Macros/BinaryStringMacros.h"
4 #include "otsdaq/RootUtilities/VisualDataManager.h"
5 #include "otsdaq/XmlUtilities/XmlDocument.h"
7 #include <boost/regex.hpp>
8 #include "otsdaq/DataManager/DQMHistosConsumerBase.h"
9 #include "otsdaq/Macros/MessageTools.h"
10 #include "otsdaq/RootUtilities/RootFileExplorer.h"
15 #include <TBranchElement.h>
17 #include <TBufferJSON.h>
20 #include <TDirectory.h>
24 #include <TIterator.h>
31 #include "TBufferFile.h"
37 #include <xdaq/NamespaceURI.h>
47 #define ROOT_BROWSER_PATH __ENV__("ROOT_BROWSER_PATH")
48 #define ROOT_DISPLAY_CONFIG_PATH __ENV__("ROOT_DISPLAY_CONFIG_PATH")
50 #define LIVEDQM_DIR std::string("LIVE_DQM")
51 #define PRE_MADE_ROOT_CFG_DIR std::string("Pre-made Views")
53 #define PRE_MADE_ROOT_CFG_FILE_EXT std::string(".rcfg")
55 #define PREFERENCES_PATH std::string(__ENV__("SERVICE_DATA_PATH")) + "/VisualizerData/"
56 #define PREFERENCES_FILE_EXT ".pref"
58 #define ROOT_VIEWER_PERMISSIONS_THRESHOLD 100
63 #define __MF_SUBJECT__ "Visualizer"
68 #define STDLINE(X, Y) __COUT__ << X
71 VisualSupervisor::VisualSupervisor(xdaq::ApplicationStub* stub)
74 __SUP_COUT__ <<
"Constructor." << __E__;
77 mkdir(((std::string)PREFERENCES_PATH).c_str(), 0755);
78 ROOT::EnableThreadSafety();
80 __SUP_COUT__ <<
"Constructed." << __E__;
84 VisualSupervisor::~VisualSupervisor(
void)
86 __SUP_COUT__ <<
"Destructor." << __E__;
88 __SUP_COUT__ <<
"Destructed." << __E__;
92 void VisualSupervisor::destroy(
void)
94 __SUP_COUT__ <<
"Destroying..." << __E__;
97 if(theStateMachineImplementation_.size() > 1)
99 __SS__ <<
"Not expecting more than one visual data manager!" << __E__;
102 if(theStateMachineImplementation_.size())
103 theStateMachineImplementation_.pop_back();
105 __COUT_WARN__ <<
"No visual data manager was pushed." << __E__;
112 __SUP_COUT__ <<
"Configuring..." << __E__;
116 if(RunControlStateMachine::getIterationIndex() == 0 &&
117 RunControlStateMachine::getSubIterationIndex() == 0)
120 SOAPUtilities::translate(theStateMachine_.getCurrentMessage())
122 .getValue(
"ConfigurationTableGroupName"),
124 SOAPUtilities::translate(theStateMachine_.getCurrentMessage())
126 .getValue(
"ConfigurationTableGroupKey")));
128 __SUP_COUT__ <<
"Configuration table group name: " << theGroup.first
129 <<
" key: " << theGroup.second << __E__;
132 theConfigurationManager_->loadTableGroup(
145 ConfigurationManager::LoadGroupType::ALL_TYPES,
154 theConfigurationManager_->__GET_CONFIG__(
XDAQContextTable)->getTableName() +
155 CorePropertySupervisorBase::getSupervisorConfigurationPath());
157 catch(
const std::runtime_error& e)
159 __SS__ <<
"The link to the Visual Supervisor configuration seems to be broken. "
160 "Please check this path: "
164 CorePropertySupervisorBase::getSupervisorConfigurationPath()
165 << __E__ << __E__ << e.what() << __E__;
170 "/" + theConfigurationManager_->__GET_CONFIG__(
XDAQContextTable)->getTableName() +
171 CorePropertySupervisorBase::getSupervisorConfigurationPath());
177 theDataManager_ = DataManagerSingleton::getInstance<VisualDataManager>(
178 theConfigurationManager_->getNode(
181 CorePropertySupervisorBase::getSupervisorConfigurationPath(),
182 CorePropertySupervisorBase::getSupervisorUID());
184 CoreSupervisorBase::theStateMachineImplementation_.push_back(theDataManager_);
186 __SUP_COUT__ <<
"Done instantiating Visual data manager." << __E__;
189 __SUP_COUT__ <<
"No Visual Supervisor configuration link, so skipping Visual "
190 "data manager instantiation."
194 CoreSupervisorBase::transitionConfiguringFSMs();
196 __SUP_COUT__ <<
"Configured." << __E__;
198 catch(
const std::runtime_error& e)
200 __SS__ <<
"Error with VisualSupervisor::transitionConfiguring(): " << e.what()
202 __COUT_ERR__ << ss.str();
206 theStateMachine_.setErrorMessage(ss.str());
207 throw toolbox::fsm::exception::Exception(
210 "VisualSupervisor::transitionConfiguring" ,
217 void VisualSupervisor::transitionHalting(toolbox::Event::Reference e)
219 __SUP_COUT__ <<
"Halting..." << __E__;
224 __SUP_COUT__ <<
"Halted." << __E__;
233 CorePropertySupervisorBase::setSupervisorProperty(
234 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.AllowNoLoginRequestTypes,
235 "setUserPreferences | getUserPreferences | getDirectoryContents | getRoot | "
238 CorePropertySupervisorBase::setSupervisorProperty(
239 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.UserPermissionsThreshold,
240 "*=1 | rootAdminControls=100");
248 CorePropertySupervisorBase::setSupervisorProperty(
249 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.AutomatedRequestTypes,
250 "getRoot | getEvents");
251 CorePropertySupervisorBase::setSupervisorProperty(
252 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.NoXmlWhiteSpaceRequestTypes,
253 "getRoot | getEvents");
261 const WebUsers::RequestUserInfo& userInfo)
288 __SUP_COUT__ <<
"Request type: " << requestType << __E__;
292 __SUP_COUT__ << __E__;
297 if(theDataManager_ ==
nullptr)
299 __SS__ <<
"No data manager instantiated." << __E__;
302 __SUP_COUT__ <<
"Getting Raw data and converting to binary string" << __E__;
305 __SUP_COUT__ << __E__;
306 __SUP_SS__ <<
"Raw data visualizion is deprecated!" << __E__;
309 catch(std::exception
const& e)
312 <<
"ERROR! Exception while getting raw data. Incoming exception data..."
314 __SUP_COUT__ << e.what() << __E__;
315 __SUP_COUT__ <<
"End Exception Data" << __E__;
319 __SUP_COUT__ <<
"ERROR! Something went wrong trying to get raw data."
325 catch(
const std::exception& e)
327 __SUP_COUT_ERR__ <<
"Exception message: " << e.what();
332 __SUP_COUT_INFO__ <<
"ERROR! Something went wrong trying to get raw data."
337 requestType ==
"setUserPreferences" &&
338 userInfo.username_ !=
341 __SUP_COUT__ <<
"userInfo.username_: " << userInfo.username_ << __E__;
342 std::string fullPath =
343 (std::string)PREFERENCES_PATH + userInfo.username_ + PREFERENCES_FILE_EXT;
344 __SUP_COUT__ <<
"fullPath: " << fullPath << __E__;
350 std::string autoRefreshPeriod =
353 __SUP_COUT__ <<
"radioSelect: " << radioSelect << __E__;
354 __SUP_COUT__ <<
"autoRefresh: " << autoRefresh << __E__;
355 __SUP_COUT__ <<
"autoHide: " << autoHide << __E__;
356 __SUP_COUT__ <<
"hardRefresh: " << hardRefresh << __E__;
357 __SUP_COUT__ <<
"autoRefreshPeriod: " << autoRefreshPeriod << __E__;
360 FILE* fp = fopen(fullPath.c_str(),
"r");
366 fgets(line, 100, fp);
367 sscanf(line,
"%*s %s", val);
368 if(radioSelect ==
"")
371 fgets(line, 100, fp);
372 sscanf(line,
"%*s %s", val);
373 if(autoRefresh ==
"")
376 fgets(line, 100, fp);
377 sscanf(line,
"%*s %s", val);
381 fgets(line, 100, fp);
382 sscanf(line,
"%*s %s", val);
383 if(hardRefresh ==
"")
386 fgets(line, 100, fp);
387 sscanf(line,
"%*s %s", val);
388 if(autoRefreshPeriod ==
"")
389 autoRefreshPeriod = val;
395 fp = fopen(fullPath.c_str(),
"w");
398 fprintf(fp,
"radioSelect %s\n", radioSelect.c_str());
399 fprintf(fp,
"autoRefresh %s\n", autoRefresh.c_str());
400 fprintf(fp,
"autoHide %s\n", autoHide.c_str());
401 fprintf(fp,
"hardRefresh %s\n", hardRefresh.c_str());
402 fprintf(fp,
"autoRefreshPeriod %s\n", autoRefreshPeriod.c_str());
406 __SUP_COUT_ERR__ <<
"Failure writing preferences to file: " << fullPath
411 "getUserPreferences")
413 __SUP_COUT__ <<
"Next is userinfo" << __E__;
414 __SUP_COUT__ <<
"userInfo.username_: " << userInfo.username_ << __E__;
415 std::string fullPath =
416 (std::string)PREFERENCES_PATH + userInfo.username_ + PREFERENCES_FILE_EXT;
417 __SUP_COUT__ <<
"fullPath: " << fullPath << __E__;
419 FILE* fp = fopen(fullPath.c_str(),
"r");
426 fgets(line, 100, fp);
427 sscanf(line,
"%*s %d", &val);
428 if(val < 0 || val > 3)
430 xmlOut.addTextElementToData(
"radioSelect", std::to_string(val));
431 fgets(line, 100, fp);
432 sscanf(line,
"%*s %d", &val);
433 xmlOut.addTextElementToData(
"autoRefresh", std::to_string(val));
434 fgets(line, 100, fp);
435 sscanf(line,
"%*s %d", &val);
436 xmlOut.addTextElementToData(
"autoHide", std::to_string(val));
437 fgets(line, 100, fp);
438 sscanf(line,
"%*s %d", &val);
439 xmlOut.addTextElementToData(
"hardRefresh", std::to_string(val));
440 fgets(line, 100, fp);
441 sscanf(line,
"%*s %d", &val);
442 xmlOut.addTextElementToData(
"autoRefreshPeriod", std::to_string(val));
448 xmlOut.addTextElementToData(
"radioSelect",
"");
449 xmlOut.addTextElementToData(
"autoRefresh",
"");
450 xmlOut.addTextElementToData(
"autoHide",
"");
451 xmlOut.addTextElementToData(
"hardRefresh",
"");
452 xmlOut.addTextElementToData(
"autoRefreshPeriod",
"");
454 __SUP_COUT__ <<
"Done with preferences!" << __E__;
458 "getDirectoryContents")
461 std::string rootpath =
462 std::string(ROOT_BROWSER_PATH) +
465 boost::regex re(
"%2F");
466 path = boost::regex_replace(path, re,
"/");
476 userInfo.permissionLevel_ >=
478 "rootAdminControls"));
479 xmlOut.addTextElementToData(
"permissions", permStr);
483 std::string dirpath = rootpath + path;
485 if(path ==
"/" + PRE_MADE_ROOT_CFG_DIR +
"/")
486 dirpath = ROOT_DISPLAY_CONFIG_PATH;
488 if(path.find(
"/" + PRE_MADE_ROOT_CFG_DIR +
"/") ==
490 dirpath = std::string(ROOT_DISPLAY_CONFIG_PATH) +
"/" +
491 path.substr(PRE_MADE_ROOT_CFG_DIR.length() + 2);
494 __SUP_COUT__ <<
"rootpath:-" << rootpath <<
"-path:-" << path <<
"-dirpath:-"
495 << dirpath <<
"-" << __E__;
498 struct dirent* entry;
501 if((pDIR = opendir(dirpath.c_str())))
503 xmlOut.addTextElementToData(
"path", path);
504 xmlOut.addTextElementToData(
"headOfSearch",
"located");
509 if(theDataManager_ !=
nullptr)
510 __COUT__ <<
"path-" << path <<
"-DM: " << theDataManager_
511 <<
" Live: " << theDataManager_->getLiveDQMHistos() << std::endl;
515 xmlOut.addTextElementToData(
"dir",
516 LIVEDQM_DIR +
".root");
519 DIR* pRtDIR = opendir(ROOT_DISPLAY_CONFIG_PATH);
520 bool recheck =
false;
524 if(mkdir(ROOT_DISPLAY_CONFIG_PATH,
525 S_IRWXU | (S_IRGRP | S_IXGRP) |
526 (S_IROTH | S_IXOTH)))
527 __SUP_COUT__ <<
"Failed to make directory for pre made views: "
528 << ROOT_DISPLAY_CONFIG_PATH << __E__;
533 if(!recheck || (pRtDIR = opendir(ROOT_DISPLAY_CONFIG_PATH)))
537 xmlOut.addTextElementToData(
"dir",
538 PRE_MADE_ROOT_CFG_DIR);
544 while((entry = readdir(pDIR)))
548 if(entry->d_name[0] !=
'.' &&
551 entry->d_type == 4 ||
557 std::string(entry->d_name).find(
".rcfg") == std::string::npos;
560 if(entry->d_type == 0)
564 DIR* pTmpDIR = opendir((dirpath + entry->d_name).c_str());
574 if((entry->d_type == 8 ||
575 (!isDir && entry->d_type == 0))
576 && std::string(entry->d_name).find(
".root") == std::string::npos &&
579 else if(entry->d_type == 4)
582 xmlOut.addTextElementToData(
583 isDir ?
"dir" : (isNotRtCfg ?
"dir" :
"file"), entry->d_name);
589 __SUP_COUT__ <<
"Failed to access directory contents!" << __E__;
601 unsigned splitter = path.find(
".root") + 5;
602 std::string rootFileName =
603 std::string(__ENV__(
"ROOT_BROWSER_PATH")) + path.substr(0, splitter);
604 __SUP_COUTV__(rootFileName);
606 std::string rootDirectoryName = path.substr(splitter, path.length() - splitter);
607 __SUP_COUTV__(rootDirectoryName);
612 bool isLiveDQM = (path.find(
"/" + LIVEDQM_DIR +
".root/") == 0) ?
true :
false;
613 __SUP_COUTV__(isLiveDQM);
615 TFile* rootFile =
nullptr;
616 TObject* tObject =
nullptr;
617 TDirectory* tDirectory =
nullptr;
621 rootFile = TFile::Open(rootFileName.c_str());
623 if(rootFile ==
nullptr || !rootFile->IsOpen())
625 __SUP_SS__ <<
"Failed to access ROOT file: " << rootFileName << __E__;
630 if((tObject = rootFile->Get(rootDirectoryName.c_str())) !=
632 (rootDirectoryName.size() &&
633 rootDirectoryName[0] ==
'/' &&
634 (tObject = rootFile->Get(rootDirectoryName.substr(1).c_str())) !=
637 if(tObject->IsA() == TCanvas::Class())
639 static_cast<TCanvas*
>(tObject)->Modified();
640 static_cast<TCanvas*
>(tObject)->Update();
642 TString json = TBufferJSON::ConvertToJSON(tObject);
643 TBufferFile tBuffer(TBuffer::kWrite);
644 tObject->Streamer(tBuffer);
646 tBuffer.Buffer(), tBuffer.Length());
648 __SUP_COUT__ <<
"Returning object from file '" << tObject->GetName()
649 <<
"' of class '" << tObject->ClassName() << __E__;
651 xmlOut.addTextElementToData(
"path", path);
652 xmlOut.addTextElementToData(
"rootType", tObject->ClassName());
653 xmlOut.addTextElementToData(
"rootData", hexString);
654 xmlOut.addTextElementToData(
"rootJSON", json.Data());
656 else if((tDirectory = rootFile->GetDirectory(rootDirectoryName.c_str())) !=
660 TIter next(tDirectory->GetListOfKeys());
661 xmlOut.addTextElementToData(
"path", path);
662 while((key = (TKey*)next()))
664 TString s = key->GetName();
665 TRegexp re(
"*", kTRUE);
666 if(s.Index(re) == kNPOS)
668 __SUP_COUT__ <<
"Class Name: " << key->GetClassName() << __E__;
669 xmlOut.addTextElementToData(
670 (std::string(key->GetClassName()).find(
"Directory") !=
672 std::string(key->GetClassName()) ==
"TTree" ||
673 std::string(key->GetClassName()).find(
"TBranch") !=
682 tObject = key->ReadObj();
683 __SUP_COUT__ <<
"JSON : " << key->GetClassName() << __E__;
685 TString json = TBufferJSON::ConvertToJSON(tObject);
686 TBufferFile tBuffer(TBuffer::kWrite);
687 tObject->Streamer(tBuffer);
688 std::string hexString =
692 __SUP_COUT__ <<
"Returning directory object from file '"
693 << tObject->GetName() <<
"' of class '"
694 << tObject->ClassName() << __E__;
696 __SUP_COUTV__(json.Data());
702 __SUP_COUT_ERR__ <<
"Failed to find object " << rootDirectoryName
703 <<
" in " << rootFileName << __E__;
707 else if(theDataManager_ !=
nullptr && theDataManager_->isReady())
709 if(theDataManager_ !=
nullptr)
710 theDataManager_->setDoNotStop(
true);
713 __SUP_COUT__ <<
"Attempting to get LIVE ROOT object." << __E__;
715 std::vector<DQMHistosBase*> dqmConsumers = theDataManager_->
getLiveDQMs();
717 for(
auto const& consumer : dqmConsumers)
719 rootFile = consumer->getFile();
720 __SUP_COUT__ <<
"LIVE file name: " << rootFile->GetName() << __E__;
721 if(rootFile ==
nullptr || !rootFile->IsOpen())
723 __SUP_SS__ <<
"Failed to access LIVE ROOT file: " << rootFileName
725 theDataManager_->setDoNotStop(
false);
729 if((tObject = rootFile->Get(rootDirectoryName.c_str())) !=
nullptr)
731 __SUP_COUT__ <<
"Object class name: " << tObject->ClassName()
733 std::string tmpClassName = tObject->ClassName();
735 TBufferFile tBuffer(TBuffer::kWrite);
736 if(tObject->IsA() == TCanvas::Class())
738 static_cast<TCanvas*
>(tObject)->Modified();
739 static_cast<TCanvas*
>(tObject)->Update();
742 std::unique_lock<std::mutex> lock(
744 ->getFillHistoMutex());
745 json = TBufferJSON::ConvertToJSON(tObject);
746 tObject->Streamer(tBuffer);
749 tBuffer.Buffer(), tBuffer.Length());
751 __SUP_COUT__ <<
"Returning object '" << tObject->GetName()
752 <<
"' of class '" << tObject->ClassName() << __E__;
755 xmlOut.addTextElementToData(
"path", path);
756 xmlOut.addTextElementToData(
"rootType", tObject->ClassName());
757 xmlOut.addTextElementToData(
"rootData", hexString);
758 xmlOut.addTextElementToData(
"rootJSON", json.Data());
760 theDataManager_->setDoNotStop(
false);
765 std::map<std::string, std::string> dirList;
767 for(
auto const& consumer : dqmConsumers)
769 __SUP_COUT__ <<
"Attempting to get LIVE ROOT directory." << __E__;
770 rootFile = consumer->getFile();
771 __SUP_COUT__ <<
"LIVE file name: " << rootFile->GetName() << __E__;
772 if(rootFile ==
nullptr || !rootFile->IsOpen())
774 __SUP_SS__ <<
"Failed to access LIVE ROOT file: " << rootFileName
776 xmlOut.addTextElementToData(
"Warning", ss.str());
777 theDataManager_->setDoNotStop(
false);
780 if((tDirectory = rootFile->GetDirectory(rootDirectoryName.c_str())) !=
783 xmlOut.addTextElementToData(
"path", path);
784 __SUP_COUT__ <<
"Directory found getting the content!" << __E__;
785 TRegexp re(
"*", kTRUE);
787 TIter nextobj(tDirectory->GetList());
788 while((obj = (TObject*)nextobj()))
790 TString s = obj->GetName();
791 if(s.Index(re) == kNPOS)
793 __SUP_COUT__ <<
"Class Name: " << obj->IsA()->GetName() << __E__;
794 dirList[obj->GetName()] =
795 (std::string(obj->IsA()->GetName()).find(
"Directory") !=
797 std::string(obj->IsA()->GetName()) ==
"TTree" ||
798 std::string(obj->IsA()->GetName()).find(
"TBranch") !=
805 for(
auto const& dir : dirList)
807 xmlOut.addTextElementToData(dir.second, dir.first);
808 __SUP_COUT__ <<
"Class Name: " << dir.second <<
" Object: " << dir.first
1216 if(theDataManager_ ==
nullptr)
1218 __SS__ <<
"No Data Manager instantiated." << __E__;
1222 int Run = atoi(cgiIn(
"run").c_str());
1224 __SUP_COUT__ <<
"getEvents for run " << Run << __E__;
1226 if(Run != (
int)loadedRunNumber_ || loadedRunNumber_ == (
unsigned int)-1)
1228 theDataManager_->load(
"Run1684.root",
"Monicelli");
1229 loadedRunNumber_ = Run;
1232 xmlOut.addTextElementToData(
"events",
"");
1275 __SUP_COUT__ <<
"Done hits xml" << __E__;
1281 __SUP_COUT__ <<
"getGeometry" << __E__;
1283 if(theDataManager_ ==
nullptr)
1285 __SS__ <<
"No Data Manager instantiated." << __E__;
1290 theDataManager_->load(
"Run1684.geo",
"Geometry");
1292 __SUP_COUT__ <<
"getGeometry" << __E__;
1294 xmlOut.addTextElementToData(
"geometry",
"");
1330 __SUP_COUT__ <<
"path " << path << __E__;
1332 if(path.find(
"/" + PRE_MADE_ROOT_CFG_DIR +
"/") ==
1335 path = std::string(ROOT_DISPLAY_CONFIG_PATH) +
"/" +
1336 path.substr(PRE_MADE_ROOT_CFG_DIR.length() + 2);
1337 __SUP_COUT__ <<
"mod path " << path << __E__;
1343 xmlOut.addTextElementToData(
"status",
"1");
1348 xmlOut.addTextElementToData(
"status",
1349 "Failed. File to properly load config file.");
1353 "rootAdminControls")
1365 std::string cmd = cgiIn(
"cmd");
1372 __SUP_COUT__ <<
"cmd " << cmd << __E__;
1373 __SUP_COUT__ <<
"path " << path << __E__;
1374 __SUP_COUT__ <<
"name " << name << __E__;
1376 if(path.find(
"/" + PRE_MADE_ROOT_CFG_DIR +
"/") ==
1379 path = std::string(ROOT_DISPLAY_CONFIG_PATH) +
"/" +
1380 path.substr(PRE_MADE_ROOT_CFG_DIR.length() + 2) + name;
1381 __SUP_COUT__ <<
"mod path " << path << __E__;
1385 if(mkdir(path.c_str(),
1386 S_IRWXU | (S_IRGRP | S_IXGRP) |
1387 (S_IROTH | S_IXOTH)))
1388 xmlOut.addTextElementToData(
"status",
1389 "Failed. Directory create rejected.");
1391 xmlOut.addTextElementToData(
"status",
"1");
1393 else if(cmd ==
"save")
1395 path += PRE_MADE_ROOT_CFG_FILE_EXT;
1397 bool useRunWildCard =
1401 __SUP_COUT__ <<
"config " << config << __E__;
1402 __SUP_COUT__ <<
"useRunWildCard " << useRunWildCard << __E__;
1405 FILE* fp = fopen(path.c_str(),
"r");
1409 xmlOut.addTextElementToData(
"status",
"Failed. File already exists.");
1410 __SUP_COUT__ <<
" Failed. File already exists." << __E__;
1419 fp = fopen(path.c_str(),
"w");
1420 fputs(config.c_str(), fp);
1429 xmlOut.addTextElementToData(
"status",
"1");
1433 xmlOut.addTextElementToData(
1434 "status",
"Failed. Fatal. Improper file format.");
1435 if(remove(path.c_str()) != 0)
1436 __SUP_COUT__ <<
"Failed. Could not remove poorly formed Root "
1442 else if(cmd ==
"delete")
1445 if(rmdir(path.c_str()) == 0 ||
1446 remove((path + PRE_MADE_ROOT_CFG_FILE_EXT).c_str()) == 0)
1447 xmlOut.addTextElementToData(
"status",
"1");
1449 xmlOut.addTextElementToData(
"status",
1450 "Failed. Target could not be deleted.");
1453 xmlOut.addTextElementToData(
"status",
"Failed. Unrecognized command.");
1456 xmlOut.addTextElementToData(
"status",
"Failed. Invalid path.");
1465 std::string fSystemPath = std::string(ROOT_BROWSER_PATH) +
"/";
1467 boost::regex re(
"%2F");
1468 fRootPath = boost::regex_replace(fRootPath, re,
"/");
1469 std::string fullPath = fSystemPath + fRootPath;
1471 STDLINE(std::string(
"Begin: fSystemPath = ") + fSystemPath, ACWhite);
1472 STDLINE(std::string(
"Begin: fRootPath = ") + fRootPath, ACWhite);
1473 STDLINE(std::string(
"Begin: fullPath = ") + fullPath, ACWhite);
1476 xmlOut.setRootPath(fRootPath);
1477 xmlOut.makeDirectoryBinaryTree(fSystemPath, fRootPath, 0, NULL);
1478 std::ostringstream* out =
new std::ostringstream();
1486 std::string fSystemPath = std::string(ROOT_BROWSER_PATH) +
"/";
1492 boost::regex re(
"%2F");
1493 fRootPath = boost::regex_replace(fRootPath, re,
"/");
1494 fFoldersPath = boost::regex_replace(fFoldersPath, re,
"/");
1502 fSystemPath, fRootPath, fFoldersPath, fHistName, fRFoldersPath, fFileName);
1503 xmlOut.setDocument(theExplorer->initialize(
false));
1569 "saveConfiguration")
1572 STDLINE(
"configPayload: ", ACRed);
1573 STDLINE(configPayload, ACYellow);
1576 outFile.open(
"/tmp/configPayload.json", ios::out | ios::app);
1577 outFile << configPayload << endl;
1585 std::string JSONPayLoad =
"";
1586 std::string line =
"";
1588 ifstream JSONFile(
"/tmp/configPayload.json");
1590 if(JSONFile.is_open())
1592 while(getline(JSONFile, line))
1594 JSONPayLoad += line;
1599 xmlOut.addTextElementToData(
"JSONPayLoad", JSONPayLoad);
1607 std::string fsmName = theStateMachine_.getCurrentStateName();
1608 bool in_transition = theStateMachine_.isInTransition();
1610 xmlOut.addTextElementToData(
"current_state", fsmName);
1611 xmlOut.addTextElementToData(
"in_transition", in_transition ?
"1" :
"0");
1615 __SUP_SS__ <<
"requestType Request, " << requestType
1616 <<
", not recognized by the Visual Supervisor (was it intended for "
1617 "another Supervisor?)."
1622 if(theDataManager_ !=
nullptr)
1623 theDataManager_->setDoNotStop(
false);
static std::string postData(cgicc::Cgicc &cgi, const std::string &needle)
static std::string getData(cgicc::Cgicc &cgi, const std::string &needle)
bool isDisconnected(void) const
ConfigurationTree getNode(const std::string &nodeName, bool doNotThrowOnBrokenUIDLinks=false) const
const std::string & getValueAsString(bool returnLinkTableValue=false) const
WebUsers::permissionLevel_t getSupervisorPropertyUserPermissionsThreshold(const std::string &requestType)
virtual void transitionHalting(toolbox::Event::Reference event)
static void deleteInstance(std::string instanceUID)
void copyDataChildren(HttpXmlDocument &document)
bool loadXmlDocument(const std::string &filePath)
void outputXmlDocument(std::ostringstream *out, bool dispStdOut=false, bool allowWhiteSpace=false, bool printErrors=false)
const std::vector< DQMHistosBase * > & getLiveDQMs(void)
virtual void setSupervisorPropertyDefaults(void) override
virtual void forceSupervisorPropertyValues(void) override
virtual void transitionConfiguring(toolbox::Event::Reference e) override
virtual void request(const std::string &requestType, cgicc::Cgicc &cgiIn, HttpXmlDocument &xmlOut, const WebUsers::RequestUserInfo &userInfo) override
void setDarioStyle(bool darioStyle)
void saveXmlDocument(const std::string &filePath)
void INIT_MF(const char *name)
static std::string binaryStringToHexString(const void *binaryBuffer, unsigned int numberOfBytes, const std::string &resultPreamble="", const std::string &resultDelimiter="")