Changeset - 070c6d185276
[Not reviewed]
default
0 3 0
Drew Perttula - 6 years ago 2019-06-01 20:06:19
drewp@bigasterisk.com
collector takes an explicit dmx message length (again). more collector timing
Ignore-this: 6db3f113ad4b209e114c1473543a5341
3 files changed with 18 insertions and 6 deletions:
0 comments (0 inline, 0 general)
bin/collector
Show inline comments
 
@@ -60,7 +60,7 @@ def launch(graph, doLoadTest=False):
 
    try:
 
        # todo: drive outputs with config files
 
        outputs = [
 
            Udmx(L9['output/dmxA/'], bus=None, address=None),
 
            Udmx(L9['output/dmxA/'], bus=None, address=None, lastDmxChannel=221),
 
            DummyOutput(L9['output/dmxB/']),
 
        ]
 
    except Exception:
light9/collector/device.py
Show inline comments
 
@@ -61,7 +61,7 @@ def resolve(
 
    # incomplete. how-to-resolve should be on the DeviceAttr defs in the graph.
 
    if deviceAttr in map(
 
            DeviceAttr,
 
        [L9['rx'], L9['ry'], L9['zoom'], L9['focus'], L9['iris']]):
 
            [L9['rx'], L9['ry'], L9['zoom'], L9['focus'], L9['iris']]):
 
        floatVals = []
 
        for v in values:
 
            if isinstance(v, Literal):
light9/collector/output.py
Show inline comments
 
@@ -46,7 +46,7 @@ class Output(object):
 
    _writeSucceed = scales.IntStat('write/succeed')
 
    _writeFail = scales.IntStat('write/fail')
 
    _writeCall = scales.PmfStat('write/call')
 

	
 
    _writeFps = scales.RecentFpsStat('write/fps')
 
    def _write(self, buf: bytes) -> None:
 
        """
 
        write buffer to output hardware (may be throttled if updates are
 
@@ -64,7 +64,7 @@ class DummyOutput(Output):
 
class BackgroundLoopOutput(Output):
 
    """Call _write forever at 20hz in background threads"""
 

	
 
    rate = 20  # Hz
 
    rate = 30  # Hz
 

	
 
    def __init__(self, uri):
 
        super().__init__(uri)
 
@@ -91,7 +91,8 @@ class BackgroundLoopOutput(Output):
 

	
 
class Udmx(BackgroundLoopOutput):
 

	
 
    def __init__(self, uri, bus, address):
 
    def __init__(self, uri, bus, address, lastDmxChannel):
 
        self.lastDmxChannel = lastDmxChannel
 
        from pyudmx import pyudmx
 
        self.dev = pyudmx.uDMXDevice()
 
        if not self.dev.open(bus=bus, address=address):
 
@@ -101,17 +102,28 @@ class Udmx(BackgroundLoopOutput):
 

	
 
    _writeOverflow = scales.IntStat('write/overflow')
 

	
 
    #def update(self, buf:bytes):
 
    #    self._write(buf)
 

	
 
    #def _loop(self):
 
    #    pass
 
    def _write(self, buf):
 
        self._writeFps.mark()
 
        with self._writeCall.time():
 
            try:
 
                if not buf:
 
                    return
 

	
 
                # ok to truncate the last channels if they just went
 
                # to 0? No it is not. DMX receivers don't add implicit
 
                # zeros there.
 
                buf = buf[:self.lastDmxChannel]
 

	
 
                if logAllDmx.isEnabledFor(logging.DEBUG):
 
                    # for testing fps, smooth fades, etc
 
                    logAllDmx.debug(
 
                        '%s: %s' %
 
                        (self.shortId(), ' '.join(map(str, buf[:20]))))
 
                        (self.shortId(), ' '.join(map(str, buf[:16]))))
 

	
 
                sent = self.dev.send_multi_value(1, buf)
 
                if sent != len(buf):
0 comments (0 inline, 0 general)