lemAutoRun  1.0
PAutoRunParser.cpp
Go to the documentation of this file.
1 /********************************************************************************************
2 
3  PAutoRunParser.cpp
4 
5 *********************************************************************************************
6 
7  begin : Andreas Suter, 2006/03/14
8  modfied: :
9  copyright : (C) 2006 by
10  email : andreas.suter@psi.ch
11 
12 ********************************************************************************************/
13 
14 /***************************************************************************
15  * *
16  * This program is free software; you can redistribute it and/or modify *
17  * it under the terms of the GNU General Public License as published by *
18  * the Free Software Foundation; either version 2 of the License, or *
19  * (at your option) any later version. *
20  * *
21  ***************************************************************************/
22 
23 #include <cmath>
24 #include <iostream>
25 
26 #include <QFile>
27 #include <QString>
28 #include <QStringList>
29 #include <QRegExp>
30 #include <QTextStream>
31 #include <QList>
32 
33 #include <xercesc/util/PlatformUtils.hpp>
34 #include <xercesc/sax2/SAX2XMLReader.hpp>
35 #include <xercesc/sax2/XMLReaderFactory.hpp>
36 #if defined(XERCES_NEW_IOSTREAMS)
37 #include <fstream>
38 #else
39 #include <fstream.h>
40 #endif
41 #include <xercesc/util/OutOfMemoryException.hpp>
42 
43 #include "lemAutoRun.h"
44 #include "PAutoRunParser.h"
45 
46 //*******************************************************************************************************
47 // implementation of the constructor
48 //*******************************************************************************************************
55 {
56  fArp = arp; // keep pointer of the calling class
57 
58  // init class variables
59  fFlnAutoRunSeq = "";
61 
62  fKey = eEmpty;
63  fCmdKey = eEmpty;
64 
65  // get pointer to the auto run sequence vector
67 
68  // clear local auto run command structure (single instruction)
70 
71  // initialize ODB tag
72  fOdbTag.tag = QString("");
73  fOdbTag.odb_path = QString("");
74  fOdbTag.idx = -1;
75 
76  fLoopNo = 0; // loop counter, needed for loops in loops ...
77 
78  fFatalError = false;
79 }
80 
81 //*******************************************************************************************************
82 // implementation of the destructor
83 //*******************************************************************************************************
88 {
89 }
90 
91 //*******************************************************************************************************
92 // implementation of the startDocument
93 //*******************************************************************************************************
98 {
99 }
100 
101 //*******************************************************************************************************
102 // implementation of the startElement
103 //*******************************************************************************************************
112 void PSAX2AutoRunParseHandler::startElement(const XMLCh *const uri, const XMLCh *const localname,
113  const XMLCh *const qname, const Attributes &attrs)
114 {
115  if (fFatalError)
116  return;
117 
118  XMLLoopInfo loopInfo;
119 
120  if (uri) {} // in order to suppress compiler warnings
121  if (localname) {} // in order to suppress compiler warnings
122  if (attrs.getLength()) {} // in order to suppress compiler warnings
123 
124  // translate keyword to QString for simpler handling
125  QString qName = QString(XMLString::transcode(qname));
126 
127  // filter (command) key words
128  if (qName == "autoRunName") {
129  fKey = eFln;
130  } else if (qName == "line") {
131  fKey = eLineNo;
132  } else if (qName == "cmd_str") {
133  fKey = eCmdStr;
134  } else if (qName == "comment") {
135  fCmdKey = eComment;
136  fAutoRunCmd.cmd = "comment";
137  } else if (qName == "alias") {
138  fCmdKey = eAlias;
139  fAutoRunCmd.cmd = "alias";
140  } else if (qName == "ignore_alarms") {
142  fAutoRunCmd.cmd = "ignore_alarms";
143  } else if (qName == "ignore_clients") {
145  fAutoRunCmd.cmd = "ignore_clients";
146  } else if (qName == "setBPV") {
147  fCmdKey = eBPV;
148  fAutoRunCmd.cmd = "setBPV";
149  } else if (qName == "odbTag") {
150  fCmdKey = eOdbTag;
151  fAutoRunCmd.cmd = "odbTag";
152  } else if (qName == "setOdbData") {
154  fAutoRunCmd.cmd = "setOdbData";
155  } else if (qName == "setOdbDataArray") {
157  fAutoRunCmd.cmd = "setOdbDataArray";
158  } else if (qName == "setTemp") {
159  fCmdKey = eSetTemp;
160  fAutoRunCmd.cmd = "setTemp";
162  } else if (qName == "setTfl") {
163  fCmdKey = eSetTfl;
164  fAutoRunCmd.cmd = "setTfl";
165  } else if (qName == "setSampleHV") {
167  fAutoRunCmd.cmd = "setSampleHV";
168  } else if (qName == "setRA_HV") {
169  fCmdKey = eSetRA_HV;
170  fAutoRunCmd.cmd = "setRA_HV";
171  } else if (qName == "setTransportHV") {
173  fAutoRunCmd.cmd = "setTransportHV";
174  } else if (qName == "setHVOff") {
175  fCmdKey = eSetHvOff;
176  fAutoRunCmd.cmd = "setHVOff";
177  } else if (qName == "setFieldWEWL") {
179  fAutoRunCmd.cmd = "setFieldWEWL";
180  } else if (qName == "setFieldWEWH") {
182  fAutoRunCmd.cmd = "setFieldWEWH";
183  } else if (qName == "setFieldDanfysik") {
185  fAutoRunCmd.cmd = "setFieldDanfysik";
186  } else if (qName == "setField") {
187  fCmdKey = eSetField;
188  fAutoRunCmd.cmd = "setField";
189  } else if (qName == "setSpinRot") {
191  fAutoRunCmd.cmd = "setSpinRot";
192  } else if (qName == "setFOM") {
193  fCmdKey = eSetFOM;
194  fAutoRunCmd.cmd = "setFOM";
195  } else if (qName == "setTitle") {
196  fCmdKey = eSetTitle;
197  fAutoRunCmd.cmd = "setTitle";
198  } else if (qName == "setTOF") {
199  fCmdKey = eSetTOF;
200  fAutoRunCmd.cmd = "setTOF";
201  } else if (qName == "setModInfo") {
203  fAutoRunCmd.cmd = "setModInfo";
204  } else if (qName == "setLEMSetup") {
206  fAutoRunCmd.cmd = "setLEMSetup";
207  } else if (qName == "setWait") {
208  fCmdKey = eSetWait;
209  fAutoRunCmd.cmd = "setWait";
210  } else if (qName == "setDump") {
211  fCmdKey = eSetDump;
212  fAutoRunCmd.cmd = "setDump";
213  } else if (qName == "runStart") {
214  fCmdKey = eRunStart;
215  fAutoRunCmd.cmd = "runStart";
216  } else if (qName == "runStop") {
217  fCmdKey = eRunStop;
218  fAutoRunCmd.cmd = "runStop";
219  } else if (qName == "warmUp") {
220  fCmdKey = eWarmUp;
221  fAutoRunCmd.cmd = "warmUp";
222  } else if (qName == "degaussWEW") {
224  fAutoRunCmd.cmd = "degaussWEW";
225  } else if (qName == "degaussDanfysik") {
227  fAutoRunCmd.cmd = "degaussDanfysik";
228  } else if (qName == "degaussMagnet") {
229  fCmdKey = eDegauss;
230  fAutoRunCmd.cmd = "degaussMagnet";
231  } else if (qName == "degaussSpinRot") {
233  fAutoRunCmd.cmd = "degaussSpinRot";
234  } else if (qName == "comment_line") {
235  fKey = eCommentLine;
236  } else if (qName == "alias_key") {
237  fKey = eAlias_key;
238  } else if (qName == "alias_value") {
239  fKey = eAlias_value;
240  } else if (qName == "loop") {
241  fCmdKey = eLoop;
242  fLoopNo++;
243  fLoopInfoVector.push_back(loopInfo);
244  } else if (qName == "loopList") {
245  fCmdKey = eLoopList;
246  } else if (qName == "loopElement") {
247  fKey = eLoopElement;
248  } else if (qName == "loopIterator") {
250  } else if (qName == "loopStart") {
251  fKey = eLoopStart;
252  } else if (qName == "loopStop") {
253  fKey = eLoopStop;
254  } else if (qName == "loopStep") {
255  fKey = eLoopStep;
256  } else if (qName == "loopSetTemp") {
258  fLoopInfoVector[fLoopNo-1].loopCmd.cmd = "loopSetTemp";
259  fLoopInfoVector[fLoopNo-1].loopCmd.noElements = 0;
260  } else if (qName == "loopTempTag") {
261  fKey = eLoopTempTag;
262  } else if (qName == "loopSetSampleHV") {
264  fLoopInfoVector[fLoopNo-1].loopCmd.cmd = "loopSetSampleHV";
265  fLoopInfoVector[fLoopNo-1].loopCmd.noElements = 0;
266  } else if (qName == "loopSampleHVTag") {
268  } else if (qName == "loopSetFieldWEWL") {
270  fLoopInfoVector[fLoopNo-1].loopCmd.cmd = "loopSetFieldWEWL";
271  fLoopInfoVector[fLoopNo-1].loopCmd.noElements = 0;
272  } else if (qName == "loopSetFieldWEWH") {
274  fLoopInfoVector[fLoopNo-1].loopCmd.cmd = "loopSetFieldWEWH";
275  fLoopInfoVector[fLoopNo-1].loopCmd.noElements = 0;
276  } else if (qName == "loopSetFieldDanfysik") {
278  fLoopInfoVector[fLoopNo-1].loopCmd.cmd = "loopSetFieldDanfysik";
279  fLoopInfoVector[fLoopNo-1].loopCmd.noElements = 0;
280  } else if (qName == "loopSetField") {
282  fLoopInfoVector[fLoopNo-1].loopCmd.cmd = "loopSetField";
283  fLoopInfoVector[fLoopNo-1].loopCmd.noElements = 0;
284  } else if (qName == "loopFieldTag") {
286  } else if (qName == "set_path") {
287  fKey = eOdbSetPath;
288  } else if (qName == "set_index") {
289  fKey = eOdbSetIndex;
290  } else if (qName == "set_value") {
291  fKey = eOdbSetValue;
292  } else if (qName == "read_path") {
293  fKey = eOdbReadPath;
294  } else if (qName == "read_index") {
296  } else if (qName == "timeout") {
297  fKey = eOdbTimeout;
298  } else if (qName == "tolerance") {
300  } else if (qName == "tfl_pos") {
301  fKey = eTfl_pos;
302  } else if (qName == "tfl_mode") {
303  fKey = eTfl_mode;
304  } else if (qName == "temp") {
305  fKey = eTemp;
306  } else if (qName == "deltaT") {
307  fKey = eDeltaT;
308  } else if (qName == "ramp") {
309  fKey = eRamp;
310  } else if (qName == "heaterRange") {
311  fKey = eHeaterRange;
312  } else if (qName == "stabilityTimeout") {
314  } else if (qName == "P_PID") {
315  fKey = eP_pid;
316  } else if (qName == "I_PID") {
317  fKey = eI_pid;
318  } else if (qName == "D_PID") {
319  fKey = eD_pid;
320  } else if (qName == "flow") {
321  fKey = eFlow;
322  } else if (qName == "hv_value") {
323  fKey = eHv_value;
324  } else if (qName == "hv_left") {
325  fKey = eHv_left;
326  } else if (qName == "hv_right") {
327  fKey = eHv_right;
328  } else if (qName == "hv_top") {
329  fKey = eHv_top;
330  } else if (qName == "hv_bottom") {
331  fKey = eHv_bottom;
332  } else if (qName == "transportHvSettingFileName") {
334  } else if (qName == "field_value") {
335  fKey = eField_value;
336  } else if (qName == "field_unit") {
337  fKey = eField_unit;
338  } else if (qName == "title") {
339  fKey = eTitle;
340  } else if (qName == "odb_sample") {
341  fKey = eOdb_sample;
342  } else if (qName == "odb_temp") {
343  fKey = eOdb_temp;
344  } else if (qName == "odb_field") {
345  fKey = eOdb_field;
346  } else if (qName == "odb_transp") {
347  fKey = eOdb_transp;
348  } else if (qName == "odb_hv_samp") {
349  fKey = eOdb_hv_samp;
350  } else if (qName == "odb_energy") {
351  fKey = eOdb_energy;
352  } else if (qName == "odb_ra_diff_lr") {
354  } else if (qName == "odb_ra_diff_tb") {
356  } else if (qName == "odb_spin_rot") {
358  } else if (qName == "start") {
359  fKey = eStart;
360  } else if (qName == "stop") {
361  fKey = eStop;
362  } else if (qName == "units") {
363  fKey = eUnits;
364  } else if (qName == "mod") {
365  fKey = eMod;
366  } else if (qName == "mod_date") {
367  fKey = eMod_date;
368  } else if (qName == "setup") {
369  fKey = eSetup;
370  } else if (qName == "wait") {
371  fKey = eWait;
372  } else if (qName == "no_events") {
373  fKey = eNo_events;
374  } else if (qName == "no_dumps") {
375  fKey = eNo_dumps;
376  } else if (qName == "date") {
377  fKey = eDate;
378  } else if (qName == "time") {
379  fKey = eTime;
380  } else if (qName == "vent") {
381  fKey = eVent;
382  } else if (qName == "current") {
383  fKey = eCurrent;
384  } else if (qName == "angle") {
385  fKey = eAngle;
386  } else if (qName == "no_degauss") {
387  fKey = eNoDegauss;
388  } else if (qName == "chamber") {
389  fKey = eChamber;
390  } else if (qName == "label") {
391  fKey = eLabel;
392  } else if (qName == "state") {
393  fKey = eState;
394  }
395 }
396 
397 //*******************************************************************************************************
398 // implementation of the characters
399 //*******************************************************************************************************
406 void PSAX2AutoRunParseHandler::characters(const XMLCh *const chars, const XMLSize_t)
407 {
408  if (fFatalError)
409  return;
410 
411  // keep some global information
412  QString str("");
413  switch (fKey) {
414  case eFln:
415  fFlnAutoRunSeq = QString(XMLString::transcode(chars));
416  break;
417  case eLineNo:
418  fCurrentUserLineNo = QString(XMLString::transcode(chars)).toInt();
419  break;
420  default:
421  break;
422  }
423 
424  if (fCmdKey == eComment) {
425  switch (fKey) {
426  case eLineNo:
428  break;
429  case eCmdStr:
430  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
431  break;
432  default:
433  break;
434  }
435  }
436 
437  if (fCmdKey == eIgnoreAlarms) {
438  switch (fKey) {
439  case eLineNo:
441  break;
442  case eCmdStr:
443  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
444  break;
445  case eState:
446  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
447  break;
448  default:
449  break;
450  }
451  }
452 
453  if (fCmdKey == eIgnoreClients) {
454  switch (fKey) {
455  case eLineNo:
457  break;
458  case eCmdStr:
459  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
460  break;
461  case eState:
462  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
463  break;
464  default:
465  break;
466  }
467  }
468 
469  if (fCmdKey == eAlias) {
470  switch (fKey) {
471  case eLineNo:
473  break;
474  case eCmdStr:
475  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
476  break;
477  case eAlias_key:
478  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
480  break;
481  case eAlias_value:
482  fAutoRunCmd.param[1] = QString(XMLString::transcode(chars));
484  break;
485  default:
486  break;
487  }
488  }
489 
490  if (fCmdKey == eBPV) {
491  switch (fKey) {
492  case eLineNo:
494  break;
495  case eCmdStr:
496  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
497  break;
498  case eLabel:
499  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
501  break;
502  case eState:
503  fAutoRunCmd.param[1] = QString(XMLString::transcode(chars));
505  break;
506  default:
507  break;
508  }
509  }
510 
511  if (fCmdKey == eOdbTag) {
512  switch (fKey) {
513  case eLineNo:
515  break;
516  case eCmdStr:
517  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
518  break;
519  case eLabel:
520  fOdbTag.tag = QString(XMLString::transcode(chars));
521  break;
522  case eOdbReadPath:
523  fOdbTag.odb_path = QString(XMLString::transcode(chars));
524  break;
525  case eOdbReadIndex:
526  fOdbTag.idx = QString(XMLString::transcode(chars)).toInt();
527  break;
528  default:
529  break;
530  }
531  }
532 
533  if (fCmdKey == eDegaussWEW) { // collect degauss cmd for the WEW magnet
534  switch (fKey) {
535  case eLineNo:
537  break;
538  case eCmdStr:
539  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
540  break;
541  default:
542  break;
543  }
544  }
545 
546  if (fCmdKey == eDegaussDanfysik) { // collect degauss cmd for the danfysik power supply
547  switch (fKey) {
548  case eLineNo:
550  break;
551  case eCmdStr:
552  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
553  break;
554  default:
555  break;
556  }
557  }
558 
559  if (fCmdKey == eDegauss) { // collect degauss cmd for the sample magnet
560  switch (fKey) {
561  case eLineNo:
563  break;
564  case eCmdStr:
565  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
566  break;
567  default:
568  break;
569  }
570  }
571 
572  if (fCmdKey == eDegaussSpinRot) { // collect degauss cmd for the spin rotator
573  switch (fKey) {
574  case eLineNo:
576  break;
577  case eCmdStr:
578  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
579  break;
580  default:
581  break;
582  }
583  }
584 
585  if (fCmdKey == eSetOdbData) { // collect set odb data
586  switch (fKey) {
587  case eLineNo:
589  break;
590  case eCmdStr:
591  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
592  break;
593  case eOdbSetPath:
594  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
596  break;
597  case eOdbSetIndex:
598  fAutoRunCmd.param[1] = QString(XMLString::transcode(chars));
600  break;
601  case eOdbSetValue:
602  fAutoRunCmd.param[2] = QString(XMLString::transcode(chars));
604  break;
605  case eOdbReadPath:
606  fAutoRunCmd.param[3] = QString(XMLString::transcode(chars));
608  break;
609  case eOdbReadIndex:
610  fAutoRunCmd.param[4] = QString(XMLString::transcode(chars));
612  break;
613  case eOdbTimeout:
614  fAutoRunCmd.param[5] = QString(XMLString::transcode(chars));
616  break;
617  case eOdbTolerance:
618  fAutoRunCmd.param[6] = QString(XMLString::transcode(chars));
620  break;
621  default:
622  break;
623  }
624  }
625 
626  if (fCmdKey == eSetOdbDataArray) {
627  switch (fKey) {
628  case eLineNo:
630  break;
631  case eCmdStr:
632  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
633  break;
634  case eOdbSetPath:
635  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
637  break;
638  case eOdbSetValue:
639  fAutoRunCmd.param[fAutoRunCmd.noElements++] = QString(XMLString::transcode(chars));
640  break;
641  default:
642  break;
643  }
644  }
645 
646  if (fCmdKey == eSetTfl) { // collect set tfl cmd
647  switch (fKey) {
648  case eLineNo:
650  break;
651  case eCmdStr:
652  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
653  break;
654  case eTfl_pos:
655  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
657  break;
658  case eTfl_mode:
659  fAutoRunCmd.param[1] = QString(XMLString::transcode(chars));
661  break;
662  default:
663  break;
664  }
665  }
666 
667  if (fCmdKey == eSetTemp) { // collect set temp cmd
668  switch (fKey) {
669  case eLineNo:
671  break;
672  case eCmdStr:
673  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
674  break;
675  case eTemp:
676  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
677  break;
678  case eDeltaT:
679  fAutoRunCmd.param[1] = QString(XMLString::transcode(chars));
680  break;
681  case eStabilityTimeout:
682  fAutoRunCmd.param[2] = QString(XMLString::transcode(chars));
683  break;
684  case eRamp:
685  fAutoRunCmd.param[3] = QString(XMLString::transcode(chars));
686  break;
687  case eHeaterRange:
688  fAutoRunCmd.param[4] = QString(XMLString::transcode(chars));
689  break;
690  case eP_pid:
691  fAutoRunCmd.param[5] = QString(XMLString::transcode(chars));
692  break;
693  case eI_pid:
694  fAutoRunCmd.param[6] = QString(XMLString::transcode(chars));
695  break;
696  case eD_pid:
697  fAutoRunCmd.param[7] = QString(XMLString::transcode(chars));
698  break;
699  case eFlow:
700  fAutoRunCmd.param[8] = QString(XMLString::transcode(chars));
701  break;
702  default:
703  break;
704  }
705  }
706 
707  if (fCmdKey == eSetSampleHV) { // collect sample HV cmd
708  switch (fKey) {
709  case eLineNo:
711  break;
712  case eCmdStr:
713  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
714  break;
715  case eHv_value:
716  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
718  break;
719  default:
720  break;
721  }
722  }
723 
724  if (fCmdKey == eSetRA_HV) { // collect ring anode HV cmd
725  switch (fKey) {
726  case eLineNo:
728  break;
729  case eCmdStr:
730  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
731  break;
732  case eHv_left:
733  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
735  break;
736  case eHv_right:
737  fAutoRunCmd.param[1] = QString(XMLString::transcode(chars));
739  break;
740  case eHv_top:
741  fAutoRunCmd.param[2] = QString(XMLString::transcode(chars));
743  break;
744  case eHv_bottom:
745  fAutoRunCmd.param[3] = QString(XMLString::transcode(chars));
747  break;
748  default:
749  break;
750  }
751  }
752 
753  if (fCmdKey == eSetTransportHV) {
754  switch (fKey) {
755  case eLineNo:
757  break;
758  case eCmdStr:
759  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
760  break;
762  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
764  break;
765  default:
766  break;
767  }
768  }
769 
770  if (fCmdKey == eSetHvOff) {
771  switch (fKey) {
772  case eLineNo:
774  break;
775  case eCmdStr:
776  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
777  break;
778  case eChamber:
779  str = QString(XMLString::transcode(chars));
780  if (!str.contains("mc", Qt::CaseInsensitive) && !str.contains("tc", Qt::CaseInsensitive) &&
781  !str.contains("sc", Qt::CaseInsensitive)) {
782  QString err = QString("PSAX2AutoRunParseHandler::characters: found chamber name '%1' which is not supported").arg(str);
783  internalFatalError(err);
784  }
785  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
787  break;
788  default:
789  break;
790  }
791  }
792 
793  if (fCmdKey == eSetFieldWEWL) { // collect set field WEWL cmd
794  switch (fKey) {
795  case eLineNo:
797  break;
798  case eCmdStr:
799  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
800  break;
801  case eField_value:
802  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
804  break;
805  case eField_unit:
806  fAutoRunCmd.param[1] = QString(XMLString::transcode(chars));
808  default:
809  break;
810  }
811  }
812 
813  if (fCmdKey == eSetFieldWEWH) { // collect set field WEWH cmd
814  switch (fKey) {
815  case eLineNo:
817  break;
818  case eCmdStr:
819  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
820  break;
821  case eField_value:
822  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
824  break;
825  case eField_unit:
826  fAutoRunCmd.param[1] = QString(XMLString::transcode(chars));
828  default:
829  break;
830  }
831  }
832 
833  if (fCmdKey == eSetFieldDanfysik) { // collect set field Danfysik cmd
834  switch (fKey) {
835  case eLineNo:
837  break;
838  case eCmdStr:
839  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
840  break;
841  case eField_value:
842  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
844  break;
845  case eField_unit:
846  fAutoRunCmd.param[1] = QString(XMLString::transcode(chars));
848  default:
849  break;
850  }
851  }
852 
853  if (fCmdKey == eSetField) { // collect set field sample magnet cmd
854  switch (fKey) {
855  case eLineNo:
857  break;
858  case eCmdStr:
859  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
860  break;
861  case eField_value:
862  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
864  break;
865  case eField_unit:
866  fAutoRunCmd.param[1] = QString(XMLString::transcode(chars));
868  default:
869  break;
870  }
871  }
872 
873  if (fCmdKey == eSetSpinRot) {
874  switch (fKey) {
875  case eLineNo:
877  break;
878  case eCmdStr:
879  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
880  break;
881  case eAngle:
882  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
884  break;
885  case eNoDegauss:
886  fAutoRunCmd.param[1] = QString(XMLString::transcode(chars));
888  break;
889  default:
890  break;
891  }
892  }
893 
894  if (fCmdKey == eSetFOM) { // collect set FOM cmd
895  switch (fKey) {
896  case eLineNo:
898  break;
899  case eCmdStr:
900  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
901  break;
902  case eCurrent:
903  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
905  break;
906  default:
907  break;
908  }
909  }
910 
911  if (fCmdKey == eSetTitle) { // collect set title cmd
912  switch (fKey) {
913  case eLineNo:
915  break;
916  case eCmdStr:
917  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
918  break;
919  case eTitle:
920  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
922  break;
923  case eOdb_sample:
924  fAutoRunCmd.param[1] = QString(XMLString::transcode(chars));
926  break;
927  case eOdb_temp:
928  fAutoRunCmd.param[2] = QString(XMLString::transcode(chars));
930  break;
931  case eOdb_field:
932  fAutoRunCmd.param[3] = QString(XMLString::transcode(chars));
934  break;
935  case eOdb_transp:
936  fAutoRunCmd.param[4] = QString(XMLString::transcode(chars));
938  break;
939  case eOdb_hv_samp:
940  fAutoRunCmd.param[5] = QString(XMLString::transcode(chars));
942  break;
943  case eOdb_energy:
944  fAutoRunCmd.param[6] = QString(XMLString::transcode(chars));
946  break;
947  case eOdb_ra_diff_lr:
948  fAutoRunCmd.param[7] = QString(XMLString::transcode(chars));
950  break;
951  case eOdb_ra_diff_tb:
952  fAutoRunCmd.param[8] = QString(XMLString::transcode(chars));
954  break;
955  case eOdb_spin_rot:
956  fAutoRunCmd.param[9] = QString(XMLString::transcode(chars));
958  break;
959  default:
960  break;
961  }
962  }
963 
964  if (fCmdKey == eSetTOF) { // collect set TOF cmd
965  switch (fKey) {
966  case eLineNo:
968  break;
969  case eCmdStr:
970  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
971  break;
972  case eStart:
973  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
975  break;
976  case eStop:
977  fAutoRunCmd.param[1] = QString(XMLString::transcode(chars));
979  break;
980  default:
981  break;
982  }
983  }
984 
985  if (fCmdKey == eSetModInfo) { // collect set moderator info cmd
986  switch (fKey) {
987  case eLineNo:
989  break;
990  case eCmdStr:
991  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
992  break;
993  case eMod:
994  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
996  break;
997  case eMod_date:
998  fAutoRunCmd.param[1] = QString(XMLString::transcode(chars));
1000  break;
1001  default:
1002  break;
1003  }
1004  }
1005 
1006  if (fCmdKey == eSetLEMSetup) { // collect set LEM setup info cmd
1007  switch (fKey) {
1008  case eLineNo:
1010  break;
1011  case eCmdStr:
1012  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
1013  break;
1014  case eSetup:
1015  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
1017  break;
1018  default:
1019  break;
1020  }
1021  }
1022 
1023  if (fCmdKey == eSetWait) { // collect set wait cmd
1024  switch (fKey) {
1025  case eLineNo:
1027  break;
1028  case eCmdStr:
1029  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
1030  break;
1031  case eWait:
1032  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
1034  break;
1035  default:
1036  break;
1037  }
1038  }
1039 
1040  if (fCmdKey == eSetDump) { // collect set dump cmd
1041  switch (fKey) {
1042  case eLineNo:
1044  break;
1045  case eCmdStr:
1046  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
1047  break;
1048  case eNo_dumps:
1049  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
1051  break;
1052  default:
1053  break;
1054  }
1055  }
1056 
1057  if (fCmdKey == eRunStart) { // collect run start cmd
1058  switch (fKey) {
1059  case eLineNo:
1061  break;
1062  case eCmdStr:
1063  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
1064  break;
1065  case eNo_events:
1066  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
1068  break;
1069  case eUnits:
1070  fAutoRunCmd.param[1] = QString(XMLString::transcode(chars));
1072  if (fAutoRunCmd.param[1].toLower() != "sec") {
1073  QString err = QString("PSAX2AutoRunParseHandler::characters: found units '%1' in START command. Currently only 'sec' are supported!").arg(fAutoRunCmd.param[1].toLower());
1074  internalFatalError(err);
1075  }
1076  break;
1077  default:
1078  break;
1079  }
1080  }
1081 
1082  if (fCmdKey == eRunStop) { // collect run stop cmd
1083  switch (fKey) {
1084  case eLineNo:
1086  break;
1087  case eCmdStr:
1088  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
1089  break;
1090  case eNo_events:
1091  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
1093  break;
1094  case eUnits:
1095  fAutoRunCmd.param[1] = QString(XMLString::transcode(chars));
1097  if (fAutoRunCmd.param[1].toLower() != "sec") {
1098  QString err = QString("PSAX2AutoRunParseHandler::characters: found units '%1' in STOP command. Currently only 'sec' are supported!").arg(fAutoRunCmd.param[1].toLower());
1099  internalFatalError(err);
1100  }
1101  break;
1102  default:
1103  break;
1104  }
1105  }
1106 
1107  if (fCmdKey == eWarmUp) { // collect warm up cmd
1108  switch (fKey) {
1109  case eLineNo:
1111  break;
1112  case eCmdStr:
1113  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
1114  break;
1115  case eDate:
1116  fAutoRunCmd.param[0] = QString(XMLString::transcode(chars));
1118  break;
1119  case eTime:
1120  fAutoRunCmd.param[1] = QString(XMLString::transcode(chars));
1122  break;
1123  case eVent:
1124  fAutoRunCmd.param[2] = QString(XMLString::transcode(chars));
1126  break;
1127  default:
1128  break;
1129  }
1130  }
1131 
1132  if (fCmdKey == eLoopList) { // collect loop list elements
1133  switch (fKey) {
1134  case eLoopElement:
1135  if (fLoopNo <= 0) { // fatal error
1136  // stop parsing
1137  QString err("PSAX2AutoRunParseHandler::characters: negative loop fall back!");
1138  internalFatalError(err);
1139  fFatalError = true;
1140  return;
1141  } else {
1142  fLoopInfoVector[fLoopNo-1].list.push_back(QString(XMLString::transcode(chars)).toDouble());
1143  }
1144  default:
1145  break;
1146  }
1147  }
1148 
1149  if (fCmdKey == eLoopIterator) { // collect start, stop, step of the loop iterator
1150  if (fLoopNo <= 0) { // fatal error
1151  // stop parsing
1152  QString err("PSAX2AutoRunParseHandler::characters: negative loop fall back!");
1153  internalFatalError(err);
1154  fFatalError = true;
1155  return;
1156  }
1157  switch (fKey) {
1158  case eLoopStart:
1159  fLoopInfoVector[fLoopNo-1].iterator[0] = QString(XMLString::transcode(chars)).toDouble();
1160  break;
1161  case eLoopStop:
1162  fLoopInfoVector[fLoopNo-1].iterator[1] = QString(XMLString::transcode(chars)).toDouble();
1163  break;
1164  case eLoopStep:
1165  fLoopInfoVector[fLoopNo-1].iterator[2] = QString(XMLString::transcode(chars)).toDouble();
1166  break;
1167  default:
1168  break;
1169  }
1170  }
1171 
1172  if (fCmdKey == eLoopSetTemp) { // collect loop set temperature command information
1173  if (fLoopNo <= 0) { // fatal error
1174  // stop parsing
1175  QString err("PSAX2AutoRunParseHandler::characters: negative loop fall back!");
1176  internalFatalError(err);
1177  fFatalError = true;
1178  return;
1179  }
1180  switch (fKey) {
1181  case eLineNo:
1182  fLoopInfoVector[fLoopNo-1].loopCmd.lineNo = fCurrentUserLineNo;
1183  break;
1184  case eLoopTempTag:
1185  fLoopInfoVector[fLoopNo-1].loopCmd.param[0] = QString(XMLString::transcode(chars));
1186  fLoopInfoVector[fLoopNo-1].loopCmd.noElements++;
1187  break;
1188  case eDeltaT:
1189  fLoopInfoVector[fLoopNo-1].loopCmd.param[1] = QString(XMLString::transcode(chars));
1190  fLoopInfoVector[fLoopNo-1].loopCmd.noElements++;
1191  break;
1192  case eStabilityTimeout:
1193  fLoopInfoVector[fLoopNo-1].loopCmd.param[2] = QString(XMLString::transcode(chars));
1194  fLoopInfoVector[fLoopNo-1].loopCmd.noElements++;
1195  break;
1196  case eRamp:
1197  fLoopInfoVector[fLoopNo-1].loopCmd.param[3] = QString(XMLString::transcode(chars));
1198  fLoopInfoVector[fLoopNo-1].loopCmd.noElements++;
1199  break;
1200  default:
1201  break;
1202  }
1203  }
1204 
1205  if (fCmdKey == eLoopSetSampleHV) { // collect loop set sample HV command information
1206  if (fLoopNo <= 0) { // fatal error
1207  // stop parsing
1208  QString err("PSAX2AutoRunParseHandler::characters: negative loop fall back!");
1209  internalFatalError(err);
1210  fFatalError = true;
1211  return;
1212  }
1213  switch (fKey) {
1214  case eLineNo:
1215  fLoopInfoVector[fLoopNo-1].loopCmd.lineNo = fCurrentUserLineNo;
1216  break;
1217  case eCmdStr:
1218  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
1219  break;
1220  case eLoopSampleHVTag:
1221  fLoopInfoVector[fLoopNo-1].loopCmd.param[0] = QString(XMLString::transcode(chars));
1222  fLoopInfoVector[fLoopNo-1].loopCmd.noElements++;
1223  break;
1224  default:
1225  break;
1226  }
1227  }
1228 
1229  if (fCmdKey == eLoopSetFieldWEWL) { // collect loop set field WEWL command information
1230  if (fLoopNo <= 0) { // fatal error
1231  // stop parsing
1232  QString err("PSAX2AutoRunParseHandler::characters: negative loop fall back!");
1233  internalFatalError(err);
1234  fFatalError = true;
1235  return;
1236  }
1237  switch (fKey) {
1238  case eLineNo:
1239  fLoopInfoVector[fLoopNo-1].loopCmd.lineNo = fCurrentUserLineNo;
1240  break;
1241  case eCmdStr:
1242  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
1243  break;
1244  case eLoopFieldTag:
1245  fLoopInfoVector[fLoopNo-1].loopCmd.param[0] = QString(XMLString::transcode(chars));
1246  fLoopInfoVector[fLoopNo-1].loopCmd.noElements++;
1247  break;
1248  case eField_unit:
1249  fLoopInfoVector[fLoopNo-1].loopCmd.param[1] = QString(XMLString::transcode(chars));
1250  fLoopInfoVector[fLoopNo-1].loopCmd.noElements++;
1251  break;
1252  default:
1253  break;
1254  }
1255  }
1256 
1257  if (fCmdKey == eLoopSetFieldWEWH) { // collect loop set field WEWH command information
1258  if (fLoopNo <= 0) { // fatal error
1259  // stop parsing
1260  QString err("PSAX2AutoRunParseHandler::characters: negative loop fall back!");
1261  internalFatalError(err);
1262  fFatalError = true;
1263  return;
1264  }
1265  switch (fKey) {
1266  case eLineNo:
1267  fLoopInfoVector[fLoopNo-1].loopCmd.lineNo = fCurrentUserLineNo;
1268  break;
1269  case eCmdStr:
1270  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
1271  break;
1272  case eLoopFieldTag:
1273  fLoopInfoVector[fLoopNo-1].loopCmd.param[0] = QString(XMLString::transcode(chars));
1274  fLoopInfoVector[fLoopNo-1].loopCmd.noElements++;
1275  break;
1276  case eField_unit:
1277  fLoopInfoVector[fLoopNo-1].loopCmd.param[1] = QString(XMLString::transcode(chars));
1278  fLoopInfoVector[fLoopNo-1].loopCmd.noElements++;
1279  break;
1280  default:
1281  break;
1282  }
1283  }
1284 
1285  if (fCmdKey == eLoopSetFieldDanfysik) { // collect loop set field Danfysik command information
1286  if (fLoopNo <= 0) { // fatal error
1287  // stop parsing
1288  QString err("PSAX2AutoRunParseHandler::characters: negative loop fall back!");
1289  internalFatalError(err);
1290  fFatalError = true;
1291  return;
1292  }
1293  switch (fKey) {
1294  case eLineNo:
1295  fLoopInfoVector[fLoopNo-1].loopCmd.lineNo = fCurrentUserLineNo;
1296  break;
1297  case eCmdStr:
1298  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
1299  break;
1300  case eLoopFieldTag:
1301  fLoopInfoVector[fLoopNo-1].loopCmd.param[0] = QString(XMLString::transcode(chars));
1302  fLoopInfoVector[fLoopNo-1].loopCmd.noElements++;
1303  break;
1304  case eField_unit:
1305  fLoopInfoVector[fLoopNo-1].loopCmd.param[1] = QString(XMLString::transcode(chars));
1306  fLoopInfoVector[fLoopNo-1].loopCmd.noElements++;
1307  break;
1308  default:
1309  break;
1310  }
1311  }
1312 
1313  if (fCmdKey == eLoopSetField) { // collect loop set field sample magnet command information
1314  if (fLoopNo <= 0) { // fatal error
1315  // stop parsing
1316  QString err("PSAX2AutoRunParseHandler::characters: negative loop fall back!");
1317  internalFatalError(err);
1318  fFatalError = true;
1319  return;
1320  }
1321  switch (fKey) {
1322  case eLineNo:
1323  fLoopInfoVector[fLoopNo-1].loopCmd.lineNo = fCurrentUserLineNo;
1324  break;
1325  case eCmdStr:
1326  fAutoRunCmd.cmdString = QString(XMLString::transcode(chars));
1327  break;
1328  case eLoopFieldTag:
1329  fLoopInfoVector[fLoopNo-1].loopCmd.param[0] = QString(XMLString::transcode(chars));
1330  fLoopInfoVector[fLoopNo-1].loopCmd.noElements++;
1331  break;
1332  case eField_unit:
1333  fLoopInfoVector[fLoopNo-1].loopCmd.param[1] = QString(XMLString::transcode(chars));
1334  fLoopInfoVector[fLoopNo-1].loopCmd.noElements++;
1335  break;
1336  default:
1337  break;
1338  }
1339  }
1340 }
1341 
1342 //*******************************************************************************************************
1343 // implementation of the endElement
1344 //*******************************************************************************************************
1352 void PSAX2AutoRunParseHandler::endElement(const XMLCh *const uri, const XMLCh *const localname,
1353  const XMLCh *const qname)
1354 {
1355  if (fFatalError)
1356  return;
1357 
1358  if (uri) {} // in order to suppress compiler warnings
1359  if (localname) {} // in order to suppress compiler warnings
1360 
1361  QString qName = QString(XMLString::transcode(qname));
1362 
1363  fKey = eEmpty;
1364 
1365  if (qName == "odbTag") {
1366  if ((fOdbTag.tag == "") || (fOdbTag.odb_path == "")) {
1367  // stop parsing
1368  QString err("PSAX2AutoRunParseHandler::endElement: ODB tag not complete");
1369  internalFatalError(err);
1370  fFatalError = true;
1371  return;
1372  }
1373  fArp->fOdbTagVector->push_back(fOdbTag);
1374  }
1375 
1376  if ((qName == "comment") || (qName == "alias") || (qName == "ignore_alarms") || (qName == "ignore_clients") || (qName == "odbTag") ||
1377  (qName == "setBPV") || (qName == "setTfl") || (qName == "setTemp") || (qName == "setSampleHV") || (qName == "setRA_HV") ||
1378  (qName == "setTransportHV") || (qName == "setFieldWEWL") || (qName == "setFieldWEWH") || (qName == "setFieldDanfysik") ||
1379  (qName == "setField") || (qName == "setSpinRot") || (qName == "setTitle") || (qName == "setTOF") || (qName == "setModInfo") ||
1380  (qName == "setLEMSetup") || (qName == "setWait") || (qName == "setDump") ||
1381  (qName == "runStart") || (qName == "runStop") || (qName == "warmUp") ||
1382  (qName == "degaussDanfysik") || (qName == "degaussWEW") || (qName == "degaussMagnet") || (qName == "degaussSpinRot") ||
1383  (qName == "setFOM") || (qName == "setOdbData") || (qName == "setOdbDataArray") || (qName == "setHVOff")) {
1384 
1385  if (qName == "setOdbData")
1387 
1388  if (fLoopNo == 0)
1389  fAutoRunCmdVector->push_back(fAutoRunCmd);
1390  else
1391  fLoopInfoVector[fLoopNo-1].cmd.push_back(fAutoRunCmd);
1392  ClearAutoRunCmd();
1393  }
1394 
1395  if (qName == "loopIterator") { // convert start, stop, step to a list
1396  int no_elements = -1;
1397 
1398  if (fLoopInfoVector[fLoopNo-1].iterator[2] == 0.0) { // fatal error
1399  // stop parsing
1400  QString err("PSAX2AutoRunParseHandler::endElement: loop step iterator == 0!");
1401  internalFatalError(err);
1402  fFatalError = true;
1403  return;
1404  } else {
1405  no_elements = (int)round(round(fLoopInfoVector[fLoopNo-1].iterator[1] -
1406  fLoopInfoVector[fLoopNo-1].iterator[0]) / fLoopInfoVector[fLoopNo-1].iterator[2])+1;
1407 
1408  for (int i=0; i<no_elements; i++)
1409  fLoopInfoVector[fLoopNo-1].list.push_back(fLoopInfoVector[fLoopNo-1].iterator[0] +
1410  i*fLoopInfoVector[fLoopNo-1].iterator[2]);
1411  }
1412  }
1413 
1414  if (qName == "loop") {
1415  // expand loop cmd's
1416  AutoRunCmd expandedLoopCmd;
1417 
1418  expandedLoopCmd.lineNo = fLoopInfoVector[fLoopNo-1].loopCmd.lineNo;
1419  expandedLoopCmd.noElements = fLoopInfoVector[fLoopNo-1].loopCmd.noElements;
1420  for (int i=1; i<fLoopInfoVector[fLoopNo-1].loopCmd.noElements; i++)
1421  expandedLoopCmd.param[i] = fLoopInfoVector[fLoopNo-1].loopCmd.param[i];
1422 
1423  // filter what loop cmd it is
1424  if (fLoopInfoVector[fLoopNo-1].loopCmd.cmd == "loopSetTemp") {
1425  expandedLoopCmd.cmd = "setTemp";
1426  } else if (fLoopInfoVector[fLoopNo-1].loopCmd.cmd == "loopSetSampleHV") {
1427  expandedLoopCmd.cmd = "setSampleHV";
1428  } else if (fLoopInfoVector[fLoopNo-1].loopCmd.cmd == "loopSetFieldWEWL") {
1429  expandedLoopCmd.cmd = "setFieldWEWL";
1430  } else if (fLoopInfoVector[fLoopNo-1].loopCmd.cmd == "loopSetFieldWEWH") {
1431  expandedLoopCmd.cmd = "setFieldWEWH";
1432  } else if (fLoopInfoVector[fLoopNo-1].loopCmd.cmd == "loopSetFieldDanfysik") {
1433  expandedLoopCmd.cmd = "setFieldDanfysik";
1434  } else if (fLoopInfoVector[fLoopNo-1].loopCmd.cmd == "loopSetField") {
1435  expandedLoopCmd.cmd = "setField";
1436  } else { // fatal error
1437  // stop parsing
1438  QString err("PSAX2AutoRunParseHandler::endElement: syntactically incorrect command!");
1439  internalFatalError(err);
1440  fFatalError = true;
1441  return;
1442  }
1443 
1444  // loop over all elements in the list
1445  PXMLLoopListVector::Iterator listIter;
1446  PAutoRunCmdVector::Iterator cmdIter;
1447 
1448  for (listIter = fLoopInfoVector[fLoopNo-1].list.begin();
1449  listIter != fLoopInfoVector[fLoopNo-1].list.end(); ++listIter) {
1450 
1451  expandedLoopCmd.param[0] = QString("%1").arg(*listIter); // copy loop list value
1452  fLoopInfoVector[fLoopNo-1].expandedCmd.push_back(expandedLoopCmd);
1453 
1454  // copy all the remaining cmd's of the loop
1455  for (cmdIter = fLoopInfoVector[fLoopNo-1].cmd.begin();
1456  cmdIter != fLoopInfoVector[fLoopNo-1].cmd.end(); ++cmdIter) {
1457  fLoopInfoVector[fLoopNo-1].expandedCmd.push_back(*cmdIter);
1458  }
1459  }
1460 
1461  // decrement loop nesting counter
1462  fLoopNo--;
1463  if (fLoopNo < 0) { // fatal error
1464  // stop parsing
1465  QString err("PSAX2AutoRunParseHandler::endElement: negative loop fall back!");
1466  internalFatalError(err);
1467  fFatalError = true;
1468  return;
1469  }
1470  PAutoRunCmdVector::Iterator iter;
1471  if (fLoopNo == 0) { // back from all the loops -> add expanded list to fAutoRunCmdVector
1472  QString lastLoopVal("");
1473  for (iter = fLoopInfoVector[0].expandedCmd.begin();
1474  iter != fLoopInfoVector[0].expandedCmd.end(); ++iter) {
1475  // for the loop, the cmdStr might need to be created here
1476  if (iter->cmd == "setSampleHV") {
1477  iter->cmdString = QString("SAMPLE_HV ");
1478  for (int i=0; i<LAR_MAX_PARAM; i++) {
1479  if (!iter->param[i].isEmpty())
1480  iter->cmdString += iter->param[i] + ", ";
1481  }
1482  // remove last ','
1483  iter->cmdString.truncate(iter->cmdString.length()-2);
1484  // keep loop command value
1485  iter->loopVal = iter->param[0];
1486  lastLoopVal = iter->param[0];
1487  } else if (iter->cmd == "setTemp") {
1488  iter->cmdString = QString("TEMP ");
1489  for (int i=0; i<LAR_MAX_PARAM; i++) {
1490  if (!iter->param[i].isEmpty())
1491  iter->cmdString += iter->param[i] + ", ";
1492  }
1493  // remove last ','
1494  iter->cmdString.truncate(iter->cmdString.length()-2);
1495  // keep loop command value
1496  iter->loopVal = iter->param[0];
1497  lastLoopVal = iter->param[0];
1498  } else if (iter->cmd == "setFieldWEWL") {
1499  iter->cmdString = QString("FIELD_WEWL ");
1500  for (int i=0; i<LAR_MAX_PARAM; i++) {
1501  if (!iter->param[i].isEmpty())
1502  iter->cmdString += iter->param[i] + ", ";
1503  }
1504  // remove last ','
1505  iter->cmdString.truncate(iter->cmdString.length()-2);
1506  // keep loop command value
1507  iter->loopVal = iter->param[0];
1508  lastLoopVal = iter->param[0];
1509  } else if (iter->cmd == "setFieldWEWH") {
1510  iter->cmdString = QString("FIELD_WEWH ");
1511  for (int i=0; i<LAR_MAX_PARAM; i++) {
1512  if (!iter->param[i].isEmpty())
1513  iter->cmdString += iter->param[i] + ", ";
1514  }
1515  // remove last ','
1516  iter->cmdString.truncate(iter->cmdString.length()-2);
1517  // keep loop command value
1518  iter->loopVal = iter->param[0];
1519  lastLoopVal = iter->param[0];
1520  } else if (iter->cmd == "setFieldDanfysik") {
1521  iter->cmdString = QString("FIELD_DANFYSIK ");
1522  for (int i=0; i<LAR_MAX_PARAM; i++) {
1523  if (!iter->param[i].isEmpty())
1524  iter->cmdString += iter->param[i] + ", ";
1525  }
1526  // remove last ','
1527  iter->cmdString.truncate(iter->cmdString.length()-2);
1528  // keep loop command value
1529  iter->loopVal = iter->param[0];
1530  lastLoopVal = iter->param[0];
1531  } else if (iter->cmd == "setField") {
1532  iter->cmdString = QString("FIELD ");
1533  for (int i=0; i<LAR_MAX_PARAM; i++) {
1534  if (!iter->param[i].isEmpty())
1535  iter->cmdString += iter->param[i] + ", ";
1536  }
1537  // remove last ','
1538  iter->cmdString.truncate(iter->cmdString.length()-2);
1539  // keep loop command value
1540  iter->loopVal = iter->param[0];
1541  lastLoopVal = iter->param[0];
1542  } else {
1543  iter->loopVal = lastLoopVal;
1544  }
1545 
1546  // store the expanded command
1547  fAutoRunCmdVector->push_back(*iter);
1548  }
1549  // clear the loop list
1550  fLoopInfoVector.clear();
1551  } else { // back from an inner loop -> add expanded list to current loop
1552  for (iter = fLoopInfoVector[fLoopNo].expandedCmd.begin();
1553  iter != fLoopInfoVector[fLoopNo].expandedCmd.end(); ++iter) {
1554  fLoopInfoVector[fLoopNo-1].cmd.push_back(*iter);
1555  }
1556  }
1557  // remove processed loop
1558  if (fLoopInfoVector.size() > 0)
1559  fLoopInfoVector.pop_back();
1560  }
1561 }
1562 
1563 //*******************************************************************************************************
1564 // implementation of the endDocument
1565 //*******************************************************************************************************
1570 {
1571 }
1572 
1573 //*******************************************************************************************************
1574 // implementation of the warning
1575 //*******************************************************************************************************
1581 void PSAX2AutoRunParseHandler::warning(const SAXParseException& exc)
1582 {
1583  XMLParseError err;
1584 
1585  // fill warning information
1586  err.errorCode = LAR_XML_WARNING;
1587  err.lineNo = fCurrentUserLineNo;
1588  err.errorMsg = QString(XMLString::transcode(exc.getMessage()));
1589 
1590  // add to the error message queque
1593  p->push_back(err);
1594 }
1595 
1596 //*******************************************************************************************************
1597 // implementation of the error
1598 //*******************************************************************************************************
1604 void PSAX2AutoRunParseHandler::error(const SAXParseException& exc)
1605 {
1606  XMLParseError err;
1607 
1608  // fill error information
1609  err.errorCode = LAR_XML_ERROR;
1610  err.lineNo = fCurrentUserLineNo;
1611  err.errorMsg = QString(XMLString::transcode(exc.getMessage()));
1612 
1613  // add to the error message queque
1616  p->push_back(err);
1617 }
1618 
1619 //*******************************************************************************************************
1620 // implementation of the fatalError
1621 //*******************************************************************************************************
1627 void PSAX2AutoRunParseHandler::fatalError(const SAXParseException& exc)
1628 {
1629  XMLParseError err;
1630 
1631  // fill error information
1632  err.errorCode = LAR_XML_FATAL;
1633  err.lineNo = fCurrentUserLineNo;
1634  err.errorMsg = QString(XMLString::transcode(exc.getMessage()));
1635 
1636  // add to the error message queque
1639  p->push_back(err);
1640 }
1641 
1642 //*******************************************************************************************************
1643 // implementation of the internalFatalError
1644 //*******************************************************************************************************
1651 {
1652  XMLParseError err;
1653 
1654  // fill error information
1655  err.errorCode = LAR_XML_FATAL;
1656  err.lineNo = fCurrentUserLineNo;
1657  err.errorMsg = msg;
1658 
1659  // add to the error message queque
1662  p->push_back(err);
1663 }
1664 
1665 //*******************************************************************************************************
1666 // implementation of the ClearAutoRunCmd
1667 //*******************************************************************************************************
1672 {
1673  fAutoRunCmd.cmd = "";
1674  fAutoRunCmd.lineNo = -1;
1675  fAutoRunCmd.noElements = 0;
1676  for (int i=0; i<LAR_MAX_PARAM; i++)
1677  fAutoRunCmd.param[i] = "";
1678  fAutoRunCmd.loopVal = "";
1679 }
1680 
1681 //*******************************************************************************************************
1682 // implementation of the CheckOdbSetDataParamsStructure
1683 //*******************************************************************************************************
1688 {
1689  bool error = false;
1690  QString err("PSAX2AutoRunParseHandler::CheckOdbSetDataParamsStructure: ");
1691 
1692  /***************************************************************************
1693  param[0] = set_path (required)
1694  param[1] = set_index
1695  param[2] = set_value (required)
1696  param[3] = read_path
1697  param[4] = read_index
1698  param[5] = timeout
1699  param[6] = tolerance
1700  ****************************************************************************/
1701 
1702  switch (fAutoRunCmd.noElements) {
1703  case 2: // parameters set_path, set_value needs to be set
1704  if ((fAutoRunCmd.param[0].length() == 0) || (fAutoRunCmd.param[2].length() == 0)) {
1705  // set_path or set_value are empty which would be the only valid filling
1706  error = true;
1707  err += QString("if only 2 values are given, they have to be set_path and set_value!");
1708  }
1709  break;
1710  case 3: // parameters set_path, set_index, set_value needs to be set
1711  if ((fAutoRunCmd.param[0].length() == 0) || (fAutoRunCmd.param[1].length() == 0) ||
1712  (fAutoRunCmd.param[2].length() == 0)) {
1713  // set_path, set_index or set_value are empty which would be the only valid filling
1714  error = true;
1715  err += QString("if only 3 values are given, they have to be set_path, set_index, and set_value!");
1716  }
1717  break;
1718  case 5: // parameters set_path, set_value, read_path, timeout, tolerance needs to be set
1719  if ((fAutoRunCmd.param[1].length() != 0) || (fAutoRunCmd.param[4].length() != 0)) {
1720  // set_index or read_index set -> error since the above parameter needs to be set
1721  error = true;
1722  err += QString("if 5 values are given, they have to be: set_path, set_value, read_path, timeout, tolerance!");
1723  }
1724  break;
1725  case 6: // parameters set_path, set_value, read_path, timeout, tolerance, and (set_index or read_index) needs to be set
1726  if ((fAutoRunCmd.param[1].length() != 0) && (fAutoRunCmd.param[4].length() != 0)) {
1727  // set_index and read_index set -> error since the above parameter needs to be set
1728  error = true;
1729  err += QString("if 6 values are given, they have to be: set_path, set_value, read_path, timeout, tolerance, and (set_index or read_index) !");
1730  }
1731  break;
1732  case 7: // all used, from syntax point of view correct
1733  break;
1734  default:
1735  error = true;
1736  err += QString("ODB_SET_DATA parameter error! Please check the manual");
1737  break;
1738  }
1739 
1740  if (error) { // parameter error
1741  internalFatalError(err);
1742  fFatalError = true;
1743  return;
1744  }
1745 }
1746 
1747 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1748 
1749 //*******************************************************************************************************
1750 // implementation of the constructor
1751 //*******************************************************************************************************
1760 PAutoRunParser::PAutoRunParser(QString userAutoRunSeqFln, QString &schemaPath, QString &xmlFln,
1761  PAutoRunCmdVector *arcv, POdbTagVector *odbtagv) :
1762  fInputFileName(userAutoRunSeqFln),
1763  fAutoRunXMLSchemaPath(schemaPath),
1764  fXMLFileName(xmlFln),
1765  fAutoRunCmdVector(arcv),
1766  fOdbTagVector(odbtagv)
1767 {
1769 
1771 }
1772 
1773 //*******************************************************************************************************
1774 // implementation of the destructor
1775 //*******************************************************************************************************
1780 {
1781 }
1782 
1783 //*******************************************************************************************************
1784 // implementation of ConvertToXML
1785 //*******************************************************************************************************
1791 {
1792  int line_no = 0;
1793  int loop_no = 0;
1794  QString errorMsg;
1795  QString str;
1796  QString offset = "";
1797  QStringList runSeq;
1798  QStringList runSeqXML;
1799 
1800  QFile file(fInputFileName);
1801 
1802  // check if file exists
1803  if (!file.exists()) {
1804  errorMsg = "File does not exist: '" + fInputFileName + "'";
1806  fParseErrorCounter = 1;
1807  return;
1808  }
1809 
1810  // read file into string list
1811  if (file.open(QIODevice::ReadOnly)) {
1812  QTextStream stream( &file );
1813  QString line;
1814  while ( !stream.atEnd() ) {
1815  line = stream.readLine(); // line of text excluding '\n'
1816  runSeq += line;
1817  }
1818  file.close();
1819  } else {
1820  errorMsg = "Couldn't open file (" + fInputFileName + ")";
1822  }
1823 
1824  // collect all the alias
1825  QString key(""), value("");
1826  line_no = 0;
1827  for (QStringList::Iterator it = runSeq.begin(); it != runSeq.end(); ++it) {
1828  line_no++;
1829  str = (QString)*it;
1830  str = str.trimmed();
1831  if (str.startsWith("ALIAS")) {
1832  key = str.section(' ', 1, 1);
1833  value = str.section(' ', 2);
1834  if ((key.length() == 0) || (value.length() == 0)) {
1835  QString err = QString("**ERROR** Invalid ALIAS command!");
1836  emit ParseError(fXMLParseErrorVector->size(), fParseErrorCounter, LAR_INVALID_CMD, line_no, err);
1837  return;
1838  }
1839  fAlias[key] = value;
1840  }
1841  }
1842 
1843  // convert to XML
1844  // write header
1845  runSeqXML.clear();
1846  runSeqXML += QString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
1847  runSeqXML += QString("<autoRun xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
1848  runSeqXML += QString(" xsi:noNamespaceSchemaLocation=\"file:")+fAutoRunXMLSchemaPath+QString("\">");
1849  runSeqXML += QString("<autoRunName>%1</autoRunName>").arg(fInputFileName);
1850 
1851  // write body
1852  line_no = 0;
1853  for (QStringList::Iterator it = runSeq.begin(); it != runSeq.end(); ++it) {
1854  line_no++;
1855  str = (QString)*it;
1856  str = str.trimmed();
1857  str = str.simplified();
1858 
1859  if (str.isEmpty())
1860  continue;
1861 
1862  if (str.startsWith("%"))
1863  ConvertComment(str, line_no, offset, runSeqXML);
1864  else if (str.startsWith("ALIAS"))
1865  ConvertAlias(str, line_no, offset, runSeqXML);
1866  else if (str.startsWith("IGNORE_ALARMS"))
1867  ConvertIgnoreAlarms(str, line_no, offset, runSeqXML);
1868  else if (str.startsWith("IGNORE_CLIENTS"))
1869  ConvertIgnoreClients(str, line_no, offset, runSeqXML);
1870  else if (str.startsWith("BPV"))
1871  ConvertBPV(str, line_no, offset, runSeqXML);
1872  else if (str.startsWith("FIELD_WEWL"))
1873  ConvertFieldWEWL(str, line_no, offset, runSeqXML);
1874  else if (str.startsWith("FIELD_WEWH"))
1875  ConvertFieldWEWH(str, line_no, offset, runSeqXML);
1876  else if (str.startsWith("FIELD_DANFYSIK"))
1877  ConvertFieldDanfysik(str, line_no, offset, runSeqXML);
1878  else if (str.startsWith("FIELD "))
1879  ConvertField(str, line_no, offset, runSeqXML);
1880  else if (str.startsWith("FOM"))
1881  ConvertFOM(str, line_no, offset, runSeqXML);
1882  else if (str.startsWith("LEM_SETUP"))
1883  ConvertLEMSetup(str, line_no, offset, runSeqXML);
1884  else if (str.startsWith("MODERATOR"))
1885  ConvertModerator(str, line_no, offset, runSeqXML);
1886  else if (str.startsWith("SAMPLE_HV"))
1887  ConvertSampleHV(str, line_no, offset, runSeqXML);
1888  else if (str.startsWith("RA_HV"))
1889  ConvertRA_HV(str, line_no, offset, runSeqXML);
1890  else if (str.startsWith("TRANSPORT_HV"))
1891  ConvertTransportHV(str, line_no, offset, runSeqXML);
1892  else if (str.startsWith("HV_OFF"))
1893  ConvertHVOff(str, line_no, offset, runSeqXML);
1894  else if (str.startsWith("ODB_TAG"))
1895  ConvertOdbTag(str, line_no, offset, runSeqXML);
1896  else if (str.startsWith("ODB_SET_DATA"))
1897  if (str.startsWith("ODB_SET_DATA_ARRAY")) {
1898  ConvertOdbSetDataArray(str, line_no, offset, runSeqXML);
1899  } else {
1900  ConvertOdbSetData(str, line_no, offset, runSeqXML);
1901  }
1902  else if (str.startsWith("SPIN_ROT"))
1903  ConvertSpinRot(str, line_no, offset, runSeqXML);
1904  else if (str.startsWith("START"))
1905  ConvertStart(str, line_no, offset, runSeqXML);
1906  else if (str.startsWith("STOP"))
1907  ConvertStop(str, line_no, offset, runSeqXML);
1908  else if (str.startsWith("TFL"))
1909  ConvertTfl(str, line_no, offset, runSeqXML);
1910  else if (str.startsWith("TEMP"))
1911  ConvertTemp(str, line_no, offset, runSeqXML);
1912  else if (str.startsWith("TITLE"))
1913  ConvertTitle(str, line_no, offset, runSeqXML);
1914  else if (str.startsWith("TOF"))
1915  ConvertTOF(str, line_no, offset, runSeqXML);
1916  else if (str.startsWith("WAIT"))
1917  ConvertWait(str, line_no, offset, runSeqXML);
1918  else if (str.startsWith("WARMUP"))
1919  ConvertWarmUp(str, line_no, offset, runSeqXML);
1920  else if (str.startsWith("DUMP"))
1921  ConvertDump(str, line_no, offset, runSeqXML);
1922  else if (str.startsWith("DEGAUSS_WEW"))
1923  ConvertDegaussWEW(str, line_no, offset, runSeqXML);
1924  else if (str.startsWith("DEGAUSS_DANFYSIK"))
1925  ConvertDegaussDanfysik(str, line_no, offset, runSeqXML);
1926  else if (str.startsWith("DEGAUSS_MAGNET"))
1927  ConvertDegauss(str, line_no, offset, runSeqXML);
1928  else if (str.startsWith("DEGAUSS_SPIN_ROT"))
1929  ConvertDegaussSpinRot(str, line_no, offset, runSeqXML);
1930  else if (str.startsWith("LOOP_START")) {
1931  ConvertLoopStart(line_no, offset, runSeqXML);
1932  loop_no++;
1933  offset = "";
1934  for (int i=0; i<loop_no; i++)
1935  offset += " ";
1936  }
1937  else if (str.startsWith("LOOP_LIST"))
1938  ConvertLoopList(str, offset, runSeqXML);
1939  else if (str.startsWith("LOOP_ITERATOR"))
1940  ConvertLoopIterator(str, offset, runSeqXML);
1941  else if (str.startsWith("LOOP_TEMP"))
1942  ConvertLoopTemp(str, line_no, offset, runSeqXML);
1943  else if (str.startsWith("LOOP_SAMPLE_HV"))
1944  ConvertLoopSampleHV(str, line_no, offset, runSeqXML);
1945  else if (str.startsWith("LOOP_FIELD_WEWL"))
1946  ConvertLoopFieldWEWL(str, line_no, offset, runSeqXML);
1947  else if (str.startsWith("LOOP_FIELD_WEWH"))
1948  ConvertLoopFieldWEWH(str, line_no, offset, runSeqXML);
1949  else if (str.startsWith("LOOP_FIELD_DANFYSIK"))
1950  ConvertLoopFieldDanfysik(str, line_no, offset, runSeqXML);
1951  else if (str.startsWith("LOOP_FIELD "))
1952  ConvertLoopField(str, line_no, offset, runSeqXML);
1953  else if (str.startsWith("LOOP_END")) {
1954  loop_no--;
1955  offset = "";
1956  for (int i=0; i<loop_no; i++)
1957  offset += " ";
1958  ConvertLoopEnd(offset, runSeqXML);
1959  }
1960  else {
1962  emit ParseError(fXMLParseErrorVector->size(), fParseErrorCounter, LAR_INVALID_CMD, line_no, "Invalid Auto Run Command.");
1963  }
1964  }
1965  // write closure
1966  runSeqXML += QString("</autoRun>");
1967 
1968  // save XML-file
1969  QFile fileOut( fXMLFileName );
1970  if (fileOut.open( QIODevice::WriteOnly )) {
1971  QTextStream stream( &fileOut );
1972  for ( QStringList::Iterator it = runSeqXML.begin(); it != runSeqXML.end(); ++it )
1973  stream << *it << "\n";
1974  fileOut.close();
1975  } else {
1976  emit ParseError(fXMLParseErrorVector->size(), fParseErrorCounter, LAR_OUTPUT_FILE_WRITE_ERROR, 0, "Couldn't write XML ouput.");
1977  }
1978 }
1979 
1980 
1981 //*******************************************************************************************************
1982 // implementation of CheckForAlias
1983 //*******************************************************************************************************
1991 QString PAutoRunParser::CheckForAlias(QString &str)
1992 {
1993  QString result = str;
1994  QStringList tokens = result.split(QRegExp("[\\s,\\[\\]]"), Qt::SkipEmptyParts);
1995 
1996  QList<QString> keys = fAlias.keys();
1997  QList<QString>::iterator it;
1998  QString key(""), sKey(""), sAlias("");
1999  int idx1, idx2;
2000  for (it = keys.begin(); it != keys.end(); ++it) {
2001  key = (QString)*it; // alias key
2002  for (int i=0; i<tokens.count(); i++) { // tokenized lar string
2003  if (key == tokens[i]) {
2004  sKey = " "+key; // needed to make sure that key in results starts with a space
2005  sAlias = " "+fAlias[key];
2006  result.replace(sKey, sAlias);
2007 
2008  // check if something like "..."[idx] is found, and if yes fix it
2009  idx1 = result.indexOf("\"[");
2010  if (idx1 > 0) {
2011  idx2 = result.indexOf("]", idx1);
2012  for (int i=idx1; i<=idx2; i++)
2013  result[i] = result[i+1];
2014  result[idx2] = '"';
2015  }
2016  }
2017  }
2018  }
2019 
2020  return result;
2021 }
2022 
2023 
2024 //*******************************************************************************************************
2025 // implementation of ConvertAlias
2026 //*******************************************************************************************************
2035 void PAutoRunParser::ConvertAlias(QString &str, int lineNo, QString &offset, QStringList &xml)
2036 {
2037  xml += offset + QString("<autoRunCmd>");
2038  xml += offset + QString(" <alias>");
2039  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2040  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2041  xml += offset + QString(" <alias_key>%1</alias_key>").arg(str.section(' ', 1, 1));
2042  xml += offset + QString(" <alias_value>%1</alias_value>").arg(str.section(' ', 2, 2));
2043  xml += offset + QString(" </alias>");
2044  xml += offset + QString("</autoRunCmd>");
2045 }
2046 
2047 //*******************************************************************************************************
2048 // implementation of ConvertIgnoreAlarms
2049 //*******************************************************************************************************
2058 void PAutoRunParser::ConvertIgnoreAlarms(QString &str, int lineNo, QString &offset, QStringList &xml)
2059 {
2060  xml += offset + QString("<autoRunCmd>");
2061  xml += offset + QString(" <ignore_alarms>");
2062  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2063  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2064  xml += offset + QString(" <state>%1</state>").arg(str.section(' ', 1, 1).toLower());
2065  xml += offset + QString(" </ignore_alarms>");
2066  xml += offset + QString("</autoRunCmd>");
2067 }
2068 
2069 //*******************************************************************************************************
2070 // implementation of ConvertIgnoreClients
2071 //*******************************************************************************************************
2080 void PAutoRunParser::ConvertIgnoreClients(QString &str, int lineNo, QString &offset, QStringList &xml)
2081 {
2082  xml += offset + QString("<autoRunCmd>");
2083  xml += offset + QString(" <ignore_clients>");
2084  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2085  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2086  xml += offset + QString(" <state>%1</state>").arg(str.section(' ', 1, 1).toLower());
2087  xml += offset + QString(" </ignore_clients>");
2088  xml += offset + QString("</autoRunCmd>");
2089 }
2090 
2091 //*******************************************************************************************************
2092 // implementation of ConvertBPV
2093 //*******************************************************************************************************
2102 void PAutoRunParser::ConvertBPV(QString &str, int lineNo, QString &offset, QStringList &xml)
2103 {
2104  xml += offset + QString("<autoRunCmd>");
2105  xml += offset + QString(" <setBPV>");
2106  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2107  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2108  if (str.contains("X"))
2109  xml += offset + QString(" <label>X</label>");
2110  else if (str.contains("Y"))
2111  xml += offset + QString(" <label>Y</label>");
2112  else
2113  xml += offset + QString(" <label>?</label>");
2114  xml += offset + QString(" <state>%1</state>").arg(str.section(' ', 1, 1).toLower());
2115  xml += offset + QString(" </setBPV>");
2116  xml += offset + QString("</autoRunCmd>");
2117 }
2118 
2119 //*******************************************************************************************************
2120 // implementation of ConvertComment
2121 //*******************************************************************************************************
2130 void PAutoRunParser::ConvertComment(QString &str, int lineNo, QString &offset, QStringList &xml)
2131 {
2132  QString comment = str;
2133  comment.replace("<", " less-than ");
2134  comment.replace(">", " greater-than ");
2135 
2136  xml += offset + QString("<autoRunCmd>");
2137  xml += offset + QString(" <comment>");
2138  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2139  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(comment);
2140  xml += offset + QString(" </comment>");
2141  xml += offset + QString("</autoRunCmd>");
2142 }
2143 
2144 //*******************************************************************************************************
2145 // implementation of ConvertDump
2146 //*******************************************************************************************************
2156 void PAutoRunParser::ConvertDump(QString &str, int lineNo, QString &offset, QStringList &xml)
2157 {
2158  QString line = CheckForAlias(str);
2159  xml += offset + QString("<autoRunCmd>");
2160  xml += offset + QString(" <setDump>");
2161  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2162  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2163  xml += offset + QString(" <no_dumps>%1</no_dumps>").arg(line.section(' ', 1, 1));
2164  xml += offset + QString(" </setDump>");
2165  xml += offset + QString("</autoRunCmd>");
2166 }
2167 
2168 //*******************************************************************************************************
2169 // implementation of ConvertFieldWEWL
2170 //*******************************************************************************************************
2180 void PAutoRunParser::ConvertFieldWEWL(QString &str, int lineNo, QString &offset, QStringList &xml)
2181 {
2182  QString line = CheckForAlias(str);
2183  xml += offset + QString("<autoRunCmd>");
2184  xml += offset + QString(" <setFieldWEWL>");
2185  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2186  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2187  xml += offset + QString(" <field_value>%1</field_value>").arg(line.section(' ', 1, 1));
2188  QString unit("");
2189  unit = line.section(' ', 2, 2);
2190  if ((unit != "A") && (unit != "G") && (unit != "")) {
2191  QString err = QString("**ERROR** Wrong units in FIELD_WEWL cmd, Found '%1', allowed 'G', 'A', or nothing which is identical to 'A'.").arg(unit);
2193  return;
2194  }
2195  if (unit == "G")
2196  xml += offset + QString(" <field_unit>G</field_unit>");
2197  else
2198  xml += offset + QString(" <field_unit>A</field_unit>");
2199  xml += offset + QString(" </setFieldWEWL>");
2200  xml += offset + QString("</autoRunCmd>");
2201 }
2202 
2203 //*******************************************************************************************************
2204 // implementation of ConvertFieldWEWH
2205 //*******************************************************************************************************
2215 void PAutoRunParser::ConvertFieldWEWH(QString &str, int lineNo, QString &offset, QStringList &xml)
2216 {
2217  QString line = CheckForAlias(str);
2218  xml += offset + QString("<autoRunCmd>");
2219  xml += offset + QString(" <setFieldWEWH>");
2220  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2221  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2222  xml += offset + QString(" <field_value>%1</field_value>").arg(line.section(' ', 1, 1));
2223  QString unit("");
2224  unit = line.section(' ', 2, 2);
2225  if ((unit != "A") && (unit != "G") && (unit != "")) {
2226  QString err = QString("**ERROR** Wrong units in FIELD_WEWH cmd, Found '%1', allowed 'G', 'A', or nothing which is identical to 'A'.").arg(unit);
2228  return;
2229  }
2230  if (unit == "G")
2231  xml += offset + QString(" <field_unit>G</field_unit>");
2232  else
2233  xml += offset + QString(" <field_unit>A</field_unit>");
2234  xml += offset + QString(" </setFieldWEWH>");
2235  xml += offset + QString("</autoRunCmd>");
2236 }
2237 
2238 //*******************************************************************************************************
2239 // implementation of ConvertFieldDanfysik
2240 //*******************************************************************************************************
2250 void PAutoRunParser::ConvertFieldDanfysik(QString &str, int lineNo, QString &offset, QStringList &xml)
2251 {
2252  QString line = CheckForAlias(str);
2253  xml += offset + QString("<autoRunCmd>");
2254  xml += offset + QString(" <setFieldDanfysik>");
2255  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2256  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2257  xml += offset + QString(" <field_value>%1</field_value>").arg(line.section(' ', 1, 1));
2258  QString unit("");
2259  unit = line.section(' ', 2, 2);
2260  if ((unit != "A") && (unit != "G") && (unit != "")) {
2261  QString err = QString("**ERROR** Wrong units in FIELD_DANFYSIK cmd, Found '%1', allowed 'G', 'A', or nothing which is identical to 'A'.").arg(unit);
2263  return;
2264  }
2265  if (unit == "G")
2266  xml += offset + QString(" <field_unit>G</field_unit>");
2267  else
2268  xml += offset + QString(" <field_unit>A</field_unit>");
2269  xml += offset + QString(" </setFieldDanfysik>");
2270  xml += offset + QString("</autoRunCmd>");
2271 }
2272 
2273 //*******************************************************************************************************
2274 // implementation of ConvertField
2275 //*******************************************************************************************************
2285 void PAutoRunParser::ConvertField(QString &str, int lineNo, QString &offset, QStringList &xml)
2286 {
2287  QString line = CheckForAlias(str);
2288  xml += offset + QString("<autoRunCmd>");
2289  xml += offset + QString(" <setField>");
2290  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2291  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2292  xml += offset + QString(" <field_value>%1</field_value>").arg(line.section(' ', 1, 1));
2293  QString unit("");
2294  unit = line.section(' ', 2, 2);
2295  if ((unit != "A") && (unit != "G") && (unit != "")) {
2296  QString err = QString("**ERROR** Wrong units in FIELD cmd, Found '%1', allowed 'G', 'A', or nothing which is identical to 'A'.").arg(unit);
2298  return;
2299  }
2300  if (unit == "G")
2301  xml += offset + QString(" <field_unit>G</field_unit>");
2302  else
2303  xml += offset + QString(" <field_unit>A</field_unit>");
2304  xml += offset + QString(" </setField>");
2305  xml += offset + QString("</autoRunCmd>");
2306 }
2307 
2308 //*******************************************************************************************************
2309 // implementation of ConvertFOM
2310 //*******************************************************************************************************
2320 void PAutoRunParser::ConvertFOM(QString &str, int lineNo, QString &offset, QStringList &xml)
2321 {
2322  QString line = CheckForAlias(str);
2323  xml += offset + QString("<autoRunCmd>");
2324  xml += offset + QString(" <setFOM>");
2325  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2326  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2327  xml += offset + QString(" <current>%1</current>").arg(line.section(' ', 1, 1).remove(","));
2328  xml += offset + QString(" </setFOM>");
2329  xml += offset + QString("</autoRunCmd>");
2330 }
2331 
2332 //*******************************************************************************************************
2333 // implementation of ConvertLEMSetup
2334 //*******************************************************************************************************
2344 void PAutoRunParser::ConvertLEMSetup(QString &str, int lineNo, QString &offset, QStringList &xml)
2345 {
2346  QString line = CheckForAlias(str);
2347  xml += offset + QString("<autoRunCmd>");
2348  xml += offset + QString(" <setLEMSetup>");
2349  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2350  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2351  xml += offset + QString(" <setup>%1</setup>").arg(line.section(' ', 1));
2352  xml += offset + QString(" </setLEMSetup>");
2353  xml += offset + QString("</autoRunCmd>");
2354 }
2355 
2356 //*******************************************************************************************************
2357 // implementation of ConvertLoopStart
2358 //*******************************************************************************************************
2367 void PAutoRunParser::ConvertLoopStart(int lineNo, QString &offset, QStringList &xml)
2368 {
2369  xml += offset + QString("<autoRunCmd>");
2370  xml += offset + QString(" <loop>");
2371  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2372 }
2373 
2374 //*******************************************************************************************************
2375 // implementation of ConvertLoopList
2376 //*******************************************************************************************************
2385 void PAutoRunParser::ConvertLoopList(QString &str, QString &offset, QStringList &xml)
2386 {
2387  QString workStr;
2388  QString value;
2389  int i=0;
2390 
2391  xml += offset + QString("<loopList>");
2392  workStr = str.section('[', 1).trimmed();
2393  value = " ";
2394  while (!value.isEmpty()) {
2395  value = workStr.section(',',i,i);
2396  value.remove(",");
2397  if (!value.trimmed().isEmpty()) {
2398  value = value.trimmed().remove("]");
2399  xml += offset + QString(" <loopElement>%1</loopElement>").arg(value);
2400  }
2401  i++;
2402  }
2403  xml += offset + QString("</loopList>");
2404 }
2405 
2406 //*******************************************************************************************************
2407 // implementation of ConvertLoopIterator
2408 //*******************************************************************************************************
2417 void PAutoRunParser::ConvertLoopIterator(QString &str, QString &offset, QStringList &xml)
2418 {
2419  QString workStr;
2420  QString value;
2421  int i=0;
2422 
2423  xml += offset + QString("<loopIterator>");
2424  workStr = str.section('[', 1).trimmed();
2425  value = " ";
2426  while (!value.isEmpty()) {
2427  value = workStr.section(',',i,i);
2428  value.remove(",");
2429  if (!value.trimmed().isEmpty()) {
2430  value = value.trimmed().remove("]");
2431  switch (i) {
2432  case 0:
2433  xml += offset + QString(" <loopStart>%1</loopStart>").arg(value);
2434  break;
2435  case 1:
2436  xml += offset + QString(" <loopStop>%1</loopStop>").arg(value);
2437  break;
2438  case 2:
2439  xml += offset + QString(" <loopStep>%1</loopStep>").arg(value);
2440  break;
2441  default:
2442  break;
2443  }
2444  }
2445  i++;
2446  }
2447  xml += offset + QString("</loopIterator>");
2448 }
2449 
2450 //*******************************************************************************************************
2451 // implementation of ConvertLoopTemp
2452 //*******************************************************************************************************
2462 void PAutoRunParser::ConvertLoopTemp(QString &str, int lineNo, QString &offset, QStringList &xml)
2463 {
2464  QString workStr;
2465  QString line = CheckForAlias(str);
2466 
2467  xml += offset + QString("<loopSetTemp>");
2468  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2469  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2470  workStr = line.section(' ', 1, 1);
2471  workStr.remove(",");
2472  xml += offset + QString(" <loopTempTag>%1</loopTempTag>").arg(workStr);
2473  xml += offset + QString(" <deltaT>%1</deltaT>").arg(line.section(',', 1, 1).trimmed());
2474  xml += offset + QString(" <stabilityTimeout>%1</stabilityTimeout>").arg(line.section(',', 2, 2).trimmed());
2475  workStr = line.section(',', 3, 3); // ramp
2476  // check if a ramp value is given
2477  if (workStr.remove(",").trimmed().length()>0) {
2478  xml += offset + QString(" <ramp>%1</ramp>").arg(workStr.remove(",").trimmed());
2479  }
2480  xml += offset + QString("</loopSetTemp>");
2481 }
2482 
2483 //*******************************************************************************************************
2484 // implementation of ConvertLoopSampleHV
2485 //*******************************************************************************************************
2495 void PAutoRunParser::ConvertLoopSampleHV(QString &str, int lineNo, QString &offset, QStringList &xml)
2496 {
2497  QString line = CheckForAlias(str);
2498  xml += offset + QString("<loopSetSampleHV>");
2499  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2500  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2501  xml += offset + QString(" <loopSampleHVTag>%1</loopSampleHVTag>").arg(line.section(' ', 1, 1));
2502  xml += offset + QString("</loopSetSampleHV>");
2503 }
2504 
2505 //*******************************************************************************************************
2506 // implementation of ConvertLoopFieldWEWL
2507 //*******************************************************************************************************
2517 void PAutoRunParser::ConvertLoopFieldWEWL(QString &str, int lineNo, QString &offset, QStringList &xml)
2518 {
2519  QString line = CheckForAlias(str);
2520  xml += offset + QString("<loopSetFieldWEWL>");
2521  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2522  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2523  xml += offset + QString(" <loopFieldTag>%1</loopFieldTag>").arg(line.section(' ', 1, 1));
2524  QString unit("");
2525  unit = line.section(' ', 2, 2);
2526  if ((unit != "A") && (unit != "G") && (unit != "")) {
2527  QString err = QString("**ERROR** Wrong units in LOOP_FIELD_WEWL cmd, Found '%1', allowed 'G', 'A', or nothing which is identical to 'A'.").arg(unit);
2529  return;
2530  }
2531  if (unit == "G")
2532  xml += offset + QString(" <field_unit>G</field_unit>");
2533  else
2534  xml += offset + QString(" <field_unit>A</field_unit>");
2535  xml += offset + QString("</loopSetFieldWEWL>");
2536 }
2537 
2538 //*******************************************************************************************************
2539 // implementation of ConvertLoopFieldWEWH
2540 //*******************************************************************************************************
2550 void PAutoRunParser::ConvertLoopFieldWEWH(QString &str, int lineNo, QString &offset, QStringList &xml)
2551 {
2552  QString line = CheckForAlias(str);
2553  xml += offset + QString("<loopSetFieldWEWH>");
2554  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2555  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2556  xml += offset + QString(" <loopFieldTag>%1</loopFieldTag>").arg(line.section(' ', 1, 1));
2557  QString unit("");
2558  unit = line.section(' ', 2, 2);
2559  if ((unit != "A") && (unit != "G") && (unit != "")) {
2560  QString err = QString("**ERROR** Wrong units in LOOP_FIELD_WEWH cmd, Found '%1', allowed 'G', 'A', or nothing which is identical to 'A'.").arg(unit);
2562  return;
2563  }
2564  if (unit == "G")
2565  xml += offset + QString(" <field_unit>G</field_unit>");
2566  else
2567  xml += offset + QString(" <field_unit>A</field_unit>");
2568  xml += offset + QString("</loopSetFieldWEWH>");
2569 }
2570 
2571 //*******************************************************************************************************
2572 // implementation of ConvertLoopFieldDanfysik
2573 //*******************************************************************************************************
2583 void PAutoRunParser::ConvertLoopFieldDanfysik(QString &str, int lineNo, QString &offset, QStringList &xml)
2584 {
2585  QString line = CheckForAlias(str);
2586  xml += offset + QString("<loopSetFieldDanfysik>");
2587  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2588  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2589  xml += offset + QString(" <loopFieldTag>%1</loopFieldTag>").arg(line.section(' ', 1, 1));
2590  QString unit("");
2591  unit = line.section(' ', 2, 2);
2592  if ((unit != "A") && (unit != "G") && (unit != "")) {
2593  QString err = QString("**ERROR** Wrong units in LOOP_FIELD_DANFYSIK cmd, Found '%1', allowed 'G', 'A', or nothing which is identical to 'A'.").arg(unit);
2595  return;
2596  }
2597  if (unit == "G")
2598  xml += offset + QString(" <field_unit>G</field_unit>");
2599  else
2600  xml += offset + QString(" <field_unit>A</field_unit>");
2601  xml += offset + QString("</loopSetFieldDanfysik>");
2602 }
2603 
2604 //*******************************************************************************************************
2605 // implementation of ConvertLoopField
2606 //*******************************************************************************************************
2616 void PAutoRunParser::ConvertLoopField(QString &str, int lineNo, QString &offset, QStringList &xml)
2617 {
2618  QString line = CheckForAlias(str);
2619  xml += offset + QString("<loopSetField>");
2620  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2621  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2622  xml += offset + QString(" <loopFieldTag>%1</loopFieldTag>").arg(line.section(' ', 1, 1));
2623  QString unit("");
2624  unit = line.section(' ', 2, 2);
2625  if ((unit != "A") && (unit != "G") && (unit != "")) {
2626  QString err = QString("**ERROR** Wrong units in LOOP_FIELD cmd, Found '%1', allowed 'G', 'A', or nothing which is identical to 'A'.").arg(unit);
2628  return;
2629  }
2630  if (unit == "G")
2631  xml += offset + QString(" <field_unit>G</field_unit>");
2632  else
2633  xml += offset + QString(" <field_unit>A</field_unit>");
2634  xml += offset + QString("</loopSetField>");
2635 }
2636 
2637 //*******************************************************************************************************
2638 // implementation of ConvertLoopEnd
2639 //*******************************************************************************************************
2647 void PAutoRunParser::ConvertLoopEnd(QString &offset, QStringList &xml)
2648 {
2649  xml += offset + QString(" </loop>");
2650  xml += offset + QString("</autoRunCmd>");
2651 }
2652 
2653 //*******************************************************************************************************
2654 // implementation of ConvertModerator
2655 //*******************************************************************************************************
2665 void PAutoRunParser::ConvertModerator(QString &str, int lineNo, QString &offset, QStringList &xml)
2666 {
2667  QString line = CheckForAlias(str);
2668  QString workStr;
2669 
2670  xml += offset + QString("<autoRunCmd>");
2671  xml += offset + QString(" <setModInfo>");
2672  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2673  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2674  workStr = line.section(' ', 1, 1);
2675  workStr.remove(",");
2676  xml += offset + QString(" <mod>%1</mod>").arg(workStr);
2677  xml += offset + QString(" <mod_date>%1</mod_date>").arg(line.section(' ', 2));
2678  xml += offset + QString(" </setModInfo>");
2679  xml += offset + QString("</autoRunCmd>");
2680 }
2681 
2682 //*******************************************************************************************************
2683 // implementation of ConvertOdbSetData
2684 //*******************************************************************************************************
2694 void PAutoRunParser::ConvertOdbSetData(QString &str, int lineNo, QString &offset, QStringList &xml)
2695 {
2696  QString line = CheckForAlias(str);
2697  line.remove("ODB_SET_DATA ");
2698 
2699  QStringList tokens = line.split(QRegExp("[,]"));
2700 
2701  if ((tokens.count() != 2) && (tokens.count() != 5)) { // something is totaly wrong
2702  QString err = QString("**ERROR** Invalid ODB_SET_DATA command! Given number of parameters have to be 2 or 5 found %1").arg(tokens.count());
2704  return;
2705  }
2706 
2707  xml += offset + QString("<autoRunCmd>");
2708  xml += offset + QString(" <setOdbData>");
2709  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2710  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2711 
2712  QString sec("");
2713  if (tokens.count() == 2) { // ODB_SET_DATA without readback
2714  int idx1 = tokens[0].indexOf("["), idx2;
2715  if (idx1 == -1) {
2716  // set path
2717  xml += offset + QString(" <set_path>%1</set_path>").arg(tokens[0].remove('"').trimmed());
2718  } else {
2719  // set path
2720  sec = tokens[0];
2721  sec.truncate(idx1);
2722  xml += offset + QString(" <set_path>%1</set_path>").arg(sec.remove('"').trimmed());
2723  // set index
2724  idx2 = tokens[0].indexOf("]", idx1);
2725  xml += offset + QString(" <set_index>%1</set_index>").arg(tokens[0].mid(idx1+1,idx2-idx1-1));
2726  }
2727  // set value
2728  xml += offset + QString(" <set_value>%1</set_value>").arg(tokens[1].remove('"').trimmed());
2729  } else if (tokens.count() == 5) {
2730  int idx1 = tokens[0].indexOf("["), idx2;
2731  if (idx1 == -1) { // no index
2732  // set path
2733  xml += offset + QString(" <set_path>%1</set_path>").arg(tokens[0].remove('"').trimmed());
2734  } else {
2735  // set path
2736  sec = tokens[0];
2737  sec.truncate(idx1);
2738  xml += offset + QString(" <set_path>%1</set_path>").arg(sec.remove('"').trimmed());
2739  // set index
2740  idx2 = tokens[0].indexOf("]", idx1);
2741  xml += offset + QString(" <set_index>%1</set_index>").arg(tokens[0].mid(idx1+1,idx2-idx1-1));
2742  }
2743  // set value
2744  xml += offset + QString(" <set_value>%1</set_value>").arg(tokens[1].remove('"').trimmed());
2745 
2746  // set readback path (and index if present)
2747  idx1 = tokens[2].indexOf("[");
2748  if (idx1 == -1) {
2749  // set path
2750  xml += offset + QString(" <read_path>%1</read_path>").arg(tokens[2].remove('"').trimmed());
2751  } else {
2752  // set path
2753  sec = tokens[2];
2754  sec.truncate(idx1);
2755  xml += offset + QString(" <read_path>%1</read_path>").arg(sec.remove('"').trimmed());
2756  // set index
2757  idx2 = tokens[2].indexOf("]", idx1);
2758  xml += offset + QString(" <read_index>%1</read_index>").arg(tokens[2].mid(idx1+1,idx2-idx1-1));
2759  }
2760 
2761  // set timeout
2762  xml += offset + QString(" <timeout>%1</timeout>").arg(tokens[3].trimmed());
2763 
2764  // tolerance
2765  xml += offset + QString(" <tolerance>%1</tolerance>").arg(tokens[4].trimmed());
2766  } else {
2767  QString err = QString("**ERROR** Invalid ODB_SET_DATA command! Given number of parameters have to be 2 or 5 found %1").arg(tokens.count());
2769  return;
2770  }
2771 
2772  xml += offset + QString(" </setOdbData>");
2773  xml += offset + QString("</autoRunCmd>");
2774 }
2775 
2776 //*******************************************************************************************************
2777 // implementation of ConvertOdbSetDataArray
2778 //*******************************************************************************************************
2787 void PAutoRunParser::ConvertOdbSetDataArray(QString &str, int lineNo, QString &offset, QStringList &xml)
2788 {
2789  QString line = CheckForAlias(str);
2790  QString sec;
2791 
2792  xml += offset + QString("<autoRunCmd>");
2793  xml += offset + QString(" <setOdbDataArray>");
2794  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2795  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2796  // set path
2797  sec = line.section(",", 0, 0);
2798  sec.remove("ODB_SET_DATA_ARRAY ");
2799  xml += offset + QString(" <set_path>%1</set_path>").arg(sec.remove('"').trimmed());
2800 
2801  // handle all the potentially being present entries
2802  int i=1;
2803  bool done = false, ok;
2804  do {
2805  sec = str.section(",", i, i);
2806  sec = sec.trimmed();
2807  if (sec.length() == 0) { // no token left
2808  done = true;
2809  } else {
2810  sec.toFloat(&ok);
2811  if (ok) {
2812  xml += offset + QString(" <set_value>%1</set_value>").arg(sec);
2813  i++;
2814  } else {
2815  QString err = QString("**ERROR** Invalid ODB_SET_DATA_ARRAY command! Currently only float arrays are supported.");
2817  return;
2818  }
2819  }
2820  } while (!done);
2821 
2822  xml += offset + QString(" </setOdbDataArray>");
2823  xml += offset + QString("</autoRunCmd>");
2824 }
2825 
2826 //*******************************************************************************************************
2827 // implementation of ConvertSampleHV
2828 //*******************************************************************************************************
2838 void PAutoRunParser::ConvertOdbTag(QString &str, int lineNo, QString &offset, QStringList &xml)
2839 {
2840  QString line = CheckForAlias(str);
2841 
2842  // get ODB path
2843  QString path = line.section(' ', 2);
2844  int pos = path.indexOf("[");
2845  if (pos >= 0)
2846  path.truncate(pos);
2847 
2848  // get ODB path index if present
2849  QString idxStr("-1"); // -1 means there is no index present, i.e. ODB path is a single variable
2850  if (pos >= 0) {
2851  QString sstr = line.section(' ', 2);
2852  int pos2 = sstr.indexOf("]");
2853  sstr.truncate(pos2);
2854  idxStr = sstr.right(pos2-pos-1);
2855  }
2856 
2857  xml += offset + QString("<autoRunCmd>");
2858  xml += offset + QString(" <odbTag>");
2859  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2860  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2861  xml += offset + QString(" <label>%1</label>").arg(line.section(' ', 1, 1));
2862  xml += offset + QString(" <read_path>%1</read_path>").arg(path);
2863  xml += offset + QString(" <read_index>%1</read_index>").arg(idxStr);
2864  xml += offset + QString(" </odbTag>");
2865  xml += offset + QString("</autoRunCmd>");
2866 }
2867 
2868 //*******************************************************************************************************
2869 // implementation of ConvertSampleHV
2870 //*******************************************************************************************************
2880 void PAutoRunParser::ConvertSampleHV(QString &str, int lineNo, QString &offset, QStringList &xml)
2881 {
2882  QString line = CheckForAlias(str);
2883  xml += offset + QString("<autoRunCmd>");
2884  xml += offset + QString(" <setSampleHV>");
2885  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2886  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2887  xml += offset + QString(" <hv_value>%1</hv_value>").arg(line.section(' ', 1, 1));
2888  xml += offset + QString(" </setSampleHV>");
2889  xml += offset + QString("</autoRunCmd>");
2890 }
2891 
2892 //*******************************************************************************************************
2893 // implementation of ConvertRA_HV
2894 //*******************************************************************************************************
2904 void PAutoRunParser::ConvertRA_HV(QString &str, int lineNo, QString &offset, QStringList &xml)
2905 {
2906  QString line = CheckForAlias(str);
2907  QString workStr;
2908  QStringList tokens;
2909 
2910  // check that there are the right number of tokens, this could e.g. fail if somebody writes accidently
2911  // RA_HV 9.15, 9.15, 9.15, 9,15
2912  // ^
2913  // |--- error here !!
2914  tokens = str.split(",", Qt::SkipEmptyParts);
2915  if ((tokens.count() != 2) && (tokens.count() != 4)) { // error
2916  QString err = QString("**ERROR** Invalid HV_RA command! Found %1 HV values: '%2' (2 or 4 required).").arg(tokens.count()).arg(str);
2918  return;
2919  }
2920 
2921  xml += offset + QString("<autoRunCmd>");
2922  xml += offset + QString(" <setRA_HV>");
2923  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2924  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2925  workStr = line.section(' ', 1, 1);
2926  workStr = workStr.section(',', 0, 0);
2927  workStr.remove(",");
2928  xml += offset + QString(" <hv_left>%1</hv_left>").arg(workStr.trimmed());
2929  workStr = str.section(',', 1, 1);
2930  xml += offset + QString(" <hv_right>%1</hv_right>").arg(workStr.trimmed());
2931  workStr = str.section(',', 2, 2);
2932  if (!workStr.isNull()) {
2933  xml += offset + QString(" <hv_top>%1</hv_top>").arg(workStr.trimmed());
2934  workStr = str.section(',', 3, 3);
2935  xml += offset + QString(" <hv_bottom>%1</hv_bottom>").arg(workStr.trimmed());
2936  }
2937  xml += offset + QString(" </setRA_HV>");
2938  xml += offset + QString("</autoRunCmd>");
2939 }
2940 
2941 //*******************************************************************************************************
2942 // implementation of ConvertTransportHV
2943 //*******************************************************************************************************
2953 void PAutoRunParser::ConvertTransportHV(QString &str, int lineNo, QString &offset, QStringList &xml)
2954 {
2955  QString line = CheckForAlias(str);
2956  xml += offset + QString("<autoRunCmd>");
2957  xml += offset + QString(" <setTransportHV>");
2958  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2959  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2960  xml += offset + QString(" <transportHvSettingFileName>%1</transportHvSettingFileName>").arg(line.remove("TRANSPORT_HV "));
2961  xml += offset + QString(" </setTransportHV>");
2962  xml += offset + QString("</autoRunCmd>");
2963 }
2964 
2965 //*******************************************************************************************************
2966 // implementation of ConvertHVOff
2967 //*******************************************************************************************************
2977 void PAutoRunParser::ConvertHVOff(QString &str, int lineNo, QString &offset, QStringList &xml)
2978 {
2979  QString line = CheckForAlias(str);
2980  xml += offset + QString("<autoRunCmd>");
2981  xml += offset + QString(" <setHVOff>");
2982  xml += offset + QString(" <line>%1</line>").arg(lineNo);
2983  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
2984  xml += offset + QString(" <chamber>%1</chamber>").arg(line.remove("HV_OFF "));
2985  xml += offset + QString(" </setHVOff>");
2986  xml += offset + QString("</autoRunCmd>");
2987 }
2988 
2989 //*******************************************************************************************************
2990 // implementation of ConvertSpinRot
2991 //*******************************************************************************************************
3001 void PAutoRunParser::ConvertSpinRot(QString &str, int lineNo, QString &offset, QStringList &xml)
3002 {
3003  QString line = CheckForAlias(str);
3004 
3005  // make sure that the argument is either "off" or a number within range
3006  QString arg = line;
3007  arg = line.section(' ', 1, 1);
3008  if (!arg.contains("off")) {
3009  bool ok;
3010  float fval = arg.toFloat(&ok);
3011  if (!ok) {
3012  QString err = QString("**ERROR** Invalid SPIN_ROT command! Argument is neither \"off\", nor a number between -90.0..+90.0.");
3014  return;
3015  }
3016  if ((fval < -90.0) || (fval > 90.0)) {
3017  QString err = QString("**ERROR** Invalid SPIN_ROT command! Argument is out of range (-90.0..+90.0), found %1.").arg(fval);
3019  return;
3020  }
3021  }
3022 
3023  xml += offset + QString("<autoRunCmd>");
3024  xml += offset + QString(" <setSpinRot>");
3025  xml += offset + QString(" <line>%1</line>").arg(lineNo);
3026  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
3027  xml += offset + QString(" <angle>%1</angle>").arg(line.section(' ', 1, 1));
3028  QString noDegauss = line.section(' ', 2, 2);
3029  if (arg.contains("off") && (noDegauss.indexOf("ndg", 0, Qt::CaseInsensitive) == 0)) {
3030  QString err = QString("**ERROR** Invalid SPIN_ROT command! You cannot combine 'off' with 'ndg'").arg(noDegauss);
3032  return;
3033  }
3034  if (!noDegauss.isEmpty()) {
3035  if (noDegauss.indexOf("ndg", 0, Qt::CaseInsensitive) == 0) {
3036  xml += offset + QString(" <no_degauss>%1</no_degauss>").arg(noDegauss);
3037  } else {
3038  QString err = QString("**ERROR** Invalid SPIN_ROT command! Unkown 2nd argument '%1'. Allowed would be 'ndg'").arg(noDegauss);
3040  return;
3041  }
3042  }
3043  xml += offset + QString(" </setSpinRot>");
3044  xml += offset + QString("</autoRunCmd>");
3045 }
3046 
3047 //*******************************************************************************************************
3048 // implementation of ConvertStart
3049 //*******************************************************************************************************
3059 void PAutoRunParser::ConvertStart(QString &str, int lineNo, QString &offset, QStringList &xml)
3060 {
3061  QString line = CheckForAlias(str);
3062  QString units("");
3063 
3064  xml += offset + QString("<autoRunCmd>");
3065  xml += offset + QString(" <runStart>");
3066  xml += offset + QString(" <line>%1</line>").arg(lineNo);
3067  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
3068  xml += offset + QString(" <no_events>%1</no_events>").arg((int)line.section(' ', 1, 1).toDouble());
3069  units = line.section(' ', 2, 2);
3070  if (!units.isEmpty()) {
3071  xml += offset + QString(" <units>%1</units>").arg(units);
3072  }
3073  xml += offset + QString(" </runStart>");
3074  xml += offset + QString("</autoRunCmd>");
3075 }
3076 
3077 //*******************************************************************************************************
3078 // implementation of ConvertStop
3079 //*******************************************************************************************************
3089 void PAutoRunParser::ConvertStop(QString &str, int lineNo, QString &offset, QStringList &xml)
3090 {
3091  QString line = CheckForAlias(str);
3092  QString units("");
3093  xml += offset + QString("<autoRunCmd>");
3094  xml += offset + QString(" <runStop>");
3095  xml += offset + QString(" <line>%1</line>").arg(lineNo);
3096  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
3097  xml += offset + QString(" <no_events>%1</no_events>").arg((int)line.section(' ', 1, 1).toDouble());
3098  units = line.section(' ', 2, 2);
3099  if (!units.isEmpty()) {
3100  xml += offset + QString(" <units>%1</units>").arg(units);
3101  }
3102  xml += offset + QString(" </runStop>");
3103  xml += offset + QString("</autoRunCmd>");
3104 }
3105 
3106 //*******************************************************************************************************
3107 // implementation of ConvertTfl
3108 //*******************************************************************************************************
3117 void PAutoRunParser::ConvertTfl(QString &str, int lineNo, QString &offset, QStringList &xml)
3118 {
3119  QString line = CheckForAlias(str);
3120  QString workStr;
3121 
3122  xml += offset + QString("<autoRunCmd>");
3123  xml += offset + QString(" <setTfl>");
3124  xml += offset + QString(" <line>%1</line>").arg(lineNo);
3125  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
3126  workStr = line.section(' ', 1, 1);
3127  workStr = workStr.section(',', 0, 0);
3128  workStr.remove(",");
3129  xml += offset + QString(" <tfl_pos>%1</tfl_pos>").arg(workStr);
3130  workStr = line.section(',', 1, 1);
3131  workStr.remove(",");
3132  xml += offset + QString(" <tfl_mode>%1</tfl_mode>").arg(workStr.trimmed());
3133  xml += offset + QString(" </setTfl>");
3134  xml += offset + QString("</autoRunCmd>");
3135 }
3136 
3137 //*******************************************************************************************************
3138 // implementation of ConvertTemp
3139 //*******************************************************************************************************
3149 void PAutoRunParser::ConvertTemp(QString &str, int lineNo, QString &offset, QStringList &xml)
3150 {
3151  QString line = CheckForAlias(str);
3152  QString workStr;
3153 
3154  xml += offset + QString("<autoRunCmd>");
3155  xml += offset + QString(" <setTemp>");
3156  xml += offset + QString(" <line>%1</line>").arg(lineNo);
3157  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
3158  workStr = line.section(' ', 1, 1);
3159  workStr = workStr.section(',', 0, 0);
3160  workStr.remove(",");
3161  xml += offset + QString(" <temp>%1</temp>").arg(workStr);
3162  workStr = line.section(',', 1);
3163  if (workStr.contains(",")>0) { // full command
3164  workStr = line.section(',', 1, 1); // dT
3165  workStr.remove(",");
3166  xml += offset + QString(" <deltaT>%1</deltaT>").arg(workStr.trimmed());
3167  workStr = line.section(',', 2, 2); // stability timeout
3168  workStr.remove(",");
3169  xml += offset + QString(" <stabilityTimeout>%1</stabilityTimeout>").arg(workStr.trimmed());
3170  workStr = line.section(',', 3, 3); // ramp
3171  // check if a ramp value is given
3172  if (workStr.remove(",").trimmed().length()>0) {
3173  xml += offset + QString(" <ramp>%1</ramp>").arg(workStr.remove(",").trimmed());
3174  }
3175  workStr = line.section(',', 4, 4); // heater range
3176  // check if a heater range value is given
3177  if (workStr.remove(",").trimmed().length()>0) {
3178  xml += offset + QString(" <heaterRange>%1</heaterRange>").arg(workStr.remove(",").trimmed());
3179  }
3180  workStr = line.section(',', 5, 5); // P
3181  // check if a P value is given
3182  if (workStr.remove(",").trimmed().length()>0) {
3183  xml += offset + QString(" <P_PID>%1</P_PID>").arg(workStr.remove(",").trimmed());
3184  }
3185  workStr = line.section(',', 6, 6); // I
3186  // check if a I value is given
3187  if (workStr.remove(",").trimmed().length()>0) {
3188  xml += offset + QString(" <I_PID>%1</I_PID>").arg(workStr.remove(",").trimmed());
3189  }
3190  workStr = line.section(',', 7, 7); // D
3191  // check if a D value is given
3192  if (workStr.remove(",").trimmed().length()>0) {
3193  xml += offset + QString(" <D_PID>%1</D_PID>").arg(workStr.remove(",").trimmed());
3194  }
3195  workStr = line.section(',', 8, 8); // flow
3196  // check if a flow value is given
3197  if (workStr.remove(",").trimmed().length()>0) {
3198  xml += offset + QString(" <flow>%1</flow>").arg(workStr.remove(",").trimmed());
3199  }
3200  } else { // only T, dT given
3201  xml += offset + QString(" <deltaT>%1</deltaT>").arg(workStr.trimmed());
3202  }
3203  xml += offset + QString(" </setTemp>");
3204  xml += offset + QString("</autoRunCmd>");
3205 }
3206 
3207 //*******************************************************************************************************
3208 // implementation of ConvertTitle
3209 //*******************************************************************************************************
3219 void PAutoRunParser::ConvertTitle(QString &str, int lineNo, QString &offset, QStringList &xml)
3220 {
3221  QString line = CheckForAlias(str);
3222  QString workStr;
3223 
3224  xml += offset + QString("<autoRunCmd>");
3225  xml += offset + QString(" <setTitle>");
3226  xml += offset + QString(" <line>%1</line>").arg(lineNo);
3227  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
3228  xml += offset + QString(" <title>%1</title>").arg(line.section(' ', 1));
3229  // check for ODB tags
3230  if (line.contains("ODB_SAMPLE")>0)
3231  xml += offset + QString(" <odb_sample>true</odb_sample>");
3232  else
3233  xml += offset + QString(" <odb_sample>false</odb_sample>");
3234  if (line.contains("ODB_TEMP")>0)
3235  xml += offset + QString(" <odb_temp>true</odb_temp>");
3236  else
3237  xml += offset + QString(" <odb_temp>false</odb_temp>");
3238  if (line.contains("ODB_FIELD")>0)
3239  xml += offset + QString(" <odb_field>true</odb_field>");
3240  else
3241  xml += offset + QString(" <odb_field>false</odb_field>");
3242  if (line.contains("ODB_TRANSP")>0)
3243  xml += offset + QString(" <odb_transp>true</odb_transp>");
3244  else
3245  xml += offset + QString(" <odb_transp>false</odb_transp>");
3246  if (line.contains("ODB_HV_SAMP")>0)
3247  xml += offset + QString(" <odb_hv_samp>true</odb_hv_samp>");
3248  else
3249  xml += offset + QString(" <odb_hv_samp>false</odb_hv_samp>");
3250  if (line.contains("ODB_ENERGY")>0)
3251  xml += offset + QString(" <odb_energy>true</odb_energy>");
3252  else
3253  xml += offset + QString(" <odb_energy>false</odb_energy>");
3254  if (line.contains("ODB_RA_DIFF_LR")>0)
3255  xml += offset + QString(" <odb_ra_diff_lr>true</odb_ra_diff_lr>");
3256  else
3257  xml += offset + QString(" <odb_ra_diff_lr>false</odb_ra_diff_lr>");
3258  if (line.contains("ODB_RA_DIFF_TB")>0)
3259  xml += offset + QString(" <odb_ra_diff_tb>true</odb_ra_diff_tb>");
3260  else
3261  xml += offset + QString(" <odb_ra_diff_tb>false</odb_ra_diff_tb>");
3262  if (line.contains("ODB_SPIN_ROT")>0)
3263  xml += offset + QString(" <odb_spin_rot>true</odb_spin_rot>");
3264  else
3265  xml += offset + QString(" <odb_spin_rot>false</odb_spin_rot>");
3266  xml += offset + QString(" </setTitle>");
3267  xml += offset + QString("</autoRunCmd>");
3268 }
3269 
3270 //*******************************************************************************************************
3271 // implementation of ConvertTOF
3272 //*******************************************************************************************************
3282 void PAutoRunParser::ConvertTOF(QString &str, int lineNo, QString &offset, QStringList &xml)
3283 {
3284  QString line = CheckForAlias(str);
3285  QString workStr;
3286 
3287  xml += offset + QString("<autoRunCmd>");
3288  xml += offset + QString(" <setTOF>");
3289  xml += offset + QString(" <line>%1</line>").arg(lineNo);
3290  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
3291  workStr = line.section(' ', 1, 1);
3292  workStr = workStr.section(',', 0, 0);
3293  workStr.remove(",");
3294  xml += offset + QString(" <start>%1</start>").arg(workStr);
3295  xml += offset + QString(" <stop>%1</stop>").arg(line.section(',', 1, 1).trimmed());
3296  xml += offset + QString(" </setTOF>");
3297  xml += offset + QString("</autoRunCmd>");
3298 }
3299 
3300 //*******************************************************************************************************
3301 // implementation of ConvertWait
3302 //*******************************************************************************************************
3312 void PAutoRunParser::ConvertWait(QString &str, int lineNo, QString &offset, QStringList &xml)
3313 {
3314  QString line = CheckForAlias(str);
3315  xml += offset + QString("<autoRunCmd>");
3316  xml += offset + QString(" <setWait>");
3317  xml += offset + QString(" <line>%1</line>").arg(lineNo);
3318  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
3319  xml += offset + QString(" <wait>%1</wait>").arg(line.section(' ', 1, 1, QString::SectionSkipEmpty));
3320  xml += offset + QString(" </setWait>");
3321  xml += offset + QString("</autoRunCmd>");
3322 }
3323 
3324 //*******************************************************************************************************
3325 // implementation of ConvertWarmUp
3326 //*******************************************************************************************************
3336 void PAutoRunParser::ConvertWarmUp(QString &str, int lineNo, QString &offset, QStringList &xml)
3337 {
3338  QString line = CheckForAlias(str);
3339  xml += offset + QString("<autoRunCmd>");
3340  xml += offset + QString(" <warmUp>");
3341  xml += offset + QString(" <line>%1</line>").arg(lineNo);
3342  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
3343  xml += offset + QString(" <date>%1</date>").arg(line.section(' ', 1, 1).remove(",").trimmed());
3344  xml += offset + QString(" <time>%1</time>").arg(line.section(',', 1, 1).trimmed());
3345  if (line.indexOf("vent") == -1) {
3346  xml += offset + QString(" <vent>0</vent>");
3347  } else {
3348  xml += offset + QString(" <vent>1</vent>");
3349  }
3350  xml += offset + QString(" </warmUp>");
3351  xml += offset + QString("</autoRunCmd>");
3352 }
3353 
3354 //*******************************************************************************************************
3355 // implementation of ConvertDegaussWEW
3356 //*******************************************************************************************************
3365 void PAutoRunParser::ConvertDegaussWEW(QString &str, int lineNo, QString &offset, QStringList &xml)
3366 {
3367  xml += offset + QString("<autoRunCmd>");
3368  xml += offset + QString(" <degaussWEW>");
3369  xml += offset + QString(" <line>%1</line>").arg(lineNo);
3370  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
3371  xml += offset + QString(" </degaussWEW>");
3372  xml += offset + QString("</autoRunCmd>");
3373 }
3374 
3375 //*******************************************************************************************************
3376 // implementation of ConvertDegaussDanfysik
3377 //*******************************************************************************************************
3386 void PAutoRunParser::ConvertDegaussDanfysik(QString &str, int lineNo, QString &offset, QStringList &xml)
3387 {
3388  xml += offset + QString("<autoRunCmd>");
3389  xml += offset + QString(" <degaussDanfysik>");
3390  xml += offset + QString(" <line>%1</line>").arg(lineNo);
3391  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
3392  xml += offset + QString(" </degaussDanfysik>");
3393  xml += offset + QString("</autoRunCmd>");
3394 }
3395 
3396 //*******************************************************************************************************
3397 // implementation of ConvertDegauss
3398 //*******************************************************************************************************
3407 void PAutoRunParser::ConvertDegauss(QString &str, int lineNo, QString &offset, QStringList &xml)
3408 {
3409  xml += offset + QString("<autoRunCmd>");
3410  xml += offset + QString(" <degaussMagnet>");
3411  xml += offset + QString(" <line>%1</line>").arg(lineNo);
3412  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
3413  xml += offset + QString(" </degaussMagnet>");
3414  xml += offset + QString("</autoRunCmd>");
3415 }
3416 
3417 //*******************************************************************************************************
3418 // implementation of ConvertDegaussSpinRot
3419 //*******************************************************************************************************
3428 void PAutoRunParser::ConvertDegaussSpinRot(QString &str, int lineNo, QString &offset, QStringList &xml)
3429 {
3430  xml += offset + QString("<autoRunCmd>");
3431  xml += offset + QString(" <degaussSpinRot>");
3432  xml += offset + QString(" <line>%1</line>").arg(lineNo);
3433  xml += offset + QString(" <cmd_str>%1</cmd_str>").arg(str);
3434  xml += offset + QString(" </degaussSpinRot>");
3435  xml += offset + QString("</autoRunCmd>");
3436 }
3437 
3438 //*******************************************************************************************************
3439 // implementation of Parse
3440 //*******************************************************************************************************
3445 {
3446  QString errorMsg;
3447 
3448  // initialize xerces XML framework
3449  try {
3450  XMLPlatformUtils::Initialize();
3451  } catch (const XMLException &toCatch) {
3452  errorMsg = QString("XML xerces Error during initialization! Message:\n") +
3453  QString(XMLString::transcode(toCatch.getMessage()));
3455  }
3456 
3457  // create a SAX parser object
3458  SAX2XMLReader *parser = XMLReaderFactory::createXMLReader();
3459  // set all the necessary parser flags
3460  parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true);
3461  parser->setFeature(XMLUni::fgXercesSchema, true);
3462  parser->setFeature(XMLUni::fgXercesSchemaFullChecking, true);
3463  // for validation scheme 'auto'
3464  parser->setFeature(XMLUni::fgSAX2CoreValidation, true);
3465  parser->setFeature(XMLUni::fgXercesDynamic, true);
3466 
3467  // create XML parse handler
3468  PSAX2AutoRunParseHandler handler(this);
3469  parser->setContentHandler(&handler);
3470  parser->setErrorHandler(&handler);
3471 
3472  // do the parsing
3473  try {
3474  parser->parse(fXMLFileName.toLatin1().data());
3475  } catch(const OutOfMemoryException&) {
3476  errorMsg = QString("XML xerces: Out of Memory Exception!");
3478  } catch(const XMLException &e) {
3479  errorMsg = QString("Error during parsing in '") + fXMLFileName +
3480  QString("', Exception message:\n") +
3481  QString(XMLString::transcode(e.getMessage()));
3483  } catch(...) {
3484  errorMsg = QString("");
3486  }
3487 
3488  // delete parser
3489  if (parser) {
3490  delete parser;
3491  parser = 0;
3492  }
3493 
3494  // terminate xerces XML framework
3495  XMLPlatformUtils::Terminate();
3496 
3497  // emit all encountered errors
3498  PXMLParseErrorVector::iterator it;
3499  for (it = fXMLParseErrorVector->begin(); it != fXMLParseErrorVector->end(); ++it) {
3500  emit ParseError(fXMLParseErrorVector->size(), fParseErrorCounter, it->errorCode, it->lineNo, it->errorMsg);
3502  }
3503 
3504  // clean up fXMLParseErrorVector
3505  fXMLParseErrorVector->clear();
3506 }
void ConvertLoopTemp(QString &str, int lineNo, QString &offset, QStringList &xml)
void ConvertField(QString &str, int lineNo, QString &offset, QStringList &xml)
void ConvertLoopFieldDanfysik(QString &str, int lineNo, QString &offset, QStringList &xml)
bool fFatalError
indicates an internal fatal error while parsing
int fCurrentUserLineNo
current line number of the user auto run sequence. Needed for error msg
void ConvertComment(QString &str, int lineNo, QString &offset, QStringList &xml)
void ConvertDump(QString &str, int lineNo, QString &offset, QStringList &xml)
int lineNo
line number in the user auto run seqence where the error occured
QMap< QString, QString > fAlias
keep all alias
#define LAR_XML_INIT_ERROR
XML init error tag.
Definition: lemAutoRun.h:56
#define LAR_XML_ERROR
XML error tag (parsing)
Definition: lemAutoRun.h:61
void ConvertWait(QString &str, int lineNo, QString &offset, QStringList &xml)
void ConvertLoopField(QString &str, int lineNo, QString &offset, QStringList &xml)
QString fFlnAutoRunSeq
file name of the user auto run sequence
void ConvertSpinRot(QString &str, int lineNo, QString &offset, QStringList &xml)
void ConvertTemp(QString &str, int lineNo, QString &offset, QStringList &xml)
void internalFatalError(QString &msg)
void ConvertTitle(QString &str, int lineNo, QString &offset, QStringList &xml)
void ConvertFieldDanfysik(QString &str, int lineNo, QString &offset, QStringList &xml)
QVector< XMLParseError > PXMLParseErrorVector
void error(const SAXParseException &exc)
int noElements
number of parameters used for this command
Definition: lemAutoRun.h:224
int idx
ODB variable index. -1 means variable is not an array.
Definition: lemAutoRun.h:242
void ConvertWarmUp(QString &str, int lineNo, QString &offset, QStringList &xml)
QString param[LAR_MAX_PARAM]
parameter list of the command
Definition: lemAutoRun.h:225
void ParseError(int noOfErrors, int idx, int errorNo, int line, QString errorMsg)
void ConvertBPV(QString &str, int lineNo, QString &offset, QStringList &xml)
void ConvertFieldWEWL(QString &str, int lineNo, QString &offset, QStringList &xml)
QString loopVal
value of a loop command. For non-loop commands it will be an empty string
Definition: lemAutoRun.h:226
EAutoRunKeyWords fKey
parse key selector for command parameters
#define LAR_INPUT_FILE_READ_ERROR
file read error tag
Definition: lemAutoRun.h:46
QString fXMLFileName
file name of the XML auto run sequence
void ConvertFOM(QString &str, int lineNo, QString &offset, QStringList &xml)
QString CheckForAlias(QString &str)
#define LAR_XML_EXCEPTION
XML exception error tag.
Definition: lemAutoRun.h:58
PAutoRunParser * fArp
pointer to the calling auto run parser
void ConvertDegaussDanfysik(QString &str, int lineNo, QString &offset, QStringList &xml)
QVector< AutoRunCmd > PAutoRunCmdVector
Definition: lemAutoRun.h:233
int errorCode
error code number defined in lemAutoRun.h
void ConvertSampleHV(QString &str, int lineNo, QString &offset, QStringList &xml)
void warning(const SAXParseException &exc)
void ConvertHVOff(QString &str, int lineNo, QString &offset, QStringList &xml)
void characters(const XMLCh *const chars, const XMLSize_t length)
int lineNo
line number from where in the user auto run sequence the command originates
Definition: lemAutoRun.h:223
#define LAR_INVALID_CMD
invalid cmd error tag
Definition: lemAutoRun.h:52
PAutoRunCmdVector * GetAutoRunCmdVector()
QString fInputFileName
file name of the user auto run sequence
void startElement(const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attrs)
void ConvertIgnoreAlarms(QString &str, int lineNo, QString &offset, QStringList &xml)
void ConvertTfl(QString &str, int lineNo, QString &offset, QStringList &xml)
PAutoRunParser::ConvertTfl.
void ConvertLoopFieldWEWL(QString &str, int lineNo, QString &offset, QStringList &xml)
void ConvertFieldWEWH(QString &str, int lineNo, QString &offset, QStringList &xml)
int fParseErrorCounter
the number parse errors encountered before giving up
PAutoRunCmdVector * fAutoRunCmdVector
pointer to the expanded auto run command vector
PXMLLoopInfoVector fLoopInfoVector
vector needed to handling loop expansion
#define LAR_XML_OUT_OF_MEMORY
XML out of memory error tag.
Definition: lemAutoRun.h:57
#define LAR_XML_FATAL
XML fatal error tag (parsing)
Definition: lemAutoRun.h:62
QString odb_path
ODB path.
Definition: lemAutoRun.h:241
PSAX2AutoRunParseHandler(PAutoRunParser *arp)
void ConvertModerator(QString &str, int lineNo, QString &offset, QStringList &xml)
void fatalError(const SAXParseException &exc)
#define LAR_INPUT_FILE_NOT_EXISTING
file does not exist error tag
Definition: lemAutoRun.h:45
void ConvertOdbTag(QString &str, int lineNo, QString &offset, QStringList &xml)
QString tag
ODB tag.
Definition: lemAutoRun.h:240
void ConvertLoopFieldWEWH(QString &str, int lineNo, QString &offset, QStringList &xml)
POdbTagVector * fOdbTagVector
pointer to the vector of ODB tags
void ConvertDegaussSpinRot(QString &str, int lineNo, QString &offset, QStringList &xml)
PXMLParseErrorVector * fXMLParseErrorVector
vector holding all the parse error information
QString fAutoRunXMLSchemaPath
file name of the XML-schema
void ConvertDegaussWEW(QString &str, int lineNo, QString &offset, QStringList &xml)
void ConvertOdbSetData(QString &str, int lineNo, QString &offset, QStringList &xml)
#define LAR_XML_WARNING
XML warning tag (parsing)
Definition: lemAutoRun.h:60
void ConvertTransportHV(QString &str, int lineNo, QString &offset, QStringList &xml)
void ConvertLoopList(QString &str, QString &offset, QStringList &xml)
QVector< OdbTag > POdbTagVector
Definition: lemAutoRun.h:249
QString cmd
command name string
Definition: lemAutoRun.h:222
void ConvertRA_HV(QString &str, int lineNo, QString &offset, QStringList &xml)
PAutoRunParser(QString userAutoRunSeqFln, QString &schemaPath, QString &xmlFln, PAutoRunCmdVector *arcv, POdbTagVector *odbtagv)
void ConvertLoopEnd(QString &offset, QStringList &xml)
#define LAR_XML_UNEXPECTED_EXCEPTION
XML unexpected exception error tag.
Definition: lemAutoRun.h:59
AutoRunCmd fAutoRunCmd
single auto run command. Used as parsing variable before pushed into the fAutoRunCmdVector ...
void ConvertLoopIterator(QString &str, QString &offset, QStringList &xml)
void ConvertIgnoreClients(QString &str, int lineNo, QString &offset, QStringList &xml)
void ConvertAlias(QString &str, int lineNo, QString &offset, QStringList &xml)
#define LAR_OUTPUT_FILE_WRITE_ERROR
output file write error tag
Definition: lemAutoRun.h:54
QString errorMsg
&#39;clear text&#39; error message. At the moment mostly comming from xerces
void ConvertStop(QString &str, int lineNo, QString &offset, QStringList &xml)
void ConvertLEMSetup(QString &str, int lineNo, QString &offset, QStringList &xml)
int fLoopNo
loop counter, needed for loops in loops ...
EAutoRunKeyWords fCmdKey
parse key selector for commands
void ConvertStart(QString &str, int lineNo, QString &offset, QStringList &xml)
PXMLParseErrorVector * GetXMLParseErrorVector()
void ConvertDegauss(QString &str, int lineNo, QString &offset, QStringList &xml)
void endElement(const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname)
void ConvertLoopStart(int lineNo, QString &offset, QStringList &xml)
void ConvertTOF(QString &str, int lineNo, QString &offset, QStringList &xml)
void ConvertLoopSampleHV(QString &str, int lineNo, QString &offset, QStringList &xml)
#define LAR_MAX_PARAM
maximum number of parameters for an auto run cmd
Definition: lemAutoRun.h:30
QString cmdString
untouched original lar-cmd string
Definition: lemAutoRun.h:221
void ConvertOdbSetDataArray(QString &str, int lineNo, QString &offset, QStringList &xml)
OdbTag fOdbTag
single ODB tag element.