comparison bin/gyrocontroller @ 272:460bc5ebcaaf

gyrocontroller can use patch names, Submasters gets get_all_sub_names()
author David McClosky <dmcc@bigasterisk.com>
date Fri, 17 Jun 2005 07:00:51 +0000
parents 97c08a1c4351
children 3b73f0a58a54
comparison
equal deleted inserted replaced
271:97c08a1c4351 272:460bc5ebcaaf
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 from light9.subclient import SubClient 6 from light9.subclient import SubClient
7 import light9.Patch as Patch
7 8
8 import Tix as Tk 9 import Tix as Tk
9 10
10 # TODO: move to Utility? 11 # TODO: move to Utility?
11 class circcycle: 12 class circcycle:
46 def __init__(self, subnames): 47 def __init__(self, subnames):
47 SubClient.__init__(self) 48 SubClient.__init__(self)
48 self.subnames = subnames 49 self.subnames = subnames
49 self.refresh() 50 self.refresh()
50 def get_sub(self, name): 51 def get_sub(self, name):
52 if name in self.submasters.get_all_sub_names():
53 return self.submasters.get_sub_by_name(name)
54
51 try: 55 try:
52 val = int(name) 56 val = int(name)
53 s = Submaster("Ch%d" % val, {val : 1.0}, temporary=True) 57 s = Submaster("#%d" % val, {val : 1.0}, temporary=True)
54 return s 58 return s
55 except ValueError: 59 except ValueError:
56 return self.submasters.get_sub_by_name(name) 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)
57 def refresh(self): 71 def refresh(self):
58 # reload subs from disk 72 # reload subs from disk
59 self.submasters = Submasters() 73 self.submasters = Submasters()
60 self.all_subs = circcycle(self.subnames) 74 self.all_subs = circcycle(self.subnames)
61 self.current_sub = self.get_sub(self.all_subs.next()) 75 self.current_sub = self.get_sub(self.all_subs.next())