parameter_component

This module handles parameter access in a VirtualPump.

class turboctl.virtualpump.parameter_component.ParameterComponent(parameters)

This class defines the part of a VirtualPump that holds the values of pump parameters and handles access to them.

parameters

A dict that represents pump parameters. The keys should be parameter numbers (int) and values corresponding ExtendedParameter objects.

__init__(parameters)

Initialize a new ParameterComponent.

Parameters:

parameters – The object to be assigned to parameters.

handle_parameter(query, reply)

Access a parameter as commanded by query.

The data to be returned to the user is written to reply.

Parameters:
  • query – A TelegramReader object, which represents the telegram sent to the pump.

  • reply – A TelegramBuilder object, which is used to construct the telegram sent back from the pump.

class turboctl.virtualpump.parameter_component.ExtendedParameter(parameter, extended_parameters)

This class represents a parameter that has a value which can change, while the regular Parameter class only describes the immutable attributes of a parameter.

number

See Parameter.number.

indices

See Parameter.indices.

default

See Parameter.default.

writable

See Parameter.writable.

datatype

See Parameter.datatype.

bits

See Parameter.bits.

value

The current values of the indices of the parameter as a list. This will be a list even for unindexed parameters, but in that case the length of the list will be 1. The values of the list will be instances of datatype.

Type:

turboctl.telegram.datatypes.Data

parameters

A dict of all instances of this class, with parameter numbers as keys and objects as values. This is needed, because the min_value and max_value attributes of some parameters depend on the values of other parameters.

__init__(parameter, extended_parameters)

Initialize a new ExtendedParameter.

Parameters:
  • parameter (Parameter) – The non-extended version of this parameter. Most attributes of this object are copied from parameter.

  • extended_parameters – The object to be assigned to parameters.

property min_value

Return the minimum value of the parameter.

This is always a Data subclass instance. If the min_value of the original non-extended parameter is a reference to the value of another parameter, this property returns that value.

Raises:

KeyError – If a referenced parameter cannot be found in parameters.

property max_value

Return the maximum value of the parameter.

This is always a Data subclass instance. If the max_value of the original non-extended parameter is a reference to the value of another parameter, this property returns that value.

Raises:

KeyError – If a referenced parameter cannot be found in parameters.

__str__()

Returns a str with the following format:

ExtendedParameter(
    number=<number>,
    indices=<indices>,
    min_value=<min_value>,
    max_value=<max_value>,
    default=<default>,
    writable=<writable>,
    datatype=<datatype>,
    bits=<bits>,
    value=<value>
)

If the min_value or max_value attributes of the original parameter are references, both the reference and the actual value are displayed. The following is an example of the format:

...
min_value='P18' (Uint(1, 16)),
...
class turboctl.virtualpump.parameter_component.ExtendedParameters(parameters)

Bases: dict

A dict of ExtendedParameter objects.

This class can be used to avoid the need to manually initialize a dict of ExtendedParameter objects. After initialization instances of this class behave like regular dict objects.

__init__(parameters)

Initialize a new ExtendedParameters object from parameters (a dict of Parameter objects).

The data from each Parameter object is copied into an ExtendedParameter object. The objects are initialized in such an order that no errors will be raised because of references to uninitialized parameters.