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:
Enum
A 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.
read
for all read modes).- indexed
True
if this mode can be only used for indexed parameters,False
if it can only be used for unindexed parameters, and...
if it can be used for both.- bits
16
or32
if 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:
ParameterCode
Different 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'
False
16
'Write a 16 bit value'
W32
'0011'
'write'
False
32
'Write a 32 bit value'
RF
'0110'
'read'
True
...
'Read a field value'
W16F
'0111'
'write'
True
16
'Write a 16 bit field value'
W32F
'1000'
'write'
True
32
'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:
ParameterCode
Different parameter response modes.
This enum contains the following members:
Member name
Value
Mode
Indexed
Bits
Description
NONE
'0000'
'none'
...
...
'No response'
S16
'0001'
'response'
False
16
'16 bit value sent'
S32
'0010'
'response'
False
32
'32 bit value sent'
S16F
'0100'
'response'
False
16
'16 bit field value sent'
S32F
'0101'
'response'
True
32
'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:
type
A metaclass for parameter exceptions.
The instances of this metaclass are different types of parameter exceptions, which all have the
member
property. 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
ParameterException
subclasses andParameterError
members 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 themember
attribute 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
ParameterException
member which has self as itsdescription
attribute.- Raises:
AttributeError – If self doesn’t match exactly one
ParameterError
member.
- exception turboctl.telegram.codes.ParameterException¶
Bases:
Exception
A superclass for exceptions that represent different error conditions which are raised when the pump cannot access a parameter.
This class uses the
ParameterExceptionMeta
metaclass, so its subclasses have themember
attribute. However, this superclass itself doesn’t represent any specific error, so trying to accessParameterException.member
raises anAttributeError
.- property member¶
Return the
member
attribute 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:
ParameterException
Raised when trying to access a parameter with a number which doesn’t exist.
- exception turboctl.telegram.codes.CannotChangeError¶
Bases:
ParameterException
Raised when a parameter cannot be changed.
- exception turboctl.telegram.codes.MinMaxError¶
Bases:
ParameterException
Raised when a value cannot be assigned to a parameter because it is outside the range of accepted values.
- exception turboctl.telegram.codes.ParameterIndexError¶
Bases:
ParameterException
Raised when trying to access a non-existent index of a parameter.
- exception turboctl.telegram.codes.AccessError¶
Bases:
ParameterException
Raised when the access code doesn’t match the parameter the pump tries to access.
- exception turboctl.telegram.codes.OtherError¶
Bases:
ParameterException
Raised for other parameter error conditions.
- exception turboctl.telegram.codes.SavingError¶
Bases:
ParameterException
Raised when trying to access a parameter which is simultaneously being saved to nonvolatile memory.
- class turboctl.telegram.codes.CustomInt(value, *args, **kwargs)¶
Bases:
int
A custom superclass for enums that inherit
int
while 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
str
describing of the meaning of the error.- exception
The
ParameterException
subclass that corresponds to this member.
This enum contains the following members:
Member name
Value
Description
Exception
WRONG_NUM
0
'Invalid parameter number'
CANNOT_CHANGE
1
'Parameter cannot be changed'
MINMAX
2
'Min/max error'
INDEX
3
'Index error'
ACCESS
5
'Access mode doesn't match parameter'
OTHER
18
'Other error'
SAVING
102
'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:
FlagBits
Different 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
ON
0
'Turn or keep the pump on'
UNUSED1
1
'Unknown control bit: 1'
UNUSED2
2
'Unknown control bit: 2'
UNUSED3
3
'Unknown control bit: 3'
UNUSED4
4
'Unknown control bit: 4'
X201
5
'Output X201 (air cooling)'
SETPOINT
6
'Enable frequency setpoint'
RESET_ERROR
7
'Reset error (all components)'
STANDBY
8
'Enable standby'
UNUSED9
9
'Unknown control bit: 9'
COMMAND
10
'Enable control bits'
X1_ERROR
11
'Error operation relay X1'
X1_WARNING
12
'Normal operation relay X1'
X1_NORMAL
13
'Warning relay X1'
X202
14
'Output X202 (packing pump)'
X203
15
'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:
FlagBits
Different 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
READY
0
'Ready for operation'
UNUSED1
1
'Unknown status bit: 1'
OPERATION
2
'Operation enabled'
ERROR
3
'Error condition (all components)'
ACCELERATION
4
'Accelerating'
DECELERATION
5
'Decelerating'
SWITCH_ON_LOCK
6
'Switch-on lock'
TEMP_WARNING
7
'Temperature warning'
UNUSED8
8
'Unknown status bit: 8'
PARAM_CHANNEL
9
'Parameter channel enabled'
DETAINED
10
'Normal operation detained'
TURNING
11
'Pump is turning'
UNUSED12
12
'Unknown status bit: 12'
OVERLOAD
13
'Overload warning'
WARNING
14
'Collective warning'
PROCESS_CHANNEL
15
'Process channel enabled'