Changeset - d34a4956417a
[Not reviewed]
default
0 3 0
drewp - 22 years ago 2002-07-13 02:57:27

rsn has a separate thread that receives rlslider connections from a potserver.py process,
rsn has a separate thread that receives rlslider connections from a potserver.py process,
and they work
3 files changed with 19 insertions and 4 deletions:
0 comments (0 inline, 0 general)
light8/ExternalInput.py
Show inline comments
 
import thread, SocketServer
 
import thread, SocketServer, socket
 

	
 

	
 
currentlevels = [0,0,0,0]
 

	
 

	
 
class NetSliderHandler(SocketServer.StreamRequestHandler):
 
    def handle(self):
 
        data = self.rfile.readline(1000)
 
        currentlevels[:] = [float(x)/255 for x in list(data.split())]
 

	
 
def start_server(levelstorage):
 
def start_server(levelstorage=0):
 
    server = SocketServer.TCPServer(
 
        ('', socket.getservbyname('rlslider', 'tcp')), 
 
        NetSliderHandler)
 
    server.serve_forever()
 

	
 
class ExternalSliders:
 
    def __init__(self, level_storage=[]):
 
        self.level_storage = level_storage
 
        self.spawn_server()
 
    def test(self):
 
        'Store fake inputs to test operations'
 
        pass
 
    def spawn_server(self):
 
        pass
 
        # thread.start_new_thread(start_server, (self.update))
 
    def update(self, *args):
 
        self.level_storage[:] = args
 
    def get_levels(self):
 
        import math, time
 
        return [max(0, math.sin(time.time() + i)) for i in range(4)] # bogus
 
        return currentlevels
 
#        import math, time
 
#        return [max(0, math.sin(time.time() + i)) for i in range(4)] # bogus
 
            
 
        # return self.level_storage
light8/rsn.py
Show inline comments
 
@@ -24,21 +24,27 @@ root.tk_focusFollowsMouse()
 

	
 
parportdmx = io.ParportDMX()
 

	
 
if not DUMMY:
 
    # this turns the parportdmx from dummy to live
 
    parportdmx.golive()
 

	
 
mr_lightboard = Lightboard(root,parportdmx,DUMMY)
 
root.tk_setPalette('gray40')
 

	
 
signal(SIGINT, mr_lightboard.quit)
 

	
 
#
 
# start net slider server in separate thread 
 
#
 
import ExternalInput, thread
 
thread.start_new_thread(ExternalInput.start_server,())
 

	
 
bindkeys(root,'<Escape>', mr_lightboard.quit)
 

	
 
root.bind_class("all","<ButtonPress-4>",lambda ev: eventtoparent(ev,"<ButtonPress-4>"))
 
root.bind_class("all","<ButtonPress-5>",lambda ev: eventtoparent(ev,"<ButtonPress-5>"))
 

	
 
root.mainloop() # Receiver switches main
 

	
 
#import profile
 
#profile.run("root.mainloop()","profile/idlemanysubs")
light8/uihelpers.py
Show inline comments
 
@@ -20,26 +20,29 @@ def make_frame(parent):
 
    f = Frame(parent, bd=0)
 
    f.pack(side='left')
 
    return f
 

	
 
def bindkeys(root,key, func):
 
    root.bind(key, func)
 
    for w in root.winfo_children():
 
        w.bind(key, func)
 

	
 

	
 
def toplevel_savegeometry(tl,name):
 
    try:
 
        geo = tl.geometry()
 
        if not geo.startswith("1x1"):
 
        f=open(".light9-window-geometry-%s" % name.replace(' ','_'),'w')
 
        f.write(tl.geometry())
 
        # else the window never got mapped
 
    except:
 
        # it's ok if there's no saved geometry
 
        pass
 

	
 
    # this would get called repeatedly for each child of the window (i
 
    # dont know why) so we unbind after the first Destroy event
 
    tl.unbind("<Destroy>",tl._toplevelat_funcid)
 

	
 
def toplevelat(name):
 
    tl = Toplevel()
 

	
 
    try:
0 comments (0 inline, 0 general)