codes¶
This module defines enums for the different codes and numbers used in TURBOVAC telegrams.
Members of enums can be accessed with any of the following syntaxes:
>>> member = EnumName.MEMBER_NAME
>>> member = EnumName['MEMBER_NAME']
>>> member = EnumName(member_value)
>>> member = EnumName(member)
- class turboctl.telegram.codes.ParameterCode(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
EnumA superclass for parameter access and response codes.
A telegram that tells the pump to accesses a parameter must contain an access code, which depends on the type of the parameter and the access mode. The reply telegram sent by the pump then contains a response code which also depends on the parameter and the access mode, and also tells whether the access was successful.
This enum doesn’t have any members, since it’s only meant to be subclassed. Members of subclasses have the following fields:
- value
The code (a 4-character
str).- mode
A string that groups the codes together by function (e.g.
readfor all read modes).- indexed
Trueif this mode can be only used for indexed parameters,Falseif it can only be used for unindexed parameters, and...if it can be used for both.- bits
16or32if the mode can only be used for 16 or 32 bit parameters, and...if it can be used for both.- description
A verbal description of the meaning of the code.
- __new__(value)¶
- class turboctl.telegram.codes.ParameterAccess(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
ParameterCodeDifferent parameter access modes.
This enum contains the following members:
Member name
Value
Mode
Indexed
Bits
Description
NONE'0000''none'......'No access'R'0001''read'False...'Read a value'W16'0010''write'False16'Write a 16 bit value'W32'0011''write'False32'Write a 32 bit value'RF'0110''read'True...'Read a field value'W16F'0111''write'True16'Write a 16 bit field value'W32F'1000''write'True32'Write a 32 bit field value'- __new__(value)¶
- class turboctl.telegram.codes.ParameterResponse(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
ParameterCodeDifferent parameter response modes.
This enum contains the following members:
Member name
Value
Mode
Indexed
Bits
Description
NONE'0000''none'......'No response'S16'0001''response'False16'16 bit value sent'S32'0010''response'False32'32 bit value sent'S16F'0100''response'False16'16 bit field value sent'S32F'0101''response'True32'32 bit field value sent'ERROR'0111''error'True...'Cannot run command'NO_WRITE'1000''no write'True...'No write access'- __new__(value)¶
- turboctl.telegram.codes.get_parameter_code(telegram_type, mode, indexed, bits)¶
Return the parameter code (as an enum member) that matches the arguments.
telegram_type is
'query'for messages to the pump and'reply'for messages from the pump.- Raises:
ValueError – If the number of matching members isn’t 1, or if telegram_type is invalid.
- turboctl.telegram.codes.get_parameter_mode(telegram_type, code)¶
Return the parameter mode that matches the arguments.
telegram_type is
'query'for messages to the pump and'reply'for messages from the pump.
- class turboctl.telegram.codes.ParameterExceptionMeta¶
Bases:
typeA metaclass for parameter exceptions.
The instances of this metaclass are different types of parameter exceptions, which all have the
memberproperty. Because these instances are error classes instead of instances of error classes, the correct syntax to access this property isParameterErrorX.member
instead of
ParameterErrorX().member
This metaclass exists, because
ParameterExceptionsubclasses andParameterErrormembers which represent the same error need to contain references to each other. Direct references would create circular dependencies which would prevent the objects from being initialized. The easiest way to circumvent this problem is to define thememberattribute as a property that is computed at runtime. Python doesn’t have built-in class properties, so the easiest way to give exception classes a property is to use a metaclass.- property member¶
Return the
ParameterExceptionmember which has self as itsdescriptionattribute.- Raises:
AttributeError – If self doesn’t match exactly one
ParameterErrormember.
- exception turboctl.telegram.codes.ParameterException¶
Bases:
ExceptionA superclass for exceptions that represent different error conditions which are raised when the pump cannot access a parameter.
This class uses the
ParameterExceptionMetametaclass, so its subclasses have thememberattribute. However, this superclass itself doesn’t represent any specific error, so trying to accessParameterException.memberraises anAttributeError.- property member¶
Return the
memberattribute of the class of which self is an instance.This property is defined in order for the syntax
ParameterErrorX().member
to work alongside
ParameterErrorX.member
This makes it possible to write try-catch blocks like the following:
try: # Do something. except ParameterException as error: member = error.member # This would have to be "type(error).member" without this # property. # Do something with *member*.
- exception turboctl.telegram.codes.WrongNumError¶
Bases:
ParameterExceptionRaised when trying to access a parameter with a number which doesn’t exist.
- exception turboctl.telegram.codes.CannotChangeError¶
Bases:
ParameterExceptionRaised when a parameter cannot be changed.
- exception turboctl.telegram.codes.MinMaxError¶
Bases:
ParameterExceptionRaised when a value cannot be assigned to a parameter because it is outside the range of accepted values.
- exception turboctl.telegram.codes.ParameterIndexError¶
Bases:
ParameterExceptionRaised when trying to access a non-existent index of a parameter.
- exception turboctl.telegram.codes.AccessError¶
Bases:
ParameterExceptionRaised when the access code doesn’t match the parameter the pump tries to access.
- exception turboctl.telegram.codes.OtherError¶
Bases:
ParameterExceptionRaised for other parameter error conditions.
- exception turboctl.telegram.codes.SavingError¶
Bases:
ParameterExceptionRaised when trying to access a parameter which is simultaneously being saved to nonvolatile memory.
- class turboctl.telegram.codes.CustomInt(value, *args, **kwargs)¶
Bases:
intA custom superclass for enums that inherit
intwhile having members with multiple fields.
- class turboctl.telegram.codes.ParameterError(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
-
Different parameter errors.
This class also inherits
CustomInt, which means its members can e.g. be easily ordered.- Members of this enum have the following fields:
- value
The number of the error (
int).- description
A short
strdescribing of the meaning of the error.- exception
The
ParameterExceptionsubclass that corresponds to this member.
This enum contains the following members:
Member name
Value
Description
Exception
WRONG_NUM0'Invalid parameter number'CANNOT_CHANGE1'Parameter cannot be changed'MINMAX2'Min/max error'INDEX3'Index error'ACCESS5'Access mode doesn't match parameter'OTHER18'Other error'SAVING102'Parameter is being saved to nonvolatile memory'- __init__(value, description, exception)¶
- __repr__()¶
Return repr(self).
- __format__(format_spec)¶
Convert to a string according to format_spec.
- class turboctl.telegram.codes.FlagBits(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
-
A superclass for control and status bits.
This class is otherwise similar to
ParameterError, but it doesn’t have any members since it’s only meant to be subclassed, and the members of its subclasses lack the exception field.- __init__(value, description)¶
- __repr__()¶
Return repr(self).
- __format__(format_spec)¶
Convert to a string according to format_spec.
- class turboctl.telegram.codes.ControlBits(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
FlagBitsDifferent control bits.
Unused control bits have been assigned values in order to prevent errors in the program.
This class inherits
FlagBits, but for some reason Sphinx doesn’t show that properly.This enum contains the following members:
Member name
Value
Description
ON0'Turn or keep the pump on'UNUSED11'Unknown control bit: 1'UNUSED22'Unknown control bit: 2'UNUSED33'Unknown control bit: 3'UNUSED44'Unknown control bit: 4'X2015'Output X201 (air cooling)'SETPOINT6'Enable frequency setpoint'RESET_ERROR7'Reset error (all components)'STANDBY8'Enable standby'UNUSED99'Unknown control bit: 9'COMMAND10'Enable control bits'X1_ERROR11'Error operation relay X1'X1_WARNING12'Normal operation relay X1'X1_NORMAL13'Warning relay X1'X20214'Output X202 (packing pump)'X20315'Output X203 (venting valve)'- ON = 0¶
Lorem ipsum.
- UNUSED1 = 1¶
Dolor sit amet.
- class turboctl.telegram.codes.StatusBits(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
FlagBitsDifferent status bits.
Unused status bits have been assigned values in order to prevent errors in the program.
This class inherits
FlagBits, but for some reason Sphinx doesn’t show that properly.This enum contains the following members:
Member name
Value
Description
READY0'Ready for operation'UNUSED11'Unknown status bit: 1'OPERATION2'Operation enabled'ERROR3'Error condition (all components)'ACCELERATION4'Accelerating'DECELERATION5'Decelerating'SWITCH_ON_LOCK6'Switch-on lock'TEMP_WARNING7'Temperature warning'UNUSED88'Unknown status bit: 8'PARAM_CHANNEL9'Parameter channel enabled'DETAINED10'Normal operation detained'TURNING11'Pump is turning'UNUSED1212'Unknown status bit: 12'OVERLOAD13'Overload warning'WARNING14'Collective warning'PROCESS_CHANNEL15'Process channel enabled'