13 #include "xcept/Exception.h"
14 #include "xcept/tools.h"
16 #include "cgicc/CgiDefs.h"
17 #include "cgicc/Cgicc.h"
18 #include "cgicc/HTMLClasses.h"
25 using namespace cgicc;
33 IndependentWebGUI::IndependentWebGUI(xdaq::Application* app)
35 , log_(app->getApplicationContext()->getLogger())
38 , itemGroupListener_(0)
39 , parametersExported_(
false)
40 , countersAddedToParams_(
false)
41 , largeAppIcon_(
"/evf/images/rbicon.jpg")
42 , smallAppIcon_(
"/evf/images/rbicon.jpg")
43 , smallDbgIcon_(
"/evf/images/bugicon.jpg")
44 , smallCtmIcon_(
"/evf/images/spoticon.jpg")
45 , hyperDAQIcon_(
"/hyperdaq/images/HyperDAQ.jpg")
46 , currentExternalStateName_(
"N/A")
47 , currentInternalStateName_(
"N/A")
48 , versionString_(
"__version string not set__")
51 string appClass=
app_->getApplicationDescriptor()->getClassName();
52 unsigned int instance=
app_->getApplicationDescriptor()->getInstance();
57 urn_ =
"/"+
app_->getApplicationDescriptor()->getURN();
59 std::stringstream oss2;
60 oss2<<
"urn:xdaq-monitorable-"<<appClass;
61 string monInfoSpaceName=oss2.str();
62 toolbox::net::URN urn =
app_->createQualifiedInfoSpace(monInfoSpaceName);
65 monInfoSpace_=xdata::getInfoSpaceFactory()->get(urn.toString());
99 htmlHead(
in,
out,sourceId_);
101 htmlHeadline(
in,
out);
102 *
out<<
"<table cellpadding=\"25\"><tr valign=\"top\"><td>"<<endl;
103 htmlTable(
in,
out,
"Standard Parameters",standardParams_);
104 *
out<<
"</td><td>"<<endl;
105 htmlTable(
in,
out,
"Monitored Parameters",monitorParams_);
106 *
out<<
"</td></tr></table>"<<endl;
107 *
out<<body()<<endl<<
"</html>"<<endl;
117 *
out<<
"<html>"<<endl;
118 htmlHead(
in,
out,sourceId_+
" [DEBUG]");
120 htmlHeadline(
in,
out);
121 *
out<<
"<table cellpadding=\"25\"><tr valign=\"top\"><td>"<<endl;
122 htmlTable(
in,
out,
"Debug Parameters",debugParams_);
123 *
out<<
"</td></tr></table>"<<endl;
124 *
out<<body()<<endl<<
"</html>"<<endl;
140 LOG4CPLUS_ERROR(
log_,
"Failed to add standard parameter '"<<name<<
"'.");
151 LOG4CPLUS_ERROR(
log_,
"Failed to add monitor parameter '"<<name<<
"'.");
162 LOG4CPLUS_ERROR(
log_,
"Failed to add debug parameter '"<<name<<
"'.");
173 LOG4CPLUS_ERROR(
log_,
"can't add standard counter '"<<name
174 <<
"' to IndependentWebGUI of "<<
sourceId_);
184 LOG4CPLUS_ERROR(
log_,
"can't add monitor counter '"<<name
185 <<
"' to IndependentWebGUI of "<<
sourceId_);
195 LOG4CPLUS_ERROR(
log_,
"can't add debug counter '"<<name
196 <<
"' to IndependentWebGUI of "<<
sourceId_);
244 LOG4CPLUS_ERROR(
log_,
"Can't add ItemChangedListener for parameter '"<<name
245 <<
"' before IndependentWebGUI::exportParameters() is called.");
253 LOG4CPLUS_ERROR(
log_,
"failed to add ItemChangedListener to "
254 <<
"application infospace for parameter '"<<name<<
"'.");
262 LOG4CPLUS_ERROR(
log_,
"failed to add ItemChangedListener to "
263 <<
"monitor infospace for parameter '"<<name<<
"'.");
276 xdata::InfoSpace* infoSpace)
278 for (
unsigned int i=0;
i<params.size();
i++) {
279 string name =params[
i].first;
282 infoSpace->fireItemAvailable(name,value);
285 LOG4CPLUS_ERROR(
log_,
"Can't add parameter '"<<name<<
"' to info space '"
286 <<infoSpace->name()<<
"': "
287 <<xcept::stdformat_exception_history(e));
320 ParamVec_t::const_iterator it;
322 if (it->first==name)
return true;
331 std::list<std::string> emptyList;
341 *out<<
table().set(
"frame",
"void").set(
"rules",
"rows")
342 .set(
"class",
"modules").set(
"width",
"300")<<endl
343 <<tr()<<th(title).set(
"colspan",
"2")<<tr()<<endl
345 <<th(
"Parameter").set(
"align",
"left")
346 <<th(
"Value").set(
"align",
"right")
350 for (
unsigned int i=0;
i<params.size();
i++) {
351 string valueAsString;
353 valueAsString = params[
i].second->toString();
356 valueAsString = e.what();
359 <<td(params[
i].
first).set(
"align",
"left")
360 <<td(valueAsString).set(
"align",
"right")
370 *out<<head()<<endl<<
cgicc::link().set(
"type",
"text/css")
371 .set(
"rel",
"stylesheet")
372 .set(
"href",
urn_+
"/styles.css")
373 <<endl<<
title(pageTitle.c_str())<<endl<<head()<<endl;
384 *out<<
table().set(
"border",
"0").set(
"width",
"100%")<<endl
385 <<tr()<<td().set(
"align",
"left")<<endl
387 .set(
"alt",
"main") .set(
"width",
"64")
388 .set(
"height",
"64") .set(
"border",
"")
396 <<td().set(
"width",
"32")<<endl
397 <<
a().set(
"href",
"/urn:xdaq-application:lid=3")
399 .set(
"alt",
"HyperDAQ").set(
"width",
"32")
400 .set(
"height",
"32") .set(
"border",
"")
403 <<td().set(
"width",
"32")<<td()
404 <<td().set(
"width",
"32")
405 <<
a().set(
"href",
urn_+
"/defaultWebPage")
407 .set(
"alt",
"Debug") .set(
"width",
"32")
408 .set(
"height",
"32") .set(
"border",
"")
411 <<td().set(
"width",
"32")<<td()
412 <<td().set(
"width",
"32")
413 <<
a().set(
"href",
urn_+
"/debugWebPage")
415 .set(
"alt",
"Debug") .set(
"width",
"32")
416 .set(
"height",
"32") .set(
"border",
"")
419 <<td().set(
"width",
"32")<<td()
420 <<td().set(
"width",
"32")
421 <<
a().set(
"href",
urn_+
"/customWebPage")
423 .set(
"alt",
"Debug") .set(
"width",
"32")
424 .set(
"height",
"32") .set(
"border",
"")
426 <<td()<<tr()<<
table()<<endl;
428 *out<<
p().set(
"style",
"font-size:small").set(
"align",
"right")<<version<<
p()<<endl;
void addCountersToParams()
void addStandardCounter(CString_t &name, Counter_t *counter)
void addStandardParam(CString_t &name, Param_t *param)
void addMonitorCounter(CString_t &name, Counter_t *counter)
std::string currentInternalStateName_
CounterVec_t monitorCounters_
std::string smallAppIcon_
static PFTauRenderPlugin instance
void addDebugParam(CString_t &name, Param_t *param)
xdata::UnsignedInteger32 Counter_t
const std::string CString_t
bool isMonitorParam(CString_t &name)
xdata::Serializable Param_t
xdata::ActionListener * itemGroupListener_
std::string largeAppIcon_
void defaultWebPage(Input_t *in, Output_t *out)
CounterVec_t standardCounters_
void htmlTable(Input_t *in, Output_t *out, CString_t &title, const ParamVec_t ¶ms)
U second(std::pair< T, U > const &p)
std::string link(std::string &nm, std::string &ns)
bool countersAddedToParams_
void addItemChangedListener(CString_t &name, xdata::ActionListener *l)
void addDebugCounter(CString_t &name, Counter_t *counter)
std::string hyperDAQIcon_
virtual ~IndependentWebGUI()
void htmlHead(Input_t *in, Output_t *out, CString_t &pageTitle)
xdata::InfoSpace * monInfoSpace_
CounterVec_t debugCounters_
ParamVec_t monitorParams_
void addParamsToInfoSpace(const ParamVec_t ¶ms, xdata::InfoSpace *infoSpace)
xdata::InfoSpace * appInfoSpace_
xdata::InfoSpace * appInfoSpace()
xgi::exception::Exception XgiException_t
xdata::InfoSpace * monInfoSpace()
std::string smallDbgIcon_
void debugWebPage(Input_t *in, Output_t *out)
std::string smallCtmIcon_
std::string currentExternalStateName_
void addMonitorParam(CString_t &name, Param_t *param)
void css(Input_t *in, Output_t *out)
void htmlHeadline(Input_t *in, Output_t *out)
std::vector< std::pair< std::string, Param_t * > > ParamVec_t
ParamVec_t standardParams_
std::string versionString_