diff options
author | Ben Connors <benconnors@outlook.com> | 2019-02-22 13:19:53 -0500 |
---|---|---|
committer | Ben Connors <benconnors@outlook.com> | 2019-02-22 13:36:16 -0500 |
commit | f36b02ce4917bddb46fe4737409ad379310fe81e (patch) | |
tree | 15ec6ec109f9cb23532e10b6f8e96ee7da03063b | |
parent | 170b300f10133314cad0f34ba1087327df96a6c2 (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.py | 11 | ||||
-rw-r--r-- | blc/output.py | 6 | ||||
-rwxr-xr-x | blc/tk.py | 2 | ||||
-rwxr-xr-x | blc/workspace.py | 3 |
4 files changed, 14 insertions, 8 deletions
@@ -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 @@ -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") |