Hallo,
nachdem ich bereits im Besitz eines USB DMX Dongels bin, der leider
vom bestehenden Plugin nicht unterstützt wird hab ich ein Plugin für OLA
( Open Lighting Architecture - OpenDMX.net ) gebastelt.
die Funktionsweise ist analog zum bestehenden DMX Plugin.
gesteuert kann ein in OLA konfiguriertes DMX Universe werden.
als Voraussetzung wird eine funktionierende OLA Installation und der OLA Python ClientWrapper benötigt.
das ganze funktioniert wunderbar auf einem RasPi mit einigen DMX LED Controllern.
schönen Abend
Lai
nachdem ich bereits im Besitz eines USB DMX Dongels bin, der leider
vom bestehenden Plugin nicht unterstützt wird hab ich ein Plugin für OLA
( Open Lighting Architecture - OpenDMX.net ) gebastelt.
Code:
#!/usr/bin/env python # vim: set encoding=utf-8 tabstop=4 softtabstop=4 shiftwidth=4 expandtab ######################################################################### # 2013 dalai@gmx.at ######################################################################### # OLA-Plugin for SmartHome.py. # # This plugin is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This plugin is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with SmartHome.py. If not, see <http://www.gnu.org/licenses/>. ######################################################################### import logging import threading import array from ola.ClientWrapper import ClientWrapper logger = logging.getLogger('') class OLA(): def __init__(self, smarthome, universe=1): self._sh = smarthome self.TICK_INTERVAL=100 self.wrapper = None self.universe = universe self.data = array.array('B', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,]) def _DmxSent(self,state): if not state.Succeeded(): self.wrapper.Stop() def _SendDMXFrame(self): # schdule a function call in 100ms # we do this first in case the frame computation takes a long time. self.wrapper.AddEvent(self.TICK_INTERVAL, self._SendDMXFrame) # send self.wrapper.Client().SendDmx(1, self.data, self._DmxSent) def run(self): self.alive = True self.wrapper = ClientWrapper() self.wrapper.AddEvent(self.TICK_INTERVAL, self._SendDMXFrame) self.wrapper.Run() def stop(self): self.alive = False self.wrapper.Stop() #def send(self): #self.wrapper = ClientWrapper() #client = self.wrapper.Client() #self.client.SendDmx(int(self.universe), self.data, self._DmxSent) #self.wrapper.Run() def parse_item(self, item): if 'dmx_ch' in item.conf: channels = item.conf['dmx_ch'] if isinstance(channels, str): channels = [channels, ] channels = map(int, channels) item.conf['dmx_ch'] = channels return self.update_item else: return None def update_item(self, item, caller=None, source=None, dest=None): for channel in item.conf['dmx_ch']: if (int(channel) < 512): if (int(item()) < 255): self.data[int(channel)]=int(item()) #self.send() else: logger.error("dmx: value for channel {0} bigger than 255".format(int(channel))) else: logger.error("dmx: channel is bigger than 512".format(int(channel)))
gesteuert kann ein in OLA konfiguriertes DMX Universe werden.
als Voraussetzung wird eine funktionierende OLA Installation und der OLA Python ClientWrapper benötigt.
das ganze funktioniert wunderbar auf einem RasPi mit einigen DMX LED Controllern.
schönen Abend
Lai
Kommentar