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