parser

This module contains a parser that reads data about pump parameters, errors and warnings from text files.

turboctl.telegram.parser.PARAMETERS

The pump has multiple parameters which affect its behaviour. This attribute holds a dict of these parameters, represented as Parameter objects, with the numbers of the parameters as the keys.

turboctl.telegram.parser.ERRORS

A dict of different error conditions which can affect the pump, represented as ErrorOrWarning objects, with error numbers as the keys.

turboctl.telegram.parser.WARNINGS

Like ERRORS, but for warnings instead of errors.

class turboctl.telegram.parser.Parameter(number: int, name: str, indices: range, min_value: Union[Data, str], max_value: Union[Data, str], default: Union[Data, List[Data]], unit: str, writable: bool, datatype: type, bits: int, description: str)

A class for representing pump parameters.

This is a dataclass, so the __init__, __str__ and __repr__ methods are generated automatically.

number: int

The number of the parameter.

name: str

The name of the parameter.

indices: range

A range object describing the indices of the parameter; e.g. range(5) would mean the parameter has indices numbered 0 to 4. This is range(0) for unindexed parameters.

min_value: Union[Data, str]

The minimum value of the parameter.

The minumum value of some parameters depends on the current value of another parameter. In that case, min_value is set to 'P<number>'; e.g. ‘P18’ means the value of parameter 18.

max_value: Union[Data, str]

The maximum value of the parameter.

The maximum value of some parameters depends on the current value of another parameter. In that case, max_value is set to 'P<number>'; e.g. ‘P18’ means the value of parameter 18.

default: Union[Data, List[Data]]

The default value of the parameter.

If the parameter is indexed and different indices have different default values, default will be a list of default values corresponding to the different indices.

unit: str

The unit of the parameter; e.g. '°C' for degrees Celsius.

writable: bool

Signifies whether the value of the parameter can be changed.

datatype: type

The type of the value of the parameter; a Data subclass (but not Bin).

bits: int

The size of the parameter in bits; 16 or 32.

description: str

A string describing the parameter.

property fields

Return an OrderedDict with the attribute names of this objects as keys and their values as values.

__eq__(other)

Return self==value.

__hash__ = None
__init__(number: int, name: str, indices: range, min_value: Union[Data, str], max_value: Union[Data, str], default: Union[Data, List[Data]], unit: str, writable: bool, datatype: type, bits: int, description: str) None
__repr__()

Return repr(self).

class turboctl.telegram.parser.ErrorOrWarning(number: int, name: str, possible_cause: str, remedy: str)

A class for representing pump errors and warnings.

number: int

The number of the error or warning.

name: str

The name of the error or warning.

possible_cause: str

A string describing the possible cause(s) of the error or warning.

remedy: str

A string describing possible remedies for the error or warning.

property fields

Return an OrderedDict with the attribute names of this object as keys and their values as values.

__eq__(other)

Return self==value.

__hash__ = None
__init__(number: int, name: str, possible_cause: str, remedy: str) None
__repr__()

Return repr(self).

turboctl.telegram.parser.main()

Define PARAMETERS, ERRORS and WARNINGS.

This function is automatically executed when this module is imported or run as a script.

turboctl.telegram.parser.load_parameters(path=None)

Parse the parameter file and return a dictionary of parameters.

This function is automatically called by main(), but it can also be called separately in order to create another set of parameters for testing purposes.

Parameters:

path – A text file containing parameter/error/warning data. If path isn’t specified, the file will be 'parameters.txt', located in the same directory as this module. The syntax used to define the parameters is explained in parameters.txt.

Returns:

A dict with numbers as keys and Parameter objects as values.

Raises:
turboctl.telegram.parser.load_errors(path=None)

Parse the error file and return a dictionary of errors.

This works like load_parameters(), but the default file is 'errors.txt', and the returned dict contains ErrorOrWarning objects.

turboctl.telegram.parser.load_warnings(path=None)

Parse the warning file and return a dictionary of warnings.

This works like load_parameters(), but the default file is 'warnings.txt', and the returned dict contains ErrorOrWarning objects.