40 #ifndef NOTUSELIBNOTIFY
41 #include <glib-2.0/glib.h>
42 #include <libnotify/notification.h>
43 #include <libnotify/notify.h>
53 using namespace AlarmNotifications;
56 : _desktopVersion ( desktopVersion ),
57 _activateBeedo ( activateBeedo ),
60 _flashlighton ( false ),
63 _oldestAlarm ( noAlarmActive )
66 throw std::logic_error (
"The \"beedo\" optoacoustic alarm can only be used in desktop mode!" );
67 #ifndef NOTUSELIBNOTIFY
68 notify_init (
"DCS Alarm System" );
77 #ifndef NOTUSELIBNOTIFY
85 const std::string& pvname = status.
getPVName();
95 _statusmap.insert ( std::pair<std::string, AlarmStatusEntry> ( pvname, status ) );
97 ( *entry ).second.update ( status );
105 if ( severity ==
"OK" )
107 if ( severity.substr ( severity.length()-4, 4 ) ==
"_ACK" )
171 std::cout <<
"Flash light on!" << std::endl;
180 std::cout <<
"Flash light off!" << std::endl;
188 std::vector<AlarmStatusEntry> alarmsToUse;
193 if ( ! ( *i ).second.getDesktopNotificationSent() )
195 ( *i ).second.setDesktopNotificationSent (
true );
200 if ( alarmsToUse.size() > 0 )
209 std::string alarmtext =
"Alarm on this/these PV(s):\n";
210 for (
auto i = alarm.begin(); i != alarm.end(); i++ )
212 alarmtext += ( *i ).getPVName() +
"\n";
214 #ifndef NOTUSELIBNOTIFY
215 NotifyNotification* n = notify_notification_new (
220 notify_notification_set_timeout ( n, NOTIFY_EXPIRES_NEVER );
221 notify_notification_set_urgency ( n, NOTIFY_URGENCY_CRITICAL );
222 GError* showerror =
nullptr;
223 notify_notification_show ( n, &showerror );
224 g_object_unref ( G_OBJECT ( n ) );
226 std::string command =
"notify-send -u critical -t 0 -i dialog-warning 'Detector Alarm' ";
227 command += std::string (
"'" );
228 command += alarmtext;
229 command += std::string (
"'" );
230 system ( command.c_str() );
240 std::vector<AlarmStatusEntry> alarmsToUse;
245 if ( ! ( *i ).second.getEmailNotificationSent() )
247 ( *i ).second.setEmailNotificationSent (
true );
252 if ( alarmsToUse.size() > 0 )