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 @@
"""
-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 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 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 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 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 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 @@
@@ -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 @@
@@ -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_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
+
This Page