roboglia.base.BoolRegister

class BoolRegister(bits=None, mode='any', mask=None, **kwargs)[source]

Bases: roboglia.base.register.BaseRegister

A register with BOOL representation (true/false).

Inherits from BaseRegister all methods. Overrides value_to_external and value_to_internal to process a bool value.

Parameters
  • bits (int or None) – An optional bit pattern to use in the determination of the output of the register. Default is None and in this case we simply compare the internal value with 0.

  • mode (str ('all' or 'any')) – Indicates how the bit pattern should be used: ‘all’ means all the bits in the pattern must match while ‘any’ means any bit that matches the pattern is enough to result in a True external value. Only used if bits is not None. Default is ‘any’.

  • mask (int or None) – An optional mask that allows for partial bit handling on the internal values. This mask permits handling only the specified bits without affecting the other ones in the internal value. For instance if the mask is 0b00001111 then the operations (setter, getter) will only affect the most significant 4 bits of the register.

__init__(bits=None, mode='any', mask=None, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

property bits

The bit pattern used.

property mode

The bitmasking mode (‘all’ or ‘any’).

property mask

The partial bitmask for the handling of the bits.

value_to_external(value)[source]

The external representation of bool register.

value_to_internal(value)[source]

The internal representation of the register’s value.

__str__()

Representation of the register [name]: value.

property access

Register’s access mode.

property address

The register’s address in the device.

property clone

Indicates the register is a clone of another.

property default

The register’s default value in internal format.

property device

The device the register belongs to.

property int_value

Internal value of register, if a clone return the value of the main register.

property max_ext

The register’s maximum value in external format.

property maxim

The register’s maximum value in internal format.

property min_ext

The register’s minimum value in external format.

property minim

The register’s minimum value in internal format.

property name

Register’s name.

property order

Indicates the order of the data representartion; low-high (LH) or high-low (HL)

property range

Tuple with (minim, maxim) values in internal format.

property range_ext

Tuple with (minim, maxim) values in external format.

read()

Performs the actual reading of the internal value of the register from the device. Calls the device’s method to read the value of register.

property size

The regster’s size in Bytes.

property sync

Register is subject to a sync loop update.

property value

Provides the value of the register in external format. If the register is not marked for sync then it requests the device to perform a read in order to refresh the content of the register.

Returns

The value of the register in the external format. It invokes value_to_external() which can be overridden by subclasses to provide different representations of the register’s value (hence the any return type).

Return type

any

property word

Indicates if the register is an 16 bit register (True) or an 8 bit register.

write()

Performs the actual writing of the internal value of the register to the device. Calls the device’s method to write the value of register.