annotate light8/ExternalInput.py @ 167:79bc84310e80

changes from tonight's rehearsal: changes from tonight's rehearsal: - CueFader is closer to actually running the show, computes DMX levels to send. - KeyboardComposer is not a dummy. Use DMXDUMMY=1 to disable it. - Submaster: subs can now be "temporary" -- i.e. they shouldn't be saved or loaded. to save a temporary sub, make a copy of it with a proper name since the computed name will be ugly. Also, get_normalized_copy() and crossfade() methods added. linear_fade helper (shouldn't be in Submaster, probably) added too. - dmxchanedit: longer labels - cuelist1 now has some bogus data in it and some crap removed - dmxclient: now listens to the $DMXHOST and $DMXDUMMY env variables. - patchdata: now up to date with this year's show - danshow subs song{01..19}: removed. maybe we'll re-add them in an archive directory.
author dmcc
date Tue, 08 Jul 2003 16:19:55 +0000
parents d6c48d2d3bd6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
90
d34a4956417a rsn has a separate thread that receives rlslider connections from a potserver.py process,
drewp
parents: 78
diff changeset
1 import thread, SocketServer, socket
d34a4956417a rsn has a separate thread that receives rlslider connections from a potserver.py process,
drewp
parents: 78
diff changeset
2
d34a4956417a rsn has a separate thread that receives rlslider connections from a potserver.py process,
drewp
parents: 78
diff changeset
3
d34a4956417a rsn has a separate thread that receives rlslider connections from a potserver.py process,
drewp
parents: 78
diff changeset
4 currentlevels = [0,0,0,0]
d34a4956417a rsn has a separate thread that receives rlslider connections from a potserver.py process,
drewp
parents: 78
diff changeset
5
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
6
45b12307c695 Initial revision
drewp
parents:
diff changeset
7 class NetSliderHandler(SocketServer.StreamRequestHandler):
45b12307c695 Initial revision
drewp
parents:
diff changeset
8 def handle(self):
45b12307c695 Initial revision
drewp
parents:
diff changeset
9 data = self.rfile.readline(1000)
93
d6c48d2d3bd6 shrunk the useful range of the slider so there won't be any noise at the ends
drewp
parents: 90
diff changeset
10 currentlevels[:] = [round(self.bounds(float(x)/255),3) for x in list(data.split())]
d6c48d2d3bd6 shrunk the useful range of the slider so there won't be any noise at the ends
drewp
parents: 90
diff changeset
11 def bounds(self,x):
d6c48d2d3bd6 shrunk the useful range of the slider so there won't be any noise at the ends
drewp
parents: 90
diff changeset
12 # the last .1 both ways shall not do anything
d6c48d2d3bd6 shrunk the useful range of the slider so there won't be any noise at the ends
drewp
parents: 90
diff changeset
13 x=x*1.1-.05
d6c48d2d3bd6 shrunk the useful range of the slider so there won't be any noise at the ends
drewp
parents: 90
diff changeset
14 x=min(1,max(0,x))
d6c48d2d3bd6 shrunk the useful range of the slider so there won't be any noise at the ends
drewp
parents: 90
diff changeset
15 return x
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
16
90
d34a4956417a rsn has a separate thread that receives rlslider connections from a potserver.py process,
drewp
parents: 78
diff changeset
17 def start_server(levelstorage=0):
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
18 server = SocketServer.TCPServer(
45b12307c695 Initial revision
drewp
parents:
diff changeset
19 ('', socket.getservbyname('rlslider', 'tcp')),
45b12307c695 Initial revision
drewp
parents:
diff changeset
20 NetSliderHandler)
45b12307c695 Initial revision
drewp
parents:
diff changeset
21 server.serve_forever()
45b12307c695 Initial revision
drewp
parents:
diff changeset
22
45b12307c695 Initial revision
drewp
parents:
diff changeset
23 class ExternalSliders:
45b12307c695 Initial revision
drewp
parents:
diff changeset
24 def __init__(self, level_storage=[]):
45b12307c695 Initial revision
drewp
parents:
diff changeset
25 self.level_storage = level_storage
45b12307c695 Initial revision
drewp
parents:
diff changeset
26 self.spawn_server()
45b12307c695 Initial revision
drewp
parents:
diff changeset
27 def test(self):
45b12307c695 Initial revision
drewp
parents:
diff changeset
28 'Store fake inputs to test operations'
45b12307c695 Initial revision
drewp
parents:
diff changeset
29 pass
45b12307c695 Initial revision
drewp
parents:
diff changeset
30 def spawn_server(self):
45b12307c695 Initial revision
drewp
parents:
diff changeset
31 pass
45b12307c695 Initial revision
drewp
parents:
diff changeset
32 # thread.start_new_thread(start_server, (self.update))
45b12307c695 Initial revision
drewp
parents:
diff changeset
33 def update(self, *args):
45b12307c695 Initial revision
drewp
parents:
diff changeset
34 self.level_storage[:] = args
45b12307c695 Initial revision
drewp
parents:
diff changeset
35 def get_levels(self):
90
d34a4956417a rsn has a separate thread that receives rlslider connections from a potserver.py process,
drewp
parents: 78
diff changeset
36 return currentlevels
d34a4956417a rsn has a separate thread that receives rlslider connections from a potserver.py process,
drewp
parents: 78
diff changeset
37 # import math, time
d34a4956417a rsn has a separate thread that receives rlslider connections from a potserver.py process,
drewp
parents: 78
diff changeset
38 # return [max(0, math.sin(time.time() + i)) for i in range(4)] # bogus
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
39
45b12307c695 Initial revision
drewp
parents:
diff changeset
40 # return self.level_storage