ngc 1.5.0
 
Loading...
Searching...
No Matches
ngcbALARM.hpp
Go to the documentation of this file.
1
8#ifndef ngcbALARM_H
9#define ngcbALARM_H
10
11
12#ifndef __cplusplus
13#error This is a C++ include file and cannot be used from plain C
14#endif
15
16/*
17 * System Headers
18 */
19#include <stdlib.h>
20#include <stdio.h>
21#include <string.h>
22#include <unistd.h>
23#include <errno.h>
24
25/*
26 * Local Headers
27 */
28#include <ngc/core/ngcbLIST.hpp>
29
30/*
31 * Alarm severity levels
32 */
33#define ngcbALARM_NO_ALARM 0x00 //< no alarm
34#define ngcbALARM_WARNING 0x01 //< warning
35#define ngcbALARM_FATAL 0x02 //< fatal
36#define ngcbALARM_ACK 0x10 //< acknowledge bit mask
37#define ngcbALARM_INT 0x20 //< alarm for integer value
38#define ngcbALARM_DOUBLE 0x40 //< alarm for double value
39#define ngcbALARM_WARNING_ACK (ngcbALARM_WARNING|ngcbALARM_ACK) //< warning ack
40#define ngcbALARM_FATAL_ACK (ngcbALARM_FATAL|ngcbALARM_ACK) //< fatal ack
41
45#define ngcbALARM_MASK (ngcbALARM_WARNING|ngcbALARM_FATAL|ngcbALARM_ACK)
46
50typedef unsigned long int ngcb_alarm_id;
51
55class ngcbALARM;
56
61{
62public:
65
67 virtual ~ngcbALARM_SYS();
68
70 virtual ngcb_alarm_id Issue(ngcbALARM *alarm);
71
73 virtual void Cancel(ngcb_alarm_id id);
74
76 virtual void Ack(ngcb_alarm_id id);
77
79 void Store(ngcbALARM *alarm, ngcb_alarm_id id);
80
82 void Remove(ngcb_alarm_id id);
83
86
88 void PrintList(FILE *s);
89
90protected:
91private:
93 ngcbLIST alarmList_;
94};
95
100{
101public:
103 ngcbALARM &operator=(const ngcbALARM &other);
104
106 ngcbALARM(const ngcbALARM &other);
107
109 ngcbALARM();
110
112 ngcbALARM(ngcbALARM_SYS *sys, const char *name, int level, const char *msg);
113
115 ngcbALARM(ngcbALARM_SYS *sys, const char *name, int level, const char *msg,
116 int value, const char *unit = NULL);
117
119 ngcbALARM(ngcbALARM_SYS *sys, const char *name, int level, const char *msg,
120 double value, const char *unit = NULL);
121
123 virtual ~ngcbALARM();
124
127
129 const char *Name();
130
132 int Level();
133
135 const char *Msg();
136
138 const char *Format();
139
141 const char *Unit();
142
144 const char *Value(int showUnit);
145
147 int AckPending();
148
150 void Ack();
151
152protected:
153
154private:
156 int level_;
157
159 char name_[32];
160
162 char msg_[256];
163
165 char format_[8];
166
168 char unit_[8];
169
171 char value_[64];
172
174 int *ival_;
175
177 double *dval_;
178
180 ngcbALARM_SYS *sys_;
181
183 ngcb_alarm_id id_;
184
186 void Init_(const char *name, int level, const char *msg);
187
189 void Issue_();
190};
191
192#endif
Definition ngcbALARM.hpp:61
void Remove(ngcb_alarm_id id)
Remove item from built-in alarm container.
Definition ngcbALARM_SYS.cpp:31
virtual void Cancel(ngcb_alarm_id id)
Cancel alarm.
Definition ngcbALARM_SYS.cpp:22
virtual ngcb_alarm_id Issue(ngcbALARM *alarm)
Issue alarm and return an alarm-system specific identification itme.
Definition ngcbALARM_SYS.cpp:17
void PrintList(FILE *s)
Print alarm list (debugging function)
Definition ngcbALARM_SYS.cpp:41
void Store(ngcbALARM *alarm, ngcb_alarm_id id)
Store alarm to built-in alarm container.
Definition ngcbALARM_SYS.cpp:26
ngcbALARM * Get(ngcb_alarm_id id)
Get item from built-in alarm container.
Definition ngcbALARM_SYS.cpp:36
ngcbALARM_SYS()
Constructor.
Definition ngcbALARM_SYS.cpp:13
virtual void Ack(ngcb_alarm_id id)
Acknowledge alarm.
Definition ngcbALARM_SYS.cpp:24
virtual ~ngcbALARM_SYS()
Destructor.
Definition ngcbALARM_SYS.cpp:15
Definition ngcbALARM.hpp:100
void Ack()
Acknowledge alarm.
Definition ngcbALARM.cpp:199
ngcb_alarm_id Id()
Return alarm id.
Definition ngcbALARM.cpp:143
const char * Msg()
Return alarm message.
Definition ngcbALARM.cpp:149
const char * Unit()
Return the unit of the alarm value.
Definition ngcbALARM.cpp:153
int AckPending()
Check if alarm has acknowledge pending.
Definition ngcbALARM.cpp:197
virtual ~ngcbALARM()
Destructor.
Definition ngcbALARM.cpp:110
const char * Format()
Return format string to be used for printf-style formatted output.
Definition ngcbALARM.cpp:151
ngcbALARM()
Constructor.
Definition ngcbALARM.cpp:51
const char * Name()
Return alarm name.
Definition ngcbALARM.cpp:145
int Level()
Return actual alarm severity level.
Definition ngcbALARM.cpp:147
ngcbALARM(const ngcbALARM &other)
Copy constructor.
Definition ngcbALARM.cpp:34
ngcbALARM & operator=(const ngcbALARM &other)
Operator =.
Definition ngcbALARM.cpp:13
const char * Value(int showUnit)
Return formatted value string.
Definition ngcbALARM.cpp:155
Definition ngcbLIST.hpp:34
unsigned long int ngcb_alarm_id
Definition ngcbALARM.hpp:50