|
-
- 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
|