Browse Source

Added initial support for DSC in the beta firmware.

pyserial_fix
Scott Petersen 11 years ago
parent
commit
14cca0aaa9
2 changed files with 20 additions and 10 deletions
  1. +12
    -10
      alarmdecoder/decoder.py
  2. +8
    -0
      alarmdecoder/panels.py

+ 12
- 10
alarmdecoder/decoder.py View File

@@ -13,6 +13,7 @@ from .event import event
from .util import InvalidMessageError from .util import InvalidMessageError
from .messages import Message, ExpanderMessage, RFMessage, LRRMessage from .messages import Message, ExpanderMessage, RFMessage, LRRMessage
from .zonetracking import Zonetracker from .zonetracking import Zonetracker
from .panels import MODES, ADEMCO, DSC




class AlarmDecoder(object): class AlarmDecoder(object):
@@ -80,6 +81,8 @@ class AlarmDecoder(object):
"""The status of the devices LRR emulation.""" """The status of the devices LRR emulation."""
deduplicate = False deduplicate = False
"""The status of message deduplication as configured on the device.""" """The status of message deduplication as configured on the device."""
mode = ADEMCO
"""The panel mode that the AlarmDecoder is in. Currently supports ADEMCO and DSC."""


def __init__(self, device): def __init__(self, device):
""" """
@@ -110,6 +113,7 @@ class AlarmDecoder(object):
self.emulate_relay = [False for x in range(4)] self.emulate_relay = [False for x in range(4)]
self.emulate_lrr = False self.emulate_lrr = False
self.deduplicate = False self.deduplicate = False
self.mode = ADEMCO


def __enter__(self): def __enter__(self):
""" """
@@ -222,20 +226,16 @@ class AlarmDecoder(object):
config_entries = [] config_entries = []


# HACK: This is ugly.. but I can't think of an elegant way of doing it. # HACK: This is ugly.. but I can't think of an elegant way of doing it.
config_entries.append(('ADDRESS',
'{0}'.format(self.address)))
config_entries.append(('CONFIGBITS',
'{0:x}'.format(self.configbits)))
config_entries.append(('MASK',
'{0:x}'.format(self.address_mask)))
config_entries.append(('ADDRESS', '{0}'.format(self.address)))
config_entries.append(('CONFIGBITS', '{0:x}'.format(self.configbits)))
config_entries.append(('MASK', '{0:x}'.format(self.address_mask)))
config_entries.append(('EXP', config_entries.append(('EXP',
''.join(['Y' if z else 'N' for z in self.emulate_zone]))) ''.join(['Y' if z else 'N' for z in self.emulate_zone])))
config_entries.append(('REL', config_entries.append(('REL',
''.join(['Y' if r else 'N' for r in self.emulate_relay]))) ''.join(['Y' if r else 'N' for r in self.emulate_relay])))
config_entries.append(('LRR',
'Y' if self.emulate_lrr else 'N'))
config_entries.append(('DEDUPLICATE',
'Y' if self.deduplicate else 'N'))
config_entries.append(('LRR', 'Y' if self.emulate_lrr else 'N'))
config_entries.append(('DEDUPLICATE', 'Y' if self.deduplicate else 'N'))
config_entries.append(('MODE', MODES.keys()[MODES.values().index(self.mode)]))


config_string = '&'.join(['='.join(t) for t in config_entries]) config_string = '&'.join(['='.join(t) for t in config_entries])


@@ -430,6 +430,8 @@ class AlarmDecoder(object):
self.emulate_lrr = (val == 'Y') self.emulate_lrr = (val == 'Y')
elif key == 'DEDUPLICATE': elif key == 'DEDUPLICATE':
self.deduplicate = (val == 'Y') self.deduplicate = (val == 'Y')
elif key == 'MODE':
self.mode = MODES[val]


self.on_config_received() self.on_config_received()




+ 8
- 0
alarmdecoder/panels.py View File

@@ -4,6 +4,14 @@ Representations of Panels and their templates.
.. moduleauthor:: Scott Petersen <scott@nutech.com> .. moduleauthor:: Scott Petersen <scott@nutech.com>
""" """


ADEMCO = 0
DSC = 1

MODES = {
'A': ADEMCO,
'D': DSC,
}

VISTA20 = 0 VISTA20 = 0


TEMPLATES = { TEMPLATES = {


Loading…
Cancel
Save