Changeset - 8bb2f526d457
[Not reviewed]
default
0 4 0
drewp@bigasterisk.com - 3 years ago 2022-06-02 00:00:29
drewp@bigasterisk.com
logging
4 files changed with 12 insertions and 3 deletions:
0 comments (0 inline, 0 general)
light9/collector/service.py
Show inline comments
 
@@ -4,12 +4,13 @@ Collector receives device attrs from mul
 
them, and sends output attrs to hardware. The combining part has
 
custom code for some attributes.
 

	
 
Input can be over http or zmq.
 
"""
 
import functools
 
import logging
 
import traceback
 
from typing import List
 

	
 
from light9 import networking
 
from light9.collector.collector import Collector
 
from light9.collector.output import ArtnetDmx, DummyOutput, Output  # noqa
 
@@ -59,12 +60,15 @@ async def PutAttrs(collector: Collector,
 
        client, clientSession, settings, sendTime = parseJsonMessage(await request.body())
 
        collector.setAttrs(client, clientSession, settings, sendTime)
 
        return Response('', status_code=202)
 

	
 

	
 
def main():
 
    logging.getLogger('autodepgraphapi').setLevel(logging.INFO)
 
    logging.getLogger('syncedgraph').setLevel(logging.INFO)
 

	
 
    graph = SyncedGraph(networking.rdfdb.url, "collector")
 

	
 
    try:
 
        # todo: drive outputs with config files
 
        rate = 30
 
        outputs: List[Output] = [
light9/effect/sequencer/sequencer.py
Show inline comments
 
@@ -145,13 +145,13 @@ class CodeWatcher(object):
 

	
 
        # in case we got an event at the start of the write
 
        reactor.callLater(.1, go)
 

	
 

	
 
class Sequencer(object):
 

	
 
    """Notes from the graph + current song playback -> sendToCollector"""
 
    def __init__(self,
 
                 graph: SyncedGraph,
 
                 sendToCollector: Callable[[DeviceSettings], Coroutine[None ,None,None]],
 
                 fps=40,
 
                 ):
 
        self.graph = graph
 
@@ -198,13 +198,13 @@ class Sequencer(object):
 
            except Exception:
 
                log.warn(f"failed to build Note {note} - skipping")
 
                anyErrors = True
 
                continue
 
            self.notes[song].append(n)
 
        if not anyErrors:
 
            log.info('built all notes')
 
            log.info(f'built all notes for {song}')
 

	
 
    async def updateLoop(self):
 
        while True:
 
            frameStart = time.time()
 
            try:
 
                sec = await self.update()
light9/effect/sequencer/service.py
Show inline comments
 
@@ -8,13 +8,13 @@ import logging
 
import time
 

	
 
from light9 import networking
 
from light9.collector.collector_client_asyncio import sendToCollector
 
from light9.effect.sequencer.sequencer import StateUpdate, Sequencer
 
from light9.effect.settings import DeviceSettings
 
from light9.metrics import metrics, metricsRoute
 
from light9.metrics import metrics
 
from light9.run_local import log
 
from louie import dispatcher
 
from rdfdb.syncedgraph.syncedgraph import SyncedGraph
 
from sse_starlette.sse import EventSourceResponse
 
from starlette.applications import Starlette
 
from starlette.routing import Route
 
@@ -46,12 +46,13 @@ async def send_page_updates(request):
 

	
 

	
 
def main():
 
    session = 'effectSequencer'
 
    graph = SyncedGraph(networking.rdfdb.url, "effectSequencer")
 
    logging.getLogger('autodepgraphapi').setLevel(logging.INFO)
 
    logging.getLogger('syncedgraph').setLevel(logging.INFO)
 
    logging.getLogger('sse_starlette.sse').setLevel(logging.INFO)
 

	
 
    async def send(settings: DeviceSettings):
 
        await sendToCollector('effectSequencer', session, settings)
 

	
 
    seq = Sequencer(graph, send)
light9/fade/web/Light9FadeUi.ts
Show inline comments
 
@@ -100,20 +100,24 @@ export class Light9Fader extends LitElem
 
      this.graph.runHandler(this.configure.bind(this), `config ${this.uri.value}`);
 
      this.graph.runHandler(this.valueSync.bind(this), `valueSync ${this.uri.value}`);
 

	
 
    });
 
  }
 
  configure() {
 
    //   console.time(`fader configure ${this.uri.value}`)
 
    const U = this.graph.U();
 
    this.column = this.graph.stringValue(this.uri, U(":column"));
 
    this.effect = this.graph.uriValue(this.uri, U(":effectClass"));
 
    this.effectAttr = this.graph.uriValue(this.uri, U(":effectAttr"));
 
    // console.timeEnd(`fader configure ${this.uri.value}`)
 
  }
 
valueSync() {
 
    // console.time(`valueSync ${this.uri.value}`)
 
    this.value = this.graph.floatValue(this.uri, this.graph.Uri(":value"));
 
}
 
    // console.timeEnd(`valueSync ${this.uri.value}`)
 
  onSliderInput(ev: CustomEvent) {
 
    this.value = (ev.target as any).valueAsNumber;
 
    this.graph.patchObject(this.uri, this.graph.Uri(":value"), this.graph.LiteralRoundedFloat(this.value), this.ctx);
 
  }
 
  onEffectChange(ev: CustomEvent) {
 
    const { newValue } = ev.detail;
0 comments (0 inline, 0 general)