diff --git a/bin/curvecalc b/bin/curvecalc --- a/bin/curvecalc +++ b/bin/curvecalc @@ -34,6 +34,7 @@ from light9.curvecalc.subtermview import from light9.curvecalc.output import Output from light9.gtkpyconsole import togglePyConsole +@prof.logTime def makeGraph(): graphOrig = showconfig.getGraph() graph = Graph() # a copy, since we're going to add subs into it @@ -374,4 +375,5 @@ def main(): prof.run(reactor.run, profile=False) -main() +prof.run(main, profile=False) + diff --git a/light9/Submaster.py b/light9/Submaster.py --- a/light9/Submaster.py +++ b/light9/Submaster.py @@ -1,5 +1,5 @@ from __future__ import division -import os, logging +import os, logging, time from rdflib import Graph from rdflib import RDFS, Literal, BNode from light9.namespaces import L9, XSD @@ -75,22 +75,29 @@ class Submaster: pass else: inFile = showconfig.subFile(self.name) - log.info("reading %s", inFile) + + t1 = time.time() graph.parse(inFile, format="n3") - 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: - log.error("sub %r has channel %r with no name- leaving out that channel" % (self.name, chan)) - continue - self.levels[name] = float(val) - + log.info("reading %s in %.1fms", inFile, 1000 * (time.time() - t1)) + + self.setLevelsFromGraph(graph, patchGraph) + if (not quiet) and (oldlevels != self.levels): log.info("sub %s changed" % self.name) except IOError, e: log.error("Can't read file for sub: %r (%s)" % (self.name, e)) + + def setLevelsFromGraph(self, graph, patchGraph): + 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: + log.error("sub %r has channel %r with no name- leaving out that channel" % (self.name, chan)) + continue + self.levels[name] = float(val) + def save(self): if self.temporary: log.info("not saving temporary sub named %s",self.name) @@ -231,14 +238,15 @@ class Submasters: self.submasters = {} files = os.listdir(showconfig.subsDir()) - + t1 = time.time() for filename in files: # we don't want these files if filename.startswith('.') or filename.endswith('~') or \ filename.startswith('CVS'): continue self.submasters[filename] = Submaster(filename, graph=graph) - log.info("loaded subs %s", self.submasters) + log.info("loaded all submasters in %.1fms" % ((time.time() - t1) * 1000)) + def get_all_subs(self): "All Submaster objects" l = self.submasters.items() diff --git a/light9/curvecalc/subtermview.py b/light9/curvecalc/subtermview.py --- a/light9/curvecalc/subtermview.py +++ b/light9/curvecalc/subtermview.py @@ -67,8 +67,12 @@ def add_one_subterm(graph, subUri, curve if expr is None: expr = '%s(t)' % subname - term = Subterm(Submaster.Submaster(graph=graph, name=subname, sub=subUri), - Subexpr(curveset, expr, graph)) + # this is what I'd like to have, but the name replacement above is + # too unclear for me to make the change now + #get_global_submasters(graph).get_sub_by_name( + + sub = Submaster.Submaster(graph=graph, name=subname, sub=subUri) + term = Subterm(sub, Subexpr(curveset, expr, graph)) subterms.append(term) stv = Subtermview(graph, term)