Mercurial > code > home > repos > light9
changeset 352:9d1f323fb3d3
new bin/lightsim tied to dmxserver
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Sun, 10 Jun 2007 17:25:23 +0000 |
parents | a6662d61ebcd |
children | 941cfe1e1691 |
files | bin/dmxserver bin/lightsim lightsim/__init__.py |
diffstat | 2 files changed, 87 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/bin/dmxserver Sun Jun 10 08:09:08 2007 +0000 +++ b/bin/dmxserver Sun Jun 10 17:25:23 2007 +0000 @@ -175,6 +175,11 @@ self.clientfreq[cid].update() return "ok" + def xmlrpc_currentlevels(self): + """get a list of levels we're currently sending out. All + channels beyond the list you get back, they're at zero.""" + return self.combinedlevels + parser=OptionParser() parser.add_option("-f","--fast-updates",action='store_true', help=('display all dmx output to stdout instead '
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/lightsim Sun Jun 10 17:25:23 2007 +0000 @@ -0,0 +1,82 @@ +#!/usr/bin/python + +from __future__ import division +import run_local + +from rdflib import Literal, URIRef +from twisted.internet import reactor, tksupport +from twisted.internet.task import LoopingCall +from twisted.web.xmlrpc import Proxy +import xmlrpclib, sys, logging +log = logging.getLogger() +logging.basicConfig(format="%(asctime)s %(levelname)-5s %(name)s %(filename)s:%(lineno)d: %(message)s") +log.setLevel(logging.DEBUG) +import Tkinter as tk +from light9 import networking, Patch, showconfig, dmxclient +from light9.namespaces import L9 + + +try: + from OpenGL import Tk as Togl + from OpenGL.GL import * +except ImportError: + sys.path.append("/usr/lib/python2.4/site-packages/OpenGL/Tk/linux2-tk8.4") + from OpenGL.GL import * + import Togl + +from lightsim.openglsim import Surface + + + + +def poll(graph, serv): + dmxLevels = serv.currentlevels(dmxclient._id) + level = {} # filename : level + for i, lev in enumerate(dmxLevels): + if lev == 0: + continue + + try: + chan = Patch.get_channel_uri(Patch.get_channel_name(i + 1)) + except KeyError: + continue + + for lyr in graph.objects(chan, L9['previewLayer']): + for imgPath in graph.objects(lyr, L9['path']): + level[str(imgPath)] = lev + + print level + ogl.newLevels(levels=level) + + +root = tk.Frame() +root.pack(expand=True, fill='both') +QuitButton = tk.Button(root, {'text':'Quit'}) +QuitButton.bind('<ButtonRelease-1>', sys.exit) +QuitButton.pack() + +filenames=['lightsim/skyline/bg.png', + 'lightsim/skyline/cyc-lo-red.png', + 'lightsim/skyline/cyc-lo-grn.png', + ] + +scales = {} # filename : scale +for f in filenames: + scales[f] = tk.Scale( + root, label=f, from_=0, to=1, res=.05, orient='horiz', + command=lambda *args: ogl.newLevels( + levels=dict([(f, s.get()) for f,s in scales.items()]))) + scales[f].pack() +ogl = Surface(root, filenames) +ogl.pack(side='top', expand=True, fill='both') + +graph = showconfig.getGraph() +serv = Proxy(networking.dmxServerUrl()) +LoopingCall(poll, graph, serv).start(1) + + +root.winfo_toplevel().bind("<Control-Key-q>",lambda ev: reactor.stop) +root.winfo_toplevel().bind("<Destroy>",lambda ev: reactor.stop) +root.winfo_toplevel().protocol('WM_DELETE_WINDOW', reactor.stop) +tksupport.install(ogl, ms=20) +reactor.run()