Mercurial > code > home > repos > light9
comparison bin/effecteval @ 1079:fce46850ed8c
consolidate the curve load/save rdf code more
Ignore-this: f030683dca9c44308e336137d67b5467
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Tue, 03 Jun 2014 08:24:30 +0000 |
parents | dc474426845d |
children | dfb23566a91f |
comparison
equal
deleted
inserted
replaced
1078:470cc80f5384 | 1079:fce46850ed8c |
---|---|
7 import sys, optparse, logging, subprocess, json, time, traceback | 7 import sys, optparse, logging, subprocess, json, time, traceback |
8 from rdflib import URIRef, Literal | 8 from rdflib import URIRef, Literal |
9 | 9 |
10 sys.path.append(".") | 10 sys.path.append(".") |
11 from light9 import networking, showconfig, Submaster, dmxclient | 11 from light9 import networking, showconfig, Submaster, dmxclient |
12 from light9.rdfdb.syncedgraph import SyncedGraph | 12 from light9.curvecalc.curve import CurveResource |
13 from light9.effecteval.effect import EffectNode | |
14 from light9.greplin_cyclone import StatsForCyclone | |
13 from light9.namespaces import L9, RDF, RDFS | 15 from light9.namespaces import L9, RDF, RDFS |
14 from light9.rdfdb.patch import Patch | 16 from light9.rdfdb.patch import Patch |
15 from light9.effecteval.effect import EffectNode | 17 from light9.rdfdb.syncedgraph import SyncedGraph |
16 from light9.greplin_cyclone import StatsForCyclone | |
17 from greplin import scales | 18 from greplin import scales |
18 | 19 |
19 from lib.cycloneerr import PrettyErrorHandler | 20 from lib.cycloneerr import PrettyErrorHandler |
20 | 21 |
21 class EffectEdit(PrettyErrorHandler, cyclone.web.RequestHandler): | 22 class EffectEdit(PrettyErrorHandler, cyclone.web.RequestHandler): |
40 curve = graph.sequentialUri(song + "/curve-") | 41 curve = graph.sequentialUri(song + "/curve-") |
41 | 42 |
42 with graph.currentState( | 43 with graph.currentState( |
43 tripleFilter=(dropped, RDFS.label, None)) as g: | 44 tripleFilter=(dropped, RDFS.label, None)) as g: |
44 droppedSubLabel = g.label(dropped) | 45 droppedSubLabel = g.label(dropped) |
45 | 46 |
47 cr = CurveResource(graph, curve) | |
48 cr.newCurve(ctx, label=Literal('sub %s' % droppedSubLabel)) | |
49 cr.saveCurve() | |
46 graph.patch(Patch(addQuads=[ | 50 graph.patch(Patch(addQuads=[ |
47 (song, L9['curve'], curve, ctx), | 51 (song, L9['curve'], curve, ctx), |
48 (song, L9['effect'], effect, ctx), | 52 (song, L9['effect'], effect, ctx), |
49 (effect, RDF.type, L9['Effect'], ctx), | 53 (effect, RDF.type, L9['Effect'], ctx), |
50 (effect, L9['code'], | 54 (effect, L9['code'], |
51 Literal('out = sub(%s, intensity=%s)' % (dropped.n3(), curve.n3())), | 55 Literal('out = sub(%s, intensity=%s)' % (dropped.n3(), curve.n3())), |
52 ctx), | 56 ctx), |
53 (curve, RDF.type, L9['Curve'], ctx), | |
54 (curve, RDFS.label, Literal('sub %s' % droppedSubLabel), ctx), | |
55 ])) | 57 ])) |
56 graph.patch(Patch(addQuads=[ | 58 |
57 (curve, L9['points'], Literal('0 0'), Curve(uri=curve).curvePointsContext()), | |
58 ])) | |
59 | 59 |
60 class SongEffectsUpdates(cyclone.websocket.WebSocketHandler): | 60 class SongEffectsUpdates(cyclone.websocket.WebSocketHandler): |
61 def connectionMade(self, *args, **kwargs): | 61 def connectionMade(self, *args, **kwargs): |
62 self.graph = self.settings.graph | 62 self.graph = self.settings.graph |
63 self.graph.addHandler(self.updateClient) | 63 self.graph.addHandler(self.updateClient) |