https://wiki.openlighting.org/api.php?action=feedcontributions&user=213.41.135.175&feedformat=atomwiki.openlighting.org - User contributions [en]2024-03-29T15:43:38ZUser contributionsMediaWiki 1.29.1https://wiki.openlighting.org/index.php?title=OLA_Python_API&diff=2418OLA Python API2007-12-28T20:54:56Z<p>213.41.135.175: /* Building the Python Bindings */</p>
<hr />
<div>== Building the Python Bindings ==<br />
<br />
See [[Building LLA]] but run ''./configure --enable-python-libs''<br />
<br />
Note that you have to install Swig in order to build the python bindings (sudo apt-get install swig)<br />
<br />
There is also a forbidden data in lla/python/Makefile : you have to add -I../include to the value of DEFAULT_INCLUDES at the line 70.<br />
<br />
At the end of the installation, you should run ldconfig as root in order to use the python bindings.<br />
<br />
== Interesting Classes ==<br />
<br />
; LlaClient<br />
: the main connection class<br />
; dmxBuffer<br />
: represents a list of DMX channel values<br />
; LlaClientObserver<br />
: base class to handle events<br />
; LlaPlugin<br />
: represents a Plugin<br />
; LlaDevice<br />
: represents a Device<br />
<br />
== Sending DMX ==<br />
A simple example to send DMX:<br />
<br />
<pre><br />
from lla import *<br />
import sys<br />
<br />
con = LlaClient()<br />
if con.start():<br />
sys.exit()<br />
<br />
universe = 0<br />
<br />
# create a dmxBuffer for the channel values<br />
DMX_LEN = 512<br />
dmx = dmxBuffer(DMX_LEN)<br />
for i in range(0, DMX_LEN):<br />
dmx[i] = i<br />
<br />
con.send_dmx(universe, dmx, DMX_LEN)<br />
</pre><br />
<br />
== Receiving DMX ==<br />
<br />
Receiving is slightly harder, we need to setup an Observer object to handle the events:<br />
<br />
''' THIS ISN'T WORKING YET ''' [simonn]<br />
<br />
<pre><br />
from lla import *<br />
import sys<br />
<br />
class Observer(LlaClientObserver):<br />
""" Handle the events """<br />
def new_dmx(self, uni, length, data):<br />
""" Called with new dmx buffer """<br />
return 0<br />
<br />
<br />
# create a new LlaClient<br />
con = LlaClient()<br />
<br />
# create an observer object and register<br />
ob = Observer()<br />
con.set_observer(ob)<br />
<br />
if con.start():<br />
sys.exit()<br />
<br />
con.register_uni(1, LlaClient.REGISTER)<br />
<br />
while True:<br />
con.fd_action(1)<br />
<br />
</pre></div>213.41.135.175https://wiki.openlighting.org/index.php?title=OLA_Python_API&diff=2417OLA Python API2007-12-28T20:52:15Z<p>213.41.135.175: /* Building the Python Bindings */</p>
<hr />
<div>== Building the Python Bindings ==<br />
<br />
See [[Building LLA]] but run ''./configure --enable-python-libs''<br />
<br />
Note that you have to install Swig in order to build the python bindings (sudo apt-get install swig)<br />
<br />
There is also a forbidden data in lla/python/Makefile : you have to add -I../include to the value of DEFAULT_INCLUDES at the line 70.<br />
<br />
== Interesting Classes ==<br />
<br />
; LlaClient<br />
: the main connection class<br />
; dmxBuffer<br />
: represents a list of DMX channel values<br />
; LlaClientObserver<br />
: base class to handle events<br />
; LlaPlugin<br />
: represents a Plugin<br />
; LlaDevice<br />
: represents a Device<br />
<br />
== Sending DMX ==<br />
A simple example to send DMX:<br />
<br />
<pre><br />
from lla import *<br />
import sys<br />
<br />
con = LlaClient()<br />
if con.start():<br />
sys.exit()<br />
<br />
universe = 0<br />
<br />
# create a dmxBuffer for the channel values<br />
DMX_LEN = 512<br />
dmx = dmxBuffer(DMX_LEN)<br />
for i in range(0, DMX_LEN):<br />
dmx[i] = i<br />
<br />
con.send_dmx(universe, dmx, DMX_LEN)<br />
</pre><br />
<br />
== Receiving DMX ==<br />
<br />
Receiving is slightly harder, we need to setup an Observer object to handle the events:<br />
<br />
''' THIS ISN'T WORKING YET ''' [simonn]<br />
<br />
<pre><br />
from lla import *<br />
import sys<br />
<br />
class Observer(LlaClientObserver):<br />
""" Handle the events """<br />
def new_dmx(self, uni, length, data):<br />
""" Called with new dmx buffer """<br />
return 0<br />
<br />
<br />
# create a new LlaClient<br />
con = LlaClient()<br />
<br />
# create an observer object and register<br />
ob = Observer()<br />
con.set_observer(ob)<br />
<br />
if con.start():<br />
sys.exit()<br />
<br />
con.register_uni(1, LlaClient.REGISTER)<br />
<br />
while True:<br />
con.fd_action(1)<br />
<br />
</pre></div>213.41.135.175