ProviewR Programmer's Reference Manual  V7.0.0
rt_errh.h
Go to the documentation of this file.
1 /*
2  * ProviewR Open Source Process Control.
3  * Copyright (C) 2005-2026 SSAB EMEA AB.
4  *
5  * This file is part of ProviewR.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation, either version 2 of
10  * the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with ProviewR. If not, see <http://www.gnu.org/licenses/>
19  *
20  * Linking ProviewR statically or dynamically with other modules is
21  * making a combined work based on ProviewR. Thus, the terms and
22  * conditions of the GNU General Public License cover the whole
23  * combination.
24  *
25  * In addition, as a special exception, the copyright holders of
26  * ProviewR give you permission to, from the build function in the
27  * ProviewR Configurator, combine ProviewR with modules generated by the
28  * ProviewR PLC Editor to a PLC program, regardless of the license
29  * terms of these modules. You may copy and distribute the resulting
30  * combined work under the terms of your choice, provided that every
31  * copy of the combined work is accompanied by a complete copy of
32  * the source code of ProviewR (the version used to produce the
33  * combined work), being distributed under the terms of the GNU
34  * General Public License plus this exception.
35  */
36 
37 #ifndef rt_errh_h
38 #define rt_errh_h
39 
40 #include "rt_qcom.h"
41 #include "rt_errl.h"
42 
43 #if defined __cplusplus
44 extern "C" {
45 #endif
46 
54 #ifndef errh_Bugcheck
55 #define errh_Bugcheck(sts, str) \
56  (errh_Fatal("pwr bugcheck: <%s>, in file %s, at line %d\n%m", (str), \
57  __FILE__, __LINE__, sts), \
58  (exit(sts)))
59 #endif
60 
61 #ifndef errh_ReturnOrBugcheck
62 #define errh_ReturnOrBugcheck(a, sts, lsts, str) \
63  return ( \
64  ((long int)(sts) \
65  ? ((*sts) = (lsts)) \
66  : (EVEN(lsts) ? (errh_Bugcheck(lsts, (str)), (lsts)) : (lsts))), \
67  a)
68 #endif
69 
74 #define errh_SeveritySuccess(sts) (((sts)&7) == 3)
75 #define errh_SeverityInfo(sts) (((sts)&7) == 1)
76 #define errh_SeverityWarning(sts) (((sts)&7) == 0)
77 #define errh_SeverityError(sts) (((sts)&7) == 2)
78 #define errh_SeverityFatal(sts) (((sts)&7) == 4)
79 
83 typedef enum {
84  errh_eSeverity_Null,
85  errh_eSeverity_Success,
86  errh_eSeverity_Info,
87  errh_eSeverity_Warning,
88  errh_eSeverity_Error,
89  errh_eSeverity_Fatal
91 
92 #define errh_cAnix_SrvSize 40
93 #define errh_cAnix_PlcSize 20
94 
95 
99 typedef enum {
100  errh_eNAnix = 0,
101  errh_eAnix_ini = 1,
102  errh_eAnix_qmon = 2,
103  errh_eAnix_neth = 3,
104  errh_eAnix_neth_acp = 4,
105  errh_eAnix_io = 5,
106  errh_eAnix_tmon = 6,
107  errh_eAnix_emon = 7,
108  errh_eAnix_alim = 8,
109  errh_eAnix_bck = 9,
110  errh_eAnix_linksup = 10,
111  errh_eAnix_trend = 11,
112  errh_eAnix_fast = 12,
113  errh_eAnix_elog = 13,
114  errh_eAnix_webmon = 14,
115  errh_eAnix_webmonmh = 15,
116  errh_eAnix_sysmon = 16,
117  errh_eAnix_plc = 17,
118  errh_eAnix_remote = 18,
119  errh_eAnix_opc_server = 19,
120  errh_eAnix_statussrv = 20,
121  errh_eAnix_post = 21,
122  errh_eAnix_report = 22,
123  errh_eAnix_sevhistmon = 23,
124  errh_eAnix_sim = 24,
125  errh_eAnix_powerlink = 25,
126  errh_eAnix_videomgm = 26,
127  errh_eAnix_redcom = 27,
128  errh_eAnix_websocketserver = 28,
129  errh_eAnix_maintsupserver = 29,
130  errh_eAnix_mqtt_server = 30,
131  errh_eAnix_plc1 = 41,
132  errh_eAnix_plc2 = 42,
133  errh_eAnix_plc3 = 43,
134  errh_eAnix_plc4 = 44,
135  errh_eAnix_plc5 = 45,
136  errh_eAnix_plc6 = 46,
137  errh_eAnix_plc7 = 47,
138  errh_eAnix_plc8 = 48,
139  errh_eAnix_plc9 = 49,
140  errh_eAnix_plc10 = 50,
141  errh_eAnix_plc11 = 51,
142  errh_eAnix_plc12 = 52,
143  errh_eAnix_plc13 = 53,
144  errh_eAnix_plc14 = 54,
145  errh_eAnix_plc15 = 55,
146  errh_eAnix_plc16 = 56,
147  errh_eAnix_plc17 = 57,
148  errh_eAnix_plc18 = 58,
149  errh_eAnix_plc19 = 59,
150  errh_eAnix_plc20 = 60,
151  errh_eAnix_appl1 = 61,
152  errh_eAnix_appl2 = 62,
153  errh_eAnix_appl3 = 63,
154  errh_eAnix_appl4 = 64,
155  errh_eAnix_appl5 = 65,
156  errh_eAnix_appl6 = 66,
157  errh_eAnix_appl7 = 67,
158  errh_eAnix_appl8 = 68,
159  errh_eAnix_appl9 = 69,
160  errh_eAnix_appl10 = 70,
161  errh_eAnix_appl11 = 71,
162  errh_eAnix_appl12 = 72,
163  errh_eAnix_appl13 = 73,
164  errh_eAnix_appl14 = 74,
165  errh_eAnix_appl15 = 75,
166  errh_eAnix_appl16 = 76,
167  errh_eAnix_appl17 = 77,
168  errh_eAnix_appl18 = 78,
169  errh_eAnix_appl19 = 79,
170  errh_eAnix_appl20 = 80,
171  errh_eAnix_appl21 = 81,
172  errh_eAnix_appl22 = 82,
173  errh_eAnix_appl23 = 83,
174  errh_eAnix_appl24 = 84,
175  errh_eAnix_appl25 = 85,
176  errh_eAnix_appl26 = 86,
177  errh_eAnix_appl27 = 87,
178  errh_eAnix_appl28 = 88,
179  errh_eAnix_appl29 = 89,
180  errh_eAnix_appl30 = 90,
181  errh_eAnix_appl31 = 91,
182  errh_eAnix_appl32 = 92,
183  errh_eAnix_appl33 = 93,
184  errh_eAnix_appl34 = 94,
185  errh_eAnix_appl35 = 95,
186  errh_eAnix_appl36 = 96,
187  errh_eAnix_appl37 = 97,
188  errh_eAnix_appl38 = 98,
189  errh_eAnix_appl39 = 99,
190  errh_eAnix_appl40 = 100,
191  errh_eAnix_appl41 = 101,
192  errh_eAnix_appl42 = 102,
193  errh_eAnix_appl43 = 103,
194  errh_eAnix_appl44 = 104,
195  errh_eAnix_appl45 = 105,
196  errh_eAnix_appl46 = 106,
197  errh_eAnix_appl47 = 107,
198  errh_eAnix_appl48 = 108,
199  errh_eAnix_appl49 = 109,
200  errh_eAnix_appl50 = 110,
201  errh_eAnix__ = 111
202 } errh_eAnix;
203 
207 typedef enum {
211 
212 typedef struct {
213  pwr_tBoolean send;
214  qcom_sQid logQ;
215  qcom_sPut put;
216 } errh_sLog;
217 
218 typedef struct {
219  long int message_type;
220  pwr_tStatus sts;
221  errh_eAnix anix;
222  char severity;
223  char str[LOG_MAX_MSG_SIZE];
224 } errh_sMsg;
225 
232 /* NOTE! errh_Init MUST always be called before any other
233  errh-function is called. */
234 
235 pwr_tStatus errh_Init(const char* programName, errh_eAnix anix);
236 void errh_AnixName(errh_eAnix anix, char *name);
237 void errh_SetStatus(pwr_tStatus sts);
238 void errh_Interactive(void);
239 char* errh_GetMsg(const pwr_tStatus sts, char* buf, int bufSize);
240 char* errh_GetText(const pwr_tStatus sts, char* buf, int bufSize);
241 char* errh_Log(char* buff, char severity, const char* msg, ...);
242 void errh_Fatal(const char* msg, ...);
243 void errh_Error(const char* msg, ...);
244 void errh_Warning(const char* msg, ...);
245 void errh_Info(const char* msg, ...);
246 void errh_Success(const char* msg, ...);
247 void errh_LogFatal(errh_sLog*, const char* msg, ...);
248 void errh_LogError(errh_sLog*, const char* msg, ...);
249 void errh_LogWarning(errh_sLog*, const char* msg, ...);
250 void errh_LogInfo(errh_sLog*, const char* msg, ...);
251 void errh_LogSuccess(errh_sLog*, const char* msg, ...);
252 void* errh_ErrArgMsg(pwr_tStatus sts);
253 void* errh_ErrArgAF(char* s);
254 void* errh_ErrArgL(int val);
255 void errh_CErrLog(pwr_tStatus sts, ...);
256 char* errh_Message(char* string, char severity, char* msg, ...);
257 errh_eAnix errh_Anix(void);
258 void errh_SetAnix(errh_eAnix anix);
259 void errh_SetName(char* name);
260 errh_eSeverity errh_Severity(pwr_tStatus);
261 
262 #if defined __cplusplus
263 }
264 #endif
265 
266 #endif
267 
errh_eAnix
Definition: rt_errh.h:99
errh_eMsgType
Definition: rt_errh.h:207
errh_eSeverity
Definition: rt_errh.h:83
@ errh_eMsgType_Log
Definition: rt_errh.h:208
@ errh_eMsgType_Status
Definition: rt_errh.h:209
void errh_Error(const char *msg,...)
Log an error message. The function has a variable argument list similar to sprintf.
Definition: rt_errh.c:336
pwr_tStatus errh_Init(const char *programName, errh_eAnix anix)
Initialize errh. Set up a queue to write to, set application name.
Definition: rt_errh.c:171
void errh_SetStatus(pwr_tStatus sts)
Set application status. The application status is showed in the Node graph. The application can set t...
Definition: rt_errh.c:195
errh_eAnix errh_Anix(void)
Get application index for the process.
Definition: rt_errh.c:205
void errh_Success(const char *msg,...)
Log a success message. The function has a variable argument list similar to sprintf.
Definition: rt_errh.c:273
void errh_SetName(char *name)
Set application name for the process.
Definition: rt_errh.c:221
void errh_Fatal(const char *msg,...)
Log a fatal message. The function has a variable argument list similar to sprintf.
Definition: rt_errh.c:357
void errh_SetAnix(errh_eAnix anix)
Set application index for the process.
Definition: rt_errh.c:213
void errh_Info(const char *msg,...)
Log an info message. The function has a variable argument list similar to sprintf.
Definition: rt_errh.c:294
void errh_Warning(const char *msg,...)
Log a warning message. The function has a variable argument list similar to sprintf.
Definition: rt_errh.c:315
unsigned int pwr_tBoolean
Boolean type.
Definition: pwr.h:127
int pwr_tStatus
Status type.
Definition: pwr.h:284
Include file for QCOM Queue Communication.
Put data structure.
Definition: rt_qcom.h:174
Queue identity.
Definition: rt_qcom.h:125