You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.3 KiB
Python

#!/usr/bin/env python3
import json
import pathlib
import queue
import threading
from . import config
from . import controller
from . import dect
class FieldPOC:
config = None
extensions = None
def __init__(self, config_file_path, extensions_file_path):
self.config_file_path = pathlib.Path(config_file_path)
self._load_config()
self.extensions_file_path = pathlib.Path(extensions_file_path)
self._load_extensions()
self.queues = {
"controller": queue.Queue(),
"dect": queue.Queue(),
}
self._controller = controller.Controller(self)
self._dect = dect.Dect(self)
def queue_all(self, msg):
"""
Send message to every queue
"""
for queue in self.queues.values():
queue.put(msg)
def run(self):
self._controller_thread = threading.Thread(target=self._controller.run)
self._controller_thread.start()
self._dect_thread = threading.Thread(target=self._dect.run)
self._dect_thread.start()
def _load_config(self):
self.config = config.Config(json.loads(self.config_file_path.read_text()))
def _load_extensions(self):
self.extensions = config.Extensions(json.loads(self.extensions_file_path.read_text()))