annotate flax/TimelineDMX.py @ 2405:69ca2b2fc133

overcomplicated attempt at persisting the pane layout in the rdf graph this was hard because we have to somehow wait for the graph to load before config'ing the panes
author drewp@bigasterisk.com
date Fri, 17 May 2024 16:58:26 -0700
parents 3905d3c92aaa
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
1 import sys, time, socket
45b12307c695 Initial revision
drewp
parents:
diff changeset
2 sys.path.append("../light8")
139
83e2c4ceb79a KeyboardComposer: let's get it working again
dmcc
parents: 135
diff changeset
3 import Tix as tk
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
4
45b12307c695 Initial revision
drewp
parents:
diff changeset
5 import Patch, Timeline, dmxclient, xmlrpclib
45b12307c695 Initial revision
drewp
parents:
diff changeset
6 import TheShow
45b12307c695 Initial revision
drewp
parents:
diff changeset
7
45b12307c695 Initial revision
drewp
parents:
diff changeset
8 Patch.reload_data()
45b12307c695 Initial revision
drewp
parents:
diff changeset
9
139
83e2c4ceb79a KeyboardComposer: let's get it working again
dmcc
parents: 135
diff changeset
10 class ShowRunner(tk.Frame):
83e2c4ceb79a KeyboardComposer: let's get it working again
dmcc
parents: 135
diff changeset
11 def __init__(self, master, show):
83e2c4ceb79a KeyboardComposer: let's get it working again
dmcc
parents: 135
diff changeset
12 tk.Frame.__init__(self, master)
83e2c4ceb79a KeyboardComposer: let's get it working again
dmcc
parents: 135
diff changeset
13 self.master = master
83e2c4ceb79a KeyboardComposer: let's get it working again
dmcc
parents: 135
diff changeset
14
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
15 self.show = show
45b12307c695 Initial revision
drewp
parents:
diff changeset
16 self.find_player()
139
83e2c4ceb79a KeyboardComposer: let's get it working again
dmcc
parents: 135
diff changeset
17 self.build_timeline_list()
83e2c4ceb79a KeyboardComposer: let's get it working again
dmcc
parents: 135
diff changeset
18 def build_timeline_list(self):
83e2c4ceb79a KeyboardComposer: let's get it working again
dmcc
parents: 135
diff changeset
19 self.tl_list = tk.Frame(self)
83e2c4ceb79a KeyboardComposer: let's get it working again
dmcc
parents: 135
diff changeset
20 for tl in self.show.get_timelines():
83e2c4ceb79a KeyboardComposer: let's get it working again
dmcc
parents: 135
diff changeset
21 b=tk.Button(self.tl_list,text=tl,
83e2c4ceb79a KeyboardComposer: let's get it working again
dmcc
parents: 135
diff changeset
22 anchor='w',pady=1)
83e2c4ceb79a KeyboardComposer: let's get it working again
dmcc
parents: 135
diff changeset
23 b.config(command=lambda tl=tl: self.set_timeline(tl))
83e2c4ceb79a KeyboardComposer: let's get it working again
dmcc
parents: 135
diff changeset
24 b.pack(side='top',fill='x')
83e2c4ceb79a KeyboardComposer: let's get it working again
dmcc
parents: 135
diff changeset
25 self.tl_list.pack()
83e2c4ceb79a KeyboardComposer: let's get it working again
dmcc
parents: 135
diff changeset
26 def set_timeline(self, tlname):
83e2c4ceb79a KeyboardComposer: let's get it working again
dmcc
parents: 135
diff changeset
27 print "TimelineDMX: set timeline to", tlname
83e2c4ceb79a KeyboardComposer: let's get it working again
dmcc
parents: 135
diff changeset
28 self.show.set_timeline(tlname)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
29 def find_player(self):
205
3905d3c92aaa twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents: 139
diff changeset
30 self.player = xmlrpclib.Server("http://spot:8040")
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
31 def send_levels(self):
45b12307c695 Initial revision
drewp
parents:
diff changeset
32 levels = self.show.calc_active_submaster().get_dmx_list()
45b12307c695 Initial revision
drewp
parents:
diff changeset
33
45b12307c695 Initial revision
drewp
parents:
diff changeset
34 dmxclient.outputlevels(levels)
45b12307c695 Initial revision
drewp
parents:
diff changeset
35 def sync_times(self):
45b12307c695 Initial revision
drewp
parents:
diff changeset
36 try:
45b12307c695 Initial revision
drewp
parents:
diff changeset
37 playtime = self.player.gettime()
45b12307c695 Initial revision
drewp
parents:
diff changeset
38 self.show.set_time(playtime)
45b12307c695 Initial revision
drewp
parents:
diff changeset
39 except socket.error, e:
45b12307c695 Initial revision
drewp
parents:
diff changeset
40 print "Server error %s, waiting"%e
45b12307c695 Initial revision
drewp
parents:
diff changeset
41 time.sleep(2)
45b12307c695 Initial revision
drewp
parents:
diff changeset
42 def mainloop(self):
45b12307c695 Initial revision
drewp
parents:
diff changeset
43 try:
45b12307c695 Initial revision
drewp
parents:
diff changeset
44 while 1:
45b12307c695 Initial revision
drewp
parents:
diff changeset
45 self.sync_times()
45b12307c695 Initial revision
drewp
parents:
diff changeset
46 self.send_levels()
45b12307c695 Initial revision
drewp
parents:
diff changeset
47 time.sleep(0.01)
139
83e2c4ceb79a KeyboardComposer: let's get it working again
dmcc
parents: 135
diff changeset
48 self.master.update()
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
49 except KeyboardInterrupt:
45b12307c695 Initial revision
drewp
parents:
diff changeset
50 sys.exit(0)
45b12307c695 Initial revision
drewp
parents:
diff changeset
51
45b12307c695 Initial revision
drewp
parents:
diff changeset
52 if __name__ == "__main__":
139
83e2c4ceb79a KeyboardComposer: let's get it working again
dmcc
parents: 135
diff changeset
53 root = tk.Tk()
83e2c4ceb79a KeyboardComposer: let's get it working again
dmcc
parents: 135
diff changeset
54 s = ShowRunner(root, TheShow.show)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
55 s.show.set_timeline('strobe test')
139
83e2c4ceb79a KeyboardComposer: let's get it working again
dmcc
parents: 135
diff changeset
56 s.pack()
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
57 s.mainloop()