Changeset - 5cda9c5f66dd
[Not reviewed]
default
0 1 0
Drew Perttula - 18 years ago 2007-06-15 20:18:49
drewp@bigasterisk.com
submaster ignores unknown channels
1 file changed with 3 insertions and 0 deletions:
0 comments (0 inline, 0 general)
light9/Submaster.py
Show inline comments
 
@@ -49,48 +49,51 @@ class Submaster:
 
        self.temporary = temporary
 
        if leveldict:
 
            self.levels = leveldict
 
        else:
 
            self.levels = {}
 
            self.reload(quiet=True, graph=graph)
 
        if not self.temporary:
 
            dispatcher.connect(self.reload, 'reload all subs')
 
            
 
    def reload(self, quiet=False, graph=None):
 
        if self.temporary:
 
            return
 
        try:
 
            oldlevels = self.levels.copy()
 
            self.levels.clear()
 
            patchGraph = showconfig.getGraph()
 
            if graph is None:
 
                graph = Graph()
 
                graph.parse(showconfig.subFile(self.name), format="nt")
 
            self.uri = L9['sub/%s' % self.name]
 
            for lev in graph.objects(self.uri, L9['lightLevel']):
 
                chan = graph.value(lev, L9['channel'])
 
                val = graph.value(lev, L9['level'])
 
                name = patchGraph.label(chan)
 
                if not name:
 
                    print "sub %r has channel %r with no name- leaving out that channel" % (self.name, chan)
 
                    continue
 
                self.levels[name] = float(val)
 

	
 
            if (not quiet) and (oldlevels != self.levels):
 
                print "sub %s changed" % self.name
 
        except IOError, e:
 
            print "Can't read file for sub: %r (%s)" % (self.name, e)
 
    def save(self):
 
        if self.temporary:
 
            print "not saving temporary sub named",self.name
 
            return
 

	
 
        graph = Graph()
 
        subUri = L9['sub/%s' % self.name]
 
        graph.add((subUri, RDFS.label, Literal(self.name)))
 
        for chan in self.levels.keys():
 
            try:
 
                chanUri = Patch.get_channel_uri(chan)
 
            except KeyError:
 
                print "saving dmx channels with no :Channel node is not supported yet. Give channel %s a URI for it to be saved. Omitting this channel from the sub." % chan
 
                continue
 
            lev = BNode()
 
            graph.add((subUri, L9['lightLevel'], lev))
 
            graph.add((lev, L9['channel'], chanUri))
 
            graph.add((lev, L9['level'],
0 comments (0 inline, 0 general)