Mercurial > code > home > repos > light9
changeset 1453:6906cacaa218
KC and SEQ share inotify code to reload effect code
Ignore-this: 2ae8142fda67b2290f4d0af219781c69
author | drewp@bigasterisk.com |
---|---|
date | Sun, 12 Jun 2016 00:24:57 +0000 |
parents | 74d803ff3c11 |
children | 50fe80faebab |
files | bin/keyboardcomposer light9/collector/device.py light9/effect/effecteval.py light9/effect/sequencer.py |
diffstat | 4 files changed, 31 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/bin/keyboardcomposer Sat Jun 11 22:29:23 2016 +0000 +++ b/bin/keyboardcomposer Sun Jun 12 00:24:57 2016 +0000 @@ -19,6 +19,7 @@ from light9.tkdnd import initTkdnd, dragSourceRegister, dropTargetRegister from light9.rdfdb import clientsession from light9.rdfdb.syncedgraph import SyncedGraph +from light9.effect.sequencer import CodeWatcher import light9.effect.effecteval from bcf2000 import BCF2000 @@ -163,7 +164,11 @@ self.make_buttons() self.graph.addHandler(self.redraw_sliders) - self.send_levels_loop() + + self.codeWatcher = CodeWatcher( + onChange=lambda: self.graph.addHandler(self.redraw_sliders)) + + self.send_levels_loop(delay=.05) self.graph.addHandler(self.rowFromGraph) def make_buttons(self):
--- a/light9/collector/device.py Sat Jun 11 22:29:23 2016 +0000 +++ b/light9/collector/device.py Sun Jun 12 00:24:57 2016 +0000 @@ -51,6 +51,7 @@ rgbs = [hex_to_rgb(v) for v in values] return rgb_to_hex([max(*component) for component in zip(*rgbs)]) # angles should perhaps use average; gobo choice use the most-open one + return max(values) def toOutputAttrs(deviceType, deviceAttrSettings):
--- a/light9/effect/effecteval.py Sat Jun 11 22:29:23 2016 +0000 +++ b/light9/effect/effecteval.py Sun Jun 12 00:24:57 2016 +0000 @@ -31,7 +31,7 @@ """ def __init__(self, graph, effect): self.graph = graph - self.effect = effect + self.effect = effect # effect : [(dev, attr, value, isScaled)] self.effectOutputs = {}
--- a/light9/effect/sequencer.py Sat Jun 11 22:29:23 2016 +0000 +++ b/light9/effect/sequencer.py Sun Jun 12 00:24:57 2016 +0000 @@ -74,7 +74,27 @@ """ effectSettings = [(L9['strength'], self.evalCurve(t))] return self.effectEval.outputFromEffect(effectSettings, t) - + + +class CodeWatcher(object): + 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): + def go(): + log.info("reload effecteval") + reload(effecteval) + self.onChange() + # in case we got an event at the start of the write + reactor.callLater(.1, go) + + class Sequencer(object): def __init__(self, graph, sendToCollector): @@ -88,29 +108,13 @@ self.graph.addHandler(self.compileGraph) self.update() - self.watchCode() - - def watchCode(self): - self.notifier = INotify() - self.notifier.startReading() - self.notifier.watch( - FilePath(effecteval.__file__.replace('.pyc', '.py')), - callbacks=[self.codeChange]) - - def codeChange(self, watch, path, mask): - def go(): - reload(effecteval) - self.graph.addHandler(self.compileGraph) - # in case we got an event at the start of the write - reactor.callLater(.1, go) + self.codeWatcher = CodeWatcher( + onChange=lambda: self.graph.addHandler(self.compileGraph)) def compileGraph(self): """rebuild our data from the graph""" g = self.graph - log.info("compileGraph") - reload(effecteval) - for song in g.subjects(RDF.type, L9['Song']): self.notes[song] = [] for note in g.objects(song, L9['note']):