Changeset - 460bc5ebcaaf
[Not reviewed]
default
0 2 0
David McClosky - 20 years ago 2005-06-17 07:00:51
dmcc@bigasterisk.com
gyrocontroller can use patch names, Submasters gets get_all_sub_names()
2 files changed with 18 insertions and 2 deletions:
0 comments (0 inline, 0 general)
bin/gyrocontroller
Show inline comments
 
@@ -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 @@ class AbstractSimpleController(SubClient
 
        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()
light9/Submaster.py
Show inline comments
 
@@ -173,6 +173,8 @@ class Submasters:
 
                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))
0 comments (0 inline, 0 general)