29 TDOMParser *parser = 0;
30 TXMLDocument *xmldoc = 0;
31 TXMLNode *rootnode = 0;
36 parser =
new TDOMParser();
37 parsecode = parser->ParseFile(filename);
40 Printf(
"XML ERROR: Parsing of XML file '%s' failed. Parse code error %d .", filename.Data(), parsecode);
44 xmldoc = parser->GetXMLDocument();
47 Printf(
"XML ERROR: parsing of xml file '%s' failed.", filename.Data());
51 rootnode = xmldoc->GetRootNode();
53 if ( TString(rootnode->GetNodeName()) !=
"client") {
54 Printf(
"XML ERROR: xml root node is not 'client'.");
58 node = rootnode->GetChildren();
60 while (node->HasNextNode()) {
61 node = node->GetNextNode();
62 if (node->GetNodeType() == TXMLNode::kXMLElementNode) {
63 if( TString(node->GetNodeName()) ==
"config") {
66 if( TString(node->GetNodeName()) ==
"MainWindow") {
69 if( TString(node->GetNodeName()) ==
"detector") {
90 if (!node->HasChildren()) {
91 Printf(
"XML ERROR: parsing histogram node of canvas '%s' failed.", canvas->GetName() );
95 child = node->GetChildren();
97 while (child->HasNextNode()) {
98 child = child->GetNextNode();
99 if (child->GetNodeType() == TXMLNode::kXMLElementNode) {
101 if( TString(child->GetNodeName()) ==
"name") {
103 TString histoname = child->GetText();
106 if(histoname.Contains(
' ') || histoname.Contains(
'-')) {
107 Printf(
"XML ERROR: parsing histogram node of canvas '%s' failed. Invalid histogram name '%s'.", canvas->GetName(), histoname.Data() );
113 if( TString(child->GetNodeName()) ==
"type") {
115 TString value = child->GetText();
116 if (value ==
"single") {
122 TObjArray* ar = value.Tokenize(
":");
123 TString
p1 = ((TObjString*) ar->At(0))->GetString();
124 TString
p2 = ((TObjString*) ar->At(1))->GetString();
125 TString
p3 = ((TObjString*) ar->At(2))->GetString();
126 if ( (p1 ==
"array") && (p2.IsDigit() || (p2.CompareTo(
"-1")==0)) && (p3.IsDigit() || (p3.CompareTo(
"-1")==0)) ) {
132 Printf(
"XML ERROR: type of histogram '%s' in canvas '%s' is not valid. Must be 'single', or 'array:s:m' with s,m integer values.", histo->GetName(), canvas->GetName() );
133 Printf(
"found: type: '%s', index1: '%s', index2: '%s'", p1.Data(), p2.Data(), p3.Data());
141 if( TString(child->GetNodeName()) ==
"subpad") {
147 TString val = child->GetText();
148 if (!val.IsDigit()) {
149 Printf(
"XML ERROR: subpad number '%s' of histogram '%s' in canvas '%s' is not a valid number", val.Data(), histo->GetName(), canvas->GetName() );
161 hname += canvas->GetName();
166 histo->SetName(hname);
182 if (!node->HasChildren()) {
183 Printf(
"XML ERROR: parsing canvas node of window '%s' failed.", window->GetName() );
187 child = node->GetChildren();
189 while (child->HasNextNode()) {
191 child = child->GetNextNode();
192 if (child->GetNodeType() == TXMLNode::kXMLElementNode) {
193 if( TString(child->GetNodeName()) ==
"name") {
195 TString canvasname = child->GetText();
196 if(!canvasname.IsAlnum()) {
197 Printf(
"XML ERROR: parsing canvas node of window '%s' failed. Invalid canvas name '%s'", window->GetName(), canvasname.Data() );
200 canvas->SetName(canvasname);
203 if( TString(child->GetNodeName()) ==
"width") {
207 TString val = child->GetText();
208 if (!val.IsDigit()) {
209 Printf(
"XML ERROR: width '%s' of canvas '%s' in tab '%s' in window '%s' is not a valid number.", val.Data(), canvas->GetName(), montab->GetName(), window->GetName() );
215 if( TString(child->GetNodeName()) ==
"height") {
219 TString val = child->GetText();
220 if (!val.IsDigit()) {
221 Printf(
"XML ERROR: width '%s' of canvas '%s' in tab '%s' in window '%s' is not a valid number.", val.Data(), canvas->GetName(), montab->GetName(), window->GetName() );
227 if( TString(child->GetNodeName()) ==
"splitted") {
231 TString val = child->GetText();
234 if ( (val !=
"true") && (val !=
"false") ) {
235 Printf(
"XML ERROR: The value '%s' of canvas '%s' in tab '%s' in window '%s' is not valid.", val.Data(), canvas->GetName(), montab->GetName(), window->GetName() );
236 Printf(
"Must be 'true' or 'false'.");
240 canvas->
SetSplitted((val ==
"true") ? kTRUE : kFALSE);
243 if( TString(child->GetNodeName()) ==
"nx") {
249 TString val = child->GetText();
250 if (!val.IsDigit()) {
251 Printf(
"XML ERROR: The nx split value '%s' of canvas '%s' in tab '%s' in window '%s' is not a valid number.", val.Data(), canvas->GetName(), montab->GetName(), window->GetName() );
258 if( TString(child->GetNodeName()) ==
"ny") {
264 TString val = child->GetText();
265 if (!val.IsDigit()) {
266 Printf(
"XML ERROR: The ny split value '%s' of canvas '%s' in tab '%s' in window '%s' is not a valid number.", val.Data(), canvas->GetName(), montab->GetName(), window->GetName() );
273 if( TString(child->GetNodeName()) ==
"histogram") {
289 if (!node->HasChildren()) {
290 Printf(
"XML ERROR: parsing canvas node of window '%s' failed.", window->GetName() );
294 child = node->GetChildren();
296 while (child->HasNextNode()) {
298 child = child->GetNextNode();
299 if (child->GetNodeType() == TXMLNode::kXMLElementNode) {
301 if( TString(child->GetNodeName()) ==
"name") {
303 TString canvasname = child->GetText();
304 if(!canvasname.IsAlnum()) {
305 Printf(
"XML ERROR: parsing canvas node of window '%s' failed. Invalid canvas name '%s'", window->GetName(), canvasname.Data() );
308 canvas->SetName(canvasname);
312 if( TString(child->GetNodeName()) ==
"title") {
314 canvas->SetTitle(child->GetText());
317 if( TString(child->GetNodeName()) ==
"width") {
321 TString val = child->GetText();
322 if (!val.IsDigit()) {
323 Printf(
"XML ERROR: width of canvas '%s' in window '%s' is not a valid number.", canvas->GetName(), window->GetName() );
330 if( TString(child->GetNodeName()) ==
"height") {
334 TString val = child->GetText();
335 if (!val.IsDigit()) {
336 Printf(
"XML ERROR: height of canvas '%s' in window '%s' is not a valid number.", canvas->GetName(), window->GetName() );
343 if( TString(child->GetNodeName()) ==
"splitted") {
347 TString val = child->GetText();
350 if ( (val !=
"true") && (val !=
"false") ) {
351 Printf(
"XML ERROR: The value '%s' of 'splitted' of canvas '%s' in window '%s' is not valid.", val.Data(), canvas->GetName(), window->GetName() );
352 Printf(
"Must be 'true' or 'false'.");
356 canvas->
SetSplitted( (val ==
"true") ? kTRUE : kFALSE );
359 if( TString(child->GetNodeName()) ==
"nx") {
365 TString val = child->GetText();
366 if (!val.IsDigit()) {
367 Printf(
"XML ERROR: The nx split value '%s' of canvas '%s' in window '%s' is not a valid number.", val.Data(), canvas->GetName(), window->GetName() );
374 if( TString(child->GetNodeName()) ==
"ny") {
380 TString val = child->GetText();
381 if (!val.IsDigit()) {
382 Printf(
"XML ERROR: The ny split value '%s' of canvas '%s' in window '%s' is not a valid number.", val.Data(), canvas->GetName(), window->GetName() );
389 if( TString(child->GetNodeName()) ==
"histogram") {
405 if (!node->HasChildren()) {
406 Printf(
"XML ERROR: parsing tab node of window '%s' failed.", window->GetName() );
410 child = node->GetChildren();
412 while (child->HasNextNode()) {
413 child = child->GetNextNode();
414 if (child->GetNodeType() == TXMLNode::kXMLElementNode) {
415 if( TString(child->GetNodeName()) ==
"name") {
417 TString tabname = child->GetText();
418 if(!tabname.IsAlnum()) {
419 Printf(
"XML ERROR: parsing tab node of window '%s' failed. Invalid tab name '%s'", window->GetName(), tabname.Data() );
422 montab->SetName(tabname);
425 if( TString(child->GetNodeName()) ==
"title") {
427 montab->SetTitle(child->GetText());
429 if( TString(child->GetNodeName()) ==
"canvas") {
439 Bool_t tabbed = kFALSE;
444 if (!node->HasChildren()) {
445 Printf(
"XML ERROR: parsing window node of detector '%s' failed.", detector->GetName() );
449 child = node->GetChildren();
451 while (child->HasNextNode()) {
452 child = child->GetNextNode();
454 if (child->GetNodeType() == TXMLNode::kXMLElementNode) {
455 if( TString(child->GetNodeName()) ==
"name") {
457 TString windowname = child->GetText();
458 if (!windowname.IsAlnum()) {
459 Printf(
"XML ERROR: parsing window node of detector '%s' failed. Invalid window name '%s'", detector->GetName(), windowname.Data() );
464 if( TString(child->GetNodeName()) ==
"title") {
466 title = child->GetText();
468 if( TString(child->GetNodeName()) ==
"tabbed") {
470 if (TString(child->GetText()) ==
"true") {
474 window->SetName(name);
475 window->SetTitle(title);
481 window->SetName(name);
482 window->SetTitle(title);
486 if( TString(child->GetNodeName()) ==
"canvas") {
491 Printf(
"XML ERROR: xml file wrong, found tabbed=true and canvas directly under window.");
492 Printf(
"Add a tab tag or set tabbed to false.");
493 Printf(
"Window name: %s", name.Data() );
494 Printf(
"Detector name: %s", detector->GetName() );
500 if( TString(child->GetNodeName()) ==
"tab") {
513 if (!node->HasChildren()) {
514 Printf(
"XML ERROR: parsing detector node failed.");
518 child = node->GetChildren();
520 while (child->HasNextNode()) {
521 child = child->GetNextNode();
523 if (child->GetNodeType() == TXMLNode::kXMLElementNode) {
524 if( TString(child->GetNodeName()) ==
"name") {
526 TString detname = child->GetText();
527 if (!detname.IsAlnum()) {
528 Printf(
"XML ERROR: parsing detector node failed. Invalid detector name '%s'", detname.Data());
532 detector->SetName(detname);
534 if( TString(child->GetNodeName()) ==
"title") {
536 detector->SetTitle(child->GetText());
538 if( TString(child->GetNodeName()) ==
"window") {
550 if (!node->HasChildren()) {
551 Printf(
"XML ERROR: parsing server node failed.");
555 child = node->GetChildren();
557 while (child->HasNextNode()) {
558 child = child->GetNextNode();
560 if (child->GetNodeType() == TXMLNode::kXMLElementNode) {
561 if( TString(child->GetNodeName()) ==
"host") {
565 if( TString(child->GetNodeName()) ==
"port") {
569 TString val = child->GetText();
570 if (!val.IsDigit()) {
571 Printf(
"XML ERROR: The server port is not a valid number.");
586 if (!node->HasChildren()) {
587 Printf(
"XML ERROR: parsing config node failed.");
591 child = node->GetChildren();
593 while (child->HasNextNode()) {
594 child = child->GetNextNode();
596 if (child->GetNodeType() == TXMLNode::kXMLElementNode) {
597 if( TString(child->GetNodeName()) ==
"server") {
609 if (!node->HasChildren()) {
610 Printf(
"XML ERROR: parsing MainWindow node failed.");
614 child = node->GetChildren();
616 while (child->HasNextNode()) {
617 child = child->GetNextNode();
619 if (child->GetNodeType() == TXMLNode::kXMLElementNode) {
620 if( TString(child->GetNodeName()) ==
"name") {
622 TString windowname = child->GetText();
623 if (!windowname.IsAlnum()) {
624 Printf(
"XML ERROR: parsing MainWindow node failed. Invalid MainWindow name '%s'", windowname.Data());
627 clientmainwin->SetName(windowname);
630 if( TString(child->GetNodeName()) ==
"title") {
632 clientmainwin->SetTitle(child->GetText());
635 if( TString(child->GetNodeName()) ==
"width") {
639 TString val = child->GetText();
640 if (!val.IsDigit()) {
641 Printf(
"XML ERROR: width of MainWindow is not a valid number.");
645 clientmainwin->
SetWidth(val.Atoi());
648 if( TString(child->GetNodeName()) ==
"height") {
652 TString val = child->GetText();
653 if (!val.IsDigit()) {
654 Printf(
"XML ERROR: height of MainWindow is not a valid number.");
661 if( TString(child->GetNodeName()) ==
"snapshotpath") {
664 if( TString(child->GetNodeName()) ==
"snapshotpathonline") {
668 if( TString(child->GetNodeName()) ==
"autosaverate") {
669 TString val = child->GetText();
670 if (!val.IsDigit()) {
671 Printf(
"XML ERROR: autosaverate of MainWindow is not a valid number.");
677 if( TString(child->GetNodeName()) ==
"autosaverateonline") {
678 TString val = child->GetText();
679 if (!val.IsDigit()) {
680 Printf(
"XML ERROR: autosaverateonline of MainWindow is not a valid number.");
686 if( TString(child->GetNodeName()) ==
"openlist") {
687 TString val = child->GetText();
689 TObjArray* myarguments = val.Tokenize(
",");
690 TIterator* myiter = myarguments->MakeIterator();
691 TObjString* stemp = 0;
693 while ((stemp = (TObjString*)myiter->Next()) != 0)
695 TString argument = stemp->GetString();
698 myarguments->Delete();
704 if( TString(child->GetNodeName()) ==
"reconnect") {
705 TString val = child->GetText();
706 if (!val.IsDigit()) {
707 Printf(
"XML ERROR: reconnect of MainWindow is not a valid number.");
static void SetAutoSaveInterval(Int_t minute)
void SetSubpadnumber(Int_t nr)
HOnlineMonClientDet * currentDetector
void ParseConfigNode(TXMLNode *node)
void SetServerport(Int_t port)
void ParseServerNode(TXMLNode *node)
void SetAutoSaveRate(Int_t rate)
HOnlineMonClientMain * GetMainClient()
void SetHeight(Int_t height)
void SetGuiName(TString rname)
void SetActive(Bool_t state)
TGraph p2(xdim, pgrid, respme)
Bool_t ParseXMLFile(TString filename, HOnlineMonClientMain *pclientmain)
void SetWidth(Int_t width)
TString fTextSnapshotPathOnline
void SetHeight(Int_t height)
void SetType(TString histotype)
void ParseWindowNode(TXMLNode *node, HOnlineMonClientDet *detector)
void ParseCanvasNode(TXMLNode *node, HOnlineMonClientSimpleWin *window)
void ParseHistogramNode(TXMLNode *node, HOnlineMonClientCanvas *canvas)
void SetRealName(TString rname)
void SetReconnect(Int_t recon)
void SetServerhost(TString host)
ClassImp(HOnlineMonClientXML)
void SetSplitted(Bool_t split)
static void SetAutoSaveIntervalOnline(Int_t minute)
void ParseMainWindowNode(TXMLNode *node, HOnlineMonClientMainWin *clientmainwin)
void SetArrayIndexS(Int_t s)
TGraph p1(xdim, pgrid, resplo)
void SetWidth(Int_t width)
HOnlineMonClientMainWin * clientmainwin
void ParseDetectorNode(TXMLNode *node, HOnlineMonClientDet *detector)
void SetSnapShotPath(TString path)
void SetArrayIndexM(Int_t m)
void ParseTabNode(TXMLNode *node, HOnlineMonClientTabWin *window)
HOnlineMonClientMain * clientmain
TGraph p3(xdim, pgrid, resphi)