secop_ophyd.util#

Module Contents#

Classes#

Functions#

deep_get

dt_factory

secop_enum_name_to_python

Convert SECoP enum member name to Python identifier.

command_dtype_to_python_type

Map a SECoP command argument/result datatype to a plain python type.

python_type_to_str

Render a python type object as it should appear in generated source, e.g. int -> “int”, dict[str, Any] -> “dict[str, Any]”.

command_dtype_to_annotation_str

Render a SECoP command argument/result datatype as a python type string, e.g. for use in a generated Command[[ArgT], ResT] annotation.

build_command_signature

Build the call signature for a SECoP command’s argument(s)/result.

Data#

API#

secop_ophyd.util.SCALAR_DATATYPES = ()#
class secop_ophyd.util.SECoPDataKey[source]#

Bases: event_model.DataKey

A DataKey that is used to describe the SECoP Datatype.

Initialization

Initialize self. See help(type(self)) for accurate signature.

dtype_str: typing_extensions.NotRequired[str] = None#

The array-protocol typestring of the data-type object.

dtype_descr: typing_extensions.NotRequired[list] = None#

String representation of the numpy structured array dtype.

SECOP_datainfo: str = None#

String representation of the original secop datatype.

SECoP_dtype: typing_extensions.NotRequired[str] = None#

The SECoP datatype of the data.

exception secop_ophyd.util.NestedRaggedArray[source]#

Bases: Exception

The Datatype contains nested ragged arrays

Initialization

Initialize self. See help(type(self)) for accurate signature.

secop_ophyd.util.deep_get(dictionary, keys, default=None) dict[source]#
class secop_ophyd.util.Path(parameter_name: str, module_name: str)[source]#

Initialization

append(elem: Union[str, int]) secop_ophyd.util.Path[source]#
get_param_path()[source]#
get_path_tuple()[source]#
get_memberinfo_path()[source]#
get_signal_name()[source]#
get_param_desc_path()[source]#
get_cmd_desc_path()[source]#
get_leaf()[source]#
insert_val(dic: dict, new_val)[source]#
class secop_ophyd.util.DtypeNP[source]#

Bases: abc.ABC

secop_dtype: frappy.datatypes.DataType = None#
name: str | None = None#
array_element: bool = False#
max_depth: int = 0#
abstractmethod make_numpy_dtype() tuple[source]#

Create Numpy Compatible structured Datatype

abstractmethod make_concrete_numpy_dtype(value) tuple[source]#

Create Numpy Compatible structured Datatype from a concrete data value

abstractmethod make_numpy_compatible_list(value) Any[source]#

make a make a list that is ready for numpy array import

abstractmethod make_secop_compatible_object(value) Any[source]#

make a make an SECoP Compatible Object

secop_ophyd.util.dt_factory(secop_dt: frappy.datatypes.DataType, name: str = '', array_element: bool = False) secop_ophyd.util.DtypeNP[source]#
secop_ophyd.util.STR_LEN_DEFAULT = 100#
class secop_ophyd.util.BLOBNP(blob_dt: frappy.datatypes.BLOBType, name: str = '', array_element: bool = False)[source]#

Bases: secop_ophyd.util.DtypeNP

make_numpy_dtype() tuple[source]#
make_concrete_numpy_dtype(value) tuple[source]#
make_numpy_compatible_list(value: str)[source]#
make_secop_compatible_object(value) Any[source]#
class secop_ophyd.util.BoolNP(bool_dt: frappy.datatypes.BoolType, name: str = '', array_element: bool = False)[source]#

Bases: secop_ophyd.util.DtypeNP

make_numpy_dtype() tuple[source]#
make_concrete_numpy_dtype(value) tuple[source]#
make_numpy_compatible_list(value: bool)[source]#
make_secop_compatible_object(value) Any[source]#
class secop_ophyd.util.EnumNP(enum_dt: frappy.datatypes.EnumType, name: str = '', array_element: bool = False)[source]#

Bases: secop_ophyd.util.DtypeNP

make_numpy_dtype() tuple[source]#
make_concrete_numpy_dtype(value) tuple[source]#
make_numpy_compatible_list(value: int)[source]#
make_secop_compatible_object(value) Any[source]#
class secop_ophyd.util.FloatNP(float_dt: frappy.datatypes.FloatRange, name: str = '', array_element: bool = False)[source]#

Bases: secop_ophyd.util.DtypeNP

make_numpy_dtype() tuple[source]#
make_concrete_numpy_dtype(value) tuple[source]#
make_numpy_compatible_list(value: float)[source]#
make_secop_compatible_object(value) Any[source]#
class secop_ophyd.util.IntNP(int_dt: frappy.datatypes.IntRange, name: str = '', array_element: bool = False)[source]#

Bases: secop_ophyd.util.DtypeNP

make_numpy_dtype() tuple[source]#
make_concrete_numpy_dtype(value) tuple[source]#
make_numpy_compatible_list(value: int)[source]#
make_secop_compatible_object(value) Any[source]#
class secop_ophyd.util.ScaledIntNP(scaled_int_dt: frappy.datatypes.ScaledInteger, name: str = '', array_element: bool = False)[source]#

Bases: secop_ophyd.util.DtypeNP

make_numpy_dtype() tuple[source]#
make_concrete_numpy_dtype(value) tuple[source]#
make_numpy_compatible_list(value: int)[source]#
make_secop_compatible_object(value) Any[source]#
class secop_ophyd.util.StringNP(string_dt: frappy.datatypes.StringType, name: str = '', array_element: bool = False)[source]#

Bases: secop_ophyd.util.DtypeNP

make_numpy_dtype() tuple[source]#
make_concrete_numpy_dtype(value) tuple[source]#
make_numpy_compatible_list(value: str)[source]#
make_secop_compatible_object(value) Any[source]#
class secop_ophyd.util.StructNP(struct_dt: frappy.datatypes.StructOf, name: str = '', array_element: bool = False)[source]#

Bases: secop_ophyd.util.DtypeNP

make_numpy_dtype() tuple[source]#
make_concrete_numpy_dtype(value) tuple[source]#
make_numpy_compatible_list(value: dict)[source]#
make_secop_compatible_object(value) Any[source]#
class secop_ophyd.util.TupleNP(tuple_dt: frappy.datatypes.TupleOf, name: str = '', array_element: bool = False)[source]#

Bases: secop_ophyd.util.DtypeNP

make_numpy_dtype() tuple[source]#
make_concrete_numpy_dtype(value) tuple[source]#
make_numpy_compatible_list(value: tuple)[source]#
make_secop_compatible_object(value) Any[source]#
class secop_ophyd.util.ArrayNP(array_dt: frappy.datatypes.ArrayOf, name: str = '', array_element: bool = False)[source]#

Bases: secop_ophyd.util.DtypeNP

get_root_np_str() str[source]#
make_numpy_dtype() tuple[source]#
make_concrete_numpy_dtype(value) tuple[source]#
make_numpy_compatible_list(value: list)[source]#
make_secop_compatible_object(value: numpy.ndarray) Any[source]#
class secop_ophyd.util.SECoPdtype(datatype: frappy.datatypes.DataType)[source]#

Initialization

get_datakey() dict[source]#
secop2val(reading_val) Any[source]#
val2secop(input_val) Any[source]#
update_dtype(input_val)[source]#
secop_ophyd.util.secop_enum_name_to_python(member_name: str) str[source]#

Convert SECoP enum member name to Python identifier.

Examples:

‘Low Energy’ -> ‘LOW_ENERGY’ ‘high-power’ -> ‘HIGH_POWER’ ‘Mode 1’ -> ‘MODE_1’

Parameters:

member_name – Original SECoP enum member name

Returns:

Python-compatible identifier in UPPER_CASE

secop_ophyd.util.COMMAND_DTYPE_MAPPING: dict[type[frappy.datatypes.DataType], type] = None#
secop_ophyd.util.command_dtype_to_python_type(datatype: frappy.datatypes.DataType) type[source]#

Map a SECoP command argument/result datatype to a plain python type.

secop_ophyd.util.python_type_to_str(python_type: Any) str[source]#

Render a python type object as it should appear in generated source, e.g. int -> “int”, dict[str, Any] -> “dict[str, Any]”.

secop_ophyd.util.command_dtype_to_annotation_str(datatype: frappy.datatypes.DataType) str[source]#

Render a SECoP command argument/result datatype as a python type string, e.g. for use in a generated Command[[ArgT], ResT] annotation.

secop_ophyd.util.build_command_signature(cmd_datatype: frappy.datatypes.CommandType, annotated_signature: inspect.Signature | None = None) inspect.Signature[source]#

Build the call signature for a SECoP command’s argument(s)/result.

A StructOf argument is unraveled into one KEYWORD_ONLY parameter per member (optional members default to None, matching frappy’s own “None means missing” convention for structs); any other argument datatype becomes a single POSITIONAL_OR_KEYWORD ‘arg’ parameter; no argument means no argument parameters. A trailing ‘wait_for_idle: bool = False’ is always appended (KEYWORD_ONLY if the preceding param is, to avoid mixing keyword-only and positional-or-keyword params). Used by SECoPCommandBackend to build both its real call signature and to validate/convert calls via Signature.bind().

annotated_signature, if given, is the signature captured from a real Command[[ArgT], ResT] class annotation (before this function’s caller would otherwise discard it) – when the bare (non-struct) argument or result is an Enum and annotated_signature already carries a concrete generated enum class there, that class is reused instead of building a fresh, differently-named one via _dynamic_enum_class. Struct members are unaffected: annotated_signature has a different shape there (a single flat argument, not a per-member decomposition), and struct members never get named enum classes at codegen time anyway.

class secop_ophyd.util.SECoPReading(secop_dt: secop_ophyd.util.SECoPdtype, entry: frappy.client.CacheItem | None = None)[source]#

Initialization

get_reading() bluesky.protocols.Reading[source]#
get_value()[source]#
get_secop_value()[source]#
set_reading(value) None[source]#
secop_ophyd.util.SECOP2DTYPE = None#