Changeset - ba47676dde49
[Not reviewed]
default
0 4 0
drewp@bigasterisk.com - 11 years ago 2013-09-08 05:09:53
drewp@bigasterisk.com
dmxserver can receive OSC requests too
Ignore-this: cafc864acd008d8bf7af75b4200fb188
4 files changed with 37 insertions and 2 deletions:
0 comments (0 inline, 0 general)
bin/dmxserver
Show inline comments
 
@@ -28,11 +28,38 @@ from twisted.web import xmlrpc, server
 
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 @@ print options
 
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()
 

	
light9/networking.py
Show inline comments
 
@@ -35,6 +35,7 @@ class ServiceAddress(object):
 
        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'])
pydeps
Show inline comments
 
@@ -14,4 +14,5 @@ ipdb==0.7
 
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
show/dance2013/networking.n3
Show inline comments
 
@@ -6,6 +6,7 @@ show:dance2013 :networking sh:netHome .
 
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
0 comments (0 inline, 0 general)