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")
52 #define HISTORY_DIR std::string("History")
54 #define PRE_MADE_ROOT_CFG_FILE_EXT std::string(".rcfg")
56 #define PREFERENCES_PATH std::string(__ENV__("SERVICE_DATA_PATH")) + "/VisualizerData/"
57 #define PREFERENCES_FILE_EXT ".pref"
59 #define ROOT_VIEWER_PERMISSIONS_THRESHOLD 100
64 #define __MF_SUBJECT__ "Visualizer"
69 #define STDLINE(X, Y) __COUT__ << X
72 VisualSupervisor::VisualSupervisor(xdaq::ApplicationStub* stub)
75 __SUP_COUT__ <<
"Constructor." << __E__;
78 mkdir(((std::string)PREFERENCES_PATH).c_str(), 0755);
79 ROOT::EnableThreadSafety();
81 __SUP_COUT__ <<
"Constructed." << __E__;
85 VisualSupervisor::~VisualSupervisor(
void)
87 __SUP_COUT__ <<
"Destructor." << __E__;
89 __SUP_COUT__ <<
"Destructed." << __E__;
93 void VisualSupervisor::destroy(
void)
95 __SUP_COUT__ <<
"Destroying..." << __E__;
98 if(theStateMachineImplementation_.size() > 1)
100 __SS__ <<
"Not expecting more than one visual data manager!" << __E__;
103 if(theStateMachineImplementation_.size())
104 theStateMachineImplementation_.pop_back();
106 __COUT_WARN__ <<
"No visual data manager was pushed." << __E__;
113 __SUP_COUT__ <<
"Configuring..." << __E__;
115 CoreSupervisorBase::configureInit();
121 theConfigurationManager_->__GET_CONFIG__(
XDAQContextTable)->getTableName() +
122 CorePropertySupervisorBase::getSupervisorConfigurationPath());
124 catch(
const std::runtime_error& e)
126 __SS__ <<
"The link to the Visual Supervisor configuration seems to be broken. "
127 "Please check this path: "
131 CorePropertySupervisorBase::getSupervisorConfigurationPath()
132 << __E__ << __E__ << e.what() << __E__;
137 "/" + theConfigurationManager_->__GET_CONFIG__(
XDAQContextTable)->getTableName() +
138 CorePropertySupervisorBase::getSupervisorConfigurationPath());
144 theDataManager_ = DataManagerSingleton::getInstance<VisualDataManager>(
145 theConfigurationManager_->getNode(
148 CorePropertySupervisorBase::getSupervisorConfigurationPath(),
149 CorePropertySupervisorBase::getSupervisorUID());
151 CoreSupervisorBase::theStateMachineImplementation_.push_back(theDataManager_);
153 __SUP_COUT__ <<
"Done instantiating Visual data manager." << __E__;
156 __SUP_COUT__ <<
"No Visual Supervisor configuration link, so skipping Visual "
157 "data manager instantiation."
161 CoreSupervisorBase::transitionConfiguringFSMs();
163 __SUP_COUT__ <<
"Configured." << __E__;
165 catch(
const std::runtime_error& e)
167 __SS__ <<
"Error with VisualSupervisor::transitionConfiguring(): " << e.what()
169 __COUT_ERR__ << ss.str();
173 theStateMachine_.setErrorMessage(ss.str());
174 throw toolbox::fsm::exception::Exception(
177 "VisualSupervisor::transitionConfiguring" ,
184 void VisualSupervisor::transitionHalting(toolbox::Event::Reference e)
186 __SUP_COUT__ <<
"Halting..." << __E__;
191 __SUP_COUT__ <<
"Halted." << __E__;
200 CorePropertySupervisorBase::setSupervisorProperty(
201 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.AllowNoLoginRequestTypes,
202 "setUserPreferences | getUserPreferences | getDirectoryContents | getRoot | "
205 CorePropertySupervisorBase::setSupervisorProperty(
206 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.UserPermissionsThreshold,
207 "*=1 | rootAdminControls=100");
215 CorePropertySupervisorBase::setSupervisorProperty(
216 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.AutomatedRequestTypes,
217 "getRoot | getEvents");
218 CorePropertySupervisorBase::setSupervisorProperty(
219 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.NoXmlWhiteSpaceRequestTypes,
220 "getRoot | getEvents");
228 const WebUsers::RequestUserInfo& userInfo)
255 __SUP_COUT__ <<
"Request type: " << requestType << __E__;
259 __SUP_COUT__ << __E__;
264 if(theDataManager_ ==
nullptr)
266 __SS__ <<
"No data manager instantiated." << __E__;
269 __SUP_COUT__ <<
"Getting Raw data and converting to binary string" << __E__;
272 __SUP_COUT__ << __E__;
273 __SUP_SS__ <<
"Raw data visualizion is deprecated!" << __E__;
276 catch(std::exception
const& e)
279 <<
"ERROR! Exception while getting raw data. Incoming exception data..."
281 __SUP_COUT__ << e.what() << __E__;
282 __SUP_COUT__ <<
"End Exception Data" << __E__;
286 __SUP_COUT__ <<
"ERROR! Something went wrong trying to get raw data."
292 catch(
const std::exception& e)
294 __SUP_COUT_ERR__ <<
"Exception message: " << e.what();
299 __SUP_COUT_INFO__ <<
"ERROR! Something went wrong trying to get raw data."
304 requestType ==
"setUserPreferences" &&
305 userInfo.username_ !=
308 __SUP_COUT__ <<
"userInfo.username_: " << userInfo.username_ << __E__;
309 std::string fullPath =
310 (std::string)PREFERENCES_PATH + userInfo.username_ + PREFERENCES_FILE_EXT;
311 __SUP_COUT__ <<
"fullPath: " << fullPath << __E__;
317 std::string autoRefreshPeriod =
320 __SUP_COUT__ <<
"radioSelect: " << radioSelect << __E__;
321 __SUP_COUT__ <<
"autoRefresh: " << autoRefresh << __E__;
322 __SUP_COUT__ <<
"autoHide: " << autoHide << __E__;
323 __SUP_COUT__ <<
"hardRefresh: " << hardRefresh << __E__;
324 __SUP_COUT__ <<
"autoRefreshPeriod: " << autoRefreshPeriod << __E__;
327 FILE* fp = fopen(fullPath.c_str(),
"r");
333 fgets(line, 100, fp);
334 sscanf(line,
"%*s %s", val);
335 if(radioSelect ==
"")
338 fgets(line, 100, fp);
339 sscanf(line,
"%*s %s", val);
340 if(autoRefresh ==
"")
343 fgets(line, 100, fp);
344 sscanf(line,
"%*s %s", val);
348 fgets(line, 100, fp);
349 sscanf(line,
"%*s %s", val);
350 if(hardRefresh ==
"")
353 fgets(line, 100, fp);
354 sscanf(line,
"%*s %s", val);
355 if(autoRefreshPeriod ==
"")
356 autoRefreshPeriod = val;
362 fp = fopen(fullPath.c_str(),
"w");
365 fprintf(fp,
"radioSelect %s\n", radioSelect.c_str());
366 fprintf(fp,
"autoRefresh %s\n", autoRefresh.c_str());
367 fprintf(fp,
"autoHide %s\n", autoHide.c_str());
368 fprintf(fp,
"hardRefresh %s\n", hardRefresh.c_str());
369 fprintf(fp,
"autoRefreshPeriod %s\n", autoRefreshPeriod.c_str());
373 __SUP_COUT_ERR__ <<
"Failure writing preferences to file: " << fullPath
378 "getUserPreferences")
380 __SUP_COUT__ <<
"Next is userinfo" << __E__;
381 __SUP_COUT__ <<
"userInfo.username_: " << userInfo.username_ << __E__;
382 std::string fullPath =
383 (std::string)PREFERENCES_PATH + userInfo.username_ + PREFERENCES_FILE_EXT;
384 __SUP_COUT__ <<
"fullPath: " << fullPath << __E__;
386 FILE* fp = fopen(fullPath.c_str(),
"r");
393 fgets(line, 100, fp);
394 sscanf(line,
"%*s %d", &val);
395 if(val < 0 || val > 3)
397 xmlOut.addTextElementToData(
"radioSelect", std::to_string(val));
398 fgets(line, 100, fp);
399 sscanf(line,
"%*s %d", &val);
400 xmlOut.addTextElementToData(
"autoRefresh", std::to_string(val));
401 fgets(line, 100, fp);
402 sscanf(line,
"%*s %d", &val);
403 xmlOut.addTextElementToData(
"autoHide", std::to_string(val));
404 fgets(line, 100, fp);
405 sscanf(line,
"%*s %d", &val);
406 xmlOut.addTextElementToData(
"hardRefresh", std::to_string(val));
407 fgets(line, 100, fp);
408 sscanf(line,
"%*s %d", &val);
409 xmlOut.addTextElementToData(
"autoRefreshPeriod", std::to_string(val));
415 xmlOut.addTextElementToData(
"radioSelect",
"");
416 xmlOut.addTextElementToData(
"autoRefresh",
"");
417 xmlOut.addTextElementToData(
"autoHide",
"");
418 xmlOut.addTextElementToData(
"hardRefresh",
"");
419 xmlOut.addTextElementToData(
"autoRefreshPeriod",
"");
421 __SUP_COUT__ <<
"Done with preferences!" << __E__;
425 "getDirectoryContents")
428 std::string rootpath =
429 std::string(ROOT_BROWSER_PATH) +
432 boost::regex re(
"%2F");
433 path = boost::regex_replace(path, re,
"/");
443 userInfo.permissionLevel_ >=
445 "rootAdminControls"));
446 xmlOut.addTextElementToData(
"permissions", permStr);
450 std::string dirpath = rootpath + path;
452 if(path ==
"/" + PRE_MADE_ROOT_CFG_DIR +
"/")
453 dirpath = ROOT_DISPLAY_CONFIG_PATH;
455 if(path.find(
"/" + PRE_MADE_ROOT_CFG_DIR +
"/") ==
457 dirpath = std::string(ROOT_DISPLAY_CONFIG_PATH) +
"/" +
458 path.substr(PRE_MADE_ROOT_CFG_DIR.length() + 2);
461 if(path ==
"/" + HISTORY_DIR +
"/")
462 dirpath = std::string(ROOT_BROWSER_PATH) +
"/";
463 else if(path.find(
"/" + HISTORY_DIR +
"/") == 0)
464 dirpath = std::string(ROOT_BROWSER_PATH) +
"/" +
465 path.substr(HISTORY_DIR.length() + 2);
468 __SUP_COUT__ <<
"rootpath:-" << rootpath <<
"-path:-" << path <<
"-dirpath:-"
469 << dirpath <<
"-" << __E__;
472 struct dirent* entry;
475 if((pDIR = opendir(dirpath.c_str())))
477 xmlOut.addTextElementToData(
"path", path);
478 xmlOut.addTextElementToData(
"headOfSearch",
"located");
483 if(theDataManager_ !=
nullptr)
484 __COUT__ <<
"path-" << path <<
"-DM: " << theDataManager_
485 <<
" Live: " << theDataManager_->getLiveDQMHistos() << std::endl;
489 xmlOut.addTextElementToData(
"dir",
490 LIVEDQM_DIR +
".root");
493 DIR* pRtDIR = opendir(ROOT_DISPLAY_CONFIG_PATH);
494 bool recheck =
false;
498 if(mkdir(ROOT_DISPLAY_CONFIG_PATH,
499 S_IRWXU | (S_IRGRP | S_IXGRP) |
500 (S_IROTH | S_IXOTH)))
501 __SUP_COUT__ <<
"Failed to make directory for pre made views: "
502 << ROOT_DISPLAY_CONFIG_PATH << __E__;
507 if(!recheck || (pRtDIR = opendir(ROOT_DISPLAY_CONFIG_PATH)))
511 xmlOut.addTextElementToData(
"dir",
512 PRE_MADE_ROOT_CFG_DIR);
517 xmlOut.addTextElementToData(
"dir", HISTORY_DIR);
521 while((entry = readdir(pDIR)))
525 if(entry->d_name[0] !=
'.' &&
528 entry->d_type == 4 ||
534 std::string(entry->d_name).find(
".rcfg") == std::string::npos;
537 if(entry->d_type == 0)
541 DIR* pTmpDIR = opendir((dirpath + entry->d_name).c_str());
551 if((entry->d_type == 8 ||
552 (!isDir && entry->d_type == 0))
553 && std::string(entry->d_name).find(
".root") ==
557 else if(entry->d_type == 4)
560 xmlOut.addTextElementToData(
561 isDir ?
"dir" : (isNotRtCfg ?
"dir" :
"file"), entry->d_name);
567 __SUP_COUT__ <<
"Failed to access directory contents!" << __E__;
580 std::string filePath = path;
581 if(filePath.find(
"/" + HISTORY_DIR +
"/") == 0)
582 filePath = filePath.substr(HISTORY_DIR.length() + 1);
585 filePath.find(
".root") + 5;
586 std::string rootFileName =
587 std::string(__ENV__(
"ROOT_BROWSER_PATH")) + filePath.substr(0, splitter);
588 __SUP_COUTV__(rootFileName);
590 std::string rootDirectoryName =
591 filePath.substr(splitter, filePath.length() - splitter);
592 __SUP_COUTV__(rootDirectoryName);
597 bool isLiveDQM = (path.find(
"/" + LIVEDQM_DIR +
".root/") == 0) ?
true :
false;
598 __SUP_COUTV__(isLiveDQM);
600 TFile* rootFile =
nullptr;
601 TObject* tObject =
nullptr;
602 TDirectory* tDirectory =
nullptr;
606 rootFile = TFile::Open(rootFileName.c_str());
608 if(rootFile ==
nullptr || !rootFile->IsOpen())
610 __SUP_SS__ <<
"Failed to access ROOT file: " << rootFileName << __E__;
615 if((tObject = rootFile->Get(rootDirectoryName.c_str())) !=
617 (rootDirectoryName.size() &&
618 rootDirectoryName[0] ==
'/' &&
619 (tObject = rootFile->Get(rootDirectoryName.substr(1).c_str())) !=
622 if(tObject->IsA() == TCanvas::Class())
624 static_cast<TCanvas*
>(tObject)->Modified();
625 static_cast<TCanvas*
>(tObject)->Update();
627 TString json = TBufferJSON::ConvertToJSON(tObject);
628 TBufferFile tBuffer(TBuffer::kWrite);
629 tObject->Streamer(tBuffer);
631 tBuffer.Buffer(), tBuffer.Length());
633 __SUP_COUT__ <<
"Returning object from file '" << tObject->GetName()
634 <<
"' of class '" << tObject->ClassName() << __E__;
636 xmlOut.addTextElementToData(
"path", path);
637 xmlOut.addTextElementToData(
"rootType", tObject->ClassName());
638 xmlOut.addTextElementToData(
"rootData", hexString);
639 xmlOut.addTextElementToData(
"rootJSON", json.Data());
641 else if((tDirectory = rootFile->GetDirectory(rootDirectoryName.c_str())) !=
645 TIter next(tDirectory->GetListOfKeys());
646 xmlOut.addTextElementToData(
"path", path);
647 while((key = (TKey*)next()))
649 TString s = key->GetName();
650 TRegexp re(
"*", kTRUE);
651 if(s.Index(re) == kNPOS)
653 __SUP_COUT__ <<
"Class Name: " << key->GetClassName() << __E__;
654 xmlOut.addTextElementToData(
655 (std::string(key->GetClassName()).find(
"Directory") !=
657 std::string(key->GetClassName()) ==
"TTree" ||
658 std::string(key->GetClassName()).find(
"TBranch") !=
667 tObject = key->ReadObj();
668 __SUP_COUT__ <<
"JSON : " << key->GetClassName() << __E__;
670 TString json = TBufferJSON::ConvertToJSON(tObject);
671 TBufferFile tBuffer(TBuffer::kWrite);
672 tObject->Streamer(tBuffer);
673 std::string hexString =
677 __SUP_COUT__ <<
"Returning directory object from file '"
678 << tObject->GetName() <<
"' of class '"
679 << tObject->ClassName() << __E__;
681 __SUP_COUTV__(json.Data());
687 __SUP_COUT_ERR__ <<
"Failed to find object " << rootDirectoryName
688 <<
" in " << rootFileName << __E__;
692 else if(theDataManager_ !=
nullptr && theDataManager_->isReady())
694 if(theDataManager_ !=
nullptr)
695 theDataManager_->setDoNotStop(
true);
698 __SUP_COUT__ <<
"Attempting to get LIVE ROOT object." << __E__;
700 std::vector<DQMHistosBase*> dqmConsumers = theDataManager_->
getLiveDQMs();
702 for(
auto const& consumer : dqmConsumers)
704 rootFile = consumer->getFile();
705 __SUP_COUT__ <<
"LIVE file name: " << rootFile->GetName() << __E__;
706 if(rootFile ==
nullptr || !rootFile->IsOpen())
708 __SUP_SS__ <<
"Failed to access LIVE ROOT file: " << rootFileName
710 theDataManager_->setDoNotStop(
false);
714 if((tObject = rootFile->Get(rootDirectoryName.c_str())) !=
nullptr)
716 __SUP_COUT__ <<
"Object class name: " << tObject->ClassName()
718 std::string tmpClassName = tObject->ClassName();
720 TBufferFile tBuffer(TBuffer::kWrite);
721 if(tObject->IsA() == TCanvas::Class())
723 static_cast<TCanvas*
>(tObject)->Modified();
724 static_cast<TCanvas*
>(tObject)->Update();
727 std::unique_lock<std::mutex> lock(
729 ->getFillHistoMutex());
730 json = TBufferJSON::ConvertToJSON(tObject);
731 tObject->Streamer(tBuffer);
734 tBuffer.Buffer(), tBuffer.Length());
736 __SUP_COUT__ <<
"Returning object '" << tObject->GetName()
737 <<
"' of class '" << tObject->ClassName() << __E__;
740 xmlOut.addTextElementToData(
"path", path);
741 xmlOut.addTextElementToData(
"rootType", tObject->ClassName());
742 xmlOut.addTextElementToData(
"rootData", hexString);
743 xmlOut.addTextElementToData(
"rootJSON", json.Data());
745 theDataManager_->setDoNotStop(
false);
750 std::map<std::string, std::string> dirList;
752 for(
auto const& consumer : dqmConsumers)
754 __SUP_COUT__ <<
"Attempting to get LIVE ROOT directory." << __E__;
755 rootFile = consumer->getFile();
756 __SUP_COUT__ <<
"LIVE file name: " << rootFile->GetName() << __E__;
757 if(rootFile ==
nullptr || !rootFile->IsOpen())
759 __SUP_SS__ <<
"Failed to access LIVE ROOT file: " << rootFileName
761 xmlOut.addTextElementToData(
"Warning", ss.str());
762 theDataManager_->setDoNotStop(
false);
765 if((tDirectory = rootFile->GetDirectory(rootDirectoryName.c_str())) !=
768 xmlOut.addTextElementToData(
"path", path);
769 __SUP_COUT__ <<
"Directory found getting the content!" << __E__;
770 TRegexp re(
"*", kTRUE);
772 TIter nextobj(tDirectory->GetList());
773 while((obj = (TObject*)nextobj()))
775 TString s = obj->GetName();
776 if(s.Index(re) == kNPOS)
778 __SUP_COUT__ <<
"Class Name: " << obj->IsA()->GetName() << __E__;
779 dirList[obj->GetName()] =
780 (std::string(obj->IsA()->GetName()).find(
"Directory") !=
782 std::string(obj->IsA()->GetName()) ==
"TTree" ||
783 std::string(obj->IsA()->GetName()).find(
"TBranch") !=
790 for(
auto const& dir : dirList)
792 xmlOut.addTextElementToData(dir.second, dir.first);
793 __SUP_COUT__ <<
"Class Name: " << dir.second <<
" Object: " << dir.first
1201 if(theDataManager_ ==
nullptr)
1203 __SS__ <<
"No Data Manager instantiated." << __E__;
1207 int Run = atoi(cgiIn(
"run").c_str());
1209 __SUP_COUT__ <<
"getEvents for run " << Run << __E__;
1211 if(Run != (
int)loadedRunNumber_ || loadedRunNumber_ == (
unsigned int)-1)
1213 theDataManager_->load(
"Run1684.root",
"Monicelli");
1214 loadedRunNumber_ = Run;
1217 xmlOut.addTextElementToData(
"events",
"");
1260 __SUP_COUT__ <<
"Done hits xml" << __E__;
1266 __SUP_COUT__ <<
"getGeometry" << __E__;
1268 if(theDataManager_ ==
nullptr)
1270 __SS__ <<
"No Data Manager instantiated." << __E__;
1275 theDataManager_->load(
"Run1684.geo",
"Geometry");
1277 __SUP_COUT__ <<
"getGeometry" << __E__;
1279 xmlOut.addTextElementToData(
"geometry",
"");
1315 __SUP_COUT__ <<
"path " << path << __E__;
1317 if(path.find(
"/" + PRE_MADE_ROOT_CFG_DIR +
"/") ==
1320 path = std::string(ROOT_DISPLAY_CONFIG_PATH) +
"/" +
1321 path.substr(PRE_MADE_ROOT_CFG_DIR.length() + 2);
1322 __SUP_COUT__ <<
"mod path " << path << __E__;
1328 xmlOut.addTextElementToData(
"status",
"1");
1333 xmlOut.addTextElementToData(
"status",
1334 "Failed. File to properly load config file.");
1338 "rootAdminControls")
1350 std::string cmd = cgiIn(
"cmd");
1357 __SUP_COUT__ <<
"cmd " << cmd << __E__;
1358 __SUP_COUT__ <<
"path " << path << __E__;
1359 __SUP_COUT__ <<
"name " << name << __E__;
1361 if(path.find(
"/" + PRE_MADE_ROOT_CFG_DIR +
"/") ==
1364 path = std::string(ROOT_DISPLAY_CONFIG_PATH) +
"/" +
1365 path.substr(PRE_MADE_ROOT_CFG_DIR.length() + 2) + name;
1366 __SUP_COUT__ <<
"mod path " << path << __E__;
1370 if(mkdir(path.c_str(),
1371 S_IRWXU | (S_IRGRP | S_IXGRP) |
1372 (S_IROTH | S_IXOTH)))
1373 xmlOut.addTextElementToData(
"status",
1374 "Failed. Directory create rejected.");
1376 xmlOut.addTextElementToData(
"status",
"1");
1378 else if(cmd ==
"save")
1380 path += PRE_MADE_ROOT_CFG_FILE_EXT;
1382 bool useRunWildCard =
1386 __SUP_COUT__ <<
"config " << config << __E__;
1387 __SUP_COUT__ <<
"useRunWildCard " << useRunWildCard << __E__;
1390 FILE* fp = fopen(path.c_str(),
"r");
1394 xmlOut.addTextElementToData(
"status",
"Failed. File already exists.");
1395 __SUP_COUT__ <<
" Failed. File already exists." << __E__;
1404 fp = fopen(path.c_str(),
"w");
1405 fputs(config.c_str(), fp);
1414 xmlOut.addTextElementToData(
"status",
"1");
1418 xmlOut.addTextElementToData(
1419 "status",
"Failed. Fatal. Improper file format.");
1420 if(remove(path.c_str()) != 0)
1421 __SUP_COUT__ <<
"Failed. Could not remove poorly formed Root "
1427 else if(cmd ==
"delete")
1430 if(rmdir(path.c_str()) == 0 ||
1431 remove((path + PRE_MADE_ROOT_CFG_FILE_EXT).c_str()) == 0)
1432 xmlOut.addTextElementToData(
"status",
"1");
1434 xmlOut.addTextElementToData(
"status",
1435 "Failed. Target could not be deleted.");
1438 xmlOut.addTextElementToData(
"status",
"Failed. Unrecognized command.");
1441 xmlOut.addTextElementToData(
"status",
"Failed. Invalid path.");
1450 std::string fSystemPath = std::string(ROOT_BROWSER_PATH) +
"/";
1452 boost::regex re(
"%2F");
1453 fRootPath = boost::regex_replace(fRootPath, re,
"/");
1454 std::string fullPath = fSystemPath + fRootPath;
1456 STDLINE(std::string(
"Begin: fSystemPath = ") + fSystemPath, ACWhite);
1457 STDLINE(std::string(
"Begin: fRootPath = ") + fRootPath, ACWhite);
1458 STDLINE(std::string(
"Begin: fullPath = ") + fullPath, ACWhite);
1461 xmlOut.setRootPath(fRootPath);
1462 xmlOut.makeDirectoryBinaryTree(fSystemPath, fRootPath, 0, NULL);
1463 std::ostringstream* out =
new std::ostringstream();
1471 std::string fSystemPath = std::string(ROOT_BROWSER_PATH) +
"/";
1477 boost::regex re(
"%2F");
1478 fRootPath = boost::regex_replace(fRootPath, re,
"/");
1479 fFoldersPath = boost::regex_replace(fFoldersPath, re,
"/");
1487 fSystemPath, fRootPath, fFoldersPath, fHistName, fRFoldersPath, fFileName);
1488 xmlOut.setDocument(theExplorer->initialize(
false));
1554 "saveConfiguration")
1557 STDLINE(
"configPayload: ", ACRed);
1558 STDLINE(configPayload, ACYellow);
1561 outFile.open(
"/tmp/configPayload.json", ios::out | ios::app);
1562 outFile << configPayload << endl;
1570 std::string JSONPayLoad =
"";
1571 std::string line =
"";
1573 ifstream JSONFile(
"/tmp/configPayload.json");
1575 if(JSONFile.is_open())
1577 while(getline(JSONFile, line))
1579 JSONPayLoad += line;
1584 xmlOut.addTextElementToData(
"JSONPayLoad", JSONPayLoad);
1592 std::string fsmName = theStateMachine_.getCurrentStateName();
1593 bool in_transition = theStateMachine_.isInTransition();
1595 xmlOut.addTextElementToData(
"current_state", fsmName);
1596 xmlOut.addTextElementToData(
"in_transition", in_transition ?
"1" :
"0");
1600 __SUP_SS__ <<
"requestType Request, " << requestType
1601 <<
", not recognized by the Visual Supervisor (was it intended for "
1602 "another Supervisor?)."
1607 if(theDataManager_ !=
nullptr)
1608 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="")