annotate light9/subclient.py @ 1742:70873145cc71

get mouse events to pixi. fix pixi-vs-adj coordinate issue Ignore-this: dbf065b862823c312ceebbbe80dc99df
author Drew Perttula <drewp@bigasterisk.com>
date Sat, 19 May 2018 21:55:08 +0000
parents c45787e306ae
children 1692e8aba9f5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1391
4a7594476905 hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents: 1222
diff changeset
1 from light9.effect.sequencer import sendToCollector
1454
50fe80faebab animRainbow test. KC faster frame rate
drewp@bigasterisk.com
parents: 1414
diff changeset
2 from twisted.internet import reactor, task
1501
c45787e306ae KC don't stop sending just because an effect raised an exception
drewp@bigasterisk.com
parents: 1454
diff changeset
3 import traceback
c45787e306ae KC don't stop sending just because an effect raised an exception
drewp@bigasterisk.com
parents: 1454
diff changeset
4 import logging
c45787e306ae KC don't stop sending just because an effect raised an exception
drewp@bigasterisk.com
parents: 1454
diff changeset
5 log = logging.getLogger()
253
a92b6d1ac072 SubClient created, keyboardcomposer and gyrocontroller use it now
David McClosky <dmcc@bigasterisk.com>
parents:
diff changeset
6
a92b6d1ac072 SubClient created, keyboardcomposer and gyrocontroller use it now
David McClosky <dmcc@bigasterisk.com>
parents:
diff changeset
7 class SubClient:
254
1546c423b467 Fix bugs introduced in "SubClient created, keyboardcomposer and gyrocontroller use it now"
David McClosky <dmcc@bigasterisk.com>
parents: 253
diff changeset
8 def __init__(self):
801
caeaa88430b8 KC sends real levels
drewp@bigasterisk.com
parents: 800
diff changeset
9 """assumed that your init saves self.graph"""
254
1546c423b467 Fix bugs introduced in "SubClient created, keyboardcomposer and gyrocontroller use it now"
David McClosky <dmcc@bigasterisk.com>
parents: 253
diff changeset
10 pass # we may later need init code for network setup
800
1274e041b579 reformat
drewp@bigasterisk.com
parents: 261
diff changeset
11
253
a92b6d1ac072 SubClient created, keyboardcomposer and gyrocontroller use it now
David McClosky <dmcc@bigasterisk.com>
parents:
diff changeset
12 def get_levels_as_sub(self):
a92b6d1ac072 SubClient created, keyboardcomposer and gyrocontroller use it now
David McClosky <dmcc@bigasterisk.com>
parents:
diff changeset
13 """Subclasses must implement this method and return a Submaster
a92b6d1ac072 SubClient created, keyboardcomposer and gyrocontroller use it now
David McClosky <dmcc@bigasterisk.com>
parents:
diff changeset
14 object."""
800
1274e041b579 reformat
drewp@bigasterisk.com
parents: 261
diff changeset
15
253
a92b6d1ac072 SubClient created, keyboardcomposer and gyrocontroller use it now
David McClosky <dmcc@bigasterisk.com>
parents:
diff changeset
16 def send_levels(self):
1501
c45787e306ae KC don't stop sending just because an effect raised an exception
drewp@bigasterisk.com
parents: 1454
diff changeset
17 # shouldn't be handler- should be immediate mode!
1222
9a86ed1886db remove old code 'gyrocontroller'
Drew Perttula <drewp@bigasterisk.com>
parents: 801
diff changeset
18 self.graph.addHandler(self._send_sub)
800
1274e041b579 reformat
drewp@bigasterisk.com
parents: 261
diff changeset
19
253
a92b6d1ac072 SubClient created, keyboardcomposer and gyrocontroller use it now
David McClosky <dmcc@bigasterisk.com>
parents:
diff changeset
20 def send_levels_loop(self, delay=1000):
1454
50fe80faebab animRainbow test. KC faster frame rate
drewp@bigasterisk.com
parents: 1414
diff changeset
21 task.LoopingCall(lambda: self.graph.addHandler(self.send_levels)).start(delay)
800
1274e041b579 reformat
drewp@bigasterisk.com
parents: 261
diff changeset
22
1222
9a86ed1886db remove old code 'gyrocontroller'
Drew Perttula <drewp@bigasterisk.com>
parents: 801
diff changeset
23 def _send_sub(self):
1501
c45787e306ae KC don't stop sending just because an effect raised an exception
drewp@bigasterisk.com
parents: 1454
diff changeset
24 try:
c45787e306ae KC don't stop sending just because an effect raised an exception
drewp@bigasterisk.com
parents: 1454
diff changeset
25 outputSettings = self.get_output_settings()
c45787e306ae KC don't stop sending just because an effect raised an exception
drewp@bigasterisk.com
parents: 1454
diff changeset
26 except:
c45787e306ae KC don't stop sending just because an effect raised an exception
drewp@bigasterisk.com
parents: 1454
diff changeset
27 traceback.print_exc()
c45787e306ae KC don't stop sending just because an effect raised an exception
drewp@bigasterisk.com
parents: 1454
diff changeset
28 return
1391
4a7594476905 hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents: 1222
diff changeset
29 sendToCollector('subclient', self.session, outputSettings)