delay kwarg added.

delay added to README

delay for test suites reduced to 0.008

main stereo added to adapter tests
This commit is contained in:
onyx-and-iris 2022-11-08 15:09:20 +00:00
parent 7015383b98
commit 0b20ac953f
5 changed files with 54 additions and 26 deletions

View File

@ -55,7 +55,7 @@ if __name__ == "__main__":
main()
```
## API
#### `xair_api.connect(kind_id, ip=ip, delay=delay)`
Currently the following devices are supported:
@ -64,7 +64,16 @@ Currently the following devices are supported:
- `XR16`
- `XR12`
The `X32` is partially supported. This document covers specifically the `XAir` series, however.
The `X32` is partially supported. However, this document covers specifically the `XAir` series.
The following keyword arguments may be passed:
- `ip`: ip address of the mixer
- `port`: mixer port, defaults to 10023 for x32 and 10024 for xair
- `delay`: a delay between each command, defaults to 20ms.
- a note about delay, stability may rely on network connection. For wired connections the delay can be safely reduced.
## API
### XAirRemote class (higher level)

View File

@ -8,7 +8,7 @@ from xair_api import kinds
kind_id = "X32"
ip = "x32.local"
tests = xair_api.connect(kind_id, ip=ip)
tests = xair_api.connect(kind_id, ip=ip, delay=0.008)
kind = kinds.get(kind_id)

View File

@ -47,20 +47,20 @@ class TestSetAndGetBusConfigHigher:
""" AUXIN TESTS """
class TestSetAndGetAuxInConfigHigher:
"""Config"""
class TestSetAndGetAuxInPreampHigher:
"""Preamp"""
__test__ = True
def setup_class(self):
self.target = getattr(tests, "auxin")
self.target = getattr(self.target[data.auxrtn], "config")
self.target = getattr(self.target[data.auxrtn], "preamp")
@pytest.mark.parametrize(
"param,value",
[("name", "test0"), ("name", "test1")],
[("invert", True), ("invert", False)],
)
def test_it_sets_and_gets_auxrtn_string_params(self, param, value):
def test_it_sets_and_gets_auxrtn_bool_params(self, param, value):
setattr(self.target, param, value)
assert getattr(self.target, param) == value
@ -68,20 +68,20 @@ class TestSetAndGetAuxInConfigHigher:
""" FX RETURN TESTS """
class TestSetAndGetFXReturnConfigHigher:
"""Config"""
class TestSetAndGetFXReturnEQHigher:
"""EQ"""
__test__ = True
def setup_class(self):
self.target = getattr(tests, "fxreturn")
self.target = getattr(self.target[data.fx], "config")
self.target = getattr(self.target[data.fx], "eq")
@pytest.mark.parametrize(
"param,value",
[("name", "test0"), ("name", "test1")],
[("on", True), ("on", False)],
)
def test_it_sets_and_gets_fxrtn_string_params(self, param, value):
def test_it_sets_and_gets_fxrtn_bool_params(self, param, value):
setattr(self.target, param, value)
assert getattr(self.target, param) == value
@ -89,19 +89,39 @@ class TestSetAndGetFXReturnConfigHigher:
""" MATRIX TESTS """
class TestSetAndGetMatrixConfigHigher:
"""Config"""
class TestSetAndGetMatrixDynHigher:
"""Dyn"""
__test__ = True
def setup_class(self):
self.target = getattr(tests, "matrix")
self.target = getattr(self.target[data.matrix], "config")
self.target = getattr(self.target[data.matrix], "dyn")
@pytest.mark.parametrize(
"param,value",
[("name", "test0"), ("name", "test1")],
[("mode", "comp"), ("mode", "exp")],
)
def test_it_sets_and_gets_matrix_string_params(self, param, value):
setattr(self.target, param, value)
assert getattr(self.target, param) == value
""" MAIN STEREO TESTS """
class TestSetAndGetMainStereoInsertHigher:
"""Insert"""
__test__ = True
def setup_class(self):
self.target = getattr(tests, "mainst")
@pytest.mark.parametrize(
"param,value",
[("mode", "comp"), ("mode", "exp")],
)
def test_it_sets_and_gets_mainst_string_params(self, param, value):
setattr(self.target, param, value)
assert getattr(self.target, param) == value

View File

@ -8,7 +8,7 @@ from xair_api import kinds
kind_id = "MR18"
ip = "mixer.local"
tests = xair_api.connect(kind_id, ip=ip)
tests = xair_api.connect(kind_id, ip=ip, delay=0.008)
kind = kinds.get(kind_id)

View File

@ -48,8 +48,6 @@ class XAirRemote(abc.ABC):
logger = logging.getLogger("xair.xairremote")
_CONNECT_TIMEOUT = 0.5
_WAIT_TIME = 0.025
_REFRESH_TIMEOUT = 5
_info_response = []
@ -58,8 +56,9 @@ class XAirRemote(abc.ABC):
dispatcher.set_default_handler(self.msg_handler)
self.xair_ip = kwargs["ip"] or self._ip_from_toml()
self.xair_port = kwargs["port"]
if not (self.xair_ip and self.xair_port):
raise XAirRemoteError("No valid ip or password detected")
self._delay = kwargs["delay"]
if not self.xair_ip:
raise XAirRemoteError("No valid ip detected")
self.server = OSCClientServer((self.xair_ip, self.xair_port), dispatcher)
def __enter__(self):
@ -79,7 +78,7 @@ class XAirRemote(abc.ABC):
time.sleep(self._CONNECT_TIMEOUT)
if not self.info_response:
raise XAirRemoteError(
"Error: Failed to setup OSC connection to mixer. Please check for correct ip address."
"Failed to setup OSC connection to mixer. Please check for correct ip address."
)
print(
f"Successfully connected to {self.info_response[2]} at {self.info_response[0]}."
@ -99,7 +98,7 @@ 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._WAIT_TIME)
time.sleep(self._delay)
def query(self, address):
self.send(address)
@ -117,7 +116,7 @@ def _make_remote(kind: KindMap) -> XAirRemote:
"""
def init_x32(self, *args, **kwargs):
defaultkwargs = {"ip": None, "port": 10023}
defaultkwargs = {"ip": None, "port": 10023, "delay": 0.02}
kwargs = defaultkwargs | kwargs
XAirRemote.__init__(self, *args, **kwargs)
self.kind = kind
@ -135,7 +134,7 @@ def _make_remote(kind: KindMap) -> XAirRemote:
self.config = Config.make(self)
def init_xair(self, *args, **kwargs):
defaultkwargs = {"ip": None, "port": 10024}
defaultkwargs = {"ip": None, "port": 10024, "delay": 0.02}
kwargs = defaultkwargs | kwargs
XAirRemote.__init__(self, *args, **kwargs)
self.kind = kind