parameter_component¶
This module handles parameter access in a
VirtualPump.
- class turboctl.virtualpump.parameter_component.ParameterComponent(parameters)¶
This class defines the part of a
VirtualPumpthat holds the values of pump parameters and handles access to them.- parameters¶
A
dictthat represents pump parameters. The keys should be parameter numbers (int) and values correspondingExtendedParameterobjects.
- __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
TelegramReaderobject, which represents the telegram sent to the pump.reply – A
TelegramBuilderobject, 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
Parameterclass 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.
- parameters¶
A
dictof all instances of this class, with parameter numbers as keys and objects as values. This is needed, because themin_valueandmax_valueattributes 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
Datasubclass instance. If themin_valueof 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
Datasubclass instance. If themax_valueof 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
strwith 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_valueormax_valueattributes 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:
dictA
dictofExtendedParameterobjects.This class can be used to avoid the need to manually initialize a
dictofExtendedParameterobjects. After initialization instances of this class behave like regulardictobjects.- __init__(parameters)¶
Initialize a new
ExtendedParametersobject from parameters (adictofParameterobjects).The data from each
Parameterobject is copied into anExtendedParameterobject. The objects are initialized in such an order that no errors will be raised because of references to uninitialized parameters.