AlarmNotifications
PANDA Slow Control Alarm Daemon
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
alarmstatusentry.cpp
Go to the documentation of this file.
1 
34 #include "alarmstatusentry.h"
35 
36 using namespace AlarmNotifications;
37 
38 AlarmStatusEntry::AlarmStatusEntry ( const std::string& pvname, const std::string& severity, const std::string& status ) noexcept
39 :
40 _pvname ( pvname ),
41  _severity ( severity ),
42  _status ( status ),
43  _triggertime ( std::time ( nullptr ) ),
44  _desktopNotificationSent ( false ),
45  _emailNotificationSent ( false )
46 {
47 
48 }
49 
51 {
52 
53 }
54 
56 :
57 _pvname ( other._pvname ),
58 _severity ( other._severity ),
59 _status ( other._status ),
60 _triggertime ( other._triggertime ),
61 _desktopNotificationSent ( other._desktopNotificationSent ),
62 _emailNotificationSent ( other._emailNotificationSent )
63 {
64 
65 }
66 
68 :
69 _pvname ( std::move ( other._pvname ) ),
70 _severity ( std::move ( other._severity ) ),
71 _status ( std::move ( other._status ) ),
72 _triggertime ( other._triggertime ),
73 _desktopNotificationSent ( other._desktopNotificationSent ),
74 _emailNotificationSent ( other._emailNotificationSent )
75 {
76 
77 }
78 
80 {
81  if ( this != &other )
82  {
83  _pvname = other._pvname;
84  _severity = other._severity;
85  _status = other._status;
86  _triggertime = other._triggertime;
87  _desktopNotificationSent = other._desktopNotificationSent;
88  _emailNotificationSent = other._emailNotificationSent;
89  }
90  return *this;
91 }
92 
94 {
95  if ( this != &other )
96  {
97  _pvname = std::move ( other._pvname );
98  _severity = std::move ( other._severity );
99  _status = std::move ( other._status );
100  _triggertime = other._triggertime;
101  _desktopNotificationSent = other._desktopNotificationSent;
102  _emailNotificationSent = other._emailNotificationSent;
103  }
104  return *this;
105 }
106 
108 {
109  return ( _pvname == other._pvname ) && ( _severity == other._severity ) && ( _status == other._status ) && ( _triggertime == other._triggertime ) && ( _desktopNotificationSent == other._desktopNotificationSent ) && ( _emailNotificationSent == other._emailNotificationSent );
110 }
111 
112 const std::string& AlarmStatusEntry::getPVName() const noexcept
113 {
114  return _pvname;
115 }
116 
117 const std::string& AlarmStatusEntry::getSeverity() const noexcept
118 {
119  return _severity;
120 }
121 
122 void AlarmStatusEntry::setSeverity ( const std::string& severity ) noexcept
123 {
124  _severity = severity;
125 }
126 
127 const std::string& AlarmStatusEntry::getStatus() const noexcept
128 {
129  return _status;
130 }
131 
132 void AlarmStatusEntry::setStatus ( const std::string& status ) noexcept
133 {
134  _status = status;
135 }
136 
138 {
139  return _triggertime;
140 }
141 
142 void AlarmStatusEntry::setTriggerTime ( const time_t triggertime ) noexcept
143 {
144  _triggertime = triggertime;
145 }
146 
148 {
149  if ( _triggertime < newdata._triggertime )
150  {
151  _severity = newdata._severity;
152  _status = newdata._status;
153  }
154 }
155 
157 {
159 }
160 
161 void AlarmStatusEntry::setDesktopNotificationSent ( const bool desktopNotificationSent ) noexcept
162 {
163  _desktopNotificationSent = desktopNotificationSent;
164 }
165 
167 {
168  return _emailNotificationSent;
169 }
170 
171 void AlarmStatusEntry::setEmailNotificationSent ( const bool emailNotificationSent ) noexcept
172 {
173  _emailNotificationSent = emailNotificationSent;
174 }
175 
176 std::ostream& AlarmNotifications::operator<< ( std::ostream& os, const AlarmNotifications::AlarmStatusEntry& ase )
177 {
178  os << "PV: " << ase.getPVName() << " Severity: " << ase.getSeverity() << " Status: " << ase.getStatus() << " Time: " << ase.getTriggerTime();
179  return os;
180 }
const std::string & getPVName() const noexcept
Query PV name.
std::string _status
The alarm status of the PV.
~AlarmStatusEntry() noexcept
Destructor.
STL namespace.
void setSeverity(const std::string &severity) noexcept
Change the severity.
void setDesktopNotificationSent(const bool desktopNotificationSent) noexcept
Change desktop notification flag.
std::ostream & operator<<(std::ostream &os, const AlarmNotifications::AlarmStatusEntry &ase)
Stream output operator for AlarmStatusEntry.
std::string _severity
The severity of the alarm.
Alarm entry for the AlarmServerConnector.
Entry in the AlarmServerConnector statusmap.
time_t _triggertime
Time the alarm message was received.
bool getEmailNotificationSent() const noexcept
Query e-mail notification flag.
bool _emailNotificationSent
Flag for sent e-mail notification.
Namespace for Alarm Notifications application.
AlarmStatusEntry & operator=(const AlarmStatusEntry &other) noexcept
Copy assignment.
void setStatus(const std::string &status) noexcept
Change the status.
bool operator==(const AlarmStatusEntry &other) noexcept
Equality operator.
#define noexcept
Allow using the noexcept keyword with GCC < 4.6.
Definition: oldgcccompat.h:52
std::string _pvname
Name of the PV.
time_t getTriggerTime() const noexcept
Query the trigger time.
const std::string & getSeverity() const noexcept
Query the severity.
void setTriggerTime(const time_t triggertime) noexcept
Change the trigger time_t.
AlarmStatusEntry(const std::string &pvname, const std::string &severity, const std::string &status) noexcept
Constructor.
void setEmailNotificationSent(const bool emailNotificationSent) noexcept
Change e-mail notification flag.
bool getDesktopNotificationSent() const noexcept
Query desktop notification flag.
bool _desktopNotificationSent
Flag for sent desktop notification.
void update(const AlarmStatusEntry &newdata) noexcept
Update severity and status data.
const std::string & getStatus() const noexcept
Query the status.