Mercurial > code > home > repos > light9
changeset 1009:ba47676dde49
dmxserver can receive OSC requests too
Ignore-this: cafc864acd008d8bf7af75b4200fb188
author | drewp@bigasterisk.com |
---|---|
date | Sun, 08 Sep 2013 05:09:53 +0000 |
parents | f7de3c3c0e9a |
children | 45290696a438 |
files | bin/dmxserver light9/networking.py pydeps show/dance2013/networking.n3 |
diffstat | 4 files changed, 37 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/bin/dmxserver Tue Jun 18 02:19:17 2013 +0000 +++ b/bin/dmxserver Sun Sep 08 05:09:53 2013 +0000 @@ -28,11 +28,38 @@ import sys,time,os from optparse import OptionParser import run_local +import txosc.dispatch, txosc.async from light9.io import ParportDMX, UsbDMX from light9.updatefreq import Updatefreq from light9 import networking + +class ReceiverApplication(object): + """ + receive UDP OSC messages. address is /dmx/1 for dmx channel 1, + arguments are 0-1 floats for that channel and any number of + following channels. + """ + def __init__(self, port, lightServer): + self.port = port + self.lightServer = lightServer + self.receiver = txosc.dispatch.Receiver() + self.receiver.addCallback("/dmx/*", self.pixel_handler) + self._server_port = reactor.listenUDP( + self.port, + txosc.async.DatagramServerProtocol(self.receiver), + interface='0.0.0.0') + print "Listening OSC on udp port %s" % (self.port) + + def pixel_handler(self, message, address): + # this is already 1-based though I don't know why + startChannel = int(message.address.split('/')[2]) + levels = [a.value for a in message.arguments] + allLevels = [0] * (startChannel - 1) + levels + self.lightServer.xmlrpc_outputlevels("osc@%s" % startChannel, + allLevels) + class XMLRPCServe(xmlrpc.XMLRPC): def __init__(self,options): @@ -215,8 +242,13 @@ if options.dummy: os.environ['DMXDUMMY'] = "1" + port = networking.dmxServer.port print "starting xmlrpc server on port %s" % port -reactor.listenTCP(port,server.Site(XMLRPCServe(options))) +xmlrpcServe = XMLRPCServe(options) +reactor.listenTCP(port,server.Site(xmlrpcServe)) + +oscApp = ReceiverApplication(9051, xmlrpcServe) + reactor.run()
--- a/light9/networking.py Tue Jun 18 02:19:17 2013 +0000 +++ b/light9/networking.py Sun Sep 08 05:09:53 2013 +0000 @@ -35,6 +35,7 @@ return self.url + str(more) dmxServer = ServiceAddress(L9['dmxServer']) +oscDmxServer = ServiceAddress(L9['oscDmxServer']) musicPlayer = ServiceAddress(L9['musicPlayer']) keyboardComposer = ServiceAddress(L9['keyboardComposer']) curveCalc = ServiceAddress(L9['curveCalc'])
--- a/pydeps Tue Jun 18 02:19:17 2013 +0000 +++ b/pydeps Sun Sep 08 05:09:53 2013 +0000 @@ -14,4 +14,5 @@ git+git://github.com/drewp/python-coloredlogs@9803112ddf7d4cd7dd001912ad1aa482fb8383f6 genshi==0.7 pyjade==2.0.2 -python-dateutil==2.1 \ No newline at end of file +python-dateutil==2.1 +txosc==0.2.0 \ No newline at end of file
--- a/show/dance2013/networking.n3 Tue Jun 18 02:19:17 2013 +0000 +++ b/show/dance2013/networking.n3 Sun Sep 08 05:09:53 2013 +0000 @@ -6,6 +6,7 @@ sh:netHome :musicPlayer <http://plus:8040/>; :dmxServer <http://plus:8030/>; + :oscDmxServer <udp://plus:9050/>; :curveCalc <http://plus:8060/>; :keyboardComposer <http://plus:8050/>; :vidref <http://amp:8053/> . \ No newline at end of file