changeset 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 5a2c85174a19
files bin/gyrocontroller light9/Submaster.py
diffstat 2 files changed, 18 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/bin/gyrocontroller	Fri Jun 17 04:23:07 2005 +0000
+++ b/bin/gyrocontroller	Fri Jun 17 07:00:51 2005 +0000
@@ -4,6 +4,7 @@
 import run_local
 from light9.Submaster import Submasters, Submaster, combine_subdict
 from light9.subclient import SubClient
+import light9.Patch as Patch
 
 import Tix as Tk
 
@@ -48,12 +49,25 @@
         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("Ch%d" % val, {val : 1.0}, temporary=True)
+            s = Submaster("#%d" % val, {val : 1.0}, temporary=True)
             return s
         except ValueError:
-            return self.submasters.get_sub_by_name(name)
+            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)
     def refresh(self):
         # reload subs from disk
         self.submasters = Submasters()
--- a/light9/Submaster.py	Fri Jun 17 04:23:07 2005 +0000
+++ b/light9/Submaster.py	Fri Jun 17 07:00:51 2005 +0000
@@ -173,6 +173,8 @@
                 notsongs.append(s)
         combined = notsongs + songs
         return combined
+    def get_all_sub_names(self):
+        return [s.name for s in self.get_all_subs()]
     def get_sub_by_name(self, name):
         "Makes a new sub if there isn't one."
         return self.submasters.get(name, Submaster(name))