changeset 1825:1692e8aba9f5

optimize KC output to collector, hopefully Ignore-this: 6378404614fe9ac95e5d1d8819c16772
author drewp@bigasterisk.com
date Sat, 09 Jun 2018 01:59:39 +0000
parents 95649051482e
children d6ec468112cb
files bin/keyboardcomposer light9/subclient.py
diffstat 2 files changed, 8 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/bin/keyboardcomposer	Sat Jun 09 01:21:38 2018 +0000
+++ b/bin/keyboardcomposer	Sat Jun 09 01:59:39 2018 +0000
@@ -454,7 +454,7 @@
             for uri, box in self.subbox.items()])
 
     def get_output_settings(self, _graph=None):
-        _graph = _graph or graph
+        _graph = _graph or self.graph
         outputSettings = []
         for setting in _graph.objects(self.session, L9['subSetting']):
             effect = _graph.value(setting, L9['sub'])
@@ -472,7 +472,7 @@
 
     def save_current_stage(self, subname):
         log.info("saving current levels as %s", subname)
-        with graph.currentState() as g:
+        with self.graph.currentState() as g:
             ds = self.get_output_settings(_graph=g)
         effect = L9['effect/%s' % subname]
         ctx = URIRef(showconfig.showUri() + '/effect/' + subname)
@@ -483,17 +483,11 @@
             (effect, L9['publishAttr'], L9['strength'], ctx),
             ])
 
-        graph.suggestPrefixes(ctx, {'eff': effect + '/'})
-        graph.patch(Patch(addQuads=stmts, delQuads=[]))
+        self.graph.suggestPrefixes(ctx, {'eff': effect + '/'})
+        self.graph.patch(Patch(addQuads=stmts, delQuads=[]))
               
         self.sub_name.delete(0, tk.END)
 
-    def send_frequent_updates(self):
-        """called when we get a fade -- send events as quickly as possible"""
-        if time.time() <= self.stop_frequent_update_time:
-            self.send_levels()
-            self.after(10, self.send_frequent_updates)
-
     def alltozero(self):
         for uri, subbox in self.subbox.items():
             if subbox.scale.scale_var.get() != 0:
--- a/light9/subclient.py	Sat Jun 09 01:21:38 2018 +0000
+++ b/light9/subclient.py	Sat Jun 09 01:59:39 2018 +0000
@@ -14,15 +14,15 @@
         object."""
 
     def send_levels(self):
-        # shouldn't be handler- should be immediate mode!
-        self.graph.addHandler(self._send_sub)
+        self._send_sub()
 
     def send_levels_loop(self, delay=1000):
-        task.LoopingCall(lambda: self.graph.addHandler(self.send_levels)).start(delay)
+        task.LoopingCall(self.send_levels).start(delay)
 
     def _send_sub(self):
         try:
-            outputSettings = self.get_output_settings()
+            with self.graph.currentState() as g:
+                outputSettings = self.get_output_settings(_graph=g)
         except:
             traceback.print_exc()
             return