Skip to content

Commit

Permalink
Move dali.device.Device class to dali.bus, device module conflicted w…
Browse files Browse the repository at this point in the history
…ith device package.
  • Loading branch information
rnixx committed May 11, 2017
1 parent 28769c7 commit d83f956
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 35 deletions.
25 changes: 20 additions & 5 deletions README.rst
Expand Up @@ -35,38 +35,53 @@ Library structure
- ``dali``

- ``address`` - Device addressing
- ``bus`` - DALI bus object

- ``bus`` - DALI bus and attached devices

- ``command`` - Command registry, interface to command decoding

- ``compat`` - Compatibility code for Python 2 and 3
- ``device`` - Control devices and events from them

- ``device`` - DALI control devices as defined in IEC 62386

- ``general`` - Commands and events from part 103

- ``driver`` - Objects to communicate with physical DALI gateways or services

- ``base`` - General driver contracts

- ``hasseb`` - Driver for Hasseb DALI Master (needs to be adopted to dali.driver.base API)

- ``tridonic`` - Driver for Tridonic DALI USB

- ``daliserver`` - Driver for https://github.com/onitake/daliserver (needs to be adopted to dali.driver.base API)

- ``exceptions`` - DALI related exceptions

- ``frame`` - Forward and backward frames
- ``gear`` - Control gear

- ``gear`` - DALI control gear as defined in IEC 62386

- ``emergency`` - Commands from part 202

- ``general`` - Commands from part 102

- ``incandescent`` - Commands from part 205
- ``fluorescent`` - Commands from part 201 (not yet implemented)

- ``led`` - Commands from part 207


Contributors
------------

- Stephen Early (Autor)
- Stephen Early (Author)

- Robert Niederreiter

- Diogo Gomes

- Caiwan

- Boldie


Expand Down
24 changes: 21 additions & 3 deletions dali/bus.py
@@ -1,6 +1,7 @@
from __future__ import division
from __future__ import unicode_literals
from dali import address
from dali import device
from dali.address import Short
from dali.exceptions import BadDevice
from dali.exceptions import DeviceAlreadyBound
from dali.exceptions import DuplicateDevice
Expand All @@ -12,6 +13,23 @@
import time


class Device(object):
"""Any DALI slave device that has been configured with a short address."""

def __init__(self, address, name=None, bus=None):
if not isinstance(address, int) or address < 0 or address > 63:
raise ValueError("address must be an integer in the range 0..63")
self.address = address
self._addressobj = Short(address)
self.bus = None
if bus:
self.bind(bus)

def bind(self, bus):
"""Bind this device object to a particular DALI bus."""
bus.add_device(self)


class Bus(object):
"""A DALI bus."""

Expand Down Expand Up @@ -55,7 +73,7 @@ def scan(self):
response = i.send(
gear.QueryControlGearPresent(address.Short(sa)))
if response.value:
device.Device(address=sa, bus=self)
Device(address=sa, bus=self)
self._bus_scanned = True

def set_search_addr(self, addr):
Expand Down Expand Up @@ -114,7 +132,7 @@ def assign_short_addresses(self):
if r.value is not True:
raise ProgramShortAddressFailure(new_addr)
i.send(gear.Withdraw())
device.Device(address=new_addr, bus=self)
Device(address=new_addr, bus=self)
else:
i.send(gear.Terminate())
raise NoFreeAddress()
Expand Down
4 changes: 2 additions & 2 deletions dali/command.py
Expand Up @@ -232,7 +232,7 @@ def response(self):
def _check_destination(destination):
"""Check that a valid destination has been specified.
destination can be a dali.device.Device object with
destination can be a dali.bus.Device object with
_addressobj attribute, a dali.address.Address object with
add_to_frame method, or an integer which will be wrapped in a
dali.address.Address object.
Expand All @@ -243,7 +243,7 @@ def _check_destination(destination):
destination = address.Short(destination)
if hasattr(destination, "add_to_frame"):
return destination
raise ValueError("destination must be an integer, dali.device.Device "
raise ValueError("destination must be an integer, dali.bus.Device "
"object or dali.address.Address object")

def __str__(self):
Expand Down
25 changes: 0 additions & 25 deletions dali/device.py

This file was deleted.

0 comments on commit d83f956

Please sign in to comment.