ophyd_async.tango.testing#
Package Contents#
Classes#
All members should exist in the Backend, and there will be no extras. |
|
Declarative ophyd-async Device pairing 1:1 with |
Functions#
Generate a random Tango domain/family prefix for use in test devices. |
|
Start a Tango device servers subprocess by running |
|
Build the TRL a device server subprocess serves |
Data#
API#
- ophyd_async.tango.testing.DEVICE_SERVERS#
None
- class ophyd_async.tango.testing.ExampleStrEnum[source]#
Bases:
ophyd_async.core.StrictEnumAll members should exist in the Backend, and there will be no extras.
- A#
‘AAA’
- B#
‘BBB’
- C#
‘CCC’
- class ophyd_async.tango.testing.TangoTestDevice(trl: str = '', name: str = '')[source]#
Bases:
ophyd_async.tango.core.TangoDevice,ophyd_async.core.StandardReadableDeclarative ophyd-async Device pairing 1:1 with
OneOfEverythingTangoDevice.Constructed with
auto_fill_signals=False, so only theseAnnotatedfields are created — a purely declarative Device, unlikeTangoDevice(trl)used on its own (the defaultauto_fill_signals=Trueprocedural/dynamic flavour, which discovers every attribute/command on the live proxy with no annotations at all). Both flavours connect to the exact same runningOneOfEverythingTangoDeviceserver instance and see identical values — seetests/system_tests/tango/core/test_tango_declarative_device.py.Field names must equal the server’s real Tango attribute/command names (Tango has no PvSuffix-equivalent indirection). A curated subset, not every datatype
OneOfEverythingTangoDeviceserves (that full matrix isOneOfEverythingTangoDeviceitself plus the fully-dynamicTangoDevice(trl)procedural flavour) — enough to demonstrate: scalar RW (a_str,a_bool), aStrictEnumfield (strenum), aDevState-backed enum (my_state), a numeric scalar with change-detect polling params (float64), a spectrum/array field (int32_spectrum), an image field (float64_image), a zero-argTriggerableCommand(void_cmd), and a typedCommand[P, T]with mismatched in/out types (float_to_bool_cmd).int32_spectrumis typednp.int_(platform-native width, notnp.int32) to match whatget_python_type(ophyd_async.tango.core) actually reports for Tango SPECTRUM attributes - it maps every signed integer Tango type to plainintregardless of width (unlike its own command return-type mapping, which is width-specific), so a width-specific annotation here would fail the connector’s datatype check even though nothing is wrong.np.int_/np.float64are used rather than bareint/floatonly becauseArray1D/np.dtypeneed annp.genericsubclass, not because the precision matters -np.dtype(np.int_) == np.dtype(int)andnp.dtype(np.float64) == np.dtype(float)are bothTrue.TangoPollingis given on every field even thoughOneOfEverythingTangoDeviceitself pushes Tango change events for all its attributes, becauseTangoDevice’s defaultsupport_events=Falsemeans the connector polls unless told otherwise — this mirrorsophyd_async.tango.demo.DemoMotor’s convention so copied-and-pasted reference code keeps working against servers that don’t push events.- a_str: Annotated[SignalRW[str], TangoPolling(0.1)]#
None
- a_bool: Annotated[SignalRW[bool], TangoPolling(0.1)]#
None
- strenum: Annotated[SignalRW[ExampleStrEnum], TangoPolling(0.1)]#
None
- my_state: Annotated[SignalRW[DevStateEnum], TangoPolling(0.1)]#
None
- float64: Annotated[SignalRW[float], TangoPolling(0.1, 0.001, 0.001)]#
None
- void_cmd: TriggerableCommand#
None
- ophyd_async.tango.testing.generate_random_trl_prefix() str[source]#
Generate a random Tango domain/family prefix for use in test devices.
- ophyd_async.tango.testing.start_tango_device_servers(script: Path, *args: str) ManagedSubprocess[source]#
Start a Tango device servers subprocess by running
scriptwithargs.Generic: doesn’t know or care which catalog
scriptis - e.g.ophyd_async.tango.testing.DEVICE_SERVERS(this package’s fixedbasic/everythingcatalog) orophyd_async.tango.demo.DEVICE_SERVERS(motor/channel/detector). Invoked with the current interpreter, not-m ophyd_async..., so the exact same argv works verbatim from a venv that doesn’t haveophyd_asyncinstalled at all. If you need a different Tango install/version, runscriptwith that venv’s python directly instead of going through this function - same as any other standalone script.- Parameters:
script – The script implementing the device server catalog to host.
args – Positional args for that script’s
__main__, e.g.(prefix, str(port))or(prefix, str(port), str(num_channels))- whatever that particular catalog’s script expects. You chooseportyourself, e.g. viaophyd_async.testing.find_free_port, and need to hang onto it to build TRLs afterwards (seetrlbelow).