Changeset - 05a5226a8d61
[Not reviewed]
default
0 4 0
drewp@bigasterisk.com - 9 years ago 2016-06-11 04:31:11
drewp@bigasterisk.com
logging and tweaks to collector
Ignore-this: d2083701fb026e834e6bd947d371584f
4 files changed with 11 insertions and 7 deletions:
0 comments (0 inline, 0 general)
bin/collector
Show inline comments
 
@@ -61,8 +61,10 @@ def startZmq(port, collector):
 
def launch(graph):
 

	
 
    # todo: drive outputs with config files
 
    outputs = [EnttecDmx(L9['output/dmx0/'], '/dev/dmx0'),
 
               Udmx(L9['output/udmx/'])]
 
    outputs = [
 
        EnttecDmx(L9['output/dmx0/'], '/dev/dmx0'),
 
        Udmx(L9['output/udmx/']),
 
    ]
 
    c = Collector(graph, outputs)
 

	
 
    server = WebServer(c)
light9/collector/collector.py
Show inline comments
 
@@ -109,7 +109,9 @@ class Collector(object):
 
            for outputAttr, value in attrs.iteritems():
 
                self.setAttr(device, outputAttr, value, pendingOut)
 

	
 
        print "%.1fms for client math" % (1000 * (time.time() - now))
 
        self.flush(pendingOut)
 
        print "%.1fms including flush" % (1000 * (time.time() - now))
 

	
 
    def setAttr(self, device, outputAttr, value, pendingOut):
 
        output, index = self.outputMap[(device, outputAttr)]
light9/collector/device.py
Show inline comments
 
@@ -9,6 +9,7 @@ import colormath.color_conversions
 

	
 
log = logging.getLogger('device')
 

	
 

	
 
class Device(object):
 
    def setAttrs():
 
        pass
light9/collector/output.py
Show inline comments
 
@@ -68,7 +68,7 @@ class EnttecDmx(DmxOutput):
 
        self.dev = Dmx(devicePath)
 
        self.currentBuffer = ''
 
        self.lastLog = 0
 
        task.LoopingCall(self._loop).start(1 / 50)
 
        task.LoopingCall(self._loop).start(0.050)
 

	
 
    @stats.update.time()
 
    def update(self, values):
 
@@ -105,7 +105,7 @@ class Udmx(DmxOutput):
 
        #   2. Retries if there are usb errors.
 
        # Copying the LoopingCall logic accomplishes those with a
 
        # little wasted time if there are no updates.
 
        task.LoopingCall(self._loop).start(1 / 50)
 
        task.LoopingCall(self._loop).start(0.050)
 

	
 
    @stats.update.time()
 
    def update(self, values):
 
@@ -117,14 +117,13 @@ class Udmx(DmxOutput):
 
        self.currentBuffer = ''.join(map(chr, values))
 
    
 
    def _loop(self):
 
        if self.lastSentBuffer == self.currentBuffer:
 
            return
 
        #if self.lastSentBuffer == self.currentBuffer:
 
        #    return
 
        with Udmx.stats.write.time():
 
            # frequently errors with usb.core.USBError
 
            try:
 
                self.dev.SendDMX(self.currentBuffer)
 
                self.lastSentBuffer = self.currentBuffer
 
                return
 
            except usb.core.USBError:
 
                Udmx.stats.usbErrors += 1
 

	
0 comments (0 inline, 0 general)