About | Log | Files | Refs
commit f36b02ce4917bddb46fe4737409ad379310fe81e
parent 170b300f10133314cad0f34ba1087327df96a6c2
Author: Ben Connors <benconnors@outlook.com>
Date: Fri, 22 Feb 2019 13:19:53 -0500
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
Diffstat:
4 files changed, 14 insertions(+), 8 deletions(-)
diff --git 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
@@ -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
@@ -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
@@ -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")