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
 
@@ -25,17 +25,44 @@ todo:
 
from __future__ import division
 
from twisted.internet import reactor
 
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):
 

	
 
        xmlrpc.XMLRPC.__init__(self)
 
        
 
        self.clientlevels={} # clientID : list of levels
 
@@ -212,11 +239,16 @@ parser.add_option("-n", "--dummy", actio
 

	
 
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
 
@@ -32,10 +32,11 @@ class ServiceAddress(object):
 
        return self._url()
 

	
 
    def path(self, more):
 
        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'])
 
vidref = ServiceAddress(L9['vidref'])
pydeps
Show inline comments
 
@@ -11,7 +11,8 @@ nose==1.3.0
 
nose-alert==0.9.0
 
ipdb==0.7
 
# waiting for https://github.com/xolox/python-coloredlogs/pull/1
 
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
 
@@ -3,9 +3,10 @@
 
@prefix sh: <http://light9.bigasterisk.com/show/dance2013/> .
 

	
 
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)