lemAutoRun  1.0
PErrorHandler.cpp
Go to the documentation of this file.
1 /********************************************************************************************
2 
3  PErrorHandler.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 <iostream>
24 using namespace std;
25 
26 #include "midas.h"
27 
28 #include "lemAutoRun.h"
29 #include "PErrorHandler.h"
30 
31 //*******************************************************************************************************
32 // implementation of the constructor
33 //*******************************************************************************************************
38 {
39  fNoOfErrors = -1;
40  fErrCount = 0;
41 }
42 
43 //*******************************************************************************************************
44 // implementation of the destructor
45 //*******************************************************************************************************
50 {
51 }
52 
53 //*******************************************************************************************************
54 // implementation of the HandleErrors
55 //*******************************************************************************************************
65 void PErrorHandler::HandleErrors(int noOfErrors, int, int errorNo, int line, QString errorMsg)
66 {
67  fNoOfErrors = noOfErrors;
68  fErrCount++;
69 
70  if (errorNo == LAR_MSG) {
71  cm_msg(MINFO, "lemAutoRun", "line : %d, %s", line, errorMsg.toLatin1().data());
72  cm_yield(0);
73  } else if ((errorNo == LAR_MSG_NO_LINE_NO) || (errorNo == LAR_AUTO_RUN_DISABLED)) {
74  cm_msg(MINFO, "lemAutoRun", errorMsg.toLatin1().data());
75  cm_yield(0);
76  } else {
77  if (line > 0)
78  cm_msg(MERROR, "lemAutoRun", "line : %d, %s", line, errorMsg.toLatin1().data());
79  else
80  cm_msg(MERROR, "lemAutoRun", "%s", errorMsg.toLatin1().data());
81  cm_yield(0);
82 
83  CheckForAlarm(errorNo, errorMsg);
84  CheckErrorNo(errorNo);
85  }
86 }
87 
88 //*******************************************************************************************************
89 // implementation of the CheckForAlarm
90 //*******************************************************************************************************
97 void PErrorHandler::CheckForAlarm(int errorNo, QString errorMsg)
98 {
99  bool warningNeeded = false;
100  char str[256];
101 
102  switch(errorNo) {
103  case LAR_OUT_OF_MEMORY:
106  case LAR_XML_INIT_ERROR:
108  case LAR_XML_EXCEPTION:
110  case LAR_XML_ERROR:
111  case LAR_XML_FATAL:
124  case LAR_FUG_NO_RESPONSE:
130  case LAR_FORCED_RA_OFF:
132  warningNeeded = true;
133  break;
134  default:
135  break;
136  }
137 
138  if (warningNeeded) {
139  strncpy(str, errorMsg.toLatin1().data(), sizeof(str));
140  al_trigger_alarm("lemAutoRun", str, "Warning", str, AT_INTERNAL);
141  }
142 }
143 
144 //*******************************************************************************************************
145 // implementation of the checkErrorNo
146 //*******************************************************************************************************
153 {
154  switch(errorNo) {
158  case LAR_OUT_OF_MEMORY:
159  case LAR_XML_INIT_ERROR:
161  case LAR_INVALID_CMD:
162  emit Terminate();
163  break;
166  break;
167  case LAR_XML_EXCEPTION:
169  emit Terminate();
170  break;
171  case LAR_XML_WARNING:
172  break;
173  case LAR_XML_ERROR:
174  case LAR_XML_FATAL:
176  if (fNoOfErrors == fErrCount)
177  emit Terminate();
178  break;
180  break;
192  case LAR_FUG_NO_RESPONSE:
193  emit Terminate();
194  break;
198  break;
200  case LAR_FATAL:
201  emit Terminate();
202  break;
203  default:
204  break;
205  }
206 }
207 
208 //*******************************************************************************************************
209 // end
210 //*******************************************************************************************************
#define LAR_LOST_NETWORK_CONNECTION
lost network connection error tag
Definition: lemAutoRun.h:48
#define LAR_MIDAS_CONNECTION_FAILED
MIDAS connection failed error tag.
Definition: lemAutoRun.h:67
#define LAR_MIDAS_CANNOT_START_RUN
MIDAS cannot start run error tag.
Definition: lemAutoRun.h:72
#define LAR_FATAL
something unexpected really bad happend
Definition: lemAutoRun.h:35
#define LAR_XML_INIT_ERROR
XML init error tag.
Definition: lemAutoRun.h:56
#define LAR_MSG
message tag for the message/error handler
Definition: lemAutoRun.h:33
#define LAR_XML_ERROR
XML error tag (parsing)
Definition: lemAutoRun.h:61
#define LAR_FOM_CURRENT_NOT_REACHED
FOM current not reached.
Definition: lemAutoRun.h:83
#define LAR_BPV_CLOSED_AT_RUN_START
BPVX/Y closed at run start.
Definition: lemAutoRun.h:84
#define LAR_FIELD_NOT_REACHED
field not reached within timeout error tag
Definition: lemAutoRun.h:77
#define LAR_AUTO_RUN_DISABLED
auto run disabled tag
Definition: lemAutoRun.h:50
#define LAR_SAMPLE_HV_NOT_REACHED
sample high voltage not reached within timeout error tag
Definition: lemAutoRun.h:76
#define LAR_LS340_TEMP_NOT_STABLE
sample temperature is out of the tolerance band
Definition: lemAutoRun.h:81
#define LAR_INPUT_FILE_READ_ERROR
file read error tag
Definition: lemAutoRun.h:46
#define LAR_MIDAS_READBACK_FAILURE
MIDAS readback verification timeout fired.
Definition: lemAutoRun.h:74
#define LAR_XML_EXCEPTION
XML exception error tag.
Definition: lemAutoRun.h:58
#define LAR_MIDAS_KEY_FAILURE
MIDAS key failure error tag.
Definition: lemAutoRun.h:68
#define LAR_FUG_NO_RESPONSE
FUG high voltage not responding error tag.
Definition: lemAutoRun.h:79
void CheckForAlarm(int errorNo, QString errorMsg)
#define LAR_XML_FILE_MISSING
XML file missing error tag.
Definition: lemAutoRun.h:64
#define LAR_INVALID_CMD
invalid cmd error tag
Definition: lemAutoRun.h:52
#define LAR_RA_HV_OFF_AT_RUN_START
RA HV&#39;s off at run starts.
Definition: lemAutoRun.h:85
#define LAR_BPVY_NO_RESPONSE
BPVY not responding error tag.
Definition: lemAutoRun.h:78
#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
#define LAR_RECIEVED_SHUTDOWN_CMD
recieved shutdown cmd tag
Definition: lemAutoRun.h:49
#define LAR_INPUT_FILE_NOT_EXISTING
file does not exist error tag
Definition: lemAutoRun.h:45
#define LAR_MIDAS_DEVICE_NOT_REMOTE
MIDAS device not remote error tag.
Definition: lemAutoRun.h:71
#define LAR_OMEGA_TEMP_NOT_STABLE
sample temperature of the oven is out of the tolerance band
Definition: lemAutoRun.h:82
void HandleErrors(int noOfErrors, int idx, int errorNo, int line, QString errorMsg)
#define LAR_XML_WARNING
XML warning tag (parsing)
Definition: lemAutoRun.h:60
#define LAR_MSG_NO_LINE_NO
message tag for the message/error handler for no line number information
Definition: lemAutoRun.h:34
#define LAR_OUT_OF_MEMORY
out of memory error tag
Definition: lemAutoRun.h:47
#define LAR_XML_UNEXPECTED_EXCEPTION
XML unexpected exception error tag.
Definition: lemAutoRun.h:59
void CheckErrorNo(int errorNo)
#define LAR_OUTPUT_FILE_WRITE_ERROR
output file write error tag
Definition: lemAutoRun.h:54
#define LAR_MIDAS_FE_NOT_RUNNING
MIDAS frontend not running error tag.
Definition: lemAutoRun.h:70
#define LAR_MIDAS_ODB_FAILURE
MIDAS odb failure error tag.
Definition: lemAutoRun.h:69
#define LAR_LS340_INPUT_NONSENSE
sample lakshore readback doesn&#39;t make any sense
Definition: lemAutoRun.h:80
#define LAR_STOP_STOP_NONSENSE
run stopped and STOP command called: doesn&#39;t make any sense
Definition: lemAutoRun.h:87
#define LAR_MIDAS_NO_RUN_TRANSITION
MIDAS no run transition notification obtained within 60sec.
Definition: lemAutoRun.h:73
#define LAR_XML_MISSING_ENTRY
XML missing entry error tag.
Definition: lemAutoRun.h:65
#define LAR_FORCED_RA_OFF
forced switch off of the RA HV&#39;s
Definition: lemAutoRun.h:86