From 035c8d65071d30cfd722dded87f949a2d8b0ed2f Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Sat, 3 Feb 2024 13:03:49 +0000 Subject: [PATCH] move delay into {XAirRemote}.query() update getters --- xair_api/bus.py | 3 +-- xair_api/config.py | 3 +-- xair_api/dca.py | 3 +-- xair_api/fx.py | 3 +-- xair_api/lr.py | 3 +-- xair_api/rtn.py | 3 +-- xair_api/strip.py | 3 +-- xair_api/xair.py | 2 +- 8 files changed, 8 insertions(+), 15 deletions(-) diff --git a/xair_api/bus.py b/xair_api/bus.py index 1df3ace..cd8538f 100644 --- a/xair_api/bus.py +++ b/xair_api/bus.py @@ -13,8 +13,7 @@ class IBus(abc.ABC): self.index = index + 1 def getter(self, param: str): - self._remote.send(f"{self.address}/{param}") - return self._remote.info_response + return self._remote.query(f"{self.address}/{param}") def setter(self, param: str, val: int): self._remote.send(f"{self.address}/{param}", val) diff --git a/xair_api/config.py b/xair_api/config.py index 9dc8d0b..98aaac2 100644 --- a/xair_api/config.py +++ b/xair_api/config.py @@ -13,8 +13,7 @@ class IConfig(abc.ABC): self._remote = remote def getter(self, param: str): - self._remote.send(f"{self.address}/{param}") - return self._remote.info_response + return self._remote.query(f"{self.address}/{param}") def setter(self, param: str, val: int): self._remote.send(f"{self.address}/{param}", val) diff --git a/xair_api/dca.py b/xair_api/dca.py index e7ed5b7..95d7074 100644 --- a/xair_api/dca.py +++ b/xair_api/dca.py @@ -11,8 +11,7 @@ class IDCA(abc.ABC): self.index = index + 1 def getter(self, param: str) -> tuple: - self._remote.send(f"{self.address}/{param}") - return self._remote.info_response + return self._remote.query(f"{self.address}/{param}") def setter(self, param: str, val: int): self._remote.send(f"{self.address}/{param}", val) diff --git a/xair_api/fx.py b/xair_api/fx.py index c8450af..d597657 100644 --- a/xair_api/fx.py +++ b/xair_api/fx.py @@ -13,8 +13,7 @@ class IFX(abc.ABC): self.index = index + 1 def getter(self, param: str): - self._remote.send(f"{self.address}/{param}") - return self._remote.info_response + return self._remote.query(f"{self.address}/{param}") def setter(self, param: str, val: int): self._remote.send(f"{self.address}/{param}", val) diff --git a/xair_api/lr.py b/xair_api/lr.py index 85236b4..8821779 100644 --- a/xair_api/lr.py +++ b/xair_api/lr.py @@ -15,8 +15,7 @@ class ILR(abc.ABC): self.index = index + 1 def getter(self, param: str): - self._remote.send(f"{self.address}/{param}") - return self._remote.info_response + return self._remote.query(f"{self.address}/{param}") def setter(self, param: str, val: int): self._remote.send(f"{self.address}/{param}", val) diff --git a/xair_api/rtn.py b/xair_api/rtn.py index 47a3c88..f9171ed 100644 --- a/xair_api/rtn.py +++ b/xair_api/rtn.py @@ -15,8 +15,7 @@ class IRtn(abc.ABC): self.index = index + 1 def getter(self, param: str): - self._remote.send(f"{self.address}/{param}") - return self._remote.info_response + return self._remote.query(f"{self.address}/{param}") def setter(self, param: str, val: int): self._remote.send(f"{self.address}/{param}", val) diff --git a/xair_api/strip.py b/xair_api/strip.py index 19800cf..448dcb7 100644 --- a/xair_api/strip.py +++ b/xair_api/strip.py @@ -13,8 +13,7 @@ class IStrip(abc.ABC): self.index = index + 1 def getter(self, param: str) -> tuple: - self._remote.send(f"{self.address}/{param}") - return self._remote.info_response + return self._remote.query(f"{self.address}/{param}") def setter(self, param: str, val: int): self._remote.send(f"{self.address}/{param}", val) diff --git a/xair_api/xair.py b/xair_api/xair.py index 8d3d7c5..485ec54 100644 --- a/xair_api/xair.py +++ b/xair_api/xair.py @@ -98,10 +98,10 @@ class XAirRemote(abc.ABC): def send(self, addr: str, param: Optional[str] = None): self.logger.debug(f"sending: {addr} {param if param is not None else ''}") self.server.send_message(addr, param) - time.sleep(self._delay) def query(self, address): self.send(address) + time.sleep(self._delay) return self.info_response def __exit__(self, exc_type, exc_value, exc_tr):