Changeset - 60e559cb1a5e
[Not reviewed]
default
0 3 0
Drew Perttula - 8 years ago 2017-05-17 08:02:58
drewp@bigasterisk.com
collector now runs the device function even on devs that have no settings, in case they have some fixed output values (e.g. light mode)
Ignore-this: f13d891964f1a3274f63a52684b4c896
3 files changed with 10 insertions and 7 deletions:
0 comments (0 inline, 0 general)
light9/collector/collector.py
Show inline comments
 
@@ -54,6 +54,8 @@ class Collector(Generic[ClientType, Clie
 
        self.outputs = outputs
 
        self.listeners = listeners
 
        self.clientTimeoutSec = clientTimeoutSec
 
        self.initTime = time.time()
 
        self.allDevices = set()
 

	
 
        self.graph.addHandler(self.rebuildOutputMap)
 

	
 
@@ -69,6 +71,7 @@ class Collector(Generic[ClientType, Clie
 
        self.remapOut = {} # (device, deviceAttr) : (start, end)
 
        for dc in self.graph.subjects(RDF.type, L9['DeviceClass']):
 
            for dev in self.graph.subjects(RDF.type, dc):
 
                self.allDevices.add(dev)
 
                self.deviceType[dev] = dc
 

	
 
                for remap in self.graph.objects(dev, L9['outputAttrRange']):
 
@@ -99,7 +102,7 @@ class Collector(Generic[ClientType, Clie
 

	
 
    def _warnOnLateRequests(self, client, now, sendTime):
 
        requestLag = now - sendTime
 
        if requestLag > .1:
 
        if requestLag > .1 and now > self.initTime + 5:
 
            log.warn('collector.setAttrs from %s is running %.1fms after the request was made',
 
                     client, requestLag * 1000)
 
        
 
@@ -145,13 +148,13 @@ class Collector(Generic[ClientType, Clie
 
                daDict[da] = v
 
                    
 
        outputAttrs = {} # device: {outputAttr: value}
 
        for d in deviceAttrs:
 
        for d in self.allDevices:
 
            try:
 
                devType = self.deviceType[d]
 
            except KeyError:
 
                log.warn("request for output to unconfigured device %s" % d)
 
                continue
 
            outputAttrs[d] = toOutputAttrs(devType, deviceAttrs[d])
 
            outputAttrs[d] = toOutputAttrs(devType, deviceAttrs.get(d, {}))
 
            if self.listeners:
 
                self.listeners.outputAttrsSet(d, outputAttrs[d], self.outputMap)
 
        
light9/collector/collector_test.py
Show inline comments
 
@@ -219,8 +219,8 @@ class TestCollector(unittest.TestCase):
 
        c.setAttrs('client1', 'sess1', [(DEV['inst1'], L9['brightness'], 1)], t0)
 
        c.setAttrs('client1', 'sess1', [(DEV['colorStrip'], L9['color'], '#00ff00')], t0)
 

	
 
        self.assertEqual([[0, 0, 0, 0], 'flush',
 
                          [0, 0, 0, 0], 'flush',
 
        self.assertEqual([[215, 0, 0, 0], 'flush',
 
                          [215, 0, 0, 0], 'flush',
 
                          [215, 0, 255, 0], 'flush'],
 
                         self.udmx.updates)
 
        self.assertEqual([[127, 0, 0, 0], 'flush',
light9/collector/web/index.html
Show inline comments
 
@@ -56,6 +56,7 @@
 
                   graph: {type: Object, notify: true},
 
                   uri: {type: String, notify: true},
 
                   label: {type: String, notify: true},
 
                   attrs: {type: Array, notify: true},
 
               },
 
               observers: [
 
                   "setLabel(graph, uri)",
 
@@ -64,7 +65,7 @@
 
               initUpdates: function(updates) {
 
                   updates.addListener(function(msg) {
 
                       if (msg.outputAttrsSet && msg.outputAttrsSet.dev == this.uri) {
 
                           this.attrs = msg.outputAttrsSet.attrs;
 
                           this.set('attrs', msg.outputAttrsSet.attrs);
 
                           this.attrs.forEach(function(row) {
 
                               row.valClass = row.val == 255 ? 'full' : (row.val ? 'nonzero' : '');
 
                           });
 
@@ -72,7 +73,6 @@
 
                   }.bind(this));
 
               },
 
               setLabel: function(graph, uri) {
 
                   console.log('setlab', uri);
 
                   this.label = uri.replace(/.*\//, '');
 
                   graph.runHandler(function() {
 
                       this.label = graph.stringValue(uri, graph.Uri('rdfs:label'));
0 comments (0 inline, 0 general)