diff --git a/dmx_queue.py b/dmx_queue.py index 105cb95..522eace 100644 --- a/dmx_queue.py +++ b/dmx_queue.py @@ -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) diff --git a/main.py b/main.py index 220d477..0c54a35 100755 --- a/main.py +++ b/main.py @@ -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")