Skip to content

Commit

Permalink
Improved Handling of New Zone Faults
Browse files Browse the repository at this point in the history
Avoids some inaccuracies where a newly faulted zone could cause
other faulted zones to appear as ready temporarily.

Fixes #50
  • Loading branch information
krkeegan committed Jun 25, 2020
1 parent e2a85ac commit 66752a6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions alarmdecoder/zonetracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ def update(self, message):
self._update_zone(zone)
self._clear_zones(zone)

# Save our spot for the next message.
self._last_zone_fault = zone

else:
status = Zone.FAULT
if message.check_zone:
Expand All @@ -207,8 +210,8 @@ def update(self, message):
self._zones_faulted.append(zone)
self._zones_faulted.sort()

# Save our spot for the next message.
self._last_zone_fault = zone
# A new zone fault, so it is out of sequence.
self._last_zone_fault = 0

self._clear_expired_zones()

Expand Down Expand Up @@ -245,6 +248,11 @@ def _clear_zones(self, zone):
:param zone: current zone being processed
:type zone: int
"""

if self._last_zone_fault == 0:
# We don't know what the last faulted zone was, nothing to do
return

cleared_zones = []
found_last_faulted = found_current = at_end = False

Expand Down

0 comments on commit 66752a6

Please sign in to comment.