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
 
@@ -39,6 +39,7 @@ 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):
 
@@ -235,9 +236,12 @@ def launch(opts, args, root, graph, sess
 
    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')
 

	
light9/networking.py
Show inline comments
 
@@ -44,5 +44,6 @@ 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)