get multi-universe stuff working
This commit is contained in:
parent
9054c91832
commit
6f22408a3f
2 changed files with 16 additions and 9 deletions
12
dmx_queue.py
12
dmx_queue.py
|
@ -9,9 +9,9 @@ import lights
|
||||||
|
|
||||||
|
|
||||||
class DMXQueue:
|
class DMXQueue:
|
||||||
def __init__(self, config, universe, queue):
|
def __init__(self, config, universe_name, queue, sender_port):
|
||||||
self.log = logging.getLogger(f"DMXQueue {universe}")
|
self.log = logging.getLogger(f"DMXQueue {universe_name}")
|
||||||
self.config = config.universes[universe]
|
self.config = config.universes[universe_name]
|
||||||
self.queue = queue
|
self.queue = queue
|
||||||
|
|
||||||
self.lights = []
|
self.lights = []
|
||||||
|
@ -24,17 +24,17 @@ class DMXQueue:
|
||||||
self.worker_should_be_running = False
|
self.worker_should_be_running = False
|
||||||
|
|
||||||
self.sacn = sACNsender(
|
self.sacn = sACNsender(
|
||||||
|
bind_port=sender_port,
|
||||||
fps=40,
|
fps=40,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.log.info("")
|
self.log.info("")
|
||||||
self.log.info(f" Base Brightness: {self.config.rainbow_brightness}")
|
self.log.info(f" Base Brightness: {self.config.rainbow_brightness}")
|
||||||
self.log.info(f" Alert Brightness: {self.config.alert_brightness}")
|
self.log.info(f" Alert Brightness: {self.config.alert_brightness}")
|
||||||
for light in self.lights:
|
for idx, light in enumerate(self.lights, start=1):
|
||||||
self.log.info(f" LIGHT: {light}")
|
self.log.info(f" Light {idx:>3}: {light}")
|
||||||
self.log.info("")
|
self.log.info("")
|
||||||
|
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
self.sacn.start()
|
self.sacn.start()
|
||||||
self.sacn.activate_output(self.config.universe)
|
self.sacn.activate_output(self.config.universe)
|
||||||
|
|
13
main.py
13
main.py
|
@ -6,13 +6,15 @@ from queue import Queue
|
||||||
from sys import exit
|
from sys import exit
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
|
from sacn.sending.sender_socket_base import DEFAULT_PORT
|
||||||
|
|
||||||
from conf import load_and_validate_config
|
from conf import load_and_validate_config
|
||||||
from dmx_queue import DMXQueue
|
from dmx_queue import DMXQueue
|
||||||
from mqtt_queue import MQTTQueue
|
from mqtt_queue import MQTTQueue
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=logging.INFO,
|
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")
|
LOG = logging.getLogger("main")
|
||||||
|
@ -37,9 +39,14 @@ def main():
|
||||||
mqttq = MQTTQueue(config, queues)
|
mqttq = MQTTQueue(config, queues)
|
||||||
mqttq.start()
|
mqttq.start()
|
||||||
|
|
||||||
for universe in config.universes:
|
for idx, universe in enumerate(config.universes):
|
||||||
queues[universe] = Queue()
|
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()
|
dmx_workers[universe].start()
|
||||||
|
|
||||||
LOG.info("initialization done, now running. Press Ctrl-C to stop")
|
LOG.info("initialization done, now running. Press Ctrl-C to stop")
|
||||||
|
|
Loading…
Add table
Reference in a new issue