Beta models: full function once added, only a note in the add-device form
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
86ee492ec3
commit
f7d5e22bb0
9 files changed
+28
-86
No files matched your search
+2
-16
@@ -22,14 +22,12 @@ class Device:
|
||||
def __init__(self, dev_id: str, name: str, host: str, port: int = P.PORT, model: str = "auto",
|
||||
addr: int = 1, autoconnect: bool = True, on_event=None, transport: str = "tcp", usb: str = "",
|
||||
lock_code: str = "", auto_unlock: bool = False, test_saved: list | None = None,
|
||||
colors: dict | None = None, maxgain: dict | None = None, linknames: dict | None = None,
|
||||
beta_write: bool = False):
|
||||
colors: dict | None = None, maxgain: dict | None = None, linknames: dict | None = None):
|
||||
self.id = dev_id
|
||||
self.name = name
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.model_key = model # "auto" or a key of P.MODELS
|
||||
self.beta_write = beta_write # beta models: the user has checked the shown values and allowed changes
|
||||
self.addr = addr
|
||||
self.autoconnect = autoconnect
|
||||
self.transport = "usb" if transport == "usb" else "tcp"
|
||||
@@ -77,8 +75,7 @@ class Device:
|
||||
"model": self.model_key, "addr": self.addr, "autoconnect": self.autoconnect,
|
||||
"transport": self.transport, "usb": self.usb,
|
||||
"lock_code": self.lock_code, "auto_unlock": self.auto_unlock, "test_saved": self.test_saved,
|
||||
"colors": self.colors, "maxgain": self.maxgain, "linknames": self.linknames,
|
||||
"beta_write": self.beta_write}
|
||||
"colors": self.colors, "maxgain": self.maxgain, "linknames": self.linknames}
|
||||
|
||||
def snapshot(self) -> dict:
|
||||
cfg = self.config()
|
||||
@@ -88,7 +85,6 @@ class Device:
|
||||
"detected_model": self.model_name or None,
|
||||
"n_in": self.model.n_in if self.model else 0,
|
||||
"n_out": self.model.n_out if self.model else 0,
|
||||
"beta": bool(self.model and self.model.beta), "read_only": self.read_only,
|
||||
"presets": self.presets, "state": self.state}
|
||||
|
||||
def start(self):
|
||||
@@ -108,17 +104,10 @@ class Device:
|
||||
await self._close()
|
||||
self._set_status("disconnected")
|
||||
|
||||
@property
|
||||
def read_only(self) -> bool:
|
||||
"""A beta model only reads until the user has compared the shown values with the DSP."""
|
||||
return bool(self.model and self.model.beta and not self.beta_write)
|
||||
|
||||
def set_param(self, kind: str, idx: int, param: str, value):
|
||||
"""Update local state and queue the command (coalesced per parameter)."""
|
||||
if not self.state or not self.model:
|
||||
raise RuntimeError("device not loaded")
|
||||
if self.read_only:
|
||||
raise RuntimeError("Beta model: changes are off")
|
||||
chans = self.state["inputs" if kind == "in" else "outputs"]
|
||||
ch = chans[idx]
|
||||
if param == "name":
|
||||
@@ -343,9 +332,6 @@ class Device:
|
||||
"""Send one command and wait for its answer (the DSP is strictly request/response)."""
|
||||
if not self._writer:
|
||||
raise ConnectionError("not connected")
|
||||
if self.read_only and cmd not in P.READ_COMMANDS:
|
||||
log.warning("%s: read-only, command 0x%02x not sent", self.name, cmd)
|
||||
return None
|
||||
async with self._lock:
|
||||
deadline = time.monotonic() + timeout
|
||||
self._writer.write(P.build_frame(cmd, payload, self.addr))
|
||||
|
||||
Reference in new issue
Block a user