Browse Source

Added base class to messages.

pyserial_fix
Scott Petersen 11 years ago
parent
commit
6b467c80f6
1 changed files with 11 additions and 4 deletions
  1. +11
    -4
      pyad2usb/messages.py

+ 11
- 4
pyad2usb/messages.py View File

@@ -6,7 +6,14 @@ Message representations received from the panel through the AD2USB.

import re

class Message(object):
class BaseMessage(object):
"""
Base class for messages.
"""
def __init__(self):
self.raw = None

class Message(BaseMessage):
"""
Represents a message from the alarm panel.
"""
@@ -95,7 +102,7 @@ class Message(object):
"""
return 'msg > {0:0<9} [{1}{2}{3}] -- ({4}) {5}'.format(hex(self.mask), 1 if self.ready else 0, 1 if self.armed_away else 0, 1 if self.armed_home else 0, self.numeric_code, self.text)

class ExpanderMessage(object):
class ExpanderMessage(BaseMessage):
"""
Represents a message from a zone or relay expansion module.
"""
@@ -151,7 +158,7 @@ class ExpanderMessage(object):
elif header == '!REL':
self.type = ExpanderMessage.RELAY

class RFMessage(object):
class RFMessage(BaseMessage):
"""
Represents a message from an RF receiver.
"""
@@ -203,7 +210,7 @@ class RFMessage(object):
self.loop[2] = is_bit_set(7)
self.loop[3] = is_bit_set(8)

class LRRMessage(object):
class LRRMessage(BaseMessage):
"""
Represent a message from a Long Range Radio.
"""


Loading…
Cancel
Save