secop_ophyd.codegen.module_class#

The generated class of one SECoP module, built from its description.

Module Contents#

Classes#

ModuleClassBuilder

Builds the attributes of the generated class of one module, and the enum classes and TypedDicts they need.

Functions#

normalize_description

Description text for generated comments: without trailing whitespace and newlines, keeping intentional internal newlines.

internalize_name

how to create internal names

split_accessibles

The parameters and the commands of a module description, by internal name, each with its frappy datatype added under ‘datatype’.

module_class_name

Name of the generated class of a module: its self-reported “implementation” module property (or else the module name), in CamelCase.

API#

secop_ophyd.codegen.module_class.normalize_description(description: str | None) → str[source]#

Description text for generated comments: without trailing whitespace and newlines, keeping intentional internal newlines.

secop_ophyd.codegen.module_class.internalize_name(name: str) → str[source]#

how to create internal names

secop_ophyd.codegen.module_class.split_accessibles(moddescr: dict) → tuple[dict[str, dict], dict[str, dict]][source]#

The parameters and the commands of a module description, by internal name, each with its frappy datatype added under ‘datatype’.

secop_ophyd.codegen.module_class.module_class_name(modname: str, properties: dict) → str[source]#

Name of the generated class of a module: its self-reported “implementation” module property (or else the module name), in CamelCase.

A controller class declares its channels, which differ between controllers of one implementation: there is one class per controller, with the module name appended.

class secop_ophyd.codegen.module_class.ModuleClassBuilder[source]#

Builds the attributes of the generated class of one module, and the enum classes and TypedDicts they need.

name: str = None#
device_class: type[secop_ophyd.devices.base.SECoPDevice] = None#
enums: list[secop_ophyd.codegen.model.EnumClass] = 'field(...)'#
typed_dicts: list[secop_ophyd.codegen.model.TypedDictClass] = 'field(...)'#
target_type: str | None = None#
bases() → list[str][source]#

Base classes of the generated class: the device class, parametrized with the type of ‘target’ if it is generic over it (e.g. SECoPMoveableDevice[float] instead of the implicitly Any form).

commands(commands: dict[str, dict]) → list[secop_ophyd.codegen.model.CommandAttribute][source]#
parameters(parameters: dict[str, dict]) → list[secop_ophyd.codegen.model.ParameterAttribute][source]#
properties(properties: dict) → list[secop_ophyd.codegen.model.PropertyAttribute][source]#
channels(controller_channels: dict[str, str], taken: set[str], class_names: dict[str, str]) → list[secop_ophyd.codegen.model.ChannelAttribute][source]#

The channel devices of an acquisition controller, named by role.

controller_channels maps role -> channel module, taken are the attribute names already in use and class_names the generated class of each module.