Changeset - 65f0179a9254
[Not reviewed]
default
0 2 3
drewp@bigasterisk.com - 11 years ago 2014-06-15 02:23:39
drewp@bigasterisk.com
subcomposer has a web ui with buttons for toggling lights
Ignore-this: f8cf76c46d81eec86c8945a61f6a594d
5 files changed with 76 insertions and 0 deletions:
0 comments (0 inline, 0 general)
bin/subcomposer
Show inline comments
 
@@ -36,12 +36,13 @@ from light9.rdfdb.syncedgraph import Syn
 
from light9.rdfdb import clientsession
 
from light9.tkdnd import initTkdnd
 
from light9.namespaces import L9
 
from light9.rdfdb.patch import Patch
 
from light9.observable import Observable
 
from light9.editchoice import EditChoice, Local
 
from light9.subcomposer import subcomposerweb
 

	
 

	
 
class Subcomposer(tk.Frame):
 
    """
 
    <session> l9:currentSub ?sub is the URI of the sub we're tied to for displaying and
 
    editing. If we don't have a currentSub, then we're actually
 
@@ -232,14 +233,17 @@ class Subcomposer(tk.Frame):
 

	
 

	
 
def launch(opts, args, root, graph, session):
 
    if not opts.no_geometry:
 
        toplevelat("subcomposer - %s" % opts.session, root, graph, session)
 

	
 
        
 
    sc = Subcomposer(root, graph, session)
 
    sc.pack()
 
    
 
    subcomposerweb.init(graph, session, sc.currentSub)
 

	
 
    tk.Label(root,text="Bindings: B1 adjust level; B2 set full; B3 instant bump",
 
             font="Helvetica -12 italic",anchor='w').pack(side='top',fill='x')
 

	
 
    if len(args) == 1:
 
        # it might be a little too weird that cmdline arg to this
light9/networking.py
Show inline comments
 
@@ -41,8 +41,9 @@ musicPlayer = ServiceAddress(L9['musicPl
 
keyboardComposer = ServiceAddress(L9['keyboardComposer'])
 
curveCalc = ServiceAddress(L9['curveCalc'])
 
vidref = ServiceAddress(L9['vidref'])
 
effectEval = ServiceAddress(L9['effectEval'])
 
picamserve = ServiceAddress(L9['picamserve'])
 
rdfdb = ServiceAddress(L9['rdfdb'])
 
subComposer = ServiceAddress(L9['subComposer'])
 

	
 
patchReceiverUpdateHost = ServiceAddress(L9['patchReceiverUpdateHost'])
light9/subcomposer/__init__.py
Show inline comments
 
new file 100644
light9/subcomposer/index.html
Show inline comments
 
new file 100644
 
<!doctype html>
 
<html>
 
  <head>
 
    <title>subcomposer</title>
 
    <meta charset="utf-8" />
 
    <style>
 
     button {
 
       min-width: 200px;
 
       min-height: 50px;
 
       display: block;
 
     }
 
    </style>
 
  </head>
 
  <body>
 
    <div>Toggle channel in current sub</div>
 

	
 
    <button data-chan="http://light9.bigasterisk.com/theater/piedmont/channel/f1-blue">f1-blue</button>
 
    <button data-chan="http://light9.bigasterisk.com/theater/piedmont/channel/f2">f2</button>
 
    <button data-chan="http://light9.bigasterisk.com/theater/piedmont/channel/f3">f3</button>
 
    <button data-chan="http://light9.bigasterisk.com/theater/piedmont/channel/f4-pool-l">f4-pool-l</button>
 
    <button data-chan="http://light9.bigasterisk.com/theater/piedmont/channel/f5-fill">f5-fill</button>
 
    <button data-chan="http://light9.bigasterisk.com/theater/piedmont/channel/sharlyn">sharlyn</button>
 
    <button data-chan="http://light9.bigasterisk.com/theater/piedmont/channel/f7">f7</button>
 
    <button data-chan="http://light9.bigasterisk.com/theater/piedmont/channel/f8-fill">f8-fill</button>
 
    <button data-chan="http://light9.bigasterisk.com/theater/piedmont/channel/f9-pool-r">f9-pool-r</button>
 
    <button data-chan="http://light9.bigasterisk.com/theater/piedmont/channel/f10">f10</button>
 
    <button data-chan="http://light9.bigasterisk.com/theater/piedmont/channel/f11-blue">f11-blue</button>
 
    <button data-chan="http://light9.bigasterisk.com/theater/piedmont/channel/f12-purp">f12-purp</button>
 

	
 
    <script src="static/jquery-2.1.1.min.js"></script>
 
    <script>
 
      $(document).on("click", "button", function (ev) {
 
          var chan = ev.target.getAttribute('data-chan');
 
          $.ajax({
 
              type: 'POST',
 
              url: 'toggle',
 
              data: {chan: chan}
 
          });
 
      });
 
    </script>
 
  </body>
 
</html>
light9/subcomposer/subcomposerweb.py
Show inline comments
 
new file 100644
 
import logging
 
import cyclone.web, cyclone.websocket, cyclone.httpclient
 
from lib.cycloneerr import PrettyErrorHandler
 
from light9 import networking
 
from rdflib import URIRef, Literal
 
from twisted.internet import reactor
 
log = logging.getLogger('web')
 

	
 
def init(graph, session, currentSub):
 
    SFH = cyclone.web.StaticFileHandler
 
    app = cyclone.web.Application(handlers=[
 
        (r'/()', SFH,
 
         {'path': 'light9/subcomposer', 'default_filename': 'index.html'}),
 
        (r'/static/(.*)', SFH, {'path': 'static/'}),
 
        (r'/toggle', Toggle),
 
    ], debug=True, graph=graph, currentSub=currentSub)
 
    reactor.listenTCP(networking.subComposer.port, app)
 
    log.info("listening on %s" % networking.subComposer.port)
 

	
 
class Toggle(PrettyErrorHandler, cyclone.web.RequestHandler):
 
    def post(self):
 
        chan = URIRef(self.get_argument('chan'))
 
        log.info("toggle %r", chan)
 
        sub = self.settings.currentSub()
 
        
 
        chanKey = Literal(chan.rsplit('/', 1)[1])
 
        old = sub.get_levels().get(chanKey, 0)
 

	
 
        sub.editLevel(chan, 0 if old else 1)
0 comments (0 inline, 0 general)