From 2b0cb0c36e03df915dd6e44d8c6dde0d5494052a Mon Sep 17 00:00:00 2001 From: Anna Waldron Date: Tue, 20 Nov 2018 17:01:05 -0800 Subject: [PATCH] Issue #92 - Allow for frequency notification option to not be specified --- ait/gui/__init__.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ait/gui/__init__.py b/ait/gui/__init__.py index 5b9eee93..fcc9c50a 100644 --- a/ait/gui/__init__.py +++ b/ait/gui/__init__.py @@ -389,8 +389,11 @@ def telem_handler(session): for k, v in tlm.getDefaultDict().iteritems(): packet_dict[v.uid] = v - notif_thrshld = cfg.AitConfig.get('notifications.options.threshold') - notif_freq = cfg.AitConfig.get('notifications.options.frequency') + notif_thrshld = cfg.AitConfig().get('notifications.options.threshold') + if cfg.AitConfig().get('notifications.options.frequency'): + notif_freq = cfg.AitConfig().get('notifications.options.frequency') + else: + notif_freq = float('inf') log.info('Starting telemetry limit monitoring') try: @@ -417,8 +420,9 @@ def telem_handler(session): limit_trip_repeats[packet.name][field] += 1 - if limit_trip_repeats[packet.name][field] == notif_thrshld or - limit_trip_repeats[packet.name][field] % notif_freq == 0: + if (limit_trip_repeats[packet.name][field] == notif_thrshld or + (limit_trip_repeats[packet.name][field] - notif_thrshld) + % notif_freq == 0): notify.trigger_notification('limit-error', msg) elif defn.warn(v): @@ -427,8 +431,9 @@ def telem_handler(session): limit_trip_repeats[packet.name][field] += 1 - if limit_trip_repeats[packet.name][field] == notif_thrshld or - limit_trip_repeats[packet.name][field] % notif_freq == 0: + if (limit_trip_repeats[packet.name][field] == notif_thrshld or + (limit_trip_repeats[packet.name][field] - notif_thrshld) + % notif_freq == 0): notify.trigger_notification('limit-warn', msg) else: