openpectus.lang.exec.readings

Classes

ReadingCommand

Defines commands that are available in the frontend for a given reading/process value.

Reading

Defines a reading that is displayed to the frontend user as a Process Value.

ReadingWithEntry

Defines a reading that is displayed to the frontend user as a Process Value.

ReadingWithChoice

A reading that is displayed with a list of possible commands.

ReadingCollection

UodCommandDescription

Describes a command and its usage.

Module Contents

class openpectus.lang.exec.readings.ReadingCommand(name, command)

Defines commands that are available in the frontend for a given reading/process value.

Parameters:
  • name (str)

  • command (str)

command_id: str = ''
name: str
command: str
choice_names: list[str] = []
__str__()
Return type:

str

class openpectus.lang.exec.readings.Reading(tag_name)

Defines a reading that is displayed to the frontend user as a Process Value.

It is typically defined by matching it with a tag to display that tag’s value and with one or more commands to allow the user to invoke these commands. The cases where commands are added are handled by Reading subclasses.

execute_command_name is the name of the command to execute when the command is posted from the frontend. It defaults to tag_name which is usually fine. It can be set to something else if so desired.

Parameters:

tag_name (str)

discriminator = 'reading'
tag_name
commands: list[ReadingCommand] = []
tag: openpectus.lang.exec.tags.Tag | None = None
valid_value_units: list[str] | None = None
entry_data_type: openpectus.engine.models.EntryDataType | None = None
command_options: dict[str, str] | None = None
__str__()
Return type:

str

match_with_tags(tags)

Match the reading with the provided tags. Raises UodValidationError or error.

Parameters:

tags (openpectus.lang.exec.tags.TagCollection)

build_commands_list()

Override to specify the commands available in the UI for this process value.

Is invoked after validation and match_with_tags so tag and valid_value_units have been set.

resolve_entry_type()

If entry_data_type is ‘auto’, resolve its type using the tag’s current value.

If resolved, mutate reading to use the resolved type as entry_data_type.

as_reading_info()
Return type:

openpectus.protocol.models.ReadingInfo

class openpectus.lang.exec.readings.ReadingWithEntry(tag_name, entry_data_type='auto', execute_command_name=None)

Bases: Reading

Defines a reading that is displayed to the frontend user as a Process Value.

It is typically defined by matching it with a tag to display that tag’s value and with one or more commands to allow the user to invoke these commands. The cases where commands are added are handled by Reading subclasses.

execute_command_name is the name of the command to execute when the command is posted from the frontend. It defaults to tag_name which is usually fine. It can be set to something else if so desired.

Parameters:
  • tag_name (str)

  • entry_data_type (openpectus.engine.models.EntryDataType)

  • execute_command_name (str | None)

execute_command_name
discriminator = 'reading_with_entry'
entry_data_type = 'auto'
match_with_tags(tags)

Match the reading with the provided tags. Raises UodValidationError or error.

Parameters:

tags (openpectus.lang.exec.tags.TagCollection)

build_commands_list()

Override to specify the commands available in the UI for this process value.

Is invoked after validation and match_with_tags so tag and valid_value_units have been set.

class openpectus.lang.exec.readings.ReadingWithChoice(tag_name, command_options=None)

Bases: Reading

A reading that is displayed with a list of possible commands.

Parameters:
  • tag_name (str)

  • command_options (dict[str, str] | None)

discriminator = 'reading_with_choice'
command_options = None
match_with_tags(tags)

Internal, used in validation.

Parameters:

tags (openpectus.lang.exec.tags.TagCollection)

build_commands_list()

Internal, used during validation.

class openpectus.lang.exec.readings.ReadingCollection

Bases: Iterable[Reading]

_readings: list[Reading] = []
add(reading)
Parameters:

reading (Reading)

__iter__()
__len__()
Return type:

int

class openpectus.lang.exec.readings.UodCommandDescription(name)

Describes a command and its usage.

Parameters:

name (str)

name: str

Name of the command as used in pcode.

docstring: str = ''

Description of the command’s purpose, provided by uod author as docstring on the exec function.

argument_type: Literal['float', 'unknown', 'none'] = 'unknown'

the type of the argument in case the commands takes a single argument

argument_valid_units: list[str] = []

Valid argument units if applicable.

argument_exclusive_options: list[str] = []

Exclusive options if applicable.

argument_additive_options: list[str] = []

Additive options if applicable.

__str__()
Return type:

str

as_command_info()
Return type:

openpectus.protocol.models.CommandInfo

set_docstring(docstring)
Parameters:

docstring (str | None)

get_docstring_pcode()
Return type:

str

generate_pcode_examples()

For commands with regex arg parser, generate pcode examples to test the command using combinations of argument values and units.

Return type:

list[str]