From b47dc9707e7d802480dbad89ef9264fda3609221 Mon Sep 17 00:00:00 2001 From: PONS Date: Tue, 8 Sep 2026 13:20:00 +0200 Subject: [PATCH 1/2] Fix signal name method --- .pre-commit-config.yaml | 14 +++++++------- pyaml_cs_oa/signal.py | 11 ++++++++++- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 75f5e97..38805b4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,10 +12,10 @@ repos: args: [--fix] - id: ruff-format -# - repo: https://github.com/pre-commit/mirrors-mypy -# rev: v1.18.2 -# hooks: -# - id: mypy -# additional_dependencies: [ -# "pydantic>=2.0", -# ] + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.18.2 + hooks: + - id: mypy + additional_dependencies: [ + "pydantic>=2.0", + ] diff --git a/pyaml_cs_oa/signal.py b/pyaml_cs_oa/signal.py index 3cb7de2..e39450d 100644 --- a/pyaml_cs_oa/signal.py +++ b/pyaml_cs_oa/signal.py @@ -34,6 +34,8 @@ def build(self): self.SP, self.RB = get_SP_RB(self._cfg) + self._readable = self.SP + if self.SP: self.SP.__peer__ = self if self.RB: @@ -45,7 +47,14 @@ def get_cs(self) -> str: def name(self) -> str: """Return the backend signal name.""" - return self._signal.name + if isinstance(self._cfg, EpicsConfigR): + return self._cfg.read_pvname + elif isinstance(self._cfg, (EpicsConfigW, EpicsConfigRW)): + return self._cfg.write_pvname + elif isinstance(self._cfg, TangoConfigAtt): + return self._cfg.attribute + else: + raise ValueError(f"Unsupported control system config type: {type(self._cfg)!r}") def measure_name(self) -> str: """Return the configured process-variable or attribute name.""" From f7acdee9a027902c63baf3a8ee19fc718e2fec99 Mon Sep 17 00:00:00 2001 From: PONS Date: Tue, 8 Sep 2026 14:56:07 +0200 Subject: [PATCH 2/2] Fix with RO Tango attribute --- pyaml_cs_oa/container.py | 1 - pyaml_cs_oa/signal.py | 11 ++++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pyaml_cs_oa/container.py b/pyaml_cs_oa/container.py index 4a4872a..c28b76e 100644 --- a/pyaml_cs_oa/container.py +++ b/pyaml_cs_oa/container.py @@ -61,7 +61,6 @@ async def _run_get(self) -> SignalDatatypeT: """Connect and fetch the backend's current value.""" await self._r_sig.connect() backend = self._r_sig._connector.backend - print(f"Read {self._r_sig.name}") return await backend.get_value() async def async_get(self) -> SignalDatatypeT: diff --git a/pyaml_cs_oa/signal.py b/pyaml_cs_oa/signal.py index e39450d..6f6c64d 100644 --- a/pyaml_cs_oa/signal.py +++ b/pyaml_cs_oa/signal.py @@ -34,7 +34,16 @@ def build(self): self.SP, self.RB = get_SP_RB(self._cfg) - self._readable = self.SP + # FIXME: Find a way using Ophyd to get attribute config to see if the TangoAtt is R or RW + # rather than creating a DeviceProxy for nothing + # Work around the issue by checking that the setpoint is None + if isinstance(self._cfg, TangoConfigAtt): + try: + setpoint = self.SP.get() + if setpoint is None: + self._writable = False + except Exception as ex: + ... if self.SP: self.SP.__peer__ = self