Browse Source

Comments.

pyserial_fix
Scott Petersen 11 years ago
parent
commit
2ad6bd5581
2 changed files with 18 additions and 0 deletions
  1. +5
    -0
      pyad2usb/ad2usb.py
  2. +13
    -0
      pyad2usb/zonetracking.py

+ 5
- 0
pyad2usb/ad2usb.py View File

@@ -337,6 +337,7 @@ class AD2USB(object):

def _handle_lrr(self, data):
"""
Handle Long Range Radio messages.
"""
msg = messages.LRRMessage(data)

@@ -444,6 +445,10 @@ class AD2USB(object):
self._update_zone_tracker(message)

def _update_zone_tracker(self, message):
"""
Trigger an update of the zonetracker.
"""

# Retrieve a list of faults.
# NOTE: This only happens on first boot or after exiting programming mode.
if isinstance(message, messages.Message):


+ 13
- 0
pyad2usb/zonetracking.py View File

@@ -162,6 +162,9 @@ class Zonetracker(object):
self._update_zone(z, Zone.CLEAR)

def _clear_expired_zones(self):
"""
Update zone status for all expired zones.
"""
zones = []

for z in self._zones.keys():
@@ -200,12 +203,22 @@ class Zonetracker(object):
self.on_restore(zone)

def _zone_expired(self, zone):
"""
Determine if a zone is expired or not.
"""
if time.time() > self._zones[zone].timestamp + Zonetracker.EXPIRE:
return True

return False

def _expander_to_zone(self, address, channel):
"""
Convert an address and channel into a zone number.
"""

# TODO: This is going to need to be reworked to support the larger
# panels without fixed addressing on the expanders.

idx = address - 7 # Expanders start at address 7.

return address + channel + (idx * 7) + 1

Loading…
Cancel
Save