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
dictof these parameters, represented asParameterobjects, with the numbers of the parameters as the keys.
- turboctl.telegram.parser.ERRORS¶
A
dictof different error conditions which can affect the pump, represented asErrorOrWarningobjects, with error numbers as the keys.
- 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.- indices: range¶
A
rangeobject describing the indices of the parameter; e.g.range(5)would mean the parameter has indices numbered 0 to 4. This isrange(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_valueis 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_valueis 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,
defaultwill be alistof default values corresponding to the different indices.
- property fields¶
Return an
OrderedDictwith 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.
- property fields¶
Return an
OrderedDictwith the attribute names of this object as keys and their values as values.
- __eq__(other)¶
Return self==value.
- __hash__ = None¶
- __repr__()¶
Return repr(self).
- turboctl.telegram.parser.main()¶
Define
PARAMETERS,ERRORSandWARNINGS.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 inparameters.txt.- Returns:
A
dictwith numbers as keys andParameterobjects as values.- Raises:
FileNotFoundError – If filename cannot be found.
RuntimeError – If a line in filename cannot be parsed.
- 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 returneddictcontainsErrorOrWarningobjects.
- 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 returneddictcontainsErrorOrWarningobjects.