#include <WebGUI.h>
Public Types | |
typedef xdata::UnsignedInteger32 | Counter_t |
typedef std::vector< std::pair < std::string, Counter_t * > > | CounterVec_t |
typedef const std::string | CString_t |
typedef xgi::Input | Input_t |
typedef xgi::Output | Output_t |
typedef xdata::Serializable | Param_t |
typedef std::vector< std::pair < std::string, Param_t * > > | ParamVec_t |
typedef std::vector< std::pair < std::string, void * > > | UpdateVec_t |
typedef xgi::exception::Exception | XgiException_t |
Public Member Functions | |
void | addDebugCounter (CString_t &name, Counter_t *counter) |
void | addDebugParam (CString_t &name, Param_t *param) |
void | addItemChangedListener (CString_t &name, xdata::ActionListener *l) |
void | addMonitorCounter (CString_t &name, Counter_t *counter) |
void | addMonitorParam (CString_t &name, Param_t *param) |
void | addStandardCounter (CString_t &name, Counter_t *counter) |
void | addStandardParam (CString_t &name, Param_t *param) |
xdata::InfoSpace * | appInfoSpace () |
void | css (Input_t *in, Output_t *out) throw (XgiException_t) |
void | debugWebPage (Input_t *in, Output_t *out) throw (XgiException_t) |
void | defaultWebPage (Input_t *in, Output_t *out) throw (XgiException_t) |
void | exportParameters () |
void | htmlHead (Input_t *in, Output_t *out, CString_t &pageTitle) |
void | htmlHeadline (Input_t *in, Output_t *out) |
void | htmlTable (Input_t *in, Output_t *out, CString_t &title, const ParamVec_t ¶ms) |
xdata::InfoSpace * | monInfoSpace () |
void | resetCounters () |
void | setHyperDAQIcon (CString_t &icon) |
void | setLargeAppIcon (CString_t &icon) |
void | setSmallAppIcon (CString_t &icon) |
void | setSmallDbgIcon (CString_t &icon) |
WebGUI (xdaq::Application *app, StateMachine *fsm) | |
virtual | ~WebGUI () |
Private Member Functions | |
void | addCountersToParams () |
void | addParamsToInfoSpace (const ParamVec_t ¶ms, xdata::InfoSpace *infoSpace) |
bool | isMonitorParam (CString_t &name) |
void | updateParams () |
Private Attributes | |
xdaq::Application * | app_ |
xdata::InfoSpace * | appInfoSpace_ |
bool | countersAddedToParams_ |
Css | css_ |
CounterVec_t | debugCounters_ |
ParamVec_t | debugParams_ |
StateMachine * | fsm_ |
std::string | hyperDAQIcon_ |
xdata::ActionListener * | itemGroupListener_ |
std::string | largeAppIcon_ |
Logger | log_ |
xdata::InfoSpace * | monInfoSpace_ |
CounterVec_t | monitorCounters_ |
ParamVec_t | monitorParams_ |
bool | parametersExported_ |
std::string | smallAppIcon_ |
std::string | smallCtmIcon_ |
std::string | smallDbgIcon_ |
std::string | sourceId_ |
CounterVec_t | standardCounters_ |
ParamVec_t | standardParams_ |
std::string | urn_ |
typedef xdata::UnsignedInteger32 evf::WebGUI::Counter_t |
typedef std::vector<std::pair<std::string,Counter_t*> > evf::WebGUI::CounterVec_t |
typedef const std::string evf::WebGUI::CString_t |
typedef xgi::Input evf::WebGUI::Input_t |
typedef xgi::Output evf::WebGUI::Output_t |
typedef xdata::Serializable evf::WebGUI::Param_t |
typedef std::vector<std::pair<std::string,Param_t*> > evf::WebGUI::ParamVec_t |
typedef std::vector<std::pair<std::string,void*> > evf::WebGUI::UpdateVec_t |
WebGUI::WebGUI | ( | xdaq::Application * | app, |
StateMachine * | fsm | ||
) |
Definition at line 32 of file WebGUI.cc.
References app_, appInfoSpace(), appInfoSpace_, css(), debugWebPage(), defaultWebPage(), itemGroupListener_, largeAppIcon_, monInfoSpace(), monInfoSpace_, sourceId_, and urn_.
: app_(app) , fsm_(fsm) , log_(app->getApplicationContext()->getLogger()) , appInfoSpace_(0) , monInfoSpace_(0) , itemGroupListener_(0) , parametersExported_(false) , countersAddedToParams_(false) , largeAppIcon_("/evf/images/rbicon.jpg") , smallAppIcon_("/evf/images/rbicon.jpg") , smallDbgIcon_("/evf/images/bugicon.jpg") , smallCtmIcon_("/evf/images/spoticon.jpg") , hyperDAQIcon_("/hyperdaq/images/HyperDAQ.jpg") { // initialize application information string appClass=app_->getApplicationDescriptor()->getClassName(); unsigned int instance=app_->getApplicationDescriptor()->getInstance(); stringstream oss; oss<<appClass<<instance; sourceId_=oss.str(); urn_ ="/"+app_->getApplicationDescriptor()->getURN(); std::stringstream oss2; oss2<<"urn:xdaq-monitorable-"<<appClass; string monInfoSpaceName=oss2.str(); toolbox::net::URN urn = app_->createQualifiedInfoSpace(monInfoSpaceName); appInfoSpace_=app_->getApplicationInfoSpace(); monInfoSpace_=xdata::getInfoSpaceFactory()->get(urn.toString()); app_->getApplicationDescriptor()->setAttribute("icon",largeAppIcon_); // bind xgi callbacks xgi::bind(this,&WebGUI::defaultWebPage,"defaultWebPage"); xgi::bind(this,&WebGUI::debugWebPage, "debugWebPage"); xgi::bind(this,&WebGUI::css, "styles.css"); // set itemGroupListener itemGroupListener_ = dynamic_cast<xdata::ActionListener*>(app_); if (0!=itemGroupListener_) { appInfoSpace()->addGroupRetrieveListener(itemGroupListener_); monInfoSpace()->addGroupRetrieveListener(itemGroupListener_); } }
void WebGUI::addCountersToParams | ( | ) | [private] |
Definition at line 291 of file WebGUI.cc.
References countersAddedToParams_, debugCounters_, debugParams_, first, i, monitorCounters_, monitorParams_, edm::second(), standardCounters_, and standardParams_.
Referenced by exportParameters().
{ if (countersAddedToParams_) return; // standard counters for (unsigned int i=0;i<standardCounters_.size();i++) { standardParams_.push_back(make_pair(standardCounters_[i].first, standardCounters_[i].second)); } // monitor counters for (unsigned int i=0;i<monitorCounters_.size();i++) { monitorParams_.push_back(make_pair(monitorCounters_[i].first, monitorCounters_[i].second)); } // debug counters for (unsigned int i=0;i<debugCounters_.size();i++) { debugParams_.push_back(make_pair(debugCounters_[i].first, debugCounters_[i].second)); } countersAddedToParams_=true; }
Definition at line 189 of file WebGUI.cc.
References countersAddedToParams_, debugCounters_, log_, and sourceId_.
Referenced by evf::FUResourceBroker::exportParameters().
{ if (countersAddedToParams_) { LOG4CPLUS_ERROR(log_,"can't add debug counter '"<<name <<"' to WebGUI of "<<sourceId_); } debugCounters_.push_back(make_pair(name,counter)); }
Definition at line 156 of file WebGUI.cc.
References debugParams_, log_, and parametersExported_.
{ if (parametersExported_) { LOG4CPLUS_ERROR(log_,"Failed to add debug parameter '"<<name<<"'."); return; } debugParams_.push_back(make_pair(name,param)); }
void WebGUI::addItemChangedListener | ( | CString_t & | name, |
xdata::ActionListener * | l | ||
) |
Definition at line 238 of file WebGUI.cc.
References appInfoSpace(), Exception, isMonitorParam(), log_, monInfoSpace(), and parametersExported_.
Referenced by evf::FUResourceBroker::exportParameters(), and evf::BU::exportParameters().
{ if (!parametersExported_) { LOG4CPLUS_ERROR(log_,"Can't add ItemChangedListener for parameter '"<<name <<"' before WebGUI::exportParameters() is called."); return; } try { appInfoSpace()->addItemChangedListener(name,l); } catch (xcept::Exception) { LOG4CPLUS_ERROR(log_,"failed to add ItemChangedListener to " <<"application infospace for parameter '"<<name<<"'."); } if (isMonitorParam(name)) { try { monInfoSpace()->addItemChangedListener(name,l); } catch (xcept::Exception) { LOG4CPLUS_ERROR(log_,"failed to add ItemChangedListener to " <<"monitor infospace for parameter '"<<name<<"'."); } } }
Definition at line 178 of file WebGUI.cc.
References countersAddedToParams_, log_, monitorCounters_, and sourceId_.
Referenced by evf::FUResourceBroker::exportParameters(), and evf::BU::exportParameters().
{ if (countersAddedToParams_) { LOG4CPLUS_ERROR(log_,"can't add monitor counter '"<<name <<"' to WebGUI of "<<sourceId_); } monitorCounters_.push_back(make_pair(name,counter)); }
Definition at line 145 of file WebGUI.cc.
References log_, monitorParams_, and parametersExported_.
Referenced by evf::FUResourceBroker::exportParameters(), and evf::BU::exportParameters().
{ if (parametersExported_) { LOG4CPLUS_ERROR(log_,"Failed to add monitor parameter '"<<name<<"'."); return; } monitorParams_.push_back(make_pair(name,param)); }
void WebGUI::addParamsToInfoSpace | ( | const ParamVec_t & | params, |
xdata::InfoSpace * | infoSpace | ||
) | [private] |
Definition at line 272 of file WebGUI.cc.
References Exception, i, log_, mergeVDriftHistosByStation::name, and relativeConstraints::value.
Referenced by exportParameters().
{ for (unsigned int i=0;i<params.size();i++) { string name =params[i].first; Param_t* value=params[i].second; try { infoSpace->fireItemAvailable(name,value); } catch (xcept::Exception &e) { LOG4CPLUS_ERROR(log_,"Can't add parameter '"<<name<<"' to info space '" <<infoSpace->name()<<"': " <<xcept::stdformat_exception_history(e)); } } }
Definition at line 167 of file WebGUI.cc.
References countersAddedToParams_, log_, sourceId_, and standardCounters_.
{ if (countersAddedToParams_) { LOG4CPLUS_ERROR(log_,"can't add standard counter '"<<name <<"' to WebGUI of "<<sourceId_); } standardCounters_.push_back(make_pair(name,counter)); }
Definition at line 134 of file WebGUI.cc.
References log_, parametersExported_, and standardParams_.
Referenced by evf::FUResourceBroker::exportParameters(), and evf::BU::exportParameters().
{ if (parametersExported_) { LOG4CPLUS_ERROR(log_,"Failed to add standard parameter '"<<name<<"'."); return; } standardParams_.push_back(make_pair(name,param)); }
xdata::InfoSpace* evf::WebGUI::appInfoSpace | ( | ) | [inline] |
Definition at line 71 of file WebGUI.h.
References appInfoSpace_.
Referenced by addItemChangedListener(), exportParameters(), updateParams(), and WebGUI().
{ return appInfoSpace_; }
void WebGUI::css | ( | Input_t * | in, |
Output_t * | out | ||
) | throw (XgiException_t) |
Definition at line 127 of file WebGUI.cc.
References recoMuon::in, and dbtoconf::out.
Referenced by WebGUI().
void WebGUI::debugWebPage | ( | Input_t * | in, |
Output_t * | out | ||
) | throw (XgiException_t) |
Definition at line 110 of file WebGUI.cc.
References recoMuon::in, and dbtoconf::out.
Referenced by WebGUI().
{ updateParams(); *out<<"<html>"<<endl; htmlHead(in,out,sourceId_+" [DEBUG]"); *out<<body()<<endl; htmlHeadline(in,out); *out<<"<table cellpadding=\"25\"><tr valign=\"top\"><td>"<<endl; htmlTable(in,out,"Debug Parameters",debugParams_); *out<<"</td></tr></table>"<<endl; *out<<body()<<endl<<"</html>"<<endl; return; }
void WebGUI::defaultWebPage | ( | Input_t * | in, |
Output_t * | out | ||
) | throw (XgiException_t) |
Definition at line 91 of file WebGUI.cc.
References recoMuon::in, and dbtoconf::out.
Referenced by WebGUI().
{ updateParams(); *out<<"<html>"<<endl; htmlHead(in,out,sourceId_); *out<<body()<<endl; htmlHeadline(in,out); *out<<"<table cellpadding=\"25\"><tr valign=\"top\"><td>"<<endl; htmlTable(in,out,"Standard Parameters",standardParams_); *out<<"</td><td>"<<endl; htmlTable(in,out,"Monitored Parameters",monitorParams_); *out<<"</td></tr></table>"<<endl; *out<<body()<<endl<<"</html>"<<endl; return; }
void WebGUI::exportParameters | ( | ) |
Definition at line 200 of file WebGUI.cc.
References addCountersToParams(), addParamsToInfoSpace(), appInfoSpace(), countersAddedToParams_, debugParams_, monInfoSpace(), monitorParams_, parametersExported_, and standardParams_.
Referenced by evf::FUResourceBroker::exportParameters(), and evf::BU::exportParameters().
{ if (parametersExported_) return; if (!countersAddedToParams_) addCountersToParams(); addParamsToInfoSpace(standardParams_,appInfoSpace()); addParamsToInfoSpace(monitorParams_, appInfoSpace()); addParamsToInfoSpace(debugParams_, appInfoSpace()); addParamsToInfoSpace(monitorParams_,monInfoSpace()); parametersExported_=true; }
Definition at line 365 of file WebGUI.cc.
References link(), indexGen::title, and urn_.
{ *out<<head()<<endl<<cgicc::link().set("type","text/css") .set("rel","stylesheet") .set("href",urn_+"/styles.css") <<endl<<title(pageTitle.c_str())<<endl<<head()<<endl; }
Definition at line 375 of file WebGUI.cc.
References a, b, fsm_, hyperDAQIcon_, BuildWebpage::img, largeAppIcon_, smallAppIcon_, smallCtmIcon_, smallDbgIcon_, sourceId_, evf::StateMachine::stateName(), asciidump::table, and urn_.
{ string stateName=fsm_->stateName()->toString(); *out<<table().set("border","0").set("width","100%")<<endl <<tr()<<td().set("align","left")<<endl <<img().set("align","middle").set("src",largeAppIcon_) .set("alt","main") .set("width","64") .set("height","64") .set("border","") <<endl <<b()<<sourceId_<<" "<<stateName<<b()<<endl <<td()<<endl <<td().set("width","32")<<endl <<a().set("href","/urn:xdaq-application:lid=3") <<img().set("align","middle").set("src",hyperDAQIcon_) .set("alt","HyperDAQ").set("width","32") .set("height","32") .set("border","") <<a() <<td()<<endl <<td().set("width","32")<<td() <<td().set("width","32") <<a().set("href",urn_+"/defaultWebPage") <<img().set("align","middle").set("src",smallAppIcon_) .set("alt","Debug") .set("width","32") .set("height","32") .set("border","") <<a() <<td()<<endl <<td().set("width","32")<<td() <<td().set("width","32") <<a().set("href",urn_+"/debugWebPage") <<img().set("align","middle").set("src",smallDbgIcon_) .set("alt","Debug") .set("width","32") .set("height","32") .set("border","") <<a() <<td()<<endl <<td().set("width","32")<<td() <<td().set("width","32") <<a().set("href",urn_+"/customWebPage") <<img().set("align","middle").set("src",smallCtmIcon_) .set("alt","Debug") .set("width","32") .set("height","32") .set("border","") <<a() <<td()<<tr()<<table()<<endl; *out<<hr()<<endl; }
void WebGUI::htmlTable | ( | Input_t * | in, |
Output_t * | out, | ||
CString_t & | title, | ||
const ParamVec_t & | params | ||
) |
Definition at line 335 of file WebGUI.cc.
References Exception, first, i, and asciidump::table.
{ *out<<table().set("frame","void").set("rules","rows") .set("class","modules").set("width","300")<<endl <<tr()<<th(title).set("colspan","2")<<tr()<<endl <<tr() <<th("Parameter").set("align","left") <<th("Value").set("align","right") <<tr() <<endl; for (unsigned int i=0;i<params.size();i++) { string valueAsString; try { valueAsString = params[i].second->toString(); } catch (xcept::Exception& e) { valueAsString = e.what(); } *out<<tr() <<td(params[i].first).set("align","left") <<td(valueAsString).set("align","right") <<tr()<<endl; } *out<<table()<<endl; }
bool WebGUI::isMonitorParam | ( | CString_t & | name | ) | [private] |
Definition at line 315 of file WebGUI.cc.
References monitorParams_.
Referenced by addItemChangedListener().
{ ParamVec_t::const_iterator it; for (it=monitorParams_.begin();it!=monitorParams_.end();++it) if (it->first==name) return true; return false; }
xdata::InfoSpace* evf::WebGUI::monInfoSpace | ( | ) | [inline] |
Definition at line 72 of file WebGUI.h.
References monInfoSpace_.
Referenced by evf::BU::actionPerformed(), addItemChangedListener(), exportParameters(), evf::FUResourceBroker::monitoring(), evf::BU::monitoring(), and WebGUI().
{ return monInfoSpace_; }
void WebGUI::resetCounters | ( | ) |
Definition at line 217 of file WebGUI.cc.
References debugCounters_, i, monitorCounters_, and standardCounters_.
Referenced by evf::FUResourceBroker::reset(), and evf::BU::reset().
{ // standard counters for (unsigned int i=0;i<standardCounters_.size();i++) { Counter_t* counter=standardCounters_[i].second; *counter=0; } // monitor counters for (unsigned int i=0;i<monitorCounters_.size();i++) { Counter_t* counter=monitorCounters_[i].second; *counter=0; } // debug counters for (unsigned int i=0;i<debugCounters_.size();i++) { Counter_t* counter=debugCounters_[i].second; *counter=0; } }
void evf::WebGUI::setHyperDAQIcon | ( | CString_t & | icon | ) | [inline] |
void evf::WebGUI::setLargeAppIcon | ( | CString_t & | icon | ) | [inline] |
Definition at line 74 of file WebGUI.h.
References largeAppIcon_.
Referenced by evf::BU::BU().
{ largeAppIcon_=icon; }
void evf::WebGUI::setSmallAppIcon | ( | CString_t & | icon | ) | [inline] |
Definition at line 75 of file WebGUI.h.
References smallAppIcon_.
Referenced by evf::BU::BU().
{ smallAppIcon_=icon; }
void evf::WebGUI::setSmallDbgIcon | ( | CString_t & | icon | ) | [inline] |
void WebGUI::updateParams | ( | ) | [private] |
Definition at line 325 of file WebGUI.cc.
References appInfoSpace(), and itemGroupListener_.
{ if (0!=itemGroupListener_) { std::list<std::string> emptyList; appInfoSpace()->fireItemGroupRetrieve(emptyList,itemGroupListener_); } }
xdaq::Application* evf::WebGUI::app_ [private] |
xdata::InfoSpace* evf::WebGUI::appInfoSpace_ [private] |
Definition at line 109 of file WebGUI.h.
Referenced by appInfoSpace(), and WebGUI().
bool evf::WebGUI::countersAddedToParams_ [private] |
Definition at line 122 of file WebGUI.h.
Referenced by addCountersToParams(), addDebugCounter(), addMonitorCounter(), addStandardCounter(), and exportParameters().
Css evf::WebGUI::css_ [private] |
CounterVec_t evf::WebGUI::debugCounters_ [private] |
Definition at line 119 of file WebGUI.h.
Referenced by addCountersToParams(), addDebugCounter(), and resetCounters().
ParamVec_t evf::WebGUI::debugParams_ [private] |
Definition at line 116 of file WebGUI.h.
Referenced by addCountersToParams(), addDebugParam(), and exportParameters().
StateMachine* evf::WebGUI::fsm_ [private] |
Definition at line 102 of file WebGUI.h.
Referenced by htmlHeadline().
std::string evf::WebGUI::hyperDAQIcon_ [private] |
Definition at line 128 of file WebGUI.h.
Referenced by htmlHeadline(), and setHyperDAQIcon().
xdata::ActionListener* evf::WebGUI::itemGroupListener_ [private] |
Definition at line 112 of file WebGUI.h.
Referenced by updateParams(), and WebGUI().
std::string evf::WebGUI::largeAppIcon_ [private] |
Definition at line 124 of file WebGUI.h.
Referenced by htmlHeadline(), setLargeAppIcon(), and WebGUI().
Logger evf::WebGUI::log_ [private] |
Definition at line 104 of file WebGUI.h.
Referenced by addDebugCounter(), addDebugParam(), addItemChangedListener(), addMonitorCounter(), addMonitorParam(), addParamsToInfoSpace(), addStandardCounter(), and addStandardParam().
xdata::InfoSpace* evf::WebGUI::monInfoSpace_ [private] |
Definition at line 110 of file WebGUI.h.
Referenced by monInfoSpace(), and WebGUI().
CounterVec_t evf::WebGUI::monitorCounters_ [private] |
Definition at line 118 of file WebGUI.h.
Referenced by addCountersToParams(), addMonitorCounter(), and resetCounters().
ParamVec_t evf::WebGUI::monitorParams_ [private] |
Definition at line 115 of file WebGUI.h.
Referenced by addCountersToParams(), addMonitorParam(), exportParameters(), and isMonitorParam().
bool evf::WebGUI::parametersExported_ [private] |
Definition at line 121 of file WebGUI.h.
Referenced by addDebugParam(), addItemChangedListener(), addMonitorParam(), addStandardParam(), and exportParameters().
std::string evf::WebGUI::smallAppIcon_ [private] |
Definition at line 125 of file WebGUI.h.
Referenced by htmlHeadline(), and setSmallAppIcon().
std::string evf::WebGUI::smallCtmIcon_ [private] |
Definition at line 127 of file WebGUI.h.
Referenced by htmlHeadline().
std::string evf::WebGUI::smallDbgIcon_ [private] |
Definition at line 126 of file WebGUI.h.
Referenced by htmlHeadline(), and setSmallDbgIcon().
std::string evf::WebGUI::sourceId_ [private] |
Definition at line 106 of file WebGUI.h.
Referenced by addDebugCounter(), addMonitorCounter(), addStandardCounter(), htmlHeadline(), and WebGUI().
CounterVec_t evf::WebGUI::standardCounters_ [private] |
Definition at line 117 of file WebGUI.h.
Referenced by addCountersToParams(), addStandardCounter(), and resetCounters().
ParamVec_t evf::WebGUI::standardParams_ [private] |
Definition at line 114 of file WebGUI.h.
Referenced by addCountersToParams(), addStandardParam(), and exportParameters().
std::string evf::WebGUI::urn_ [private] |
Definition at line 107 of file WebGUI.h.
Referenced by htmlHead(), htmlHeadline(), and WebGUI().