summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Connors <benconnors@outlook.com>2019-02-22 13:19:53 -0500
committerBen Connors <benconnors@outlook.com>2019-02-22 13:36:16 -0500
commitf36b02ce4917bddb46fe4737409ad379310fe81e (patch)
tree15ec6ec109f9cb23532e10b6f8e96ee7da03063b
parent170b300f10133314cad0f34ba1087327df96a6c2 (diff)
Change Output specification
- Allow for channel to be passed as an instance of Workspace.channel or as a 2-tuple (universe, address) - Implement iter on workspace.Channel to allow for this
-rw-r--r--blc/ola.py11
-rw-r--r--blc/output.py6
-rwxr-xr-xblc/tk.py2
-rwxr-xr-xblc/workspace.py3
4 files changed, 14 insertions, 8 deletions
diff --git a/blc/ola.py b/blc/ola.py
index 68a294c..c6e2da9 100644
--- a/blc/ola.py
+++ b/blc/ola.py
@@ -17,15 +17,16 @@ class OLAOutput(LightingOutput):
def set_values(self, values):
send = set()
for c, v in values:
- if c.universe.id in self.universe_map:
- au = self.universe_map[c.universe.id]
+ univ, addr = c
+ if univ in self.universe_map:
+ au = self.universe_map[univ]
else:
- au = c.universe.id
+ au = univ
if au not in self.universes:
self.universes[au] = array.array('B', (0 for i in range(512)))
uni = self.universes[au]
- if uni[c.address] != v:
- uni[c.address] = v
+ if uni[addr] != v:
+ uni[addr] = v
send.add(au)
for au in send:
self.client.SendDmx(au, self.universes[au])
diff --git a/blc/output.py b/blc/output.py
index e56c8ab..147ea6b 100644
--- a/blc/output.py
+++ b/blc/output.py
@@ -20,8 +20,10 @@ class LightingOutput(ABC):
(channel, value), ...
- channel entries may not be repeated and each channel will be an instance of
- workspace.Channel. value must be between 0 and 255, inclusive.
+ channel entries may not be repeated. Each channel must be either an instance of
+ Workspace.channel or a 2-tuple of integers (dmx universe, dmx channel). value must be
+ between 0 and 255, inclusive.
+ inclusive.
"""
return
diff --git a/blc/tk.py b/blc/tk.py
index efb0459..c8af473 100755
--- a/blc/tk.py
+++ b/blc/tk.py
@@ -35,4 +35,4 @@ class DMXView(Frame):
class TkOutput(LightingOutput, DMXView):
def set_values(self, values):
- self.update_values(((c.address, v) for c,v in values))
+ self.update_values((((*c,)[1], v) for c,v in values))
diff --git a/blc/workspace.py b/blc/workspace.py
index 7a1e073..495da72 100755
--- a/blc/workspace.py
+++ b/blc/workspace.py
@@ -172,6 +172,9 @@ class Channel:
def __repr__(self):
return "Channel(address=%d)" % (self.address)
+ def __iter__(self):
+ return iter((self.universe.id, self.address,))
+
def __init__(self, fixture, offset):
if offset >= fixture.channel_count or offset < 0:
raise ValueError("Invalid offset")