Changeset - aebe823b2414
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 6 years ago 2019-06-08 07:37:43
drewp@bigasterisk.com
typo on stats. and on udmx outputs, show the bus number in the scales tree
Ignore-this: ef1e89a995c01e4508bfcefcf5190db6
1 file changed with 3 insertions and 2 deletions:
0 comments (0 inline, 0 general)
light9/collector/output.py
Show inline comments
 
@@ -121,55 +121,56 @@ class FtdiDmx(BackgroundLoopOutput):
 
            # to 0? No it is not. DMX receivers don't add implicit
 
            # zeros there.
 
            buf = bytes([0]) + buf[:self.lastDmxChannel]
 

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

	
 
            self.dmx.send_dmx(buf)
 

	
 

	
 
class Udmx(BackgroundLoopOutput):
 
    _reconnections = scales.IntStat('reconnections')
 
    _connected = scales.IntStat('connected')
 

	
 
    def __init__(self, uri, bus, address, lastDmxChannel, rate=22):
 
        self.bus = bus
 
        self.address = address
 
        self.lastDmxChannel = lastDmxChannel
 
        self.dev = None
 
        super().__init__(uri, rate=rate)
 

	
 
        self.errStats = scales.collection(self.statPath + '/write',
 
        self._errStats = scales.collection(self.statPath + '/write',
 
                                          scales.IntStat('overflow'),
 
                                          scales.IntStat('ioError'),
 
                                          scales.IntStat('pipeError')
 
        )
 
        self.reconnect()
 

	
 
    def shortId(self) -> str:
 
        return super().shortId() + f'_bus={self.bus}'
 
    def reconnect(self):
 
        self._connected = 0
 
        from pyudmx import pyudmx
 
        self.dev = pyudmx.uDMXDevice()
 
        if not self.dev.open(bus=self.bus, address=self.address):
 
            raise ValueError("dmx open failed")
 
        log.info(f'opened {self.dev}')
 
        self._connected = 1
 
        self._reconnections += 1
 

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

	
 
    #def _loop(self):
 
    #    pass
 
    def _write(self, buf):
 
        if not self.dev:
 
            log.info('%s: trying to connect', self.shortId())
 
            raise ValueError()
 
        self._writeStats.fps.mark()
 
        with self._writeStats.call.time():
 
            try:
 
                if not buf:
 
                    logAllDmx.debug('%s: empty buf- no output',
0 comments (0 inline, 0 general)