From 6c02ccbd69194e1c0ed0396ee746a043946d3b8e Mon Sep 17 00:00:00 2001 From: PONS Date: Fri, 11 Sep 2026 14:41:24 +0200 Subject: [PATCH] Dynamic catalog as default --- .pre-commit-config.yaml | 14 +++++++------- pyaml_cs_oa/controlsystem.py | 19 +++++++++++++++++-- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 38805b4..75f5e97 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/controlsystem.py b/pyaml_cs_oa/controlsystem.py index ccbdfea..35d0359 100644 --- a/pyaml_cs_oa/controlsystem.py +++ b/pyaml_cs_oa/controlsystem.py @@ -13,6 +13,7 @@ from . import __version__ from .aggregator import OAAggregator from .catalog import Catalog +from .dynamic_catalog import DynamicCatalog from .epicsR import EpicsR from .epicsRW import EpicsRW from .epicsW import EpicsW @@ -33,6 +34,8 @@ def __init__( self, name: str, prefix: str = "", + backend: str | None = None, + timeout_ms: int = 3000, catalog: Catalog | None = None, debug_level: str | int | None = None, ): @@ -45,9 +48,13 @@ def __init__( prefix : str, optional Prefix added to the PV or attribute name. It can be a for instance, TANGO_HOST, or a PV prefix. + backend: str + Type of backend (Tango or EPCIS) to use when no catalog is specified. + timeout_ms: int + Default hardware access timeout in milliseconds. catalog : Catalog or None, optional Catalog instance or catalog name used to resolve PyAML device keys. - If None specified a dynamic catalog is used. + If None specified a dynamic catalog is used according to backend property. debug_level : str | int | None, optional Debug verbosity level. Such as INFO, DEBUG, WARNING, ERROR, CRITICAL. Or 10, 20, 30, 40, 50. """ @@ -55,8 +62,10 @@ def __init__( super().__init__() self._name = name self._prefix = prefix + self._backend = backend self._catalog = catalog self._debug_level = debug_level + self._timeout_ms = timeout_ms self._devices: dict[str, DeviceAccess] = {} # Dict containing all attached DeviceAccess if self._debug_level: @@ -69,6 +78,12 @@ def __init__( f" and prefix='{self._prefix}'", ) + if self._catalog is None: + if self._backend is None: + raise PyAMLException("When no catalog is specified, you have to specify which type of backend to use.") + else: + self._catalog = DynamicCatalog(backend=self._backend, timeout_ms=self._timeout_ms) + def attach(self, devs: list[OASignal | None]) -> list[OASignal | None]: """Attach configured signals; retained for compatibility.""" # Deprecated function @@ -161,4 +176,4 @@ def get_aggregator(self) -> DeviceAccessList | None: return OAAggregator() def __repr__(self): - return __pyaml_repr__() + return __pyaml_repr__(self)