Skip to content

Commit

Permalink
Issue #92 - Allow for frequency notification option to not be specified
Browse files Browse the repository at this point in the history
  • Loading branch information
aywaldron committed Dec 4, 2018
1 parent 6518331 commit 2b0cb0c
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions ait/gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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):
Expand All @@ -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:
Expand Down

0 comments on commit 2b0cb0c

Please sign in to comment.