Changeset - 8c82f13a3298
[Not reviewed]
default
2 3 0
drewp@bigasterisk.com - 20 months ago 2023-05-31 06:50:42
drewp@bigasterisk.com
rm or repair dead code (notes could come back)
5 files changed with 8 insertions and 76 deletions:
0 comments (0 inline, 0 general)
light9/effect/sequencer/note.py
Show inline comments
 
import bisect
 
import logging
 
import time
 
from dataclasses import dataclass
 
from decimal import Decimal
 
from typing import Any, Dict, List, Optional, Tuple, Union, cast
 
from light9.typedgraph import typedValue
 

	
 
from rdfdb.syncedgraph.syncedgraph import SyncedGraph
 
from rdflib import Literal
 

	
 
from light9.effect.settings import BareEffectSettings
 
from light9.namespaces import L9
 
from light9.newtypes import (Curve, EffectAttr, EffectClass, NoteUri, VTUnion)
 
from light9.newtypes import (Curve, EffectAttr, NoteUri, VTUnion)
 

	
 
log = logging.getLogger('sequencer')
 

	
 

	
 
def pyType(n):
 
    ret = n.toPython()
 
    if isinstance(ret, Decimal):
 
        return float(ret)
 
    return ret
 

	
 

	
 
def prettyFormat(x: Union[float, str]):
 
    if isinstance(x, float):
 
        return round(x, 4)
 
    return x
 

	
 

	
 
@dataclass
 
class Note:
 
    """A Note outputs EffectAttr settings.
 

	
 
    Sample graph:
 
     :note1 a :Note; :curve :n1c1; :effectClass effect:allcolor;
 

	
light9/effect/sequencer/note_test.py
Show inline comments
 
@@ -4,56 +4,56 @@ from light9.effect.sequencer import Note
 
from light9.effect.settings import BareEffectSettings
 
from light9.mock_syncedgraph import MockSyncedGraph
 
from light9.namespaces import L9
 
from light9.newtypes import EffectAttr, NoteUri
 

	
 
PREFIXES = '''
 
@prefix : <http://light9.bigasterisk.com/> .
 
@prefix effect: <http://light9.bigasterisk.com/effect/> .
 
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
 
@prefix show: <http://light9.bigasterisk.com/show/dance2023/> .
 
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
 
@prefix dev: <http://light9.bigasterisk.com/theater/test/device/> .
 
@prefix dmxA: <http://light9.bigasterisk.com/output/dmxA/> .
 
'''
 

	
 
FADER_GRAPH = PREFIXES + '''
 
    :fade1
 
        a :Fader;
 
        :effectClass effect:effect1;
 
        :effectAttr :strength;
 
        :value 0.6 .
 
'''
 

	
 

	
 
class TestUntimedFaderNote:
 
# class TestUntimedFaderNote:
 

	
 
    def test_returnsEffectSettings(self):
 
        g = MockSyncedGraph(FADER_GRAPH)
 
        n = Note(g, NoteUri(L9['fade1']), timed=False)
 
        out, report = n.outputCurrent()
 
        assert report['effectSettings'] == {'http://light9.bigasterisk.com/strength': 0.6}
 
        assert out == BareEffectSettings(s={EffectAttr(L9['strength']): 0.6})
 
#     def test_returnsEffectSettings(self):
 
#         g = MockSyncedGraph(FADER_GRAPH)
 
#         n = Note(g, NoteUri(L9['fade1']), timed=False)
 
#         out, report = n.outputCurrent()
 
#         assert report['effectSettings'] == {'http://light9.bigasterisk.com/strength': 0.6}
 
#         assert out == BareEffectSettings(s={EffectAttr(L9['strength']): 0.6})
 

	
 

	
 
NOTE_GRAPH = PREFIXES + '''
 
    :brightness
 
        a :DeviceAttr;
 
        rdfs:label "brightness";
 
        :dataType :scalar .
 

	
 
    :strength
 
        a :EffectAttr;
 
        rdfs:label "strength" .
 

	
 
    :SimpleDimmer
 
        a :DeviceClass;
 
        rdfs:label "SimpleDimmer";
 
        :deviceAttr :brightness;
 
        :attr [ :outputAttr :level; :dmxOffset 0 ] .
 

	
 
    dev:light1
 
        a :SimpleDimmer;
 
        :dmxUniverse dmxA:;
 
        :dmxBase 178 .
 

	
 
    effect:effect1
light9/effect/sequencer/sequencer.py
Show inline comments
 
'''
 
copies from effectloop.py, which this should replace
 
'''
 

	
 
import asyncio
 
import importlib
 
import logging
 
import time
 
import traceback
 
from typing import Callable, Coroutine, Dict, List, cast
 

	
 
from louie import All, dispatcher
 
from rdfdb.syncedgraph.syncedgraph import SyncedGraph
 
from rdflib import URIRef
 
from twisted.internet import reactor
 
from twisted.internet.inotify import INotify
 
from twisted.python.filepath import FilePath
 

	
 
from light9.ascoltami.musictime_client import MusicTime
 
from light9.effect import effecteval
 
from light9.effect.sequencer import Note
 
from light9.effect.settings import DeviceSettings
 
from light9.effect.simple_outputs import SimpleOutputs
 
from light9.metrics import metrics
 
from light9.namespaces import L9, RDF
 
from light9.newtypes import NoteUri, Song
 

	
 
log = logging.getLogger('sequencer')
 

	
 

	
 
class StateUpdate(All):
 
    pass
 

	
 

	
 
class CodeWatcher:
 

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

	
 
        self.notifier = INotify()
 
        self.notifier.startReading()
 
        self.notifier.watch(FilePath(effecteval.__file__.replace('.pyc',
 
                                                                 '.py')),
 
                            callbacks=[self.codeChange])
 

	
 
    def codeChange(self, watch, path, mask):
 

	
light9/effect/simple_outputs.py
Show inline comments
 
deleted file
light9/effect/simple_outputs_test.py
Show inline comments
 
deleted file
0 comments (0 inline, 0 general)