lemAutoRun  1.0
PAutoRunParser.h
Go to the documentation of this file.
1 /********************************************************************************************
2 
3  PAutoRunParser.h
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 #ifndef _PAUTORUNPARSER_H_
24 #define _PAUTORUNPARSER_H_
25 
26 #include <QObject>
27 #include <QStringList>
28 #include <QMap>
29 #include <QVector>
30 
31 #include <xercesc/sax2/Attributes.hpp>
32 #include <xercesc/sax2/DefaultHandler.hpp>
33 
34 #include "lemAutoRun.h"
35 
36 XERCES_CPP_NAMESPACE_USE
37 
38 class PAutoRunParser;
39 
40 //----------------------------------------------------------------------------------------------
44 typedef struct {
45  int errorCode;
46  int lineNo;
47  QString errorMsg;
49 
50 //----------------------------------------------------------------------------------------------
54 typedef QVector<XMLParseError> PXMLParseErrorVector;
55 
56 //----------------------------------------------------------------------------------------------
60 typedef QVector<double> PXMLLoopListVector;
61 
62 //----------------------------------------------------------------------------------------------
66 typedef struct {
68  double iterator[3];
72 } XMLLoopInfo;
73 
74 //----------------------------------------------------------------------------------------------
79 typedef QVector<XMLLoopInfo> PXMLLoopInfoVector;
80 
81 //----------------------------------------------------------------------------------------------
86 {
87  public:
108 
111 
112  void startDocument();
113  void startElement(const XMLCh *const uri, const XMLCh *const localname,
114  const XMLCh *const qname, const Attributes &attrs);
115  void characters(const XMLCh *const chars, const XMLSize_t length);
116  void endElement(const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname);
117  void endDocument();
118 
119  void warning(const SAXParseException& exc);
120  void error(const SAXParseException& exc);
121  void fatalError(const SAXParseException& exc);
122  void internalFatalError(QString& msg);
123 
124  private:
125  bool fFatalError;
126 
129 
130  QString fFlnAutoRunSeq;
132 
134  void ClearAutoRunCmd();
135 
137 
140 
141  // loop handling
142  int fLoopNo;
144 
146 };
147 
148 //----------------------------------------------------------------------------------------------
152 class PAutoRunParser : public QObject
153 {
154  Q_OBJECT
155 
156  public:
157  PAutoRunParser(QString userAutoRunSeqFln, QString &schemaPath, QString &xmlFln,
158  PAutoRunCmdVector *arcv, POdbTagVector *odbtagv);
159  ~PAutoRunParser();
160 
161  void ConvertToXML();
162  void Parse();
164 
168 
169  signals:
170  void ParseError(int noOfErrors, int idx, int errorNo, int line, QString errorMsg);
171 
172  private:
174 
175  QString fInputFileName;
177  QString fXMLFileName;
178 
179  QMap<QString, QString> fAlias;
180 
182 
185 
186  QString CheckForAlias(QString &str);
187 
188  void ConvertAlias(QString &str, int lineNo, QString &offset, QStringList &xml);
189  void ConvertIgnoreAlarms(QString &str, int lineNo, QString &offset, QStringList &xml);
190  void ConvertIgnoreClients(QString &str, int lineNo, QString &offset, QStringList &xml);
191  void ConvertBPV(QString &str, int lineNo, QString &offset, QStringList &xml);
192  void ConvertComment(QString &str, int lineNo, QString &offset, QStringList &xml);
193  void ConvertDegaussWEW(QString &str, int lineNo, QString &offset, QStringList &xml);
194  void ConvertDegaussDanfysik(QString &str, int lineNo, QString &offset, QStringList &xml);
195  void ConvertDegauss(QString &str, int lineNo, QString &offset, QStringList &xml);
196  void ConvertDegaussSpinRot(QString &str, int lineNo, QString &offset, QStringList &xml);
197  void ConvertDump(QString &str, int lineNo, QString &offset, QStringList &xml);
198  void ConvertFieldWEWL(QString &str, int lineNo, QString &offset, QStringList &xml);
199  void ConvertFieldWEWH(QString &str, int lineNo, QString &offset, QStringList &xml);
200  void ConvertFieldDanfysik(QString &str, int lineNo, QString &offset, QStringList &xml);
201  void ConvertField(QString &str, int lineNo, QString &offset, QStringList &xml);
202  void ConvertFOM(QString &str, int lineNo, QString &offset, QStringList &xml);
203  void ConvertLEMSetup(QString &str, int lineNo, QString &offset, QStringList &xml);
204  void ConvertLoopStart(int lineNo, QString &offset, QStringList &xml);
205  void ConvertLoopList(QString &str, QString &offset, QStringList &xml);
206  void ConvertLoopIterator(QString &str, QString &offset, QStringList &xml);
207  void ConvertLoopTemp(QString &str, int lineNo, QString &offset, QStringList &xml);
208  void ConvertLoopSampleHV(QString &str, int lineNo, QString &offset, QStringList &xml);
209  void ConvertLoopFieldWEWL(QString &str, int lineNo, QString &offset, QStringList &xml);
210  void ConvertLoopFieldWEWH(QString &str, int lineNo, QString &offset, QStringList &xml);
211  void ConvertLoopFieldDanfysik(QString &str, int lineNo, QString &offset, QStringList &xml);
212  void ConvertLoopField(QString &str, int lineNo, QString &offset, QStringList &xml);
213  void ConvertLoopEnd(QString &offset, QStringList &xml);
214  void ConvertModerator(QString &str, int lineNo, QString &offset, QStringList &xml);
215  void ConvertSampleHV(QString &str, int lineNo, QString &offset, QStringList &xml);
216  void ConvertRA_HV(QString &str, int lineNo, QString &offset, QStringList &xml);
217  void ConvertTransportHV(QString &str, int lineNo, QString &offset, QStringList &xml);
218  void ConvertHVOff(QString &str, int lineNo, QString &offset, QStringList &xml);
219  void ConvertOdbSetData(QString &str, int lineNo, QString &offset, QStringList &xml);
220  void ConvertOdbSetDataArray(QString &str, int lineNo, QString &offset, QStringList &xml);
221  void ConvertOdbTag(QString &str, int lineNo, QString &offset, QStringList &xml);
222  void ConvertStart(QString &str, int lineNo, QString &offset, QStringList &xml);
223  void ConvertStop(QString &str, int lineNo, QString &offset, QStringList &xml);
224  void ConvertSpinRot(QString &str, int lineNo, QString &offset, QStringList &xml);
225  void ConvertTfl(QString &str, int lineNo, QString &offset, QStringList &xml);
226  void ConvertTemp(QString &str, int lineNo, QString &offset, QStringList &xml);
227  void ConvertTitle(QString &str, int lineNo, QString &offset, QStringList &xml);
228  void ConvertTOF(QString &str, int lineNo, QString &offset, QStringList &xml);
229  void ConvertWait(QString &str, int lineNo, QString &offset, QStringList &xml);
230  void ConvertWarmUp(QString &str, int lineNo, QString &offset, QStringList &xml);
231 
232  friend class PSAX2AutoRunParser;
234 };
235 
236 #endif // _PAUTORUNPARSER_H_
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)
friend class PSAX2AutoRunParser
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
AutoRunCmd loopCmd
loop cmd (loopSetTemp or loopSetSampleHV or loopSetField)
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)
void ConvertWarmUp(QString &str, int lineNo, QString &offset, QStringList &xml)
int GetParseErrorCounts()
void ParseError(int noOfErrors, int idx, int errorNo, int line, QString errorMsg)
PXMLLoopListVector list
vector of all elements over which will be looped (e.g. temp. list)
void ConvertBPV(QString &str, int lineNo, QString &offset, QStringList &xml)
void ConvertFieldWEWL(QString &str, int lineNo, QString &offset, QStringList &xml)
EAutoRunKeyWords fKey
parse key selector for command parameters
QString fXMLFileName
file name of the XML auto run sequence
void ConvertFOM(QString &str, int lineNo, QString &offset, QStringList &xml)
QString CheckForAlias(QString &str)
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)
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
QVector< double > PXMLLoopListVector
PSAX2AutoRunParseHandler(PAutoRunParser *arp)
void ConvertModerator(QString &str, int lineNo, QString &offset, QStringList &xml)
void fatalError(const SAXParseException &exc)
void ConvertOdbTag(QString &str, int lineNo, QString &offset, QStringList &xml)
PAutoRunCmdVector * fAutoRunCmdVector
pointer to the vector of the expanded auto run sequence
void ConvertLoopFieldWEWH(QString &str, int lineNo, QString &offset, QStringList &xml)
PAutoRunCmdVector cmd
vector of additional cmd&#39;s in the loop
POdbTagVector * fOdbTagVector
pointer to the vector of ODB tags
POdbTagVector * GetOdbTagVector()
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
QVector< XMLLoopInfo > PXMLLoopInfoVector
void ConvertDegaussWEW(QString &str, int lineNo, QString &offset, QStringList &xml)
void ConvertOdbSetData(QString &str, int lineNo, QString &offset, QStringList &xml)
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
EAutoRunKeyWords
enumeration for the XML key word handling
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)
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)
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)
PAutoRunCmdVector expandedCmd
vector of the expanded loop cmd&#39;s: generated at the end of the loop
void ConvertOdbSetDataArray(QString &str, int lineNo, QString &offset, QStringList &xml)
OdbTag fOdbTag
single ODB tag element.