12 #include "xcept/Exception.h"
13 #include "xcept/tools.h"
15 #include "cgicc/CgiDefs.h"
16 #include "cgicc/Cgicc.h"
17 #include "cgicc/HTMLClasses.h"
24 using namespace cgicc;
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")
48 string appClass=
app_->getApplicationDescriptor()->getClassName();
49 unsigned int instance=
app_->getApplicationDescriptor()->getInstance();
54 urn_ =
"/"+
app_->getApplicationDescriptor()->getURN();
56 std::stringstream oss2;
57 oss2<<
"urn:xdaq-monitorable-"<<appClass;
58 string monInfoSpaceName=oss2.str();
59 toolbox::net::URN urn =
app_->createQualifiedInfoSpace(monInfoSpaceName);
62 monInfoSpace_=xdata::getInfoSpaceFactory()->get(urn.toString());
96 htmlHead(
in,
out,sourceId_);
99 *
out<<
"<table cellpadding=\"25\"><tr valign=\"top\"><td>"<<endl;
100 htmlTable(
in,
out,
"Standard Parameters",standardParams_);
101 *
out<<
"</td><td>"<<endl;
102 htmlTable(
in,
out,
"Monitored Parameters",monitorParams_);
103 *
out<<
"</td></tr></table>"<<endl;
104 *
out<<body()<<endl<<
"</html>"<<endl;
114 *
out<<
"<html>"<<endl;
115 htmlHead(
in,
out,sourceId_+
" [DEBUG]");
117 htmlHeadline(
in,
out);
118 *
out<<
"<table cellpadding=\"25\"><tr valign=\"top\"><td>"<<endl;
119 htmlTable(
in,
out,
"Debug Parameters",debugParams_);
120 *
out<<
"</td></tr></table>"<<endl;
121 *
out<<body()<<endl<<
"</html>"<<endl;
137 LOG4CPLUS_ERROR(
log_,
"Failed to add standard parameter '"<<name<<
"'.");
148 LOG4CPLUS_ERROR(
log_,
"Failed to add monitor parameter '"<<name<<
"'.");
159 LOG4CPLUS_ERROR(
log_,
"Failed to add debug parameter '"<<name<<
"'.");
170 LOG4CPLUS_ERROR(
log_,
"can't add standard counter '"<<name
181 LOG4CPLUS_ERROR(
log_,
"can't add monitor counter '"<<name
192 LOG4CPLUS_ERROR(
log_,
"can't add debug counter '"<<name
241 LOG4CPLUS_ERROR(
log_,
"Can't add ItemChangedListener for parameter '"<<name
242 <<
"' before WebGUI::exportParameters() is called.");
250 LOG4CPLUS_ERROR(
log_,
"failed to add ItemChangedListener to "
251 <<
"application infospace for parameter '"<<name<<
"'.");
259 LOG4CPLUS_ERROR(
log_,
"failed to add ItemChangedListener to "
260 <<
"monitor infospace for parameter '"<<name<<
"'.");
273 xdata::InfoSpace* infoSpace)
275 for (
unsigned int i=0;
i<params.size();
i++) {
276 string name =params[
i].first;
279 infoSpace->fireItemAvailable(name,value);
282 LOG4CPLUS_ERROR(
log_,
"Can't add parameter '"<<name<<
"' to info space '"
283 <<infoSpace->name()<<
"': "
284 <<xcept::stdformat_exception_history(e));
317 ParamVec_t::const_iterator it;
319 if (it->first==name)
return true;
328 std::list<std::string> emptyList;
338 *out<<
table().set(
"frame",
"void").set(
"rules",
"rows")
339 .set(
"class",
"modules").set(
"width",
"300")<<endl
340 <<tr()<<th(title).set(
"colspan",
"2")<<tr()<<endl
342 <<th(
"Parameter").set(
"align",
"left")
343 <<th(
"Value").set(
"align",
"right")
347 for (
unsigned int i=0;
i<params.size();
i++) {
348 string valueAsString;
350 valueAsString = params[
i].second->toString();
353 valueAsString = e.what();
356 <<td(params[
i].
first).set(
"align",
"left")
357 <<td(valueAsString).set(
"align",
"right")
367 *out<<head()<<endl<<
cgicc::link().set(
"type",
"text/css")
368 .set(
"rel",
"stylesheet")
369 .set(
"href",
urn_+
"/styles.css")
370 <<endl<<
title(pageTitle.c_str())<<endl<<head()<<endl;
379 *out<<
table().set(
"border",
"0").set(
"width",
"100%")<<endl
380 <<tr()<<td().set(
"align",
"left")<<endl
382 .set(
"alt",
"main") .set(
"width",
"64")
383 .set(
"height",
"64") .set(
"border",
"")
387 <<td().set(
"width",
"32")<<endl
388 <<
a().set(
"href",
"/urn:xdaq-application:lid=3")
390 .set(
"alt",
"HyperDAQ").set(
"width",
"32")
391 .set(
"height",
"32") .set(
"border",
"")
394 <<td().set(
"width",
"32")<<td()
395 <<td().set(
"width",
"32")
396 <<
a().set(
"href",
urn_+
"/defaultWebPage")
398 .set(
"alt",
"Debug") .set(
"width",
"32")
399 .set(
"height",
"32") .set(
"border",
"")
402 <<td().set(
"width",
"32")<<td()
403 <<td().set(
"width",
"32")
404 <<
a().set(
"href",
urn_+
"/debugWebPage")
406 .set(
"alt",
"Debug") .set(
"width",
"32")
407 .set(
"height",
"32") .set(
"border",
"")
410 <<td().set(
"width",
"32")<<td()
411 <<td().set(
"width",
"32")
412 <<
a().set(
"href",
urn_+
"/customWebPage")
414 .set(
"alt",
"Debug") .set(
"width",
"32")
415 .set(
"height",
"32") .set(
"border",
"")
417 <<td()<<tr()<<
table()<<endl;
xdata::UnsignedInteger32 Counter_t
void addDebugCounter(CString_t &name, Counter_t *counter)
void htmlTable(Input_t *in, Output_t *out, CString_t &title, const ParamVec_t ¶ms)
CounterVec_t standardCounters_
void addStandardParam(CString_t &name, Param_t *param)
static PFTauRenderPlugin instance
void addCountersToParams()
const std::string CString_t
xdata::Serializable Param_t
xgi::exception::Exception XgiException_t
void htmlHead(Input_t *in, Output_t *out, CString_t &pageTitle)
std::string smallAppIcon_
CounterVec_t monitorCounters_
bool countersAddedToParams_
std::vector< std::pair< std::string, Param_t * > > ParamVec_t
void addMonitorParam(CString_t &name, Param_t *param)
void addItemChangedListener(CString_t &name, xdata::ActionListener *l)
ParamVec_t standardParams_
U second(std::pair< T, U > const &p)
std::string link(std::string &nm, std::string &ns)
void addDebugParam(CString_t &name, Param_t *param)
xdata::InfoSpace * appInfoSpace_
xdata::InfoSpace * monInfoSpace_
ParamVec_t monitorParams_
xdata::InfoSpace * appInfoSpace()
xdata::String * stateName()
xdata::InfoSpace * monInfoSpace()
void htmlHeadline(Input_t *in, Output_t *out)
void debugWebPage(Input_t *in, Output_t *out)
void addParamsToInfoSpace(const ParamVec_t ¶ms, xdata::InfoSpace *infoSpace)
void addStandardCounter(CString_t &name, Counter_t *counter)
void addMonitorCounter(CString_t &name, Counter_t *counter)
void defaultWebPage(Input_t *in, Output_t *out)
std::string largeAppIcon_
bool isMonitorParam(CString_t &name)
std::string smallCtmIcon_
CounterVec_t debugCounters_
std::string hyperDAQIcon_
xdata::ActionListener * itemGroupListener_
std::string smallDbgIcon_
void css(Input_t *in, Output_t *out)