Changeset - 3b339c468702
[Not reviewed]
default
0 2 0
drewp@bigasterisk.com - 8 years ago 2017-06-11 18:34:56
drewp@bigasterisk.com
sequencer needs to resolve values from multiple notes
Ignore-this: 28ed09979fe787b6ea5bc507c1ee7183
2 files changed with 9 insertions and 1 deletions:
0 comments (0 inline, 0 general)
light9/collector/device.py
Show inline comments
 
@@ -43,6 +43,8 @@ def resolve(deviceType, deviceAttr, valu
 
    """
 
    return one value to use for this attr, given a set of them that
 
    have come in simultaneously. len(values) >= 1.
 

	
 
    bug: some callers are passing a device instance for 1st arg
 
    """
 
    if len(values) == 1:
 
        return values[0]
light9/effect/settings.py
Show inline comments
 
@@ -11,6 +11,7 @@ from light9.namespaces import RDF, L9, D
 
from light9.rdfdb.patch import Patch
 
import logging
 
log = logging.getLogger('settings')
 
from light9.collector.device import resolve
 

	
 
def parseHex(h):
 
    if h[0] != '#': raise ValueError(h)
 
@@ -76,6 +77,7 @@ class _Settings(object):
 

	
 
    @classmethod
 
    def fromList(cls, graph, others):
 
        """note that others may have multiple values for an attr"""
 
        out = cls(graph, [])
 
        for s in others:
 
            if not isinstance(s, cls):
 
@@ -83,7 +85,11 @@ class _Settings(object):
 
            for row in s.asList(): # could work straight from s._compiled
 
                if row[0] is None:
 
                    raise TypeError('bad row %r' % (row,))
 
                out._compiled.setdefault(row[0], {})[row[1]] = row[2]
 
                dev, devAttr, value = row
 
                devDict = out._compiled.setdefault(dev, {})
 
                if devAttr in devDict:
 
                    value = resolve(dev, devAttr, [devDict[devAttr], value])
 
                devDict[devAttr] = value
 
        out._delZeros()
 
        return out
 

	
0 comments (0 inline, 0 general)