AlarmNotifications
PANDA Slow Control Alarm Daemon
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
alarmserverconnector.h
Go to the documentation of this file.
1 
34 #ifndef ALARMSERVERCONNECTOR_H
35 #define ALARMSERVERCONNECTOR_H
36 
37 #include "oldgcccompat.h" // Compatibilty macros for GCC < 4.7
38 
39 #include <map>
40 #include <limits>
41 #include <string>
42 #include <thread>
43 
44 #include <boost/thread.hpp>
45 
46 #include "alarmstatusentry.h"
47 #include "cmsclient.h"
48 
49 #if ( __WORDSIZE < 64 ) || ( LONG_MAX < 9223372036854775807L )
50 #warning Using this application on non-64bit architecture may cause it suffer from the year-2038-bug on 19 Jan 2038 03:14:07 UTC. Linux on 64bit is not affected as time_t is a long int and long int is 64bit wide there.
51 #endif
52 
53 namespace AlarmNotifications
54 {
55 
64 {
65 private:
66 #if ( OLDGCC46COMPAT == 0 )
67 
78  static const time_t noAlarmActive = std::numeric_limits<long int>::min(); // Proper definition
79 #else
80  static const time_t noAlarmActive = LONG_MIN; // Fallback to preprocessor macro for old compilers
81 #endif
82 
87  const bool _desktopVersion;
93  const bool _activateBeedo;
107  std::map<std::string, AlarmStatusEntry> _statusmap;
113  boost::mutex _statusmapmutex;
119  boost::mutex _flashlightmutex;
137  boost::thread _watcher;
143  boost::thread _flashlightthread;
149  time_t _oldestAlarm;
150 
158  bool checkSeverityString ( const std::string& severity );
165  void startWatcher();
172  void checkStatusMap();
179  void operateFlashLight();
186  void switchFlashLightOn();
193  void switchFlashLightOff();
210  void sendDesktopNotification ( const std::vector<AlarmStatusEntry > alarm );
227  void sendEMailNotification ( const std::vector< AlarmStatusEntry > alarm );
228 public:
237  AlarmServerConnector ( const bool desktopVersion = false, const bool activateBeedo = false );
250  AlarmServerConnector ( const AlarmServerConnector& other ) = delete;
257  AlarmServerConnector ( AlarmServerConnector&& other ) = delete;
265  AlarmServerConnector& operator= ( const AlarmServerConnector& other ) = delete;
281  void notifyStatusChange ( const AlarmStatusEntry status );
288  size_t getNumberOfAlarms() const noexcept;
289 };
290 
291 }
292 
293 #endif // ALARMSERVERCONNECTOR_H
CMSClient _cmsclient
ActiveMQ client instance.
void sendDesktopNotification(const std::vector< AlarmStatusEntry > alarm)
Fire desktop notification.
const bool _desktopVersion
Desktop version flag.
boost::mutex _flashlightmutex
Mutex to protect the flashlight accessed.
void switchFlashLightOn()
Switch laboratory flashlight on.
static const time_t noAlarmActive
Time of last alarm if no alarm is active.
void prepareEMailNotification()
Select alarms to be included in an e-mail notification.
boost::mutex _statusmapmutex
Mutex to protect the _statusmap.
void prepareDesktopNotification()
Select alarms to be included in a desktop notification.
Compatibility macros for older versions of the GCC.
void notifyStatusChange(const AlarmStatusEntry status)
Notify AlarmServerConnector about alarm status change.
bool _flashlighton
Flashlight status flag.
bool checkSeverityString(const std::string &severity)
Check severity string in CSS Alarm Server message.
void switchFlashLightOff()
Switch laboratory flashlight off.
C++ Messaging Service client.
Definition: cmsclient.h:70
void startWatcher()
Start the watcher thread.
Alarm entry for the AlarmServerConnector.
boost::thread _watcher
Notification thread.
Entry in the AlarmServerConnector statusmap.
void sendEMailNotification(const std::vector< AlarmStatusEntry > alarm)
Fire desktop notification.
Interface to the CMS (C++ Messaging Service) library of Apache ActiveMQ.
Namespace for Alarm Notifications application.
AlarmServerConnector & operator=(const AlarmServerConnector &other)=delete
Copy assignment (deleted)
size_t getNumberOfAlarms() const noexcept
Query number of active alarms.
#define noexcept
Allow using the noexcept keyword with GCC < 4.6.
Definition: oldgcccompat.h:52
AlarmServerConnector(const bool desktopVersion=false, const bool activateBeedo=false)
Constructor.
std::map< std::string, AlarmStatusEntry > _statusmap
Map of active alarms.
bool _runwatcher
Watcher thread abortion flag.
void operateFlashLight()
Operate the red flashlight in the laboratory.
time_t _oldestAlarm
Timestamp of oldest alarm in _statusmap.
boost::thread _flashlightthread
Flashlight operation thread.
void checkStatusMap()
Check the _statusmap for pending notifications.