diff 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
line wrap: on
line diff
--- a/bin/gyrocontroller	Sat Jun 18 04:13:46 2005 +0000
+++ b/bin/gyrocontroller	Sat Jun 18 01:45:05 2005 +0000
@@ -2,7 +2,8 @@
 # vi: syntax=python
 
 import run_local
-from light9.Submaster import Submasters, Submaster, combine_subdict
+from light9.Submaster import Submasters, Submaster, combine_subdict, \
+    get_sub_by_name
 from light9.subclient import SubClient
 import light9.Patch as Patch
 
@@ -49,25 +50,7 @@
         self.subnames = subnames
         self.refresh()
     def get_sub(self, name):
-        if name in self.submasters.get_all_sub_names():
-            return self.submasters.get_sub_by_name(name)
-
-        try:
-            val = int(name)
-            s = Submaster("#%d" % val, {val : 1.0}, temporary=True)
-            return s
-        except ValueError:
-            pass
-
-        try:
-            subnum = Patch.get_dmx_channel(name)
-            s = Submaster("'%s'" % name, {subnum : 1.0}, temporary=True)
-            return s
-        except ValueError:
-            pass
-
-        # make an error sub
-        return Submaster('%s!?' % name)
+        return get_sub_by_name(name, self.submasters)
     def refresh(self):
         # reload subs from disk
         self.submasters = Submasters()