ophyd_async.tango.core#
Package Contents#
Classes#
Used by the tango transport. |
|
Base class for protocol classes. |
|
Tango proxy for commands. |
|
Base class for protocol classes. |
|
All members should exist in the Backend, and there will be no extras. |
|
Tango backend to connect signals over tango. |
|
General class for TangoDevices. |
|
Abstract base class for generic types. |
|
Defines how a |
|
An abstraction of a Table where each field is a column. |
|
Abstract base class for generic types. |
|
An abstraction of a Table where each field is a column. |
|
Abstract base class for generic types. |
|
Abstract base class for generic types. |
|
Abstract base class for generic types. |
|
Abstract base class for generic types. |
|
Abstract base class for generic types. |
|
Abstract base class for generic types. |
|
A backend for executing commands on a Tango device. |
Functions#
Ensure decorated method has a proper asyncio executor. |
|
Convert Tango types to Python types based on the configuration. |
|
For converting tango types to numpy datatype formats. |
|
Get the tango resource locator. |
|
Infers the python type from the TRL. |
|
Create a |
|
Create a |
|
Create a |
|
Create a |
|
Attempt to cast a value to float, returning None on failure. |
|
Create a |
|
Create a |
|
API#
- class ophyd_async.tango.core.AttributeProxy(device_proxy: DeviceProxy, name: str)[source]#
Bases:
ophyd_async.tango.core._tango_transport.TangoProxyUsed by the tango transport.
- async connect() None[source]#
Perform actions after proxy is connected.
e.g. check if signal can be subscribed.
- async put(value: object | None, timeout: float | None = None) AsyncStatus | None[source]#
Put value to TRL.
- async get_config() AttributeConfig[source]#
Get TRL config async.
- class ophyd_async.tango.core.AttributeConfig[source]#
Bases:
typing.ProtocolBase class for protocol classes.
Protocol classes are defined as::
class Proto(Protocol): def meth(self) -> int: ...Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).
For example::
class C: def meth(self) -> int: return 0 def func(x: Proto) -> int: return x.meth() func(C()) # Passes static type checkSee PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as::
class GenProto(Protocol[T]): def meth(self) -> T: ...- data_format: AttrDataFormat#
None
- alarms: AttributeAlarmInfo#
None
- class ophyd_async.tango.core.CommandProxy(device_proxy: DeviceProxy, name: str)[source]#
Bases:
ophyd_async.tango.core._tango_transport.TangoProxyTango proxy for commands.
- device_proxy: DeviceProxy#
None
- abstractmethod subscribe_callback(callback: Callback | None) None[source]#
Subscribe tango CHANGE event to callback.
- async connect() None[source]#
Perform actions after proxy is connected.
e.g. check if signal can be subscribed.
- async get_config() CommandConfig[source]#
Get TRL config async.
- class ophyd_async.tango.core.CommandConfig[source]#
Bases:
typing.ProtocolBase class for protocol classes.
Protocol classes are defined as::
class Proto(Protocol): def meth(self) -> int: ...Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).
For example::
class C: def meth(self) -> int: return 0 def func(x: Proto) -> int: return x.meth() func(C()) # Passes static type checkSee PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as::
class GenProto(Protocol[T]): def meth(self) -> T: ...- in_type: CmdArgType#
None
- out_type: CmdArgType#
None
- class ophyd_async.tango.core.DevStateEnum[source]#
Bases:
ophyd_async.core.StrictEnumAll members should exist in the Backend, and there will be no extras.
- ON#
‘ON’
- OFF#
‘OFF’
- CLOSE#
‘CLOSE’
- OPEN#
‘OPEN’
- INSERT#
‘INSERT’
- EXTRACT#
‘EXTRACT’
- MOVING#
‘MOVING’
- STANDBY#
‘STANDBY’
- FAULT#
‘FAULT’
- INIT#
‘INIT’
- RUNNING#
‘RUNNING’
- ALARM#
‘ALARM’
- DISABLE#
‘DISABLE’
- UNKNOWN#
‘UNKNOWN’
- ophyd_async.tango.core.ensure_proper_executor(func: Callable[P, Coroutine[Any, Any, R]]) Callable[P, Coroutine[Any, Any, R]][source]#
Ensure decorated method has a proper asyncio executor.
- class ophyd_async.tango.core.TangoSignalBackend(datatype: type[SignalDatatypeT] | None, read_trl: str = '', write_trl: str = '', device_proxy: DeviceProxy | None = None)[source]#
Bases:
ophyd_async.core.SignalBackend[ophyd_async.core.SignalDatatypeT]Tango backend to connect signals over tango.
- source(name: str, read: bool) str[source]#
Return source of signal.
- Parameters:
name – The name of the signal, which can be used or discarded.
read – True if we want the source for reading, False if writing.
- async put(value: SignalDatatypeT | None, timeout=None) None[source]#
Put a value to the PV, if wait then wait for completion.
- async get_datakey(source: str) DataKey[source]#
Metadata like source, dtype, shape, precision, units.
- async get_reading() Reading[SignalDatatypeT][source]#
Return the current value, timestamp and severity.
- async get_value() SignalDatatypeT[source]#
Return the current value.
- async get_setpoint() SignalDatatypeT[source]#
Return the point that a signal was requested to move to.
- set_callback(callback: Callback | None) None[source]#
Observe changes to the current value, timestamp and severity.
- ophyd_async.tango.core.get_python_type(config: AttributeConfig | CommandConfig, return_input_type: bool = False) type[SignalDatatype] | None[source]#
Convert Tango types to Python types based on the configuration.
- ophyd_async.tango.core.get_dtype_extended(datatype) object | None[source]#
For converting tango types to numpy datatype formats.
- ophyd_async.tango.core.get_source_metadata(tango_resource: str, tr_configs: dict[str, AttributeConfig | CommandConfig]) SignalMetadata[source]#
- async ophyd_async.tango.core.get_tango_trl(full_trl: str, device_proxy: DeviceProxy | TangoProxy | None, timeout: float) TangoProxy[source]#
Get the tango resource locator.
- async ophyd_async.tango.core.infer_python_type(trl: str = '', proxy: DeviceProxy | None = None) tuple[type[SignalDatatype] | None, type[SignalDatatype] | None][source]#
Infers the python type from the TRL.
- async ophyd_async.tango.core.infer_signal_type(trl, proxy: DeviceProxy | None = None) type[Signal] | type[Command] | None[source]#
- ophyd_async.tango.core.make_backend(datatype: type[SignalDatatypeT] | None, read_trl: str = '', write_trl: str = '') TangoSignalBackend[source]#
- ophyd_async.tango.core.parse_precision(config: AttributeConfig)[source]#
- ophyd_async.tango.core.tango_signal_r(datatype: type[SignalDatatypeT], read_trl: str, timeout: float = DEFAULT_TIMEOUT, name: str = '') SignalR[SignalDatatypeT][source]#
Create a
SignalRbacked by 1 Tango Attribute/Command.Parameters
datatype: Check that the Attribute/Command is of this type read_trl: The Attribute/Command to read and monitor timeout: The timeout for the read operation name: The name of the Signal
- ophyd_async.tango.core.tango_signal_rw(datatype: type[SignalDatatypeT], read_trl: str, write_trl: str = '', timeout: float = DEFAULT_TIMEOUT, name: str = '') SignalRW[SignalDatatypeT][source]#
Create a
SignalRWbacked by 1 or 2 Tango Attribute/Command.Parameters
datatype: Check that the Attribute/Command is of this type read_trl: The Attribute/Command to read and monitor write_trl: If given, use this Attribute/Command to write to, otherwise use read_trl timeout: The timeout for the read and write operations name: The name of the Signal
- ophyd_async.tango.core.tango_signal_w(datatype: type[SignalDatatypeT], write_trl: str, timeout: float = DEFAULT_TIMEOUT, name: str = '') SignalW[SignalDatatypeT][source]#
Create a
SignalWbacked by 1 Tango Attribute/Command.Parameters
datatype: Check that the Attribute/Command is of this type write_trl: The Attribute/Command to write to timeout: The timeout for the write operation name: The name of the Signal
- ophyd_async.tango.core.tango_signal_x(write_trl: str, timeout: float = DEFAULT_TIMEOUT, name: str = '') SignalX[source]#
Create a
SignalXbacked by 1 Tango Attribute/Command.Deprecated since version 0.19: Use
tango_triggerable_commandinstead.Parameters
write_trl: The Attribute/Command to write its initial value to on execute timeout: The timeout for the command operation name: The name of the Signal
- class ophyd_async.tango.core.TangoDevice(trl: str = '', support_events: bool = False, name: str = '', auto_fill_signals: bool = True)[source]#
Bases:
ophyd_async.core.DeviceGeneral class for TangoDevices.
Extends Device to provide attributes for Tango devices.
- Parameters:
trl – Tango resource locator, typically of the device server. An asynchronous DeviceProxy object will be created using the trl and awaited when the device is connected.
- class ophyd_async.tango.core.TangoPolling[source]#
Bases:
typing.Generic[ophyd_async.tango.core._base_device.T]Abstract base class for generic types.
A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as::
class Mapping(Generic[KT, VT]): def getitem(self, key: KT) -> VT: … # Etc.
This class can then be used as follows::
def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default
- class ophyd_async.tango.core.TangoDeviceConnector(trl: str | None, support_events: bool, auto_fill_signals: bool = True)[source]#
Bases:
ophyd_async.core.DeviceConnectorDefines how a
Deviceshould be connected and type hints processed.- create_children_from_annotations(device: Device)[source]#
Use when children can be created from introspecting the hardware.
Some control systems allow introspection of a device to determine what children it has. To allow this to work nicely with typing we add these hints to the Device like so::
my_signal: SignalRW[int] my_device: MyDevice
This method will be run during
Device.__init__, and is responsible for turning all of those type hints into real Signal and Device instances.Subsequent runs of this function should do nothing, to allow it to be called early in Devices that need to pass references to their children during
__init__.
- async connect_mock(device: Device, mock: LazyMock)[source]#
Use during
Device.connectwithmock=True.This is called when there is no cached connect done in
mock=Truemode. It connects the Device and all its children in mock mode.
- class ophyd_async.tango.core.TangoLongStringTable(**kwargs)[source]#
Bases:
ophyd_async.core.TableAn abstraction of a Table where each field is a column.
For example:
>>> from ophyd_async.core import Table, Array1D >>> import numpy as np >>> from collections.abc import Sequence >>> class MyTable(Table): ... a: Array1D[np.int8] ... b: Sequence[str] ... >>> t = MyTable(a=[1, 2], b=["x", "y"]) >>> len(t) # the length is the number of rows 2 >>> t2 = t + t # adding tables together concatenates them >>> t2.a array([1, 2, 1, 2], dtype=int8) >>> t2.b ['x', 'y', 'x', 'y'] >>> t2[1] # slice a row array([(2, b'y')], dtype=[('a', 'i1'), ('b', 'S40')])
- class ophyd_async.tango.core.TangoLongStringTableConverter[source]#
Bases:
ophyd_async.tango.core._converters.TangoConverter[ophyd_async.tango.core._utils.TangoLongStringTable]Abstract base class for generic types.
A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as::
class Mapping(Generic[KT, VT]): def getitem(self, key: KT) -> VT: … # Etc.
This class can then be used as follows::
def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default
- class ophyd_async.tango.core.TangoDoubleStringTable(**kwargs)[source]#
Bases:
ophyd_async.core.TableAn abstraction of a Table where each field is a column.
For example:
>>> from ophyd_async.core import Table, Array1D >>> import numpy as np >>> from collections.abc import Sequence >>> class MyTable(Table): ... a: Array1D[np.int8] ... b: Sequence[str] ... >>> t = MyTable(a=[1, 2], b=["x", "y"]) >>> len(t) # the length is the number of rows 2 >>> t2 = t + t # adding tables together concatenates them >>> t2.a array([1, 2, 1, 2], dtype=int8) >>> t2.b ['x', 'y', 'x', 'y'] >>> t2[1] # slice a row array([(2, b'y')], dtype=[('a', 'i1'), ('b', 'S40')])
- class ophyd_async.tango.core.TangoDoubleStringTableConverter[source]#
Bases:
ophyd_async.tango.core._converters.TangoConverter[ophyd_async.tango.core._utils.TangoDoubleStringTable]Abstract base class for generic types.
A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as::
class Mapping(Generic[KT, VT]): def getitem(self, key: KT) -> VT: … # Etc.
This class can then be used as follows::
def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default
- class ophyd_async.tango.core.TangoConverter[source]#
Bases:
typing.Generic[ophyd_async.core.SignalDatatypeT]Abstract base class for generic types.
A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as::
class Mapping(Generic[KT, VT]): def getitem(self, key: KT) -> VT: … # Etc.
This class can then be used as follows::
def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default
- class ophyd_async.tango.core.TangoEnumConverter(labels: list[str])[source]#
Bases:
ophyd_async.tango.core._converters.TangoConverterAbstract base class for generic types.
A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as::
class Mapping(Generic[KT, VT]): def getitem(self, key: KT) -> VT: … # Etc.
This class can then be used as follows::
def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default
- class ophyd_async.tango.core.TangoEnumArrayConverter(labels: list[str])[source]#
Bases:
ophyd_async.tango.core._converters.TangoConverterAbstract base class for generic types.
A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as::
class Mapping(Generic[KT, VT]): def getitem(self, key: KT) -> VT: … # Etc.
This class can then be used as follows::
def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default
- class ophyd_async.tango.core.TangoDevStateConverter[source]#
Bases:
ophyd_async.tango.core._converters.TangoConverterAbstract base class for generic types.
A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as::
class Mapping(Generic[KT, VT]): def getitem(self, key: KT) -> VT: … # Etc.
This class can then be used as follows::
def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default
- class ophyd_async.tango.core.TangoDevStateArrayConverter[source]#
Bases:
ophyd_async.tango.core._converters.TangoConverterAbstract base class for generic types.
A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as::
class Mapping(Generic[KT, VT]): def getitem(self, key: KT) -> VT: … # Etc.
This class can then be used as follows::
def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default
- ophyd_async.tango.core.try_to_cast_as_float(value: Any) float | None[source]#
Attempt to cast a value to float, returning None on failure.
- class ophyd_async.tango.core.TangoCommandBackend(call_spec: Signature | None, trl: str = '', device_proxy: DeviceProxy | None = None)[source]#
Bases:
ophyd_async.core.CommandBackend[ophyd_async.tango.core._utils.P,ophyd_async.tango.core._utils.T]A backend for executing commands on a Tango device.
Interfaces with a Tango device command via a
CommandProxy, handling connection, type conversion, and execution while enforcing Tango’s limitations (no keyword arguments, single positional argument).- Parameters:
call_spec – Type signature of the Tango command, or
Nonefor void/void commands.trl – The Tango Resource Locator of the command, e.g.
tango://host:port/device/command.device_proxy – An optional pre-configured
DeviceProxyto use instead of creating one fromtrl.
- ophyd_async.tango.core.tango_command(call_spec: Callable[P, T], trl: str, device_proxy: DeviceProxy | None = None, *, timeout: float | None = DEFAULT_TIMEOUT, name: str = '') Command[P, T][source]#
Create a
Commandbacked by a Tango device command.For void/void Tango commands use
tango_triggerable_commandinstead. Tango commands only accept positional arguments; passing keyword arguments raisesTypeError.- Parameters:
call_spec – A callable whose signature matches that of the Tango command, used to infer parameter and return types.
trl – The Tango Resource Locator of the command, e.g.
tango://host:port/device/command.device_proxy – An optional pre-configured
DeviceProxy; if omitted one is created fromtrl.timeout – Timeout in seconds for connecting to the Tango device.
name – Name for the command device node.
- ophyd_async.tango.core.tango_triggerable_command(trl: str, device_proxy: DeviceProxy | None = None, *, timeout: float | None = DEFAULT_TIMEOUT, name: str = '') TriggerableCommand[source]#
Create a
TriggerableCommandbacked by a void/void Tango device command.Use this for Tango commands that take no arguments and return no value. For commands with arguments or a return type use
tango_command.- Parameters:
trl – The Tango Resource Locator of the command, e.g.
tango://host:port/device/command.device_proxy – An optional pre-configured
DeviceProxy; if omitted one is created fromtrl.timeout – Timeout in seconds for connecting to the Tango device.
name – Name for the command device node.
- ophyd_async.tango.core.sig_from_types(in_type: type[SignalDatatype] | None, out_type: type[SignalDatatype] | None)[source]#
- ophyd_async.tango.core.make_converter(info: AttributeConfig | CommandConfig, datatype) TangoConverter[source]#