Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
# ]
19 changes: 17 additions & 2 deletions pyaml_cs_oa/controlsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
):
Expand All @@ -45,18 +48,24 @@ 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.
"""

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:
Expand All @@ -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
Expand Down Expand Up @@ -161,4 +176,4 @@ def get_aggregator(self) -> DeviceAccessList | None:
return OAAggregator()

def __repr__(self):
return __pyaml_repr__()
return __pyaml_repr__(self)
Loading