comparison bin/gyrocontroller @ 289:3b73f0a58a54

Move general use gyro function get_sub to Submaster, make global Submasters object - gyro's error subs now look like normal subs since they might reload and turn into good subs. - Also, add Submaster.fullsub which helps you make subs from channel names.
author David McClosky <dmcc@bigasterisk.com>
date Sat, 18 Jun 2005 01:45:05 +0000
parents 460bc5ebcaaf
children
comparison
equal deleted inserted replaced
288:22529016c4f2 289:3b73f0a58a54
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # vi: syntax=python 2 # vi: syntax=python
3 3
4 import run_local 4 import run_local
5 from light9.Submaster import Submasters, Submaster, combine_subdict 5 from light9.Submaster import Submasters, Submaster, combine_subdict, \
6 get_sub_by_name
6 from light9.subclient import SubClient 7 from light9.subclient import SubClient
7 import light9.Patch as Patch 8 import light9.Patch as Patch
8 9
9 import Tix as Tk 10 import Tix as Tk
10 11
47 def __init__(self, subnames): 48 def __init__(self, subnames):
48 SubClient.__init__(self) 49 SubClient.__init__(self)
49 self.subnames = subnames 50 self.subnames = subnames
50 self.refresh() 51 self.refresh()
51 def get_sub(self, name): 52 def get_sub(self, name):
52 if name in self.submasters.get_all_sub_names(): 53 return get_sub_by_name(name, self.submasters)
53 return self.submasters.get_sub_by_name(name)
54
55 try:
56 val = int(name)
57 s = Submaster("#%d" % val, {val : 1.0}, temporary=True)
58 return s
59 except ValueError:
60 pass
61
62 try:
63 subnum = Patch.get_dmx_channel(name)
64 s = Submaster("'%s'" % name, {subnum : 1.0}, temporary=True)
65 return s
66 except ValueError:
67 pass
68
69 # make an error sub
70 return Submaster('%s!?' % name)
71 def refresh(self): 54 def refresh(self):
72 # reload subs from disk 55 # reload subs from disk
73 self.submasters = Submasters() 56 self.submasters = Submasters()
74 self.all_subs = circcycle(self.subnames) 57 self.all_subs = circcycle(self.subnames)
75 self.current_sub = self.get_sub(self.all_subs.next()) 58 self.current_sub = self.get_sub(self.all_subs.next())