This is Unofficial EPICS BASE Doxygen Site
alarm.cpp
Go to the documentation of this file.
1 /* alarm.cpp */
2 /*
3  * Copyright information and license terms for this software can be
4  * found in the file LICENSE that is included with the distribution
5  */
9 #include <string>
10 #include <stdexcept>
11 
12 #include <epicsMutex.h>
13 
14 #define epicsExportSharedSymbols
15 #include <pv/lock.h>
16 #include <pv/pvType.h>
17 #include <pv/pvIntrospect.h>
18 #include <pv/pvData.h>
19 #include <pv/alarm.h>
20 
21 using std::string;
22 
23 namespace epics { namespace pvData {
24 
26 {
27  if(value<0 || value>4) {
28  throw std::logic_error(string("getSeverity value is illegal"));
29  }
30  switch (value) {
31  case 0: return noAlarm;
32  case 1: return minorAlarm;
33  case 2: return majorAlarm;
34  case 3: return invalidAlarm;
35  case 4: return undefinedAlarm;
36  }
37  throw std::logic_error(string("should never get here"));
38 }
39 
41 {
42  static size_t severityCount = 5;
43  static StringArrayPtr severityNames;
44  static Mutex mutex;
45  Lock xx(mutex);
46  if(severityNames.get()==NULL) {
47  severityNames = StringArrayPtr(new StringArray());
48  severityNames->reserve(severityCount);
49  severityNames->push_back("NONE");
50  severityNames->push_back("MINOR");
51  severityNames->push_back("MAJOR");
52  severityNames->push_back("INVALID");
53  severityNames->push_back("UNDEFINED");
54  }
55  return severityNames;
56 }
57 
59 {
60  switch(severity) {
61  case 0: return noAlarm;
62  case 1: return minorAlarm;
63  case 2: return majorAlarm;
64  case 3: return invalidAlarm;
65  case 4: return undefinedAlarm;
66  }
67  throw std::logic_error(string("should never get here"));
68 }
69 
71 {
72  if(value<0 || value>7) {
73  throw std::logic_error(string("getStatus value is illegal"));
74  }
75  switch (value) {
76  case 0: return noStatus;
77  case 1: return deviceStatus;
78  case 2: return driverStatus;
79  case 3: return recordStatus;
80  case 4: return dbStatus;
81  case 5: return confStatus;
82  case 6: return undefinedStatus;
83  case 7: return clientStatus;
84  }
85  throw std::logic_error(string("should never get here"));
86 }
87 
89 {
90  static size_t statusCount = 8;
91  static StringArrayPtr statusNames;
92  static Mutex mutex;
93  Lock xx(mutex);
94  if(statusNames.get()==NULL) {
95  statusNames = StringArrayPtr(new StringArray());
96  statusNames->reserve(statusCount);
97  statusNames->push_back("NONE");
98  statusNames->push_back("DEVICE");
99  statusNames->push_back("DRIVER");
100  statusNames->push_back("RECORD");
101  statusNames->push_back("DB");
102  statusNames->push_back("CONF");
103  statusNames->push_back("UNDEFINED");
104  statusNames->push_back("CLIENT");
105  }
106  return statusNames;
107 }
108 
110 {
111  switch(status) {
112  case 0: return noStatus;
113  case 1: return deviceStatus;
114  case 2: return driverStatus;
115  case 3: return recordStatus;
116  case 4: return dbStatus;
117  case 5: return confStatus;
118  case 6: return undefinedStatus;
119  case 7: return clientStatus;
120  }
121  throw std::logic_error(string("should never get here"));
122 }
123 
124 }}
Definition: link.h:174
AlarmSeverity
enum definition of AlarmSeverity
Definition: alarm.h:30
pvd::Status status
TODO only here because of the Lockable.
Definition: ntaggregate.cpp:16
A lock for multithreading.
Definition: lock.h:36
#define NULL
Definition: catime.c:38
static AlarmSeverity getSeverity(int value)
Definition: alarm.cpp:25
epicsMutex mutex
Definition: pvAccess.cpp:71
APIs for the epicsMutex mutual exclusion semaphore.
AlarmStatus getStatus() const
Definition: alarm.cpp:109
AlarmStatus
enum definition of AlarmStatus
Definition: alarm.h:45
static StringArrayPtr getStatusNames()
Definition: alarm.cpp:88
std::vector< std::string > StringArray
Definition: pvType.h:110
epicsMutex Mutex
Definition: lock.h:28
static StringArrayPtr getSeverityNames()
Definition: alarm.cpp:40
std::tr1::shared_ptr< StringArray > StringArrayPtr
Definition: pvType.h:111
AlarmSeverity getSeverity() const
Definition: alarm.cpp:58
static AlarmStatus getStatus(int value)
Definition: alarm.cpp:70