get multi-universe stuff working

This commit is contained in:
Franzi 2025-01-31 20:51:08 +01:00
parent 9054c91832
commit 6f22408a3f
Signed by: kunsi
GPG key ID: 12E3D2136B818350
2 changed files with 16 additions and 9 deletions

View file

@ -9,9 +9,9 @@ import lights
class DMXQueue:
def __init__(self, config, universe, queue):
self.log = logging.getLogger(f"DMXQueue {universe}")
self.config = config.universes[universe]
def __init__(self, config, universe_name, queue, sender_port):
self.log = logging.getLogger(f"DMXQueue {universe_name}")
self.config = config.universes[universe_name]
self.queue = queue
self.lights = []
@ -24,17 +24,17 @@ class DMXQueue:
self.worker_should_be_running = False
self.sacn = sACNsender(
bind_port=sender_port,
fps=40,
)
self.log.info("")
self.log.info(f" Base Brightness: {self.config.rainbow_brightness}")
self.log.info(f" Alert Brightness: {self.config.alert_brightness}")
for light in self.lights:
self.log.info(f" LIGHT: {light}")
for idx, light in enumerate(self.lights, start=1):
self.log.info(f" Light {idx:>3}: {light}")
self.log.info("")
def start(self):
self.sacn.start()
self.sacn.activate_output(self.config.universe)

13
main.py
View file

@ -6,13 +6,15 @@ from queue import Queue
from sys import exit
from time import sleep
from sacn.sending.sender_socket_base import DEFAULT_PORT
from conf import load_and_validate_config
from dmx_queue import DMXQueue
from mqtt_queue import MQTTQueue
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s %(name)20s [%(levelname)-8s] %(message)s",
format="%(asctime)s %(name)30s [%(levelname)-8s] %(message)s",
)
LOG = logging.getLogger("main")
@ -37,9 +39,14 @@ def main():
mqttq = MQTTQueue(config, queues)
mqttq.start()
for universe in config.universes:
for idx, universe in enumerate(config.universes):
queues[universe] = Queue()
dmx_workers[universe] = DMXQueue(config, universe, queues[universe])
dmx_workers[universe] = DMXQueue(
config=config,
universe_name=universe,
queue=queues[universe],
sender_port=DEFAULT_PORT + idx,
)
dmx_workers[universe].start()
LOG.info("initialization done, now running. Press Ctrl-C to stop")