diff --git a/otsdaq/GatewaySupervisor/GatewaySupervisor.cc b/otsdaq/GatewaySupervisor/GatewaySupervisor.cc index 210e1086..3c9e15c7 100644 --- a/otsdaq/GatewaySupervisor/GatewaySupervisor.cc +++ b/otsdaq/GatewaySupervisor/GatewaySupervisor.cc @@ -1328,6 +1328,15 @@ try __COUTVS__(25,value); remoteGatewayApp.appInfo.lastStatusTime = atoi(value.c_str()); + value = StringMacros::extractXmlField(remoteStatusString, "url", 0, after); + __COUTVS__(25,value); + remoteGatewayApp.appInfo.parent_url = value; + + value = StringMacros::extractXmlField(remoteStatusString, "id", 0, after); + __COUTVS__(25,value); + remoteGatewayApp.appInfo.id = atoi(value.c_str()); + + } //end found Remote Gateway status else //found remote subapp { @@ -1352,6 +1361,13 @@ try __COUTVS__(25,value); remoteGatewayApp.subapps[name].lastStatusTime = atoi(value.c_str()); + value = StringMacros::extractXmlField(remoteStatusString, "url", 0, after); + __COUTVS__(25,value); + remoteGatewayApp.subapps[name].parent_url = value; + + value = StringMacros::extractXmlField(remoteStatusString, "id", 0, after); + __COUTVS__(25,value); + remoteGatewayApp.subapps[name].id = atoi(value.c_str()); } } //end primary loop @@ -5948,13 +5964,12 @@ try xmlOut.addTextElementToData("name", appInfo.getName()); // get application name - xmlOut.addTextElementToData("id", std::to_string(appInfo.getId())); // get application id + xmlOut.addNumberElementToData("id", appInfo.getId()); // get application id xmlOut.addTextElementToData("status", appInfo.getStatus()); // get status xmlOut.addTextElementToData( "time", appInfo.getLastStatusTime() ? StringMacros::getTimestampString(appInfo.getLastStatusTime()) : "0"); // get time stamp - xmlOut.addTextElementToData("stale", - std::to_string(time(0) - appInfo.getLastStatusTime())); // time since update - xmlOut.addTextElementToData("progress", std::to_string(appInfo.getProgress())); // get progress + xmlOut.addNumberElementToData("stale", time(0) - appInfo.getLastStatusTime()); // time since update + xmlOut.addNumberElementToData("progress", appInfo.getProgress()); // get progress xmlOut.addTextElementToData("detail", appInfo.getDetail()); // get detail xmlOut.addTextElementToData("class", appInfo.getClass()); // get application class @@ -5970,10 +5985,11 @@ try xmlOut.addTextElementToParent("subapp_time", subappInfoPair.second.lastStatusTime ? StringMacros::getTimestampString(subappInfoPair.second.lastStatusTime) : "0", subappElement); // get timestamp - xmlOut.addTextElementToParent("subapp_stale", std::to_string(time(0) - subappInfoPair.second.lastStatusTime), subappElement); // time since update - xmlOut.addTextElementToParent("subapp_progress", std::to_string(subappInfoPair.second.progress), subappElement); // get progress + xmlOut.addNumberElementToParent("subapp_stale", time(0) - subappInfoPair.second.lastStatusTime, subappElement); // time since update + xmlOut.addNumberElementToParent("subapp_progress", subappInfoPair.second.progress, subappElement); // get progress xmlOut.addTextElementToParent("subapp_detail", subappInfoPair.second.detail, subappElement); // get detail - xmlOut.addTextElementToParent("subapp_url", subappInfoPair.second.url, subappElement); // get url + xmlOut.addTextElementToParent("subapp_url", subappInfoPair.second.url, subappElement); // get detail + xmlOut.addNumberElementToParent("subapp_id", subappInfoPair.second.id, subappElement); // get url xmlOut.addTextElementToParent("subapp_class", subappInfoPair.second.class_name, subappElement); // get class } @@ -5995,32 +6011,31 @@ try xmlOut.addTextElementToData("name", appInfo.name); // get application name - xmlOut.addTextElementToData("id", std::to_string(-1)); // get application id + xmlOut.addNumberElementToData("id", appInfo.id); // get application id xmlOut.addTextElementToData("status", appInfo.status); // get status - xmlOut.addTextElementToData( - "time", appInfo.lastStatusTime ? StringMacros::getTimestampString(appInfo.lastStatusTime) : "0"); // get timestamp - xmlOut.addTextElementToData("stale", - std::to_string(time(0) - appInfo.lastStatusTime)); // time since update - xmlOut.addTextElementToData("progress", std::to_string(appInfo.progress)); // get progress - xmlOut.addTextElementToData("detail", appInfo.detail); // get detail - xmlOut.addTextElementToData("class", - appInfo.class_name); // get application class - xmlOut.addTextElementToData("url", - appInfo.url); // get application url - xmlOut.addTextElementToData("context", "Remote-" + - appInfo.url); // get context + xmlOut.addTextElementToData("time", appInfo.lastStatusTime ? + StringMacros::getTimestampString(appInfo.lastStatusTime) : "0"); // get timestamp + xmlOut.addNumberElementToData("stale", + time(0) - appInfo.lastStatusTime); // time since update + xmlOut.addNumberElementToData("progress", appInfo.progress); // get progress + xmlOut.addTextElementToData("detail", appInfo.detail); // get detail + xmlOut.addTextElementToData("class", appInfo.class_name); // get application class + xmlOut.addTextElementToData("url", appInfo.parent_url); // get application url + xmlOut.addTextElementToData("context", appInfo.name + " at " + appInfo.url); // get context auto subappElement = xmlOut.addTextElementToData("subapps", ""); for(auto& subappInfoPair : remoteApp.subapps) { xmlOut.addTextElementToParent("subapp_name", subappInfoPair.first, subappElement); xmlOut.addTextElementToParent("subapp_status", subappInfoPair.second.status, subappElement); // get status xmlOut.addTextElementToParent("subapp_time", - subappInfoPair.second.lastStatusTime ? StringMacros::getTimestampString(subappInfoPair.second.lastStatusTime) : "0", + subappInfoPair.second.lastStatusTime ? + StringMacros::getTimestampString(subappInfoPair.second.lastStatusTime) : "0", subappElement); // get time stamp - xmlOut.addTextElementToParent("subapp_stale", std::to_string(time(0) - subappInfoPair.second.lastStatusTime), subappElement); // time since update - xmlOut.addTextElementToParent("subapp_progress", std::to_string(subappInfoPair.second.progress), subappElement); // get progress + xmlOut.addNumberElementToParent("subapp_stale", time(0) - subappInfoPair.second.lastStatusTime, subappElement); // time since update + xmlOut.addNumberElementToParent("subapp_progress", subappInfoPair.second.progress, subappElement); // get progress xmlOut.addTextElementToParent("subapp_detail", subappInfoPair.second.detail, subappElement); // get detail - xmlOut.addTextElementToParent("subapp_url", subappInfoPair.second.url, subappElement); // get url + xmlOut.addTextElementToParent("subapp_url", subappInfoPair.second.parent_url, subappElement); // get detail + xmlOut.addNumberElementToParent("subapp_id", subappInfoPair.second.id, subappElement); // get url xmlOut.addTextElementToParent("subapp_class", subappInfoPair.second.class_name, subappElement); // get class } @@ -6049,10 +6064,8 @@ try } for(const auto& remoteGatewayApp : remoteGatewayApps) - { - xmlOut.addTextElementToData("RemoteGateway", "Remote-" + - remoteGatewayApp.appInfo.url); - } //end remote subsystem loop + xmlOut.addTextElementToData("RemoteGateway", + remoteGatewayApp.appInfo.name + " at " + remoteGatewayApp.appInfo.url); } else if(requestType == "getSystemMessages") { diff --git a/otsdaq/SupervisorInfo/SupervisorInfo.h b/otsdaq/SupervisorInfo/SupervisorInfo.h index 29e3a60b..18b77932 100755 --- a/otsdaq/SupervisorInfo/SupervisorInfo.h +++ b/otsdaq/SupervisorInfo/SupervisorInfo.h @@ -63,10 +63,10 @@ class SupervisorInfo struct SubappInfo { std::string name; // Also key in map std::string status; - unsigned int progress; + unsigned int progress, id; std::string detail; time_t lastStatusTime; - std::string url; + std::string url, parent_url; std::string class_name; }; // end SubappInfo struct diff --git a/otsdaq/XmlUtilities/HttpXmlDocument.h b/otsdaq/XmlUtilities/HttpXmlDocument.h index f2d2bcb9..1e962ccc 100644 --- a/otsdaq/XmlUtilities/HttpXmlDocument.h +++ b/otsdaq/XmlUtilities/HttpXmlDocument.h @@ -25,6 +25,8 @@ class HttpXmlDocument : public XmlDocument template xercesc::DOMElement* addNumberElementToData (const std::string & field , const T & value ) { return addTextElementToData(field,std::to_string(value)); } xercesc::DOMElement* addBinaryStringToData (const std::string & field , const std::string & binary ); + template + xercesc::DOMElement* addNumberElementToParent (const std::string & field , const T & value, xercesc::DOMElement* parent) { return addTextElementToParent(field,std::to_string(value),parent); } void copyDataChildren ( HttpXmlDocument & document ); std::string getMatchingValue (const std::string & field , const unsigned int occurance = 0 ); void getAllMatchingValues (const std::string & field , std::vector & retVec); diff --git a/otsdaq/XmlUtilities/XmlDocument.cc b/otsdaq/XmlUtilities/XmlDocument.cc index fd032f1e..7c7ddb44 100644 --- a/otsdaq/XmlUtilities/XmlDocument.cc +++ b/otsdaq/XmlUtilities/XmlDocument.cc @@ -43,7 +43,7 @@ using namespace ots; //============================================================================== -XmlDocument::XmlDocument(std::string rootName) : rootTagName_(rootName) +XmlDocument::XmlDocument(const std::string& rootName) : rootTagName_(rootName) { //__COUT__ << "in" << std::endl; initDocument(); @@ -177,7 +177,7 @@ void XmlDocument::terminatePlatform(void) // addTextElementToParent // add to parent by pointer to parent // returns pointer to element that is added -xercesc::DOMElement* XmlDocument::addTextElementToParent(std::string childName, std::string childText, xercesc::DOMElement* parent) +xercesc::DOMElement* XmlDocument::addTextElementToParent(const std::string& childName, const std::string& childText, xercesc::DOMElement* parent) { if(parent == 0) { @@ -217,7 +217,7 @@ xercesc::DOMElement* XmlDocument::addTextElementToParent(std::string childName, // addTextElementToParent // add to parent by instance number of parent name // returns pointer to element that is added -xercesc::DOMElement* XmlDocument::addTextElementToParent(std::string childName, std::string childText, std::string parentName, unsigned int parentIndex) +xercesc::DOMElement* XmlDocument::addTextElementToParent(const std::string& childName, const std::string& childText, const std::string&parentName, unsigned int parentIndex) { xercesc::DOMNodeList* nodeList = theDocument_->getElementsByTagName(CONVERT_TO_XML(parentName)); @@ -449,7 +449,7 @@ void XmlDocument::setDocument(xercesc::DOMDocument* doc) { theDocument_ = doc; } //============================================================================== // XmlDocument::recursiveOutputXmlDocument // recursively printout XML theDocument_ to std out and output stream if not null -void XmlDocument::recursiveOutputXmlDocument(xercesc::DOMElement* currEl, std::ostringstream* out, bool dispStdOut, std::string tabStr) +void XmlDocument::recursiveOutputXmlDocument(xercesc::DOMElement* currEl, std::ostringstream* out, bool dispStdOut, const std::string& tabStr) { // open field tag if(dispStdOut) @@ -597,7 +597,7 @@ void XmlDocument::recursiveRemoveChild(xercesc::DOMElement* childEl, xercesc::DO // XmlDocument::saveXmlDocument // wrapper for private outputXML // Warning: filePath must be accessible or program will crash! -void XmlDocument::saveXmlDocument(std::string filePath) +void XmlDocument::saveXmlDocument(const std::string& filePath) { __COUT__ << "Saving theDocument_ to file: " << filePath << std::endl; // Return the first registered theImplementation_ that has the desired features. In @@ -700,7 +700,7 @@ void XmlDocument::saveXmlDocument(std::string filePath) } //============================================================================== -bool XmlDocument::loadXmlDocument(std::string filePath) +bool XmlDocument::loadXmlDocument(const std::string& filePath) { __COUT__ << "Loading theDocument_ from file: " << filePath << std::endl; @@ -746,16 +746,16 @@ bool XmlDocument::loadXmlDocument(std::string filePath) } // clang-format off //============================================================================ -void XmlDocument::setAnchors(std::string fSystemPath, - std::string fRootPath) +void XmlDocument::setAnchors(const std::string& fSystemPath, + const std::string& fRootPath) { fSystemPath_ = fSystemPath; fRootPath_ = fRootPath; } //============================================================================ -void XmlDocument::makeDirectoryBinaryTree(std::string fSystemPath, - std::string fRootPath, +void XmlDocument::makeDirectoryBinaryTree(const std::string& fSystemPath, + const std::string& fRootPath, int indent, xercesc::DOMElement* anchorNode) { @@ -844,7 +844,7 @@ void XmlDocument::makeDirectoryBinaryTree(std::string fSystemPath, //========================================================================================== xercesc::DOMElement* XmlDocument::populateBinaryTreeNode(xercesc::DOMElement* anchorNode, - std::string name, + const std::string& name, int indent, bool isLeaf) { diff --git a/otsdaq/XmlUtilities/XmlDocument.h b/otsdaq/XmlUtilities/XmlDocument.h index d010d0d7..16e3bf8f 100644 --- a/otsdaq/XmlUtilities/XmlDocument.h +++ b/otsdaq/XmlUtilities/XmlDocument.h @@ -35,23 +35,23 @@ class XmlDocument { //--------------------------------------------------------------------------------------------------------------- public: - XmlDocument(std::string rootName = "ROOT"); + XmlDocument(const std::string& rootName = "ROOT"); XmlDocument(const XmlDocument& doc); XmlDocument& operator=(const XmlDocument& doc); ~XmlDocument(void); - xercesc::DOMElement* addTextElementToParent(std::string childName, std::string childText, xercesc::DOMElement* parent); - xercesc::DOMElement* addTextElementToParent(std::string childName, std::string childText, std::string parentName, unsigned int parentIndex = 0); - void saveXmlDocument(std::string filePath); + xercesc::DOMElement* addTextElementToParent(const std::string& childName, const std::string& childText, xercesc::DOMElement* parent); + xercesc::DOMElement* addTextElementToParent(const std::string& childName, const std::string& childText, const std::string& parentName, unsigned int parentIndex = 0); + void saveXmlDocument(const std::string& filePath); void recursiveRemoveChild(xercesc::DOMElement* childEl, xercesc::DOMElement* parentEl); - bool loadXmlDocument(std::string filePath); + bool loadXmlDocument(const std::string& filePath); void outputXmlDocument(std::ostringstream* out, bool dispStdOut = false); - void makeDirectoryBinaryTree(std::string name, std::string rootPath, int indent, xercesc::DOMElement* anchorNode); - xercesc::DOMElement* populateBinaryTreeNode(xercesc::DOMElement* anchorNode, std::string name, int indent, bool isLeaf); - void setAnchors(std::string fSystemPath, std::string fRootPath); + void makeDirectoryBinaryTree(const std::string& name, const std::string& rootPath, int indent, xercesc::DOMElement* anchorNode); + xercesc::DOMElement* populateBinaryTreeNode(xercesc::DOMElement* anchorNode, const std::string& name, int indent, bool isLeaf); + void setAnchors(const std::string& fSystemPath, const std::string& fRootPath); void setDocument(xercesc::DOMDocument* doc); void setDarioStyle(bool darioStyle); - void setRootPath(std::string rootPath) { fRootPath_ = rootPath; } + void setRootPath(const std::string& rootPath) { fRootPath_ = rootPath; } //--------------------------------------------------------------------------------------------------------------- protected: void copyDocument(const xercesc::DOMDocument* toCopy, xercesc::DOMDocument* copy); @@ -59,7 +59,7 @@ class XmlDocument void initDocument(void); void initPlatform(void); void terminatePlatform(void); - void recursiveOutputXmlDocument(xercesc::DOMElement* currEl, std::ostringstream* out, bool dispStdOut = false, std::string tabStr = ""); + void recursiveOutputXmlDocument(xercesc::DOMElement* currEl, std::ostringstream* out, bool dispStdOut = false, const std::string& tabStr = ""); xercesc::DOMImplementation* theImplementation_; xercesc::DOMDocument* theDocument_;