Changeset - d01e21621975
[Not reviewed]
default
0 9 0
Drew Perttula - 6 years ago 2019-05-27 07:41:09
drewp@bigasterisk.com
9 files changed with 26 insertions and 11 deletions:
0 comments (0 inline, 0 general)
bin/collector
Show inline comments
 
@@ -26,13 +26,12 @@ from light9.namespaces import L9
 
from light9.zmqtransport import parseJsonMessage, startZmq
 
from rdfdb.syncedgraph import SyncedGraph
 

	
 
from light9.collector.output import EnttecDmx, Udmx, DummyOutput  # noqa
 

	
 

	
 

	
 
class Updates(cyclone.websocket.WebSocketHandler):
 

	
 
    def connectionMade(self, *args, **kwargs):
 
        log.info('socket connect %s', self)
 
        self.settings.listeners.addClient(self)
 

	
bin/effecteval
Show inline comments
 
@@ -199,15 +199,15 @@ class EffectEval(PrettyErrorHandler, cyc
 
# Completely not sure where the effect background loop should
 
# go. Another process could own it, and get this request repeatedly:
 
class SongEffectsEval(PrettyErrorHandler, cyclone.web.RequestHandler):
 

	
 
    def get(self):
 
        song = URIRef(self.get_argument('song'))
 
        effects = effectsForSong(self.settings.graph, song) # noqa
 
        effects = effectsForSong(self.settings.graph, song)  # noqa
 
        raise NotImplementedError
 
        self.write(maxDict(effectDmxDict(e) for e in effects)) # noqa
 
        self.write(maxDict(effectDmxDict(e) for e in effects))  # noqa
 
        # return dmx dict for all effects in the song, already combined
 

	
 

	
 
class App(object):
 

	
 
    def __init__(self, show, outputWhere):
bin/keyboardcomposer
Show inline comments
 
@@ -178,20 +178,25 @@ class SubmasterBox(tk.Frame):
 
        self.namelabel.config(
 
            text=self.graph.label(self.sub) or shortUri(self.sub))
 

	
 

	
 
class KeyboardComposer(tk.Frame, SubClient):
 

	
 
    def __init__(self, root: tk.Tk, graph: SyncedGraph, session: URIRef, hw_sliders=True):
 
    def __init__(self,
 
                 root: tk.Tk,
 
                 graph: SyncedGraph,
 
                 session: URIRef,
 
                 hw_sliders=True):
 
        tk.Frame.__init__(self, root, bg='black')
 
        SubClient.__init__(self)
 
        self.graph = graph
 
        self.session = session
 

	
 
        self.subbox: Dict[URIRef, SubmasterBox] = {}  # sub uri : SubmasterBox
 
        self.slider_table: Dict[Tuple[int, int], SubmasterBox] = {}  # coords : SubmasterBox
 
        self.slider_table: Dict[Tuple[int, int], SubmasterBox] = {
 
        }  # coords : SubmasterBox
 
        self.rows: List[tk.Frame] = []  # this holds Tk Frames for each row
 

	
 
        self.current_row = 0  # should come from session graph
 

	
 
        self.use_hw_sliders = hw_sliders
 
        self.connect_to_hw(hw_sliders)
light9/collector/collector_client.py
Show inline comments
 
@@ -8,12 +8,13 @@ import treq
 
log = logging.getLogger('coll_client')
 

	
 
_zmqClient = None
 

	
 

	
 
class TwistedZmqClient(object):
 

	
 
    def __init__(self, service):
 
        zf = ZmqFactory()
 
        e = ZmqEndpoint('connect', 'tcp://%s:%s' % (service.host, service.port))
 
        self.conn = ZmqPushConnection(zf, e)
 

	
 
    def send(self, msg):
light9/collector/weblisteners.py
Show inline comments
 
import logging, traceback, time, json
 
log = logging.getLogger('weblisteners')
 

	
 

	
 
class WebListeners(object):
 

	
 
    def __init__(self):
 
        self.clients = []
 
        self.pendingMessageForDev = {}  # dev: (attrs, outputmap)
 
        self.lastFlush = 0
light9/effect/sequencer.py
Show inline comments
 
@@ -53,13 +53,14 @@ class Note(object):
 
        self.points: List[Tuple[float, float]] = []
 
        for curve in g.objects(uri, L9['curve']):
 
            self.points.extend(
 
                self.getCurvePoints(curve, L9['strength'], originTime))
 
        self.points.sort()
 

	
 
    def getCurvePoints(self, curve, attr, originTime) -> List[Tuple[float, float]]:
 
    def getCurvePoints(self, curve, attr,
 
                       originTime) -> List[Tuple[float, float]]:
 
        points = []
 
        po = list(self.graph.predicate_objects(curve))
 
        if dict(po).get(L9['attr'], None) != attr:
 
            return []
 
        for point in [row[1] for row in po if row[0] == L9['point']]:
 
            po2 = dict(self.graph.predicate_objects(point))
 
@@ -128,13 +129,15 @@ class CodeWatcher(object):
 
        # in case we got an event at the start of the write
 
        reactor.callLater(.1, go)
 

	
 

	
 
class Sequencer(object):
 

	
 
    def __init__(self, graph: SyncedGraph, sendToCollector: Callable[[DeviceSettings], None],
 
    def __init__(self,
 
                 graph: SyncedGraph,
 
                 sendToCollector: Callable[[DeviceSettings], None],
 
                 fps=40):
 
        self.graph = graph
 
        self.fps = fps
 
        self.sendToCollector = sendToCollector
 
        self.music = MusicTime(period=.2, pollCurvecalc=False)
 

	
light9/effect/settings.py
Show inline comments
 
@@ -9,25 +9,26 @@ from rdflib import URIRef, Literal
 
from light9.namespaces import RDF, L9
 
import logging
 
log = logging.getLogger('settings')
 
from light9.collector.device import resolve
 
from typing import Sequence, Dict, Union, List
 

	
 

	
 
def parseHex(h):
 
    if h[0] != '#': raise ValueError(h)
 
    return [int(h[i:i + 2], 16) for i in (1, 3, 5)]
 

	
 

	
 
def parseHexNorm(h):
 
    return [x / 255 for x in parseHex(h)]
 

	
 

	
 
def toHex(rgbFloat: Sequence[float]) -> str:
 
    assert len(rgbFloat) == 3
 
    scaled = (max(0, min(255, int(v * 255))) for v in rgbFloat)
 
    return '#%02x%02x%02x' % tuple(scaled) # type: ignore
 
    return '#%02x%02x%02x' % tuple(scaled)  # type: ignore
 

	
 

	
 
def getVal(graph, subj):
 
    lit = graph.value(subj, L9['value']) or graph.value(subj, L9['scaledValue'])
 
    ret = lit.toPython()
 
    if isinstance(ret, decimal.Decimal):
 
@@ -40,13 +41,14 @@ class _Settings(object):
 
    default values are 0 or '#000000'. Internal rep must not store zeros or some
 
    comparisons will break.
 
    """
 

	
 
    def __init__(self, graph, settingsList):
 
        self.graph = graph  # for looking up all possible attrs
 
        self._compiled: Dict[URIRef, Dict[URIRef, Union[float, str]]] = {}  # dev: { attr: val }; val is number or colorhex
 
        self._compiled: Dict[URIRef, Dict[URIRef, Union[float, str]]] = {
 
        }  # dev: { attr: val }; val is number or colorhex
 
        for row in settingsList:
 
            self._compiled.setdefault(row[0], {})[row[1]] = row[2]
 
        # self._compiled may not be final yet- see _fromCompiled
 
        self._delZeros()
 

	
 
    @classmethod
light9/effect/simple_outputs.py
Show inline comments
 
import traceback
 
from light9.namespaces import L9, RDF
 
from light9.effect.scale import scale
 
from typing import Dict, List, Tuple, Any
 
from rdflib import URIRef
 

	
 

	
 
class SimpleOutputs(object):
 

	
 
    def __init__(self, graph):
 
        self.graph = graph
 

	
 
        # effect : [(dev, attr, value, isScaled)]
 
        self.effectOutputs: Dict[URIRef, List[Tuple[URIRef, URIRef, Any, bool]]] = {}
 
        self.effectOutputs: Dict[URIRef, List[
 
            Tuple[URIRef, URIRef, Any, bool]]] = {}
 

	
 
        self.graph.addHandler(self.updateEffectsFromGraph)
 

	
 
    def updateEffectsFromGraph(self):
 
        for effect in self.graph.subjects(RDF.type, L9['Effect']):
 
            settings = []
light9/vidref/musictime.py
Show inline comments
 
@@ -123,9 +123,11 @@ class MusicTime(object):
 

	
 
    def sendTime(self, t):
 
        """request that the player go to this time"""
 
        fetch(
 
            method=b'POST',
 
            url=networking.musicPlayer.path('time'),
 
            postdata=json.dumps({"t": t}).encode('utf8'),
 
            postdata=json.dumps({
 
                "t": t
 
            }).encode('utf8'),
 
            headers={b"content-type": [b"application/json"]},
 
        )
0 comments (0 inline, 0 general)