Changeset - ccdfdc8183ad
bin/inputquneo
Show inline comments
 
@@ -23,13 +23,13 @@ curves = {
 
    25: URIRef('http://light9.bigasterisk.com/show/dance2014/song1/curve/c-4'),
 
    6: URIRef('http://light9.bigasterisk.com/show/dance2014/song1/curve/c-5'),
 
    18: URIRef('http://light9.bigasterisk.com/show/dance2014/song1/curve/c-6'),
 
}
 

	
 

	
 
class WatchMidi(object):
 
class WatchMidi:
 

	
 
    def __init__(self, graph):
 
        self.graph = graph
 
        pygame.midi.init()
 

	
 
        dev = self.findQuneo()
bin/paintserver
Show inline comments
 
@@ -55,13 +55,13 @@ class BestMatches(PrettyErrorHandler, cy
 
        with metrics('solve').time():
 
            img = self.settings.solver.draw(painting)
 
            outSettings = self.settings.solver.bestMatches(img, devs)
 
            self.write(json.dumps({'settings': outSettings.asList()}))
 

	
 

	
 
class App(object):
 
class App:
 

	
 
    def __init__(self, show, session):
 
        self.show = show
 
        self.session = session
 

	
 
        self.graph = SyncedGraph(networking.rdfdb.url, "paintServer")
light9/Effects.py
Show inline comments
 
@@ -15,13 +15,13 @@ registered = []
 
def register(f):
 
    registered.append(f)
 
    return f
 

	
 

	
 
@register
 
class Strip(object):
 
class Strip:
 
    """list of r,g,b tuples for sending to an LED strip"""
 
    which = 'L'  # LR means both. W is the wide one
 
    pixels = []
 

	
 
    def __repr__(self):
 
        return '<Strip which=%r px0=%r>' % (self.which, self.pixels[0])
light9/ascoltami/main.py
Show inline comments
 
@@ -19,13 +19,13 @@ from light9.ascoltami.player import Play
 
from light9.ascoltami.playlist import NoSuchSong, Playlist
 
from light9.ascoltami.webapp import makeWebApp, songLocation, songUri
 

	
 
reactor = cast(IReactorCore, reactor)
 

	
 

	
 
class App(object):
 
class App:
 

	
 
    def __init__(self, graph, show):
 
        self.graph = graph
 
        self.player = Player(onEOS=self.onEOS, autoStopOffset=0)
 
        self.show = show
 
        self.playlist = Playlist.fromShow(graph, show)
light9/ascoltami/musictime_client.py
Show inline comments
 
@@ -8,13 +8,13 @@ import treq
 

	
 
from light9 import networking
 

	
 
log = logging.getLogger()
 

	
 

	
 
class MusicTime(object):
 
class MusicTime:
 
    """
 
    fetch times from ascoltami in a background thread; return times
 
    upon request, adjusted to be more precise with the system clock
 
    """
 

	
 
    def __init__(self, period=.2, onChange=lambda position: None, pollCurvecalc='ignored'):
light9/ascoltami/player.py
Show inline comments
 
@@ -8,13 +8,13 @@ from gi.repository import Gst # type: ig
 
from twisted.internet import task
 
from light9.metrics import metrics
 
log = logging.getLogger()
 

	
 

	
 

	
 
class Player(object):
 
class Player:
 

	
 
    def __init__(self, autoStopOffset=4, onEOS=None):
 
        """autoStopOffset is the number of seconds before the end of
 
        song before automatically stopping (which is really pausing).
 
        onEOS is an optional function to be called when we reach the
 
        end of a stream (for example, can be used to advance the song).
light9/ascoltami/playlist.py
Show inline comments
 
@@ -4,13 +4,13 @@ from light9.namespaces import L9
 

	
 
class NoSuchSong(ValueError):
 
    """Raised when a song is requested that doesn't exist (e.g. one
 
    after the last song in the playlist)."""
 

	
 

	
 
class Playlist(object):
 
class Playlist:
 

	
 
    def __init__(self, graph, playlistUri):
 
        self.graph = graph
 
        self.playlistUri = playlistUri
 
        self.songs = list(graph.items(playlistUri))
 

	
light9/collector/collector_client.py
Show inline comments
 
@@ -8,13 +8,13 @@ import treq
 

	
 
log = logging.getLogger('coll_client')
 

	
 
_zmqClient = None
 

	
 

	
 
class TwistedZmqClient(object):
 
class TwistedZmqClient:
 

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

	
light9/collector/device.py
Show inline comments
 
@@ -7,13 +7,13 @@ from colormath.color_objects import sRGB
 
import colormath.color_conversions
 
from light9.newtypes import VT, DeviceClass, HexColor, OutputAttr, OutputValue, DeviceUri, DeviceAttr, VTUnion
 

	
 
log = logging.getLogger('device')
 

	
 

	
 
class Device(object):
 
class Device:
 
    pass
 

	
 

	
 
class ChauvetColorStrip(Device):
 
    """
 
     device attrs:
light9/collector/output.py
Show inline comments
 
@@ -10,13 +10,13 @@ from twisted.internet.interfaces import 
 
from light9.metrics import metrics
 

	
 
log = logging.getLogger('output')
 
logAllDmx = logging.getLogger('output.allDmx')
 

	
 

	
 
class Output(object):
 
class Output:
 
    """
 
    send a binary buffer of values to some output device. Call update
 
    as often as you want- the result will be sent as soon as possible,
 
    and with repeats as needed to outlast hardware timeouts.
 

	
 
    This base class doesn't ever call _write. Subclasses below have
light9/collector/weblisteners.py
Show inline comments
 
@@ -17,13 +17,13 @@ def shortenOutput(out: OutputUri) -> str
 
class UiListener(Protocol):
 

	
 
    async def sendMessage(self, msg):
 
        ...
 

	
 

	
 
class WebListeners(object):
 
class WebListeners:
 

	
 
    def __init__(self) -> None:
 
        self.clients: List[Tuple[UiListener, Dict[DeviceUri, Dict[OutputAttr, OutputValue]]]] = []
 
        self.pendingMessageForDev: Dict[DeviceUri, Tuple[Dict[OutputAttr, OutputValue], Dict[Tuple[DeviceUri, OutputAttr], Tuple[OutputUri,
 
                                                                                                                                 DmxMessageIndex]]]] = {}
 
        self.lastFlush = 0
light9/effect/effecteval.py
Show inline comments
 
@@ -61,13 +61,13 @@ def clamp255(x):
 
def _8bit(f):
 
    if not isinstance(f, (int, float)):
 
        raise TypeError(repr(f))
 
    return clamp255(int(f * 255))
 

	
 

	
 
class EffectEval(object):
 
class EffectEval:
 
    """
 
    runs one effect's code to turn effect attr settings into output
 
    device settings. No state; suitable for reload().
 
    """
 

	
 
    def __init__(self, graph, effect, simpleOutputs):
light9/effect/sequencer/note.py
Show inline comments
 
@@ -17,13 +17,13 @@ def pyType(n):
 
    ret = n.toPython()
 
    if isinstance(ret, Decimal):
 
        return float(ret)
 
    return ret
 

	
 

	
 
class Note(object):
 
class Note:
 

	
 
    def __init__(self, graph: SyncedGraph, uri: NoteUri, effectevalModule, simpleOutputs, timed=True):
 
        g = self.graph = graph
 
        self.uri = uri
 
        self.timed = timed
 
        self.effectEval = effectevalModule.EffectEval(graph, g.value(uri, L9['effectClass']), simpleOutputs)
light9/effect/sequencer/sequencer.py
Show inline comments
 
@@ -29,13 +29,13 @@ log = logging.getLogger('sequencer')
 

	
 

	
 
class StateUpdate(All):
 
    pass
 

	
 

	
 
class CodeWatcher(object):
 
class CodeWatcher:
 

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

	
 
        self.notifier = INotify()
 
        self.notifier.startReading()
 
@@ -51,13 +51,13 @@ class CodeWatcher(object):
 
            self.onChange()
 

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

	
 

	
 
class Sequencer(object):
 
class Sequencer:
 
    """Notes from the graph + current song playback -> sendToCollector"""
 
    def __init__(self,
 
                 graph: SyncedGraph,
 
                 sendToCollector: Callable[[DeviceSettings], Coroutine[None ,None,None]],
 
                 fps=40,
 
                 ):
light9/effect/settings.py
Show inline comments
 
@@ -33,13 +33,13 @@ def getVal(graph, subj):
 
    ret = lit.toPython()
 
    if isinstance(ret, decimal.Decimal):
 
        ret = float(ret)
 
    return ret
 

	
 

	
 
class _Settings(object):
 
class _Settings:
 
    """
 
    default values are 0 or '#000000'. Internal rep must not store zeros or some
 
    comparisons will break.
 
    """
 

	
 
    def __init__(self, graph, settingsList):
light9/effect/simple_outputs.py
Show inline comments
 
@@ -2,13 +2,13 @@ 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):
 
class SimpleOutputs:
 
    """
 
    Watches graph for effects that are just fading output attrs. 
 
    Call `values` to get (dev,attr):value settings.
 
    """
 

	
 
    def __init__(self, graph):
light9/effecteval/effect.py
Show inline comments
 
@@ -12,13 +12,13 @@ log = logging.getLogger('effect')
 

	
 

	
 
class CouldNotConvert(TypeError):
 
    pass
 

	
 

	
 
class CodeLine(object):
 
class CodeLine:
 
    """code string is immutable"""
 

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

	
 
        self.outName, self.inExpr, self.expr, self.resources = self._asPython()
 
@@ -99,13 +99,13 @@ class CodeLine(object):
 
            else:
 
                out[localVar] = CouldNotConvert(uri)
 

	
 
        return out
 

	
 

	
 
class EffectNode(object):
 
class EffectNode:
 

	
 
    def __init__(self, graph, uri):
 
        self.graph, self.uri = graph, uri
 
        # this is not expiring at the right time, when an effect goes away
 
        self.graph.addHandler(self.prepare)
 

	
light9/effecteval/effectloop.py
Show inline comments
 
@@ -16,13 +16,13 @@ from light9.effecteval.effect import Eff
 
from light9.namespaces import L9, RDF
 
from light9.metrics import metrics
 

	
 
log = logging.getLogger('effectloop')
 

	
 

	
 
class EffectLoop(object):
 
class EffectLoop:
 
    """maintains a collection of the current EffectNodes, gets time from
 
    music player, sends dmx"""
 

	
 
    def __init__(self, graph):
 
        self.graph = graph
 
        self.currentSong = None
 
@@ -190,13 +190,13 @@ class EffectLoop(object):
 
                          for k, v in list(out.get_levels().items())))
 

	
 

	
 
Z = numpy.zeros((50, 3), dtype=numpy.float16)
 

	
 

	
 
class ControlBoard(object):
 
class ControlBoard:
 

	
 
    def __init__(
 
            self,
 
            dev='/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A7027NYX-if00-port0'
 
    ):
 
        log.info('opening %s', dev)
light9/io/udmx.py
Show inline comments
 
@@ -19,13 +19,13 @@ See https://www.illutzmination.de/udmxfi
 
or https://github.com/markusb/uDMX-linux/blob/master/uDMX.c
 
"""
 

	
 
cmd_SetChannelRange = 0x0002
 

	
 

	
 
class Udmx(object):
 
class Udmx:
 

	
 
    def __init__(self, bus):
 
        self.dev = None
 
        for dev in usb.core.find(idVendor=0x16c0,
 
                                 idProduct=0x05dc,
 
                                 find_all=True):
light9/metrics.py
Show inline comments
 
@@ -98,13 +98,13 @@ class PmfStat(Stat):
 
  twenty seconds.
 

	
 

	
 

	
 
metrics consumer side can do this with the changing counts:
 

	
 
class RecentFps(object):
 
class RecentFps:
 
  def __init__(self, window=20):
 
    self.window = window
 
    self.recentTimes = []
 

	
 
  def mark(self):
 
    now = time.time()
light9/namespaces.py
Show inline comments
 
from rdflib import URIRef, Namespace, RDF, RDFS  # noqa
 
from typing import Dict
 

	
 

	
 
# Namespace was showing up in profiles
 
class FastNs(object):
 
class FastNs:
 

	
 
    def __init__(self, base):
 
        self.ns = Namespace(base)
 
        self.cache: Dict[str, URIRef] = {}
 

	
 
    def __getitem__(self, term) -> URIRef:
light9/networking.py
Show inline comments
 
@@ -3,13 +3,13 @@ from urllib.parse import urlparse
 
from rdflib import URIRef
 

	
 
from .showconfig import getGraph, showUri
 
from .namespaces import L9
 

	
 

	
 
class ServiceAddress(object):
 
class ServiceAddress:
 

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

	
 
    def _url(self) -> URIRef:
 
        graph = getGraph()
light9/observable.py
Show inline comments
 
import logging
 
log = logging.getLogger('observable')
 

	
 

	
 
class _NoNewVal(object):
 
class _NoNewVal:
 
    pass
 

	
 

	
 
class Observable(object):
 
class Observable:
 
    """
 
    like knockout's observable. Hopefully this can be replaced by a
 
    better python one
 

	
 
    compare with:
 
    http://knockoutjs.com/documentation/observables.html
0 comments (0 inline, 0 general)