ngc 1.4.0
 
Loading...
Searching...
No Matches
ngcbALARM.hpp
Go to the documentation of this file.
1
7#ifndef ngcbALARM_H
8#define ngcbALARM_H
9
10
11#ifndef __cplusplus
12#error This is a C++ include file and cannot be used from plain C
13#endif
14
15/*
16 * System Headers
17 */
18#include <stdlib.h>
19#include <stdio.h>
20#include <string.h>
21#include <unistd.h>
22#include <errno.h>
23
24/*
25 * Local Headers
26 */
27#include <ngc/core/ngcbLIST.hpp>
28
29/*
30 * Alarm severity levels
31 */
32#define ngcbALARM_NO_ALARM 0x00 //< no alarm
33#define ngcbALARM_WARNING 0x01 //< warning
34#define ngcbALARM_FATAL 0x02 //< fatal
35#define ngcbALARM_ACK 0x10 //< acknowledge bit mask
36#define ngcbALARM_INT 0x20 //< alarm for integer value
37#define ngcbALARM_DOUBLE 0x40 //< alarm for double value
38#define ngcbALARM_WARNING_ACK (ngcbALARM_WARNING|ngcbALARM_ACK) //< warning ack
39#define ngcbALARM_FATAL_ACK (ngcbALARM_FATAL|ngcbALARM_ACK) //< fatal ack
40
44#define ngcbALARM_MASK (ngcbALARM_WARNING|ngcbALARM_FATAL|ngcbALARM_ACK)
45
49typedef unsigned long int ngcb_alarm_id;
50
54class ngcbALARM;
55
60{
61public:
64
66 virtual ~ngcbALARM_SYS();
67
69 virtual ngcb_alarm_id Issue(ngcbALARM *alarm);
70
72 virtual void Cancel(ngcb_alarm_id id);
73
75 virtual void Ack(ngcb_alarm_id id);
76
78 void Store(ngcbALARM *alarm, ngcb_alarm_id id);
79
81 void Remove(ngcb_alarm_id id);
82
85
87 void PrintList(FILE *s);
88
89protected:
90private:
92 ngcbLIST alarmList_;
93};
94
99{
100public:
102 ngcbALARM &operator=(const ngcbALARM &other);
103
105 ngcbALARM(const ngcbALARM &other);
106
108 ngcbALARM();
109
111 ngcbALARM(ngcbALARM_SYS *sys, const char *name, int level, const char *msg);
112
114 ngcbALARM(ngcbALARM_SYS *sys, const char *name, int level, const char *msg,
115 int value, const char *unit = NULL);
116
118 ngcbALARM(ngcbALARM_SYS *sys, const char *name, int level, const char *msg,
119 double value, const char *unit = NULL);
120
122 virtual ~ngcbALARM();
123
126
128 const char *Name();
129
131 int Level();
132
134 const char *Msg();
135
137 const char *Format();
138
140 const char *Unit();
141
143 const char *Value(int showUnit);
144
146 int AckPending();
147
149 void Ack();
150
151protected:
152
153private:
155 int level_;
156
158 char name_[32];
159
161 char msg_[256];
162
164 char format_[8];
165
167 char unit_[8];
168
170 char value_[64];
171
173 int *ival_;
174
176 double *dval_;
177
179 ngcbALARM_SYS *sys_;
180
182 ngcb_alarm_id id_;
183
185 void Init_(const char *name, int level, const char *msg);
186
188 void Issue_();
189};
190
191#endif
Definition ngcbALARM.hpp:60
void Remove(ngcb_alarm_id id)
Remove item from built-in alarm container.
Definition ngcbALARM_SYS.cpp:30
virtual void Cancel(ngcb_alarm_id id)
Cancel alarm.
Definition ngcbALARM_SYS.cpp:21
virtual ngcb_alarm_id Issue(ngcbALARM *alarm)
Issue alarm and return an alarm-system specific identification itme.
Definition ngcbALARM_SYS.cpp:16
void PrintList(FILE *s)
Print alarm list (debugging function)
Definition ngcbALARM_SYS.cpp:40
void Store(ngcbALARM *alarm, ngcb_alarm_id id)
Store alarm to built-in alarm container.
Definition ngcbALARM_SYS.cpp:25
ngcbALARM * Get(ngcb_alarm_id id)
Get item from built-in alarm container.
Definition ngcbALARM_SYS.cpp:35
ngcbALARM_SYS()
Constructor.
Definition ngcbALARM_SYS.cpp:12
virtual void Ack(ngcb_alarm_id id)
Acknowledge alarm.
Definition ngcbALARM_SYS.cpp:23
virtual ~ngcbALARM_SYS()
Destructor.
Definition ngcbALARM_SYS.cpp:14
Definition ngcbALARM.hpp:99
void Ack()
Acknowledge alarm.
Definition ngcbALARM.cpp:198
ngcb_alarm_id Id()
Return alarm id.
Definition ngcbALARM.cpp:142
const char * Msg()
Return alarm message.
Definition ngcbALARM.cpp:148
const char * Unit()
Return the unit of the alarm value.
Definition ngcbALARM.cpp:152
int AckPending()
Check if alarm has acknowledge pending.
Definition ngcbALARM.cpp:196
virtual ~ngcbALARM()
Destructor.
Definition ngcbALARM.cpp:109
const char * Format()
Return format string to be used for printf-style formatted output.
Definition ngcbALARM.cpp:150
ngcbALARM()
Constructor.
Definition ngcbALARM.cpp:50
const char * Name()
Return alarm name.
Definition ngcbALARM.cpp:144
int Level()
Return actual alarm severity level.
Definition ngcbALARM.cpp:146
ngcbALARM(const ngcbALARM &other)
Copy constructor.
Definition ngcbALARM.cpp:33
ngcbALARM & operator=(const ngcbALARM &other)
Operator =.
Definition ngcbALARM.cpp:12
const char * Value(int showUnit)
Return formatted value string.
Definition ngcbALARM.cpp:154
Definition ngcbLIST.hpp:33
unsigned long int ngcb_alarm_id
Definition ngcbALARM.hpp:49