devices#
Import: hklpy2.devices
Ophyd device construction helpers for hklpy2.
These utilities are called during diffractometer creation to build ophyd
Component and Device objects dynamically from axis specifications
and factory configurations.
|
Base class for a diffractometer's virtual axis. |
|
Return class and kwargs of a real axis from its 'specs'. |
|
Create a |
|
Import the object given its import path as text. |
|
Create an |
|
Return an instance of the Python 'call_name'. |
|
Parse a set of axis specifications, return Device class attributes. |
Module Contents#
- class hklpy2.devices.VirtualPositionerBase(*, physical_name: str = '', **kwargs)[source]#
Import:
hklpy2.devices.VirtualPositionerBaseBases:
ophyd.SoftPositionerBase class for a diffractometer’s virtual axis.
This base class also serves as an example where the virtual axis is twice the value of the physical axis. It is used as a Component of a ‘DiffractometerBase’ definition. The
physical_nameis the name of a sibling positioner attribute.- forward(physical: float) float[source]#
Return virtual position from physical position.
Subclass should override.
- hklpy2.devices.define_real_axis(specs: None | str | KeyValueMap, kwargs: KeyValueMap) tuple[str, Sequence, Mapping][source]#
Import:
hklpy2.devices.define_real_axisReturn class and kwargs of a real axis from its ‘specs’.
- hklpy2.devices.describe_aux(diffractometer: object, name: str) dict[source]#
Import:
hklpy2.devices.describe_auxBuild a single
axes.auxiliary_axesrecord forname.Categorises the auxiliary into one of the schema-v2 categories:
"scalar"— a plainPositionerBase(the historic default; the round-tripped simulator stand-in is anSoftPositioner)."pseudo_positioner"— a nestedPseudoPositioner; sub-axis names are recorded as orderedpseudos/realslists.class/moduleare advisory metadata only — never imported by hklpy2 on restore.
- hklpy2.devices.dict_device_factory(data: KeyValueMap, **kwargs: Any) type[source]#
Import:
hklpy2.devices.dict_device_factoryCreate a
DictionaryDevice()class using the supplied dictionary.
- hklpy2.devices.dynamic_import(full_path: str) type[source]#
Import:
hklpy2.devices.dynamic_importImport the object given its import path as text.
Motivated by specification of class names for plugins when using
apstools.devices.ad_creator().EXAMPLES:
klass = dynamic_import("ophyd.EpicsMotor") m1 = klass("gp:m1", name="m1") creator = dynamic_import("hklpy2.diffract.creator") fourc = creator(name="fourc")
From the apstools package.
- hklpy2.devices.make_aux_pseudo_positioner_class(name: str, pseudos: Sequence[str], reals: Sequence[str]) type[source]#
Import:
hklpy2.devices.make_aux_pseudo_positioner_classBuild a synthetic
PseudoPositionersubclass with the given sub-axis names.The resulting class is structural only:
forward()andinverse()return zeros for every sub-axis. Its purpose is to let downstream code (printers, plan inspection, etc.) traverse the same component tree the original device exposed.
- hklpy2.devices.make_component(call_name: Any, *args: Any, **kwargs: Any) Component[source]#
Import:
hklpy2.devices.make_componentCreate an
Componentfor a custom ophyd Device class.call_namemay be either a dotted import path (str) or an already-resolved callable (type). The callable form is used byhklpy2.run_utils.simulator_from_config()when restoring a nestedPseudoPositionerauxiliary whose synthetic stand-in class is built at runtime and therefore cannot be addressed by an import path.Changed in version 0.7.0: Accept a callable in addition to a dotted import-path string. See issue #388.
- hklpy2.devices.make_dynamic_instance(call_name: str, *args: Any, **kwargs: Any) Any[source]#
Import:
hklpy2.devices.make_dynamic_instanceReturn an instance of the Python ‘call_name’.
- hklpy2.devices.parse_factory_axes(*, space: str | None = None, axes: KeyValueMap | None | Sequence[str] = None, order: Sequence[str] | None = None, canonical: Sequence[str] | None = None, labels: Sequence[str] | None = None, **_ignored: Any) Mapping[str, Component | Sequence[str]][source]#
Import:
hklpy2.devices.parse_factory_axesParse a set of axis specifications, return Device class attributes.
Called from the diffract.diffractometer_class_factory().