CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

evf::IndependentWebGUI Class Reference

#include <IndependentWebGUI.h>

List of all members.

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 &params)
 IndependentWebGUI (xdaq::Application *app)
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)
void setVersionString (std::string vers)
void updateExternalState (std::string newState)
void updateInternalState (std::string newState)
virtual ~IndependentWebGUI ()

Private Member Functions

void addCountersToParams ()
void addParamsToInfoSpace (const ParamVec_t &params, xdata::InfoSpace *infoSpace)
bool isMonitorParam (CString_t &name)
void updateParams ()

Private Attributes

xdaq::Application * app_
xdata::InfoSpace * appInfoSpace_
bool countersAddedToParams_
Css css_
std::string currentExternalStateName_
std::string currentInternalStateName_
CounterVec_t debugCounters_
ParamVec_t debugParams_
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_
std::string versionString_

Detailed Description

Definition at line 28 of file IndependentWebGUI.h.


Member Typedef Documentation

typedef xdata::UnsignedInteger32 evf::IndependentWebGUI::Counter_t

Definition at line 34 of file IndependentWebGUI.h.

typedef std::vector<std::pair<std::string, Counter_t*> > evf::IndependentWebGUI::CounterVec_t

Definition at line 36 of file IndependentWebGUI.h.

typedef const std::string evf::IndependentWebGUI::CString_t

Definition at line 40 of file IndependentWebGUI.h.

typedef xgi::Input evf::IndependentWebGUI::Input_t

Definition at line 38 of file IndependentWebGUI.h.

typedef xgi::Output evf::IndependentWebGUI::Output_t

Definition at line 39 of file IndependentWebGUI.h.

typedef xdata::Serializable evf::IndependentWebGUI::Param_t

Definition at line 33 of file IndependentWebGUI.h.

typedef std::vector<std::pair<std::string, Param_t*> > evf::IndependentWebGUI::ParamVec_t

Definition at line 35 of file IndependentWebGUI.h.

typedef std::vector<std::pair<std::string, void*> > evf::IndependentWebGUI::UpdateVec_t

Definition at line 37 of file IndependentWebGUI.h.

Definition at line 41 of file IndependentWebGUI.h.


Constructor & Destructor Documentation

IndependentWebGUI::IndependentWebGUI ( xdaq::Application *  app)

Definition at line 33 of file IndependentWebGUI.cc.

References app_, appInfoSpace(), appInfoSpace_, css(), debugWebPage(), defaultWebPage(), instance, itemGroupListener_, largeAppIcon_, monInfoSpace(), monInfoSpace_, sourceId_, and urn_.

  : app_(app)
  , 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")
  , currentExternalStateName_("N/A")
  , currentInternalStateName_("N/A")
  , versionString_("__version string not set__")
{
  // 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,&IndependentWebGUI::defaultWebPage,"defaultWebPage");
  xgi::bind(this,&IndependentWebGUI::debugWebPage,  "debugWebPage");
  xgi::bind(this,&IndependentWebGUI::css,           "styles.css");

  // set itemGroupListener
  itemGroupListener_ = dynamic_cast<xdata::ActionListener*>(app_);
  if (0!=itemGroupListener_) {
    appInfoSpace()->addGroupRetrieveListener(itemGroupListener_);
    monInfoSpace()->addGroupRetrieveListener(itemGroupListener_);
  }
}
IndependentWebGUI::~IndependentWebGUI ( ) [virtual]

Definition at line 83 of file IndependentWebGUI.cc.

{

}

Member Function Documentation

void IndependentWebGUI::addCountersToParams ( ) [private]

Definition at line 294 of file IndependentWebGUI.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;
}
void IndependentWebGUI::addDebugCounter ( CString_t name,
Counter_t counter 
)

Definition at line 192 of file IndependentWebGUI.cc.

References countersAddedToParams_, debugCounters_, log_, and sourceId_.

{
  if (countersAddedToParams_) {
    LOG4CPLUS_ERROR(log_,"can't add debug counter '"<<name
                    <<"' to IndependentWebGUI of "<<sourceId_);
  }
  debugCounters_.push_back(make_pair(name,counter));
}
void IndependentWebGUI::addDebugParam ( CString_t name,
Param_t param 
)

Definition at line 159 of file IndependentWebGUI.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 IndependentWebGUI::addItemChangedListener ( CString_t name,
xdata::ActionListener *  l 
)

Definition at line 241 of file IndependentWebGUI.cc.

References appInfoSpace(), Exception, isMonitorParam(), log_, monInfoSpace(), and parametersExported_.

{
  if (!parametersExported_) {
    LOG4CPLUS_ERROR(log_,"Can't add ItemChangedListener for parameter '"<<name
                    <<"' before IndependentWebGUI::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<<"'.");
    }
  }

}
void IndependentWebGUI::addMonitorCounter ( CString_t name,
Counter_t counter 
)

Definition at line 181 of file IndependentWebGUI.cc.

References countersAddedToParams_, log_, monitorCounters_, and sourceId_.

{
  if (countersAddedToParams_) {
    LOG4CPLUS_ERROR(log_,"can't add monitor counter '"<<name
                    <<"' to IndependentWebGUI of "<<sourceId_);
  }
  monitorCounters_.push_back(make_pair(name,counter));
}
void IndependentWebGUI::addMonitorParam ( CString_t name,
Param_t param 
)

Definition at line 148 of file IndependentWebGUI.cc.

References log_, monitorParams_, and parametersExported_.

{
  if (parametersExported_) {
    LOG4CPLUS_ERROR(log_,"Failed to add monitor parameter '"<<name<<"'.");
    return;
  }
  monitorParams_.push_back(make_pair(name,param));
}
void IndependentWebGUI::addParamsToInfoSpace ( const ParamVec_t params,
xdata::InfoSpace *  infoSpace 
) [private]

Definition at line 275 of file IndependentWebGUI.cc.

References alignCSCRings::e, 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));
    }
  }
}
void IndependentWebGUI::addStandardCounter ( CString_t name,
Counter_t counter 
)

Definition at line 170 of file IndependentWebGUI.cc.

References countersAddedToParams_, log_, sourceId_, and standardCounters_.

{
  if (countersAddedToParams_) {
    LOG4CPLUS_ERROR(log_,"can't add standard counter '"<<name
                    <<"' to IndependentWebGUI of "<<sourceId_);
  }
  standardCounters_.push_back(make_pair(name,counter));
}
void IndependentWebGUI::addStandardParam ( CString_t name,
Param_t param 
)

Definition at line 137 of file IndependentWebGUI.cc.

References log_, parametersExported_, and standardParams_.

{
  if (parametersExported_) {
    LOG4CPLUS_ERROR(log_,"Failed to add standard parameter '"<<name<<"'.");
    return;
  }
  standardParams_.push_back(make_pair(name,param));
}
xdata::InfoSpace* evf::IndependentWebGUI::appInfoSpace ( ) [inline]

Definition at line 69 of file IndependentWebGUI.h.

References appInfoSpace_.

Referenced by addItemChangedListener(), exportParameters(), IndependentWebGUI(), and updateParams().

                                       {
                return appInfoSpace_;
        }
void IndependentWebGUI::css ( Input_t in,
Output_t out 
) throw (XgiException_t)

Definition at line 130 of file IndependentWebGUI.cc.

References recoMuon::in, and dbtoconf::out.

Referenced by IndependentWebGUI().

{
  css_.css(in,out);
}
void IndependentWebGUI::debugWebPage ( Input_t in,
Output_t out 
) throw (XgiException_t)

Definition at line 113 of file IndependentWebGUI.cc.

References recoMuon::in, and dbtoconf::out.

Referenced by IndependentWebGUI().

{
  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 IndependentWebGUI::defaultWebPage ( Input_t in,
Output_t out 
) throw (XgiException_t)

Definition at line 94 of file IndependentWebGUI.cc.

References recoMuon::in, and dbtoconf::out.

Referenced by IndependentWebGUI().

{
  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 IndependentWebGUI::exportParameters ( )
void IndependentWebGUI::htmlHead ( Input_t in,
Output_t out,
CString_t pageTitle 
)

Definition at line 368 of file IndependentWebGUI.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;
}
void IndependentWebGUI::htmlHeadline ( Input_t in,
Output_t out 
)

Definition at line 378 of file IndependentWebGUI.cc.

References a, b, currentExternalStateName_, currentInternalStateName_, hyperDAQIcon_, largeAppIcon_, AlCaHLTBitMon_ParallelJobs::p, smallAppIcon_, smallCtmIcon_, smallDbgIcon_, sourceId_, asciidump::table, urn_, BeamSplash_cfg::version, and versionString_.

{
  string externalStateName=currentExternalStateName_;
  string internalStateName=currentInternalStateName_;
  string version=versionString_;

  *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_<<b()
      <<td()<<endl
      <<td()<<endl
           <<a().set("style", "font-size:x-large")<<currentExternalStateName_<<a()
           <<b().set("style", "font-size:small")<<"      /      "<<currentInternalStateName_<<b()
      <<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<<p().set("style", "font-size:small").set("align", "right")<<version<<p()<<endl;
  *out<<hr()<<endl;
}
void IndependentWebGUI::htmlTable ( Input_t in,
Output_t out,
CString_t title,
const ParamVec_t params 
)

Definition at line 338 of file IndependentWebGUI.cc.

References alignCSCRings::e, 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 IndependentWebGUI::isMonitorParam ( CString_t name) [private]

Definition at line 318 of file IndependentWebGUI.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::IndependentWebGUI::monInfoSpace ( ) [inline]
void IndependentWebGUI::resetCounters ( )

Definition at line 220 of file IndependentWebGUI.cc.

References debugCounters_, i, monitorCounters_, and standardCounters_.

Referenced by evf::rb_statemachine::SharedResources::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::IndependentWebGUI::setHyperDAQIcon ( CString_t icon) [inline]

Definition at line 85 of file IndependentWebGUI.h.

References hyperDAQIcon_.

                                              {
                hyperDAQIcon_ = icon;
        }
void evf::IndependentWebGUI::setLargeAppIcon ( CString_t icon) [inline]

Definition at line 76 of file IndependentWebGUI.h.

References largeAppIcon_.

                                              {
                largeAppIcon_ = icon;
        }
void evf::IndependentWebGUI::setSmallAppIcon ( CString_t icon) [inline]

Definition at line 79 of file IndependentWebGUI.h.

References smallAppIcon_.

                                              {
                smallAppIcon_ = icon;
        }
void evf::IndependentWebGUI::setSmallDbgIcon ( CString_t icon) [inline]

Definition at line 82 of file IndependentWebGUI.h.

References smallDbgIcon_.

                                              {
                smallDbgIcon_ = icon;
        }
void evf::IndependentWebGUI::setVersionString ( std::string  vers) [inline]

Definition at line 100 of file IndependentWebGUI.h.

References versionString_.

                                                     {
                versionString_ = vers;
        }
void evf::IndependentWebGUI::updateExternalState ( std::string  newState) [inline]
void evf::IndependentWebGUI::updateInternalState ( std::string  newState) [inline]
void IndependentWebGUI::updateParams ( ) [private]

Definition at line 328 of file IndependentWebGUI.cc.

References appInfoSpace(), and itemGroupListener_.

{
  if (0!=itemGroupListener_) {
    std::list<std::string> emptyList;
    appInfoSpace()->fireItemGroupRetrieve(emptyList,itemGroupListener_);
  }
}

Member Data Documentation

xdaq::Application* evf::IndependentWebGUI::app_ [private]

Definition at line 118 of file IndependentWebGUI.h.

Referenced by IndependentWebGUI().

xdata::InfoSpace* evf::IndependentWebGUI::appInfoSpace_ [private]

Definition at line 125 of file IndependentWebGUI.h.

Referenced by appInfoSpace(), and IndependentWebGUI().

Definition at line 119 of file IndependentWebGUI.h.

Definition at line 146 of file IndependentWebGUI.h.

Referenced by htmlHeadline(), and updateExternalState().

Definition at line 147 of file IndependentWebGUI.h.

Referenced by htmlHeadline(), and updateInternalState().

Definition at line 135 of file IndependentWebGUI.h.

Referenced by addCountersToParams(), addDebugCounter(), and resetCounters().

Definition at line 132 of file IndependentWebGUI.h.

Referenced by addCountersToParams(), addDebugParam(), and exportParameters().

Definition at line 144 of file IndependentWebGUI.h.

Referenced by htmlHeadline(), and setHyperDAQIcon().

xdata::ActionListener* evf::IndependentWebGUI::itemGroupListener_ [private]

Definition at line 128 of file IndependentWebGUI.h.

Referenced by IndependentWebGUI(), and updateParams().

Definition at line 140 of file IndependentWebGUI.h.

Referenced by htmlHeadline(), IndependentWebGUI(), and setLargeAppIcon().

Logger evf::IndependentWebGUI::log_ [private]
xdata::InfoSpace* evf::IndependentWebGUI::monInfoSpace_ [private]

Definition at line 126 of file IndependentWebGUI.h.

Referenced by IndependentWebGUI(), and monInfoSpace().

Definition at line 134 of file IndependentWebGUI.h.

Referenced by addCountersToParams(), addMonitorCounter(), and resetCounters().

Definition at line 141 of file IndependentWebGUI.h.

Referenced by htmlHeadline(), and setSmallAppIcon().

Definition at line 143 of file IndependentWebGUI.h.

Referenced by htmlHeadline().

Definition at line 142 of file IndependentWebGUI.h.

Referenced by htmlHeadline(), and setSmallDbgIcon().

std::string evf::IndependentWebGUI::sourceId_ [private]

Definition at line 133 of file IndependentWebGUI.h.

Referenced by addCountersToParams(), addStandardCounter(), and resetCounters().

Definition at line 130 of file IndependentWebGUI.h.

Referenced by addCountersToParams(), addStandardParam(), and exportParameters().

std::string evf::IndependentWebGUI::urn_ [private]

Definition at line 123 of file IndependentWebGUI.h.

Referenced by htmlHead(), htmlHeadline(), and IndependentWebGUI().

Definition at line 148 of file IndependentWebGUI.h.

Referenced by htmlHeadline(), and setVersionString().