From 0606c8d1072200d411caf35d25ffe8ae35a8a3ff Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Mon, 7 Nov 2022 17:27:41 +0000 Subject: [PATCH] info_response property added to base clase. --- __main__.py | 6 +++--- xair_api/kinds.py | 8 ++++---- xair_api/xair.py | 15 +++++++++------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/__main__.py b/__main__.py index 1aa893a..3f5e300 100644 --- a/__main__.py +++ b/__main__.py @@ -2,6 +2,9 @@ import xair_api def main(): + kind_id = "XR18" + ip = "" + with xair_api.connect(kind_id, ip=ip) as mixer: mixer.strip[8].config.name = "sm7b" mixer.strip[8].config.on = True @@ -11,7 +14,4 @@ def main(): if __name__ == "__main__": - kind_id = "MR18" - ip = "" - main() diff --git a/xair_api/kinds.py b/xair_api/kinds.py index f28798b..6bc305f 100644 --- a/xair_api/kinds.py +++ b/xair_api/kinds.py @@ -19,8 +19,8 @@ class X32KindMap(KindMap): @dataclass -class MR18KindMap(KindMap): - # note ch 17-18 defined as aux rtn +class XR18KindMap(KindMap): + # note ch 17-18 defined as aux return id_: str num_dca: int = 4 num_strip: int = 16 @@ -48,8 +48,8 @@ class XR12KindMap(KindMap): _kinds = { "X32": X32KindMap(id_="X32"), - "XR18": MR18KindMap(id_="XR18"), - "MR18": MR18KindMap(id_="MR18"), + "MR18": XR18KindMap(id_="MR18"), + "XR18": XR18KindMap(id_="XR18"), "XR16": XR16KindMap(id_="XR16"), "XR12": XR12KindMap(id_="XR12"), } diff --git a/xair_api/xair.py b/xair_api/xair.py index 0c859c0..e9324cb 100644 --- a/xair_api/xair.py +++ b/xair_api/xair.py @@ -51,7 +51,7 @@ class XAirRemote(abc.ABC): _WAIT_TIME = 0.025 _REFRESH_TIMEOUT = 5 - info_response = [] + _info_response = [] def __init__(self, **kwargs): dispatcher = Dispatcher() @@ -85,21 +85,24 @@ class XAirRemote(abc.ABC): f"Successfully connected to {self.info_response[2]} at {self.info_response[0]}." ) + @property + def info_response(self): + return self._info_response + def run_server(self): self.server.serve_forever() def msg_handler(self, addr, *data): self.logger.debug(f"received: {addr} {data if data else ''}") - self.info_response = data[:] + self._info_response = data[:] def send(self, addr: str, param: Optional[str] = None): self.logger.debug(f"sending: {addr} {param if param else ''}") self.server.send_message(addr, param) time.sleep(self._WAIT_TIME) - def _query(self, address): + def query(self, address): self.send(address) - time.sleep(self._WAIT_TIME) return self.info_response def __exit__(self, exc_type, exc_value, exc_tr): @@ -128,8 +131,8 @@ def _make_remote(kind: KindMap) -> XAirRemote: self.dca = tuple(DCA(self, i) for i in range(kind.num_dca)) self.fx = tuple(FX(self, i) for i in range(kind.num_fx)) self.fxreturn = tuple(adapter.FxRtn.make(self, i) for i in range(kind.num_fx)) - self.config = Config.make(self) self.auxin = tuple(adapter.AuxRtn.make(self, i) for i in range(kind.num_auxrtn)) + self.config = Config.make(self) def init_xair(self, *args, **kwargs): defaultkwargs = {"ip": None, "port": 10024} @@ -143,8 +146,8 @@ def _make_remote(kind: KindMap) -> XAirRemote: self.fx = tuple(FX(self, i) for i in range(kind.num_fx)) self.fxsend = tuple(FXSend.make(self, i) for i in range(kind.num_fx)) self.fxreturn = tuple(FxRtn.make(self, i) for i in range(kind.num_fx)) - self.config = Config.make(self) self.auxreturn = AuxRtn.make(self) + self.config = Config.make(self) if kind.id_ == "X32": return type(