Changeset - 9d1f323fb3d3
[Not reviewed]
default
0 1 2
Drew Perttula - 18 years ago 2007-06-10 17:25:23
drewp@bigasterisk.com
new bin/lightsim tied to dmxserver
3 files changed with 87 insertions and 0 deletions:
0 comments (0 inline, 0 general)
bin/dmxserver
Show inline comments
 
@@ -172,12 +172,17 @@ class XMLRPCServe(xmlrpc.XMLRPC):
 
                self.clientfreq[cid]=Updatefreq()
 
                
 
        self.lastseen[cid]=time.time()
 
        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 '
 
                        'of the usual reduced output'))
 
parser.add_option("-r","--updates-per-sec",type='float',default=20,
 
                  help=('dmx output frequency'))
bin/lightsim
Show inline comments
 
new file 100644
 
#!/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()
lightsim/__init__.py
Show inline comments
 
new file 100644
0 comments (0 inline, 0 general)