From 2fc1161080af972f5b961a5069ca841b5bd2fe16 Mon Sep 17 00:00:00 2001 From: Anna Waldron Date: Fri, 30 Nov 2018 11:08:09 -0800 Subject: [PATCH] Issue #92 - Small refactoring of enable_monitoring function --- ait/gui/__init__.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ait/gui/__init__.py b/ait/gui/__init__.py index 09c67b3f..3134f8e4 100644 --- a/ait/gui/__init__.py +++ b/ait/gui/__init__.py @@ -389,9 +389,9 @@ def telem_handler(session): for k, v in tlm.getDefaultDict().iteritems(): packet_dict[v.uid] = v - notif_thrshld = cfg.AitConfig().get('notifications.options.threshold') - if cfg.AitConfig().get('notifications.options.frequency'): - notif_freq = cfg.AitConfig().get('notifications.options.frequency') + notif_thrshld = ait.config.get('notifications.options.threshold') + if ait.config.get('notifications.options.frequency'): + notif_freq = ait.config.get('notifications.options.frequency') else: notif_freq = float('inf') @@ -419,10 +419,11 @@ def telem_handler(session): log.error(msg) limit_trip_repeats[packet.name][field] += 1 + repeats = limit_trip_repeats[packet.name][field] - if (limit_trip_repeats[packet.name][field] == notif_thrshld or - (limit_trip_repeats[packet.name][field] - notif_thrshld) - % notif_freq == 0): + if (repeats == notif_thrshld or + (repeats > notif_thrshld and + (repeats - notif_thrshld) % notif_freq == 0)): notify.trigger_notification('limit-error', msg) elif defn.warn(v): @@ -430,10 +431,11 @@ def telem_handler(session): log.warn(msg) limit_trip_repeats[packet.name][field] += 1 + repeats = limit_trip_repeats[packet.name][field] - if (limit_trip_repeats[packet.name][field] == notif_thrshld or - (limit_trip_repeats[packet.name][field] - notif_thrshld) - % notif_freq == 0): + if (repeats == notif_thrshld or + (repeats > notif_thrshld and + (repeats - notif_thrshld) % notif_freq == 0)): notify.trigger_notification('limit-warn', msg) else: