diff --git a/docs/_build/doctrees/environment.pickle b/docs/_build/doctrees/environment.pickle index 2e883f0..fcdc7b7 100644 Binary files a/docs/_build/doctrees/environment.pickle and b/docs/_build/doctrees/environment.pickle differ diff --git a/docs/_build/doctrees/index.doctree b/docs/_build/doctrees/index.doctree index 3a16f95..b5ec21c 100644 Binary files a/docs/_build/doctrees/index.doctree and b/docs/_build/doctrees/index.doctree differ diff --git a/docs/_build/doctrees/modules.doctree b/docs/_build/doctrees/modules.doctree index c48c080..1da7dfc 100644 Binary files a/docs/_build/doctrees/modules.doctree and b/docs/_build/doctrees/modules.doctree differ diff --git a/docs/_build/doctrees/pyad2.doctree b/docs/_build/doctrees/pyad2.doctree index c1c2073..833b99b 100644 Binary files a/docs/_build/doctrees/pyad2.doctree and b/docs/_build/doctrees/pyad2.doctree differ diff --git a/docs/_build/doctrees/pyad2.event.doctree b/docs/_build/doctrees/pyad2.event.doctree index 5cfb4bb..9d0e262 100644 Binary files a/docs/_build/doctrees/pyad2.event.doctree and b/docs/_build/doctrees/pyad2.event.doctree differ diff --git a/docs/_build/doctrees/pyad2usb.doctree b/docs/_build/doctrees/pyad2usb.doctree deleted file mode 100644 index fb08d27..0000000 Binary files a/docs/_build/doctrees/pyad2usb.doctree and /dev/null differ diff --git a/docs/_build/doctrees/pyad2usb.event.doctree b/docs/_build/doctrees/pyad2usb.event.doctree deleted file mode 100644 index 44216cc..0000000 Binary files a/docs/_build/doctrees/pyad2usb.event.doctree and /dev/null differ diff --git a/docs/_build/html/_modules/pyad2/ad2.html b/docs/_build/html/_modules/pyad2/ad2.html index e2afe29..95e5e44 100644 --- a/docs/_build/html/_modules/pyad2/ad2.html +++ b/docs/_build/html/_modules/pyad2/ad2.html @@ -48,21 +48,21 @@

Source code for pyad2.ad2

 """
-Provides the full AD2USB class and factory.
+Provides the full AD2 class and factory.
 
 .. moduleauthor:: Scott Petersen <scott@nutech.com>
 """
 
 import time
 import threading
-import re
+
 from .event import event
-from . import devices
-from . import util
-from . import messages
-from . import zonetracking
+from .devices import USBDevice
+from .util import CommError, NoDeviceError
+from .messages import Message, ExpanderMessage, RFMessage, LRRMessage
+from .zonetracking import Zonetracker
 
-
[docs]class Overseer(object): +
[docs]class AD2Factory(object): """ Factory for creation of AD2USB devices as well as provides attach/detach events." """ @@ -74,19 +74,19 @@ __devices = [] @classmethod -
[docs] def find_all(cls): +
[docs] def find_all(cls): """ Returns all AD2USB devices located on the system. :returns: list of devices found - :raises: util.CommError + :raises: CommError """ - cls.__devices = devices.USBDevice.find_all() + cls.__devices = USBDevice.find_all() return cls.__devices
@classmethod -
[docs] def devices(cls): +
[docs] def devices(cls): """ Returns a cached list of AD2USB devices located on the system. @@ -95,7 +95,7 @@ return cls.__devices
@classmethod -
[docs] def create(cls, device=None): +
[docs] def create(cls, device=None): """ Factory method that returns the requested AD2USB device, or the first device. @@ -103,18 +103,18 @@ :type device: tuple :returns: AD2USB object utilizing the specified device. - :raises: util.NoDeviceError + :raises: NoDeviceError """ cls.find_all() if len(cls.__devices) == 0: - raise util.NoDeviceError('No AD2USB devices present.') + raise NoDeviceError('No AD2USB devices present.') if device is None: device = cls.__devices[0] vendor, product, sernum, ifcount, description = device - device = devices.USBDevice((sernum, ifcount - 1)) + device = USBDevice((sernum, ifcount - 1)) return AD2(device)
@@ -127,7 +127,7 @@ :param detached_event: Event to trigger when a device is detached. :type detached_event: function """ - self._detect_thread = Overseer.DetectThread(self) + self._detect_thread = AD2Factory.DetectThread(self) if attached_event: self.on_attached += attached_event @@ -135,61 +135,61 @@ if detached_event: self.on_detached += detached_event - Overseer.find_all() + AD2Factory.find_all() self.start() -
[docs] def close(self): +
[docs] def close(self): """ Clean up and shut down. """ self.stop()
-
[docs] def start(self): +
[docs] def start(self): """ Starts the detection thread, if not already running. """ if not self._detect_thread.is_alive(): self._detect_thread.start()
-
[docs] def stop(self): +
[docs] def stop(self): """ Stops the detection thread. """ self._detect_thread.stop()
-
[docs] def get_device(self, device=None): +
[docs] def get_device(self, device=None): """ Factory method that returns the requested AD2USB device, or the first device. :param device: Tuple describing the USB device to open, as returned by find_all(). :type device: tuple """ - return Overseer.create(device) + return AD2Factory.create(device)
-
[docs] class DetectThread(threading.Thread): +
[docs] class DetectThread(threading.Thread): """ Thread that handles detection of added/removed devices. """ - def __init__(self, overseer): + def __init__(self, factory): """ Constructor - :param overseer: Overseer object to use with the thread. - :type overseer: Overseer + :param factory: AD2Factory object to use with the thread. + :type factory: AD2Factory """ threading.Thread.__init__(self) - self._overseer = overseer + self._factory = factory self._running = False -
[docs] def stop(self): +
[docs] def stop(self): """ Stops the thread. """ self._running = False
-
[docs] def run(self): +
[docs] def run(self): """ The actual detection process. """ @@ -199,20 +199,20 @@ while self._running: try: - Overseer.find_all() + AD2Factory.find_all() - current_devices = set(Overseer.devices()) + current_devices = set(AD2Factory.devices()) new_devices = [d for d in current_devices if d not in last_devices] removed_devices = [d for d in last_devices if d not in current_devices] last_devices = current_devices for d in new_devices: - self._overseer.on_attached(d) + self._factory.on_attached(d) for d in removed_devices: - self._overseer.on_detached(d) + self._factory.on_detached(d) - except util.CommError, err: + except CommError, err: pass time.sleep(0.25) @@ -220,7 +220,7 @@
[docs]class AD2(object): """ - High-level wrapper around AD2USB/AD2SERIAL devices. + High-level wrapper around AD2 devices. """ # High-level Events @@ -268,11 +268,11 @@ """ Constructor - :param device: The low-level device used for this AD2USB interface. - :type device: devices.Device + :param device: The low-level device used for this AD2 interface. + :type device: Device """ self._device = device - self._zonetracker = zonetracking.Zonetracker() + self._zonetracker = Zonetracker() self._power_status = None self._alarm_status = None @@ -294,7 +294,7 @@ @property
[docs] def id(self): """ - The ID of the AD2USB device. + The ID of the AD2 device. :returns: The identification string for the device. """ @@ -320,7 +320,9 @@ """ Closes the device. """ - self._device.close() + if self._device: + self._device.close() + del self._device self._device = None
@@ -332,7 +334,7 @@ """ Retrieves the configuration from the device. """ - self._device.write("C\r") + self.send("C\r")
[docs] def save_config(self): """ @@ -361,13 +363,13 @@ config_string = '&'.join(['='.join(t) for t in config_entries]) - self._device.write("C{0}\r".format(config_string)) + self.send("C{0}\r".format(config_string))
[docs] def reboot(self): """ Reboots the device. """ - self._device.write('=') + self.send('=')
[docs] def fault_zone(self, zone, simulate_wire_problem=False): """ @@ -388,7 +390,7 @@ status = 2 if simulate_wire_problem else 1 - self._device.write("L{0:02}{1}\r".format(zone, status)) + self.send("L{0:02}{1}\r".format(zone, status))
[docs] def clear_zone(self, zone): """ @@ -397,7 +399,7 @@ :param zone: The zone to clear. :type zone: int """ - self._device.write("L{0:02}0\r".format(zone)) + self.send("L{0:02}0\r".format(zone))
def _wire_events(self): """ @@ -420,19 +422,19 @@ :returns: An object representing the message. """ if data is None: - return None + raise InvalidMessageError() msg = None header = data[0:4] if header[0] != '!' or header == '!KPE': - msg = messages.Message(data) + msg = Message(data) if self.address_mask & msg.mask > 0: self._update_internal_states(msg) elif header == '!EXP' or header == '!REL': - msg = messages.ExpanderMessage(data) + msg = ExpanderMessage(data) self._update_internal_states(msg) @@ -451,7 +453,7 @@ return msg def _handle_rfx(self, data): - msg = messages.RFMessage(data) + msg = RFMessage(data) self.on_rfx_message(msg) @@ -466,7 +468,7 @@ :returns: An object representing the LRR message. """ - msg = messages.LRRMessage(data) + msg = LRRMessage(data) if msg.event_type == 'ALARM_PANIC': self._panic_status = True @@ -518,7 +520,7 @@ :param message: Message to update internal states with. :type message: Message, ExpanderMessage, LRRMessage, or RFMessage """ - if isinstance(message, messages.Message): + if isinstance(message, Message): if message.ac_power != self._power_status: self._power_status, old_status = message.ac_power, self._power_status @@ -560,8 +562,8 @@ self._fire_status = (message.fire_alarm, time.time()) self.on_fire(self._fire_status) - elif isinstance(message, messages.ExpanderMessage): - if message.type == messages.ExpanderMessage.RELAY: + elif isinstance(message, ExpanderMessage): + if message.type == ExpanderMessage.RELAY: self._relay_status[(message.address, message.channel)] = message.value self.on_relay_changed(message) @@ -578,9 +580,9 @@ # Retrieve a list of faults. # NOTE: This only happens on first boot or after exiting programming mode. - if isinstance(message, messages.Message): + if isinstance(message, Message): if not message.ready and "Hit * for faults" in message.text: - self._device.write('*') + self.send('*') return self._zonetracker.update(message) diff --git a/docs/_build/html/_modules/pyad2/devices.html b/docs/_build/html/_modules/pyad2/devices.html index e4e8cc5..f41fbf7 100644 --- a/docs/_build/html/_modules/pyad2/devices.html +++ b/docs/_build/html/_modules/pyad2/devices.html @@ -48,7 +48,7 @@

Source code for pyad2.devices

 """
-Contains different types of devices belonging to the AD2USB family.
+Contains different types of devices belonging to the AD2 family.
 
 .. moduleauthor:: Scott Petersen <scott@nutech.com>
 """
@@ -58,15 +58,16 @@
 import threading
 import serial, serial.tools.list_ports
 import socket
+
 from OpenSSL import SSL, crypto
 from pyftdi.pyftdi.ftdi import *
 from pyftdi.pyftdi.usbtools import *
-from . import util
+from .util import CommError, TimeoutError, NoDeviceError
 from .event import event
 
 
[docs]class Device(object): """ - Generic parent device to all AD2USB products. + Generic parent device to all AD2 products. """ # Generic device events @@ -167,7 +168,7 @@ try: self._device.read_line(timeout=self.READ_TIMEOUT) - except util.TimeoutError, err: + except TimeoutError, err: pass except Exception, err: @@ -196,7 +197,7 @@ Returns all FTDI devices matching our vendor and product IDs. :returns: list of devices - :raises: util.CommError + :raises: CommError """ devices = [] @@ -204,7 +205,7 @@ devices = Ftdi.find_all([(USBDevice.FTDI_VENDOR_ID, USBDevice.FTDI_PRODUCT_ID)], nocache=True) except (usb.core.USBError, FtdiError), err: - raise util.CommError('Error enumerating AD2USB devices: {0}'.format(str(err)), err) + raise CommError('Error enumerating AD2USB devices: {0}'.format(str(err)), err) return devices
@@ -293,7 +294,7 @@ :param no_reader_thread: Whether or not to automatically start the reader thread. :type no_reader_thread: bool - :raises: util.NoDeviceError + :raises: NoDeviceError """ # Set up defaults if baudrate is None: @@ -313,7 +314,7 @@ self._id = 'USB {0}:{1}'.format(self._device.usb_dev.bus, self._device.usb_dev.address) except (usb.core.USBError, FtdiError), err: - raise util.NoDeviceError('Error opening device: {0}'.format(str(err)), err) + raise NoDeviceError('Error opening device: {0}'.format(str(err)), err) else: self._running = True @@ -342,7 +343,7 @@ :param data: Data to write :type data: str - :raises: util.CommError + :raises: CommError """ try: self._device.write_data(data) @@ -350,14 +351,14 @@ self.on_write(data) except FtdiError, err: - raise util.CommError('Error writing to device: {0}'.format(str(err)), err) + raise CommError('Error writing to device: {0}'.format(str(err)), err)
[docs] def read(self): """ Reads a single character from the device. :returns: The character read from the device. - :raises: util.CommError + :raises: CommError """ ret = None @@ -365,7 +366,7 @@ ret = self._device.read_data(1) except (usb.core.USBError, FtdiError), err: - raise util.CommError('Error reading from device: {0}'.format(str(err)), err) + raise CommError('Error reading from device: {0}'.format(str(err)), err) return ret
@@ -379,7 +380,7 @@ :type purge_buffer: bool :returns: The line that was read. - :raises: util.CommError, util.TimeoutError + :raises: CommError, TimeoutError """ if purge_buffer: @@ -421,7 +422,7 @@ if timer: timer.cancel() - raise util.CommError('Error reading from device: {0}'.format(str(err)), err) + raise CommError('Error reading from device: {0}'.format(str(err)), err) else: if got_line: @@ -434,7 +435,7 @@ if timer.is_alive(): timer.cancel() else: - raise util.TimeoutError('Timeout while waiting for line terminator.') + raise TimeoutError('Timeout while waiting for line terminator.') return ret @@ -457,7 +458,7 @@ :type pattern: str :returns: list of devices - :raises: util.CommError + :raises: CommError """ devices = [] @@ -468,7 +469,7 @@ devices = serial.tools.list_ports.comports() except SerialException, err: - raise util.CommError('Error enumerating serial devices: {0}'.format(str(err)), err) + raise CommError('Error enumerating serial devices: {0}'.format(str(err)), err) return devices
@@ -513,14 +514,14 @@ :param no_reader_thread: Whether or not to automatically start the reader thread. :type no_reader_thread: bool - :raises: util.NoDeviceError + :raises: NoDeviceError """ # Set up the defaults if baudrate is None: baudrate = SerialDevice.BAUDRATE if self._port is None: - raise util.NoDeviceError('No device interface specified.') + raise NoDeviceError('No device interface specified.') self._device.port = self._port @@ -535,7 +536,7 @@ # all issues with it. except (serial.SerialException, ValueError), err: - raise util.NoDeviceError('Error opening device on port {0}.'.format(self._port), err) + raise NoDeviceError('Error opening device on port {0}.'.format(self._port), err) else: self._running = True @@ -561,7 +562,7 @@ :param data: The data to write. :type data: str - :raises: util.CommError + :raises: CommError """ try: self._device.write(data) @@ -570,7 +571,7 @@ pass except serial.SerialException, err: - raise util.CommError('Error writing to device.', err) + raise CommError('Error writing to device.', err) else: self.on_write(data) @@ -580,7 +581,7 @@ Reads a single character from the device. :returns: The character read from the device. - :raises: util.CommError + :raises: CommError """ ret = None @@ -588,7 +589,7 @@ ret = self._device.read(1) except serial.SerialException, err: - raise util.CommError('Error reading from device: {0}'.format(str(err)), err) + raise CommError('Error reading from device: {0}'.format(str(err)), err) return ret
@@ -602,7 +603,7 @@ :type purge_buffer: bool :returns: The line read. - :raises: util.CommError, util.TimeoutError + :raises: CommError, TimeoutError """ def timeout_event(): timeout_event.reading = False @@ -640,7 +641,7 @@ if timer: timer.cancel() - raise util.CommError('Error reading from device: {0}'.format(str(err)), err) + raise CommError('Error reading from device: {0}'.format(str(err)), err) else: if got_line: @@ -653,13 +654,13 @@ if timer.is_alive(): timer.cancel() else: - raise util.TimeoutError('Timeout while waiting for line terminator.') + raise TimeoutError('Timeout while waiting for line terminator.') return ret
[docs]class SocketDevice(Device): """ - Device that supports communication with an AD2USB that is exposed via ser2sock or another + Device that supports communication with an AD2 that is exposed via ser2sock or another Serial to IP interface. """ @@ -783,7 +784,7 @@ :param no_reader_thread: Whether or not to automatically open the reader thread. :type no_reader_thread: bool - :raises: util.NoDeviceError, util.CommError + :raises: NoDeviceError, CommError """ try: @@ -797,7 +798,7 @@ self._id = '{0}:{1}'.format(self._host, self._port) except socket.error, err: - raise util.NoDeviceError('Error opening device at {0}:{1}'.format(self._host, self._port), err) + raise NoDeviceError('Error opening device at {0}:{1}'.format(self._host, self._port), err) else: self._running = True @@ -830,7 +831,7 @@ :type data: str :returns: The number of bytes sent. - :raises: util.CommError + :raises: CommError """ data_sent = None @@ -838,12 +839,12 @@ data_sent = self._device.send(data) if data_sent == 0: - raise util.CommError('Error writing to device.') + raise CommError('Error writing to device.') self.on_write(data) except (SSL.Error, socket.error), err: - raise util.CommError('Error writing to device.', err) + raise CommError('Error writing to device.', err) return data_sent
@@ -852,7 +853,7 @@ Reads a single character from the device. :returns: The character read from the device. - :raises: util.CommError + :raises: CommError """ data = None @@ -860,7 +861,7 @@ data = self._device.recv(1) except socket.error, err: - raise util.CommError('Error while reading from device: {0}'.format(str(err)), err) + raise CommError('Error while reading from device: {0}'.format(str(err)), err) return data
@@ -874,7 +875,7 @@ :type purge_buffer: bool :returns: The line read from the device. - :raises: util.CommError, util.TimeoutError + :raises: CommError, TimeoutError """ if purge_buffer: @@ -916,7 +917,7 @@ if timer: timer.cancel() - raise util.CommError('Error reading from device: {0}'.format(str(err)), err) + raise CommError('Error reading from device: {0}'.format(str(err)), err) else: if got_line: @@ -929,7 +930,7 @@ if timer.is_alive(): timer.cancel() else: - raise util.TimeoutError('Timeout while waiting for line terminator.') + raise TimeoutError('Timeout while waiting for line terminator.') return ret
@@ -958,10 +959,9 @@ self._device = SSL.Connection(ctx, self._device) except SSL.Error, err: - raise util.CommError('Error setting up SSL connection.', err) + raise CommError('Error setting up SSL connection.', err) def _verify_ssl_callback(self, connection, x509, errnum, errdepth, ok): - #print ok return ok
diff --git a/docs/_build/html/_modules/pyad2/event/event.html b/docs/_build/html/_modules/pyad2/event/event.html index 6220ad8..3427864 100644 --- a/docs/_build/html/_modules/pyad2/event/event.html +++ b/docs/_build/html/_modules/pyad2/event/event.html @@ -48,6 +48,14 @@

Source code for pyad2.event.event

 # event.py (improved)
+#
+
+# Based on pyevent originally found at http://www.emptypage.jp/notes/pyevent.en.html
+# 
+# License: https://creativecommons.org/licenses/by/2.1/jp/deed.en
+#
+# Changes:
+#    Added type check in fire()
 
 
[docs]class Event(object): diff --git a/docs/_build/html/_modules/pyad2/messages.html b/docs/_build/html/_modules/pyad2/messages.html index 0ecdbb1..58da4c4 100644 --- a/docs/_build/html/_modules/pyad2/messages.html +++ b/docs/_build/html/_modules/pyad2/messages.html @@ -48,20 +48,30 @@

Source code for pyad2.messages

 """
-Message representations received from the panel through the AD2USB.
+Message representations received from the panel through the AD2 devices.
 
 .. moduleauthor:: Scott Petersen <scott@nutech.com>
 """
 
 import re
-from . import util
+
+from .util import InvalidMessageError
 
 
[docs]class BaseMessage(object): """ Base class for messages. """ def __init__(self): + """ + Constructor + """ self.raw = None + + def __str__(self): + """ + String conversion operator. + """ + return self.raw
[docs]class Message(BaseMessage): """ @@ -111,12 +121,12 @@ :param data: The message data. :type data: str - :raises: util.InvalidMessageError + :raises: InvalidMessageError """ m = self._regex.match(data) if m is None: - raise util.InvalidMessageError('Received invalid message: {0}'.format(data)) + raise InvalidMessageError('Received invalid message: {0}'.format(data)) self.bitfield, self.numeric_code, self.panel_data, alpha = m.group(1, 2, 3, 4) self.mask = int(self.panel_data[3:3+8], 16) @@ -150,7 +160,7 @@ """ String conversion operator. """ - 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) + return self.raw
[docs]class ExpanderMessage(BaseMessage): """ @@ -158,7 +168,9 @@ """ ZONE = 0 + """Flag indicating that the expander message relates to a Zone Expander.""" RELAY = 1 + """Flag indicating that the expander message relates to a Relay Expander.""" def __init__(self, data=None): """ @@ -180,13 +192,7 @@ """ String conversion operator. """ - expander_type = 'UNKWN' - if self.type == ExpanderMessage.ZONE: - expander_type = 'ZONE' - elif self.type == ExpanderMessage.RELAY: - expander_type = 'RELAY' - - return 'exp > [{0: <5}] {1}/{2} -- {3}'.format(expander_type, self.address, self.channel, self.value) + return self.raw def _parse_message(self, data): """ @@ -205,12 +211,14 @@ self.value = int(value) except ValueError: - raise util.InvalidMessageError('Received invalid message: {0}'.format(data)) + raise InvalidMessageError('Received invalid message: {0}'.format(data)) if header == '!EXP': self.type = ExpanderMessage.ZONE elif header == '!REL': self.type = ExpanderMessage.RELAY + else: + raise InvalidMessageError('Unknown expander message header: {0}'.format(data))
[docs]class RFMessage(BaseMessage): """ @@ -238,7 +246,7 @@ """ String conversion operator. """ - return 'rf > {0}: {1:x}'.format(self.serial_number, self.value) + return self.raw def _parse_message(self, data): """ @@ -266,7 +274,7 @@ self.loop[3] = is_bit_set(8) except ValueError: - raise util.InvalidMessageError('Received invalid message: {0}'.format(data)) + raise InvalidMessageError('Received invalid message: {0}'.format(data))
[docs]class LRRMessage(BaseMessage): @@ -293,7 +301,7 @@ """ String conversion operator. """ - return 'lrr > {0} @ {1} -- {2}'.format(self.event_data, self.partition, self.event_type) + return self.raw def _parse_message(self, data): """ @@ -309,7 +317,7 @@ self.event_data, self.partition, self.event_type = values.split(',') except ValueError: - raise util.InvalidMessageError('Received invalid message: {0}'.format(data))
+ raise InvalidMessageError('Received invalid message: {0}'.format(data))
diff --git a/docs/_build/html/_modules/pyad2/util.html b/docs/_build/html/_modules/pyad2/util.html index 52dbe3e..0e16016 100644 --- a/docs/_build/html/_modules/pyad2/util.html +++ b/docs/_build/html/_modules/pyad2/util.html @@ -48,14 +48,13 @@

Source code for pyad2.util

 """
-Provides utility classes for the AD2USB devices.
+Provides utility classes for the AD2 devices.
 
 .. moduleauthor:: Scott Petersen <scott@nutech.com>
 """
 
 import ad2
 import time
-import traceback
 import threading
 
 
[docs]class NoDeviceError(Exception): @@ -84,7 +83,7 @@
[docs]class Firmware(object): """ - Represents firmware for the AD2USB/AD2SERIAL devices. + Represents firmware for the AD2 devices. """ # Constants @@ -98,7 +97,7 @@ @staticmethod
[docs] def upload(dev, filename, progress_callback=None): """ - Uploads firmware to an AD2USB/AD2SERIAL device. + Uploads firmware to an AD2 device. :param filename: The firmware filename :type filename: str diff --git a/docs/_build/html/_modules/pyad2/zonetracking.html b/docs/_build/html/_modules/pyad2/zonetracking.html index 6bb1c19..d3db801 100644 --- a/docs/_build/html/_modules/pyad2/zonetracking.html +++ b/docs/_build/html/_modules/pyad2/zonetracking.html @@ -48,15 +48,16 @@

Source code for pyad2.zonetracking

 """
-Provides zone tracking functionality for the AD2USB device family.
+Provides zone tracking functionality for the AD2 device family.
 
 .. moduleauthor:: Scott Petersen <scott@nutech.com>
 """
 
 import re
 import time
+
 from .event import event
-from . import messages
+from .messages import ExpanderMessage
 
 
[docs]class Zone(object): """ @@ -126,10 +127,8 @@ :param message: Message to use to update the zone tracking. :type message: Message or ExpanderMessage """ - zone = -1 - - if isinstance(message, messages.ExpanderMessage): - if message.type == messages.ExpanderMessage.ZONE: + if isinstance(message, ExpanderMessage): + if message.type == ExpanderMessage.ZONE: zone = self._expander_to_zone(message.address, message.channel) status = Zone.CLEAR @@ -138,6 +137,9 @@ elif message.value == 2: status = Zone.CHECK + # NOTE: Expander zone faults are handled differently than regular messages. + # We don't include them in self._zones_faulted because they are not reported + # by the panel in it's rolling list of faults. try: self._update_zone(zone, status=status) @@ -317,10 +319,7 @@ :returns: Whether or not the zone is expired. """ - if time.time() > self._zones[zone].timestamp + Zonetracker.EXPIRE: - return True - - return False + return time.time() > self._zones[zone].timestamp + Zonetracker.EXPIRE def _expander_to_zone(self, address, channel): """ diff --git a/docs/_build/html/_sources/index.txt b/docs/_build/html/_sources/index.txt index 9b9e2c4..1acdb0d 100644 --- a/docs/_build/html/_sources/index.txt +++ b/docs/_build/html/_sources/index.txt @@ -1,4 +1,4 @@ -.. pyad2usb documentation master file, created by +.. pyad2 documentation master file, created by sphinx-quickstart on Sat Jun 8 14:38:46 2013. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. diff --git a/docs/_build/html/_sources/pyad2usb.event.txt b/docs/_build/html/_sources/pyad2usb.event.txt deleted file mode 100644 index 9f2c38b..0000000 --- a/docs/_build/html/_sources/pyad2usb.event.txt +++ /dev/null @@ -1,19 +0,0 @@ -event Package -============= - -:mod:`event` Package --------------------- - -.. automodule:: pyad2.event - :members: - :undoc-members: - :show-inheritance: - -:mod:`event` Module -------------------- - -.. automodule:: pyad2.event.event - :members: - :undoc-members: - :show-inheritance: - diff --git a/docs/_build/html/_sources/pyad2usb.txt b/docs/_build/html/_sources/pyad2usb.txt deleted file mode 100644 index f7848a5..0000000 --- a/docs/_build/html/_sources/pyad2usb.txt +++ /dev/null @@ -1,58 +0,0 @@ -pyad2usb Package -================ - -:mod:`ad2` Module --------------------- - -.. automodule:: pyad2.ad2 - :members: - :undoc-members: - :show-inheritance: - -:mod:`devices` Module ---------------------- - -.. automodule:: pyad2.devices - :members: - :undoc-members: - :show-inheritance: - -:mod:`util` Module ------------------- - -.. automodule:: pyad2.util - :members: - :undoc-members: - :show-inheritance: - -:mod:`zonetracking` Module --------------------------- - -.. automodule:: pyad2.zonetracking - :members: - :undoc-members: - :show-inheritance: - -:mod:`panels` Module --------------------- - -.. automodule:: pyad2.panels - :members: - :undoc-members: - :show-inheritance: - -:mod:`messages` Module ----------------------- - -.. automodule:: pyad2.messages - :members: - :undoc-members: - :show-inheritance: - -Subpackages ------------ - -.. toctree:: - - pyad2usb.event - diff --git a/docs/_build/html/genindex.html b/docs/_build/html/genindex.html index 2a19561..3ce87ef 100644 --- a/docs/_build/html/genindex.html +++ b/docs/_build/html/genindex.html @@ -77,9 +77,17 @@
AD2 (class in pyad2.ad2)
+ +
AD2Factory (class in pyad2.ad2) +
+
+
AD2Factory.DetectThread (class in pyad2.ad2) +
+ +
add() (pyad2.event.event.EventHandler method)
@@ -135,7 +143,7 @@
-
(pyad2.ad2.Overseer method) +
(pyad2.ad2.AD2Factory method)
@@ -160,7 +168,7 @@ -
create() (pyad2.ad2.Overseer class method) +
create() (pyad2.ad2.AD2Factory class method)
@@ -184,7 +192,7 @@ -
devices() (pyad2.ad2.Overseer class method) +
devices() (pyad2.ad2.AD2Factory class method)
@@ -244,7 +252,7 @@
-
find_all() (pyad2.ad2.Overseer class method) +
find_all() (pyad2.ad2.AD2Factory class method)
@@ -290,7 +298,7 @@
-
get_device() (pyad2.ad2.Overseer method) +
get_device() (pyad2.ad2.AD2Factory method)
@@ -378,7 +386,7 @@ -
on_attached (pyad2.ad2.Overseer attribute) +
on_attached (pyad2.ad2.AD2Factory attribute)
@@ -404,7 +412,7 @@ -
on_detached (pyad2.ad2.Overseer attribute) +
on_detached (pyad2.ad2.AD2Factory attribute)
@@ -427,12 +435,12 @@
on_lrr_message (pyad2.ad2.AD2 attribute)
+
+
on_message (pyad2.ad2.AD2 attribute)
-
-
on_open (pyad2.ad2.AD2 attribute)
@@ -509,14 +517,6 @@
- -
Overseer (class in pyad2.ad2) -
- - -
Overseer.DetectThread (class in pyad2.ad2) -
- @@ -614,7 +614,7 @@ -
run() (pyad2.ad2.Overseer.DetectThread method) +
run() (pyad2.ad2.AD2Factory.DetectThread method)
@@ -692,7 +692,7 @@ -
start() (pyad2.ad2.Overseer method) +
start() (pyad2.ad2.AD2Factory method)
@@ -700,12 +700,12 @@ -
stop() (pyad2.ad2.Overseer method) +
stop() (pyad2.ad2.AD2Factory method)
-
(pyad2.ad2.Overseer.DetectThread method) +
(pyad2.ad2.AD2Factory.DetectThread method)
diff --git a/docs/_build/html/objects.inv b/docs/_build/html/objects.inv index 2fa977e..993a0ca 100644 Binary files a/docs/_build/html/objects.inv and b/docs/_build/html/objects.inv differ diff --git a/docs/_build/html/pyad2.event.html b/docs/_build/html/pyad2.event.html index 887ce86..20eca0c 100644 --- a/docs/_build/html/pyad2.event.html +++ b/docs/_build/html/pyad2.event.html @@ -23,7 +23,9 @@ - + + + @@ -104,6 +110,9 @@ e.fire(earg).

+

Previous topic

+

pyad2 Package

This Page

- - -
-
-
-
-
-

Table Of Contents

- - -

This Page

- - - -
-
-
-
- - - - \ No newline at end of file diff --git a/docs/_build/html/searchindex.js b/docs/_build/html/searchindex.js index cb2d177..9ac06d8 100644 --- a/docs/_build/html/searchindex.js +++ b/docs/_build/html/searchindex.js @@ -1 +1 @@ -Search.setIndex({envversion:42,terms:{event:[],represent:3,all:[3,2],socketdevic:3,func:2,when:3,disarm:3,ssl_kei:3,basemessag:3,through:3,on_boot:3,stage_don:3,simulate_wire_problem:3,vari:3,paramet:3,current:3,baudrat:3,locat:3,zone:3,on_disarm:3,configur:3,fault_zon:3,send:3,should:3,on_attach:3,add:2,board:3,bypass:3,x03:3,on_read:3,x01:3,match:3,sent:3,x04:3,sourc:[3,2],"return":3,around:3,clear_zon:3,format:3,read:3,on_messag:3,stop:3,util:[],ssl:3,on_bypass:3,zonetrack:[],progress:3,report:3,detach:3,like:2,get_config:3,ad2:[],name:3,level:3,rfx:3,list:3,on_pan:3,authent:3,factori:3,"try":3,emul:3,stage_wait:3,timeout:3,contain:3,found:3,expandermessag:3,page:0,certif:3,set:3,nodeviceerror:3,on_open:3,creation:3,request:3,upload:3,"static":3,connect:3,fire_timeout:3,close:3,process:3,read_lin:3,arm:3,stop_read:3,pyseri:3,index:[0,3],statu:3,detect:3,power:3,defin:2,pattern:3,ad2seri:3,reboot:3,callback:3,content:0,pyftdi:3,written:3,earg:2,between:3,"new":2,method:3,localhost:3,ser2sock:3,shut:3,full:3,run:3,timeouterror:3,kei:3,detached_ev:3,gener:3,usbdevic:3,lrr:3,on_clos:3,base:[3,2],ssl_certif:3,on_config_receiv:3,serial:3,depend:3,"byte":3,on_detach:3,panel:[],search:[0,3],actual:3,expos:3,thread:3,fault:3,progress_callback:3,fixm:3,readthread:3,simul:3,stage_start:3,prior:3,rais:3,on_rfx_messag:3,fals:3,find_al:3,ad2usb:3,first:3,oper:2,revert:3,rang:3,via:3,attached_ev:3,modul:[],"float":3,number:3,automat:3,system:3,down:3,filenam:3,alreadi:3,messag:[],famili:3,path:3,batteri:3,on_writ:3,open:3,on_power_chang:3,identif:3,differ:3,"long":3,from:3,usb:3,commun:3,detectthread:3,support:3,devic:[],on_relay_chang:3,been:3,get_devic:3,trigger:3,call:[3,2],low:3,handl:3,interfac:3,stage_upload:3,type:3,start:3,"function":[3,2],wrapper:3,no_reader_thread:3,stage_load:3,fire:[3,2],handler:2,commerror:3,specifi:3,stage_boot:3,rfmessag:3,provid:3,radio:3,relai:3,x02:3,obj:2,line:3,on_fir:3,cach:3,serialdevic:3,must:2,high:3,none:[3,2],sender:2,retriev:3,describ:3,on_restor:3,restor:3,whether:3,remov:[3,2],purg:3,on_alarm:3,dev:3,charact:3,purge_buff:3,"while":3,can:[3,2],str:3,entri:3,alarm:3,aliv:3,creat:3,"int":3,well:3,save_config:3,reader:3,templat:3,repres:3,on_zone_restor:3,packag:[],on_fault:3,itself:2,exist:2,expir:3,ftdi_vendor_id:3,our:3,read_timeout:3,vendor:3,ftdi_product_id:3,attach:3,string:3,parent:3,present:3,serial_numb:3,author:3,check:3,anoth:3,belong:3,boot:3,"switch":3,invalid:3,port:3,write:3,also:2,client:3,bool:3,on_zone_fault:3,tupl:3,instead:2,you:2,probabl:3,panic:3,singl:3,updat:3,status:3,product:3,finish:3,recogn:3,firmwar:3,"default":3,buffer:3,expans:3,object:[3,2],ftdi:3,befor:3,wire:3,track:3,battery_timeout:3,on_arm:3,eventhandl:2,data:3,"class":[3,2],expand:3,subpackag:[],receiv:3,classmethod:3,doc:2,clear:3,descript:3,except:3,ssl_ca:3,issu:3,lrrmessag:3,which:3,is_reader_al:3,on_lrr_messag:3,error:3,clean:3,invalidmessageerror:3,overs:3,on_low_batteri:3},objtypes:{"0":"py:module","1":"py:attribute","2":"py:method","3":"py:class","4":"py:staticmethod","5":"py:classmethod","6":"py:exception"},objnames:{"0":["py","module","Python module"],"1":["py","attribute","Python attribute"],"2":["py","method","Python method"],"3":["py","class","Python class"],"4":["py","staticmethod","Python static method"],"5":["py","classmethod","Python class method"],"6":["py","exception","Python exception"]},filenames:["index","modules","pyad2.event","pyad2"],titles:["Welcome to pyad2’s documentation!","pyad2","event Package","pyad2 Package"],objects:{"pyad2.ad2.Overseer":{on_attached:[3,1,1,""],get_device:[3,2,1,""],DetectThread:[3,3,1,""],create:[3,5,1,""],stop:[3,2,1,""],devices:[3,5,1,""],on_detached:[3,1,1,""],start:[3,2,1,""],find_all:[3,5,1,""],close:[3,2,1,""]},"pyad2.messages":{Message:[3,3,1,""],BaseMessage:[3,3,1,""],RFMessage:[3,3,1,""],ExpanderMessage:[3,3,1,""],LRRMessage:[3,3,1,""]},"pyad2.devices.Device.ReadThread":{READ_TIMEOUT:[3,1,1,""],run:[3,2,1,""],stop:[3,2,1,""]},"pyad2.ad2.Overseer.DetectThread":{run:[3,2,1,""],stop:[3,2,1,""]},"pyad2.util":{CommError:[3,6,1,""],Firmware:[3,3,1,""],TimeoutError:[3,6,1,""],NoDeviceError:[3,6,1,""],InvalidMessageError:[3,6,1,""]},"pyad2.event":{event:[2,0,1,""]},"pyad2.devices.SerialDevice":{read_line:[3,2,1,""],BAUDRATE:[3,1,1,""],read:[3,2,1,""],write:[3,2,1,""],find_all:[3,4,1,""],"interface":[3,1,1,""],close:[3,2,1,""],open:[3,2,1,""]},"pyad2.messages.ExpanderMessage":{ZONE:[3,1,1,""],RELAY:[3,1,1,""]},pyad2:{ad2:[3,0,1,""],zonetracking:[3,0,1,""],messages:[3,0,1,""],devices:[3,0,1,""],util:[3,0,1,""],panels:[3,0,1,""],event:[2,0,1,""]},"pyad2.zonetracking.Zonetracker":{on_restore:[3,1,1,""],EXPIRE:[3,1,1,""],on_fault:[3,1,1,""],update:[3,2,1,""]},"pyad2.devices":{Device:[3,3,1,""],SocketDevice:[3,3,1,""],USBDevice:[3,3,1,""],SerialDevice:[3,3,1,""]},"pyad2.zonetracking.Zone":{STATUS:[3,1,1,""],FAULT:[3,1,1,""],CLEAR:[3,1,1,""],CHECK:[3,1,1,""]},"pyad2.ad2":{AD2:[3,3,1,""],Overseer:[3,3,1,""]},"pyad2.devices.SocketDevice":{ssl_key:[3,1,1,""],ssl_certificate:[3,1,1,""],read:[3,2,1,""],read_line:[3,2,1,""],ssl_ca:[3,1,1,""],write:[3,2,1,""],ssl:[3,1,1,""],"interface":[3,1,1,""],close:[3,2,1,""],open:[3,2,1,""]},"pyad2.devices.USBDevice":{read_line:[3,2,1,""],BAUDRATE:[3,1,1,""],description:[3,1,1,""],read:[3,2,1,""],write:[3,2,1,""],find_all:[3,4,1,""],FTDI_VENDOR_ID:[3,1,1,""],serial_number:[3,1,1,""],"interface":[3,1,1,""],close:[3,2,1,""],FTDI_PRODUCT_ID:[3,1,1,""],open:[3,2,1,""]},"pyad2.util.Firmware":{STAGE_LOAD:[3,1,1,""],upload:[3,4,1,""],STAGE_WAITING:[3,1,1,""],STAGE_START:[3,1,1,""],STAGE_UPLOADING:[3,1,1,""],STAGE_BOOT:[3,1,1,""],STAGE_DONE:[3,1,1,""]},"pyad2.ad2.AD2":{on_rfx_message:[3,1,1,""],fault_zone:[3,2,1,""],on_open:[3,1,1,""],save_config:[3,2,1,""],on_relay_changed:[3,1,1,""],on_boot:[3,1,1,""],close:[3,2,1,""],open:[3,2,1,""],id:[3,1,1,""],on_power_changed:[3,1,1,""],BATTERY_TIMEOUT:[3,1,1,""],on_message:[3,1,1,""],send:[3,2,1,""],reboot:[3,2,1,""],get_config:[3,2,1,""],on_zone_restore:[3,1,1,""],on_disarm:[3,1,1,""],on_fire:[3,1,1,""],on_write:[3,1,1,""],on_read:[3,1,1,""],on_lrr_message:[3,1,1,""],clear_zone:[3,2,1,""],on_zone_fault:[3,1,1,""],on_config_received:[3,1,1,""],on_close:[3,1,1,""],on_bypass:[3,1,1,""],on_low_battery:[3,1,1,""],on_arm:[3,1,1,""],F1:[3,1,1,""],F2:[3,1,1,""],F3:[3,1,1,""],F4:[3,1,1,""],on_alarm:[3,1,1,""],on_panic:[3,1,1,""],FIRE_TIMEOUT:[3,1,1,""]},"pyad2.zonetracking":{Zonetracker:[3,3,1,""],Zone:[3,3,1,""]},"pyad2.event.event.EventHandler":{fire:[2,2,1,""],add:[2,2,1,""],remove:[2,2,1,""]},"pyad2.event.event":{EventHandler:[2,3,1,""],Event:[2,3,1,""]},"pyad2.devices.Device":{on_read:[3,1,1,""],on_open:[3,1,1,""],ReadThread:[3,3,1,""],on_close:[3,1,1,""],on_write:[3,1,1,""],close:[3,2,1,""],stop_reader:[3,2,1,""],is_reader_alive:[3,2,1,""],id:[3,1,1,""]}},titleterms:{subpackag:3,ad2:3,welcom:0,pyad2:[0,1,3],pyad2usb:[],devic:3,messag:3,util:3,packag:[3,2],zonetrack:3,indic:0,tabl:0,modul:[3,2],document:0,event:2,panel:3}}) \ No newline at end of file +Search.setIndex({envversion:42,terms:{event:[0,1,3],represent:3,all:[3,2],socketdevic:3,func:2,when:3,sent:3,disarm:3,ssl_kei:3,through:3,on_boot:3,stage_don:3,simulate_wire_problem:3,vari:3,paramet:3,current:3,baudrat:3,locat:3,zone:3,on_disarm:3,configur:3,fault_zon:3,send:3,should:3,on_attach:3,add:2,board:3,bypass:3,x03:3,on_read:3,x01:3,match:3,x04:3,sourc:[3,2],"return":3,around:3,clear_zon:3,format:3,handl:3,on_messag:3,stop:3,util:[0,1],ssl:3,on_bypass:3,zonetrack:[0,1],progress:3,report:3,detach:3,like:2,serialdevic:3,ad2:[0,1],name:3,level:3,rfx:3,list:3,upload:3,authent:3,factori:3,"try":3,"default":3,expand:3,stage_wait:3,updat:3,timeout:3,contain:3,found:3,expandermessag:3,page:0,certif:3,set:3,nodeviceerror:3,on_open:3,creation:3,request:3,on_pan:3,finish:3,"static":3,connect:3,fire_timeout:3,close:3,process:3,read_lin:3,arm:3,stop_read:3,ad2factori:3,pyseri:3,index:[0,3],statu:3,wire:3,power:3,clean:3,emul:3,pattern:3,ad2seri:3,reboot:3,content:0,pyftdi:3,written:3,earg:2,between:3,"new":2,method:3,localhost:3,can:[3,2],ser2sock:3,shut:3,full:3,run:3,timeouterror:3,kei:3,detached_ev:3,gener:3,usbdevic:3,lrr:3,on_clos:3,base:[3,2],ssl_certif:3,on_config_receiv:3,depend:3,"byte":3,on_detach:3,panel:[0,1],search:[0,3],actual:3,expos:3,thread:3,fault:3,fixm:3,readthread:3,simul:3,stage_start:3,prior:3,get_config:3,on_rfx_messag:3,fals:3,find_al:3,ad2usb:3,first:3,oper:2,revert:3,rang:3,via:3,attached_ev:3,modul:[0,1],"float":3,number:3,automat:3,system:3,down:3,filenam:3,alreadi:3,"long":3,famili:3,path:3,batteri:3,on_writ:3,open:3,on_power_chang:3,identif:3,differ:3,from:3,usb:3,messag:[0,1],commun:3,detectthread:3,support:3,devic:[0,1],on_relay_chang:3,been:3,get_devic:3,trigger:3,call:[3,2],low:3,interfac:3,type:3,start:3,"function":[3,2],wrapper:3,no_reader_thread:3,classmethod:3,stage_load:3,fire:[3,2],handler:2,relat:3,specifi:3,stage_boot:3,rfmessag:3,provid:3,flag:3,radio:3,relai:3,x02:3,obj:2,line:3,on_fir:3,cach:3,present:3,must:2,high:3,none:[3,2],sender:2,retriev:3,describ:3,on_restor:3,restor:3,whether:3,remov:[3,2],purg:3,on_alarm:3,dev:3,charact:3,defin:2,"while":3,stage_upload:3,str:3,entri:3,vendor:3,alarm:3,aliv:3,creat:3,"int":3,well:3,save_config:3,reader:3,templat:3,repres:3,on_zone_restor:3,packag:[0,1],on_fault:3,itself:2,exist:2,expir:3,ftdi_vendor_id:3,our:3,read_timeout:3,on_zone_fault:3,ftdi_product_id:3,attach:3,string:3,parent:3,battery_timeout:3,serial_numb:3,author:3,receiv:3,anoth:3,belong:3,boot:3,invalid:3,port:3,write:3,also:2,client:3,bool:3,which:3,tupl:3,instead:2,you:2,probabl:3,panic:3,singl:3,purge_buff:3,status:3,product:3,commerror:3,recogn:3,firmwar:3,callback:3,buffer:3,expans:3,object:[3,2],ftdi:3,befor:3,detect:3,track:3,basemessag:3,on_arm:3,eventhandl:2,data:3,"class":[3,2],serial:3,subpackag:[0,1],read:3,doc:2,clear:3,descript:3,except:3,rais:3,ssl_ca:3,issu:3,lrrmessag:3,"switch":3,is_reader_al:3,on_lrr_messag:3,error:3,progress_callback:3,check:3,invalidmessageerror:3,on_low_batteri:3},objtypes:{"0":"py:module","1":"py:attribute","2":"py:method","3":"py:class","4":"py:staticmethod","5":"py:classmethod","6":"py:exception"},objnames:{"0":["py","module","Python module"],"1":["py","attribute","Python attribute"],"2":["py","method","Python method"],"3":["py","class","Python class"],"4":["py","staticmethod","Python static method"],"5":["py","classmethod","Python class method"],"6":["py","exception","Python exception"]},filenames:["index","modules","pyad2.event","pyad2"],titles:["Welcome to pyad2’s documentation!","pyad2","event Package","pyad2 Package"],objects:{"pyad2.messages":{Message:[3,3,1,""],BaseMessage:[3,3,1,""],RFMessage:[3,3,1,""],ExpanderMessage:[3,3,1,""],LRRMessage:[3,3,1,""]},"pyad2.devices.Device.ReadThread":{READ_TIMEOUT:[3,1,1,""],run:[3,2,1,""],stop:[3,2,1,""]},"pyad2.util":{CommError:[3,6,1,""],Firmware:[3,3,1,""],TimeoutError:[3,6,1,""],NoDeviceError:[3,6,1,""],InvalidMessageError:[3,6,1,""]},"pyad2.event":{event:[2,0,1,""]},"pyad2.ad2.AD2Factory":{on_attached:[3,1,1,""],get_device:[3,2,1,""],DetectThread:[3,3,1,""],create:[3,5,1,""],stop:[3,2,1,""],devices:[3,5,1,""],on_detached:[3,1,1,""],start:[3,2,1,""],find_all:[3,5,1,""],close:[3,2,1,""]},"pyad2.devices.SerialDevice":{write:[3,2,1,""],BAUDRATE:[3,1,1,""],read:[3,2,1,""],read_line:[3,2,1,""],find_all:[3,4,1,""],"interface":[3,1,1,""],close:[3,2,1,""],open:[3,2,1,""]},"pyad2.messages.ExpanderMessage":{ZONE:[3,1,1,""],RELAY:[3,1,1,""]},pyad2:{ad2:[3,0,1,""],zonetracking:[3,0,1,""],messages:[3,0,1,""],devices:[3,0,1,""],util:[3,0,1,""],panels:[3,0,1,""],event:[2,0,1,""]},"pyad2.ad2.AD2Factory.DetectThread":{stop:[3,2,1,""],run:[3,2,1,""]},"pyad2.zonetracking.Zonetracker":{on_restore:[3,1,1,""],EXPIRE:[3,1,1,""],on_fault:[3,1,1,""],update:[3,2,1,""]},"pyad2.devices":{Device:[3,3,1,""],SocketDevice:[3,3,1,""],USBDevice:[3,3,1,""],SerialDevice:[3,3,1,""]},"pyad2.zonetracking.Zone":{STATUS:[3,1,1,""],FAULT:[3,1,1,""],CLEAR:[3,1,1,""],CHECK:[3,1,1,""]},"pyad2.ad2":{AD2:[3,3,1,""],AD2Factory:[3,3,1,""]},"pyad2.devices.SocketDevice":{ssl_key:[3,1,1,""],ssl_certificate:[3,1,1,""],read:[3,2,1,""],read_line:[3,2,1,""],ssl_ca:[3,1,1,""],write:[3,2,1,""],ssl:[3,1,1,""],"interface":[3,1,1,""],close:[3,2,1,""],open:[3,2,1,""]},"pyad2.devices.USBDevice":{read_line:[3,2,1,""],BAUDRATE:[3,1,1,""],description:[3,1,1,""],read:[3,2,1,""],write:[3,2,1,""],find_all:[3,4,1,""],FTDI_VENDOR_ID:[3,1,1,""],serial_number:[3,1,1,""],"interface":[3,1,1,""],close:[3,2,1,""],FTDI_PRODUCT_ID:[3,1,1,""],open:[3,2,1,""]},"pyad2.util.Firmware":{STAGE_LOAD:[3,1,1,""],upload:[3,4,1,""],STAGE_WAITING:[3,1,1,""],STAGE_START:[3,1,1,""],STAGE_UPLOADING:[3,1,1,""],STAGE_BOOT:[3,1,1,""],STAGE_DONE:[3,1,1,""]},"pyad2.ad2.AD2":{on_rfx_message:[3,1,1,""],fault_zone:[3,2,1,""],on_open:[3,1,1,""],save_config:[3,2,1,""],on_relay_changed:[3,1,1,""],on_boot:[3,1,1,""],close:[3,2,1,""],open:[3,2,1,""],id:[3,1,1,""],on_power_changed:[3,1,1,""],BATTERY_TIMEOUT:[3,1,1,""],on_message:[3,1,1,""],send:[3,2,1,""],reboot:[3,2,1,""],get_config:[3,2,1,""],on_zone_restore:[3,1,1,""],on_disarm:[3,1,1,""],on_fire:[3,1,1,""],on_write:[3,1,1,""],on_read:[3,1,1,""],on_lrr_message:[3,1,1,""],clear_zone:[3,2,1,""],on_zone_fault:[3,1,1,""],on_config_received:[3,1,1,""],on_close:[3,1,1,""],on_bypass:[3,1,1,""],on_low_battery:[3,1,1,""],on_arm:[3,1,1,""],F1:[3,1,1,""],F2:[3,1,1,""],F3:[3,1,1,""],F4:[3,1,1,""],on_alarm:[3,1,1,""],on_panic:[3,1,1,""],FIRE_TIMEOUT:[3,1,1,""]},"pyad2.zonetracking":{Zonetracker:[3,3,1,""],Zone:[3,3,1,""]},"pyad2.event.event.EventHandler":{fire:[2,2,1,""],add:[2,2,1,""],remove:[2,2,1,""]},"pyad2.event.event":{EventHandler:[2,3,1,""],Event:[2,3,1,""]},"pyad2.devices.Device":{on_open:[3,1,1,""],on_write:[3,1,1,""],ReadThread:[3,3,1,""],on_close:[3,1,1,""],on_read:[3,1,1,""],close:[3,2,1,""],stop_reader:[3,2,1,""],is_reader_alive:[3,2,1,""],id:[3,1,1,""]}},titleterms:{subpackag:3,ad2:3,welcom:0,pyad2:[0,1,3],modul:[3,2],devic:3,messag:3,util:3,packag:[3,2],zonetrack:3,indic:0,tabl:0,document:0,event:2,panel:3}}) \ No newline at end of file diff --git a/docs/_build/text/index.txt b/docs/_build/text/index.txt deleted file mode 100644 index 198c575..0000000 --- a/docs/_build/text/index.txt +++ /dev/null @@ -1,37 +0,0 @@ - -Welcome to pyad2's documentation! -********************************* - -Contents: - -* pyad2 Package - - * "ad2" Module - - * "devices" Module - - * "util" Module - - * "zonetracking" Module - - * "panels" Module - - * "messages" Module - - * Subpackages - - * event Package - - * "event" Package - - * "event" Module - - -Indices and tables -****************** - -* *Index* - -* *Module Index* - -* *Search Page* diff --git a/docs/_build/text/modules.txt b/docs/_build/text/modules.txt deleted file mode 100644 index a3fc864..0000000 --- a/docs/_build/text/modules.txt +++ /dev/null @@ -1,25 +0,0 @@ - -pyad2 -***** - -* pyad2 Package - - * "ad2" Module - - * "devices" Module - - * "util" Module - - * "zonetracking" Module - - * "panels" Module - - * "messages" Module - - * Subpackages - - * event Package - - * "event" Package - - * "event" Module diff --git a/docs/_build/text/pyad2.event.txt b/docs/_build/text/pyad2.event.txt deleted file mode 100644 index e0ad292..0000000 --- a/docs/_build/text/pyad2.event.txt +++ /dev/null @@ -1,39 +0,0 @@ - -event Package -************* - - -"event" Package -=============== - - -"event" Module -============== - -class class pyad2.event.event.Event(doc=None) - - Bases: "object" - -class class pyad2.event.event.EventHandler(event, obj) - - Bases: "object" - - add(func) - - Add new event handler function. - - Event handler function must be defined like func(sender, earg). - You can add handler also by using '+=' operator. - - remove(func) - - Remove existing event handler function. - - You can remove handler also by using '-=' operator. - - fire(earg=None) - - Fire event and call all handler functions - - You can call EventHandler object itself like e(earg) instead of - e.fire(earg). diff --git a/docs/_build/text/pyad2.txt b/docs/_build/text/pyad2.txt deleted file mode 100644 index 1ee7633..0000000 --- a/docs/_build/text/pyad2.txt +++ /dev/null @@ -1,784 +0,0 @@ - -pyad2 Package -************* - - -"ad2" Module -============ - -Provides the full AD2USB class and factory. - -class class pyad2.ad2.Overseer(attached_event=None, detached_event=None) - - Bases: "object" - - Factory for creation of AD2USB devices as well as provides - attach/detach events." - - on_attached - - Called when an AD2USB device has been detected. - - on_detached - - Called when an AD2USB device has been removed. - - classmethod find_all() - - Returns all AD2USB devices located on the system. - - Returns: - list of devices found - - Raises : - util.CommError - - classmethod devices() - - Returns a cached list of AD2USB devices located on the system. - - Returns: - cached list of devices found. - - classmethod create(device=None) - - Factory method that returns the requested AD2USB device, or the - first device. - - Parameters: - **device** (*tuple*) -- Tuple describing the USB device to - open, as returned by find_all(). - - Returns: - AD2USB object utilizing the specified device. - - Raises : - util.NoDeviceError - - close() - - Clean up and shut down. - - start() - - Starts the detection thread, if not already running. - - stop() - - Stops the detection thread. - - get_device(device=None) - - Factory method that returns the requested AD2USB device, or the - first device. - - Parameters: - **device** (*tuple*) -- Tuple describing the USB device to - open, as returned by find_all(). - - class class DetectThread(overseer) - - Bases: "threading.Thread" - - Thread that handles detection of added/removed devices. - - stop() - - Stops the thread. - - run() - - The actual detection process. - -class class pyad2.ad2.AD2(device) - - Bases: "object" - - High-level wrapper around AD2USB/AD2SERIAL devices. - - on_arm - - Called when the panel is armed. - - on_disarm - - Called when the panel is disarmed. - - on_power_changed - - Called when panel power switches between AC and DC. - - on_alarm - - Called when the alarm is triggered. - - on_fire - - Called when a fire is detected. - - on_bypass - - Called when a zone is bypassed. - - on_boot - - Called when the device finishes bootings. - - on_config_received - - Called when the device receives its configuration. - - on_zone_fault - - Called when the device detects a zone fault. - - on_zone_restore - - Called when the device detects that a fault is restored. - - on_low_battery - - Called when the device detects a low battery. - - on_panic - - Called when the device detects a panic. - - on_relay_changed - - Called when a relay is opened or closed on an expander board. - - on_message - - Called when a message has been received from the device. - - on_lrr_message - - Called when an LRR message is received. - - on_rfx_message - - Called when an RFX message is received. - - on_open - - Called when the device has been opened. - - on_close - - Called when the device has been closed. - - on_read - - Called when a line has been read from the device. - - on_write - - Called when data has been written to the device. - - F1 = u'\x01\x01\x01' - - Represents panel function key #1 - - F2 = u'\x02\x02\x02' - - Represents panel function key #2 - - F3 = u'\x03\x03\x03' - - Represents panel function key #3 - - F4 = u'\x04\x04\x04' - - Represents panel function key #4 - - BATTERY_TIMEOUT = 30 - - Timeout before the battery status reverts. - - FIRE_TIMEOUT = 30 - - Timeout before the fire status reverts. - - id - - The ID of the AD2USB device. - - Returns: - The identification string for the device. - - open(baudrate=None, no_reader_thread=False) - - Opens the device. - - Parameters: - * **baudrate** (*int*) -- The baudrate used for the device. - - * **interface** (*varies depends on device type.. FIXME*) - -- The interface used for the device. - - * **index** (*int*) -- Interface index.. can probably - remove. FIXME - - * **no_reader_thread** (*bool*) -- Specifies whether or not - the automatic reader thread should be started or not - - close() - - Closes the device. - - send(data) - - get_config() - - Retrieves the configuration from the device. - - save_config() - - Sets configuration entries on the device. - - reboot() - - Reboots the device. - - fault_zone(zone, simulate_wire_problem=False) - - Faults a zone if we are emulating a zone expander. - - Parameters: - * **zone** (*int*) -- The zone to fault. - - * **simulate_wire_problem** (*bool*) -- Whether or not to - simulate a wire fault. - - clear_zone(zone) - - Clears a zone if we are emulating a zone expander. - - Parameters: - **zone** (*int*) -- The zone to clear. - - -"devices" Module -================ - -Contains different types of devices belonging to the AD2USB family. - -class class pyad2.devices.Device - - Bases: "object" - - Generic parent device to all AD2USB products. - - on_open - - Called when the device has been opened - - on_close - - Called when the device has been closed - - on_read - - Called when a line has been read from the device - - on_write - - Called when data has been written to the device - - id - - Retrieve the device ID. - - Returns: - The identification string for the device. - - is_reader_alive() - - Indicates whether or not the reader thread is alive. - - Returns: - Whether or not the reader thread is alive. - - stop_reader() - - Stops the reader thread. - - close() - - Closes the device. - - class class ReadThread(device) - - Bases: "threading.Thread" - - Reader thread which processes messages from the device. - - READ_TIMEOUT = 10 - - Timeout for the reader thread. - - stop() - - Stops the running thread. - - run() - - The actual read process. - -class class pyad2.devices.USBDevice(interface=(None, 0)) - - Bases: "pyad2.devices.Device" - - AD2USB device exposed with PyFTDI's interface. - - FTDI_VENDOR_ID = 1027 - - Vendor ID used to recognize AD2USB devices. - - FTDI_PRODUCT_ID = 24577 - - Product ID used to recognize AD2USB devices. - - BAUDRATE = 115200 - - Default baudrate for AD2USB devices. - - static find_all() - - Returns all FTDI devices matching our vendor and product IDs. - - Returns: - list of devices - - Raises : - util.CommError - - interface - - Retrieves the interface used to connect to the device. - - Returns: - the interface used to connect to the device. - - serial_number - - Retrieves the serial number of the device. - - Returns: - The serial number of the device. - - description - - Retrieves the description of the device. - - Returns: - The description of the device. - - open(baudrate=115200, no_reader_thread=False) - - Opens the device. - - Parameters: - * **baudrate** (*int*) -- The baudrate to use. - - * **no_reader_thread** (*bool*) -- Whether or not to - automatically start the reader thread. - - Raises : - util.NoDeviceError - - close() - - Closes the device. - - write(data) - - Writes data to the device. - - Parameters: - **data** (*str*) -- Data to write - - Raises : - util.CommError - - read() - - Reads a single character from the device. - - Returns: - The character read from the device. - - Raises : - util.CommError - - read_line(timeout=0.0, purge_buffer=False) - - Reads a line from the device. - - Parameters: - * **timeout** (*float*) -- Read timeout - - * **purge_buffer** (*bool*) -- Indicates whether to purge - the buffer prior to reading. - - Returns: - The line that was read. - - Raises : - util.CommError, util.TimeoutError - -class class pyad2.devices.SerialDevice(interface=None) - - Bases: "pyad2.devices.Device" - - AD2USB or AD2SERIAL device exposed with the pyserial interface. - - BAUDRATE = 19200 - - Default baudrate for Serial devices. - - static find_all(pattern=None) - - Returns all serial ports present. - - Parameters: - **pattern** (*str*) -- Pattern to search for when retrieving - serial ports. - - Returns: - list of devices - - Raises : - util.CommError - - interface - - Retrieves the interface used to connect to the device. - - Returns: - the interface used to connect to the device. - - open(baudrate=19200, no_reader_thread=False) - - Opens the device. - - Parameters: - * **baudrate** (*int*) -- The baudrate to use with the - device. - - * **no_reader_thread** (*bool*) -- Whether or not to - automatically start the reader thread. - - Raises : - util.NoDeviceError - - close() - - Closes the device. - - write(data) - - Writes data to the device. - - Parameters: - **data** (*str*) -- The data to write. - - Raises : - util.CommError - - read() - - Reads a single character from the device. - - Returns: - The character read from the device. - - Raises : - util.CommError - - read_line(timeout=0.0, purge_buffer=False) - - Reads a line from the device. - - Parameters: - * **timeout** (*float*) -- The read timeout. - - * **purge_buffer** (*bool*) -- Indicates whether to purge - the buffer prior to reading. - - Returns: - The line read. - - Raises : - util.CommError, util.TimeoutError - -class class pyad2.devices.SocketDevice(interface=('localhost', 10000)) - - Bases: "pyad2.devices.Device" - - Device that supports communication with an AD2USB that is exposed - via ser2sock or another Serial to IP interface. - - interface - - Retrieves the interface used to connect to the device. - - Returns: - the interface used to connect to the device. - - ssl - - Retrieves whether or not the device is using SSL. - - Returns: - Whether or not the device is using SSL. - - ssl_certificate - - Retrieves the SSL client certificate path used for - authentication. - - Returns: - The certificate path - - ssl_key - - Retrieves the SSL client certificate key used for - authentication. - - Returns: - The key path - - ssl_ca - - Retrieves the SSL Certificate Authority certificate used for - authentication. - - Returns: - The CA path - - open(baudrate=None, no_reader_thread=False) - - Opens the device. - - Parameters: - * **baudrate** (*int*) -- The baudrate to use - - * **no_reader_thread** (*bool*) -- Whether or not to - automatically open the reader thread. - - Raises : - util.NoDeviceError, util.CommError - - close() - - Closes the device. - - write(data) - - Writes data to the device. - - Parameters: - **data** (*str*) -- The data to write. - - Returns: - The number of bytes sent. - - Raises : - util.CommError - - read() - - Reads a single character from the device. - - Returns: - The character read from the device. - - Raises : - util.CommError - - read_line(timeout=0.0, purge_buffer=False) - - Reads a line from the device. - - Parameters: - * **timeout** (*float*) -- The read timeout. - - * **purge_buffer** (*bool*) -- Indicates whether to purge - the buffer prior to reading. - - Returns: - The line read from the device. - - Raises : - util.CommError, util.TimeoutError - - -"util" Module -============= - -Provides utility classes for the AD2USB devices. - -exception exception pyad2.util.NoDeviceError - - Bases: "exceptions.Exception" - - No devices found. - -exception exception pyad2.util.CommError - - Bases: "exceptions.Exception" - - There was an error communicating with the device. - -exception exception pyad2.util.TimeoutError - - Bases: "exceptions.Exception" - - There was a timeout while trying to communicate with the device. - -exception exception pyad2.util.InvalidMessageError - - Bases: "exceptions.Exception" - - The format of the panel message was invalid. - -class class pyad2.util.Firmware - - Bases: "object" - - Represents firmware for the AD2USB/AD2SERIAL devices. - - STAGE_START = 0 - - STAGE_WAITING = 1 - - STAGE_BOOT = 2 - - STAGE_LOAD = 3 - - STAGE_UPLOADING = 4 - - STAGE_DONE = 5 - - static upload(dev, filename, progress_callback=None) - - Uploads firmware to an AD2USB/AD2SERIAL device. - - Parameters: - * **filename** (*str*) -- The firmware filename - - * **progress_callback** (*function*) -- Callback function - used to report progress. - - Raises : - util.NoDeviceError, util.TimeoutError - - -"zonetracking" Module -===================== - -Provides zone tracking functionality for the AD2USB device family. - -class class pyad2.zonetracking.Zone(zone=0, name='', status=0) - - Bases: "object" - - Representation of a panel zone. - - CLEAR = 0 - - Status indicating that the zone is cleared. - - FAULT = 1 - - Status indicating that the zone is faulted. - - CHECK = 2 - - Status indicating that there is a wiring issue with the zone. - - STATUS = {0: 'CLEAR', 1: 'FAULT', 2: 'CHECK'} - -class class pyad2.zonetracking.Zonetracker - - Bases: "object" - - Handles tracking of zone and their statuses. - - on_fault - - Called when the device detects a zone fault. - - on_restore - - Called when the device detects that a fault is restored. - - EXPIRE = 30 - - Zone expiration timeout. - - update(message) - - Update zone statuses based on the current message. - - Parameters: - **message** (*Message or ExpanderMessage*) -- Message to use - to update the zone tracking. - - -"panels" Module -=============== - -Representations of Panels and their templates. - - -"messages" Module -================= - -Message representations received from the panel through the AD2USB. - -class class pyad2.messages.BaseMessage - - Bases: "object" - - Base class for messages. - -class class pyad2.messages.Message(data=None) - - Bases: "pyad2.messages.BaseMessage" - - Represents a message from the alarm panel. - -class class pyad2.messages.ExpanderMessage(data=None) - - Bases: "pyad2.messages.BaseMessage" - - Represents a message from a zone or relay expansion module. - - ZONE = 0 - - RELAY = 1 - -class class pyad2.messages.RFMessage(data=None) - - Bases: "pyad2.messages.BaseMessage" - - Represents a message from an RF receiver. - -class class pyad2.messages.LRRMessage(data=None) - - Bases: "pyad2.messages.BaseMessage" - - Represent a message from a Long Range Radio. - - -Subpackages -=========== - -* event Package - - * "event" Package - - * "event" Module diff --git a/pyad2/zonetracking.py b/pyad2/zonetracking.py index a7d6be9..024734f 100644 --- a/pyad2/zonetracking.py +++ b/pyad2/zonetracking.py @@ -1,5 +1,5 @@ """ -Provides zone tracking functionality for the AD2USB device family. +Provides zone tracking functionality for the AD2 device family. .. moduleauthor:: Scott Petersen """ diff --git a/setup.py b/setup.py index 925fb21..a186b4e 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ setup(name='pyad2', 'Topic :: Home Automation', 'Topic :: Security', ], - keywords='alarm data ad2usb ad2serial ad2pi security ademco dsc', + keywords='alarm data ad2 ad2usb ad2serial ad2pi security ademco dsc', url='http://github.com/nutechsoftware/pyad2', author='Nu Tech Software Solutions, Inc.', author_email='general@support.nutech.com',