diff --git a/demo.py b/demo.py index 2f7cf7c..9c9cf2f 100644 --- a/demo.py +++ b/demo.py @@ -12,4 +12,4 @@ if __name__ == "__main__": while True: time.sleep(1) - print(nxbt.get_state()) + print(nxbt.get_state()[0]) diff --git a/nxbt/nxbt.py b/nxbt/nxbt.py index 5ec8b6e..4d6d693 100644 --- a/nxbt/nxbt.py +++ b/nxbt/nxbt.py @@ -60,7 +60,6 @@ class Nxbt(): cm = ControllerManager(state) while True: - try: msg = task_queue.get_nowait() except queue.Empty: @@ -122,17 +121,19 @@ class ControllerManager(): def __init__(self, state): self.state = state + self.controller_resources = Manager() self.controller_states = [] self.controller_queues = [] def create_controller(self, index, controller_type, adapter_path): controller_queue = Queue() - controller_state = { - "state": "initializing", - "finished_macros": [], - "errors": False - } + + controller_state = self.controller_resources.dict() + controller_state["state"] = "initializing" + controller_state["finished_macros"] = [] + controller_state["errors"] = False + self.state[index] = controller_state # Get the last parameter of the path, AKA the ID device_id = adapter_path.split("/")[-1]