openpectus.engine.composite_hardware

Attributes

logger

Classes

Composite_Hardware

Combine multiple hardware layers into one by

Module Contents

openpectus.engine.composite_hardware.logger
class openpectus.engine.composite_hardware.Composite_Hardware

Bases: openpectus.engine.hardware.HardwareLayerBase

Combine multiple hardware layers into one by assigning the hardware layer on a per-register basis.

Example pseudo-code: hwl_A = Hardware_1() hwl_B = Hardware_2() registers = dict() registers[“Reg 1”] = Register(“Reg 1”, RegisterDirection.Both, hardware=hwl_A) registers[“Reg 2”] = Register(“Reg 2”, RegisterDirection.Both, hardware=hwl_B) hwl = Composite_Hardware() hwl.registers = registers with hwl:

hwl.read(registers[“Reg 1”])

_underlying_hardwares()

Construct list of unique hardwares from list of registers

Return type:

list[openpectus.engine.hardware.HardwareLayerBase]

validate_offline()

Perform checks that verify that the registers definition is valid. Raise on validation error. Virtual method.

validate_online()

Perform checks that verify online hardware access. Raise on validation error. Virtual method.

The default implementation checks that all Read registers can be read. Override to add additional checks.

read(r)

Read single register value. Abstract method.

Parameters:

r (openpectus.engine.hardware.Register)

Return type:

Any

read_batch(registers)

Divide list of registers by the hardware they belong to, perform the batch read, gather the results and order them like the list of registers.

Parameters:

registers (Iterable[openpectus.engine.hardware.Register])

Return type:

list[Any]

write(value, r)

Write single register value. Abstract method.

Parameters:
write_batch(values, registers)

Divide list of registers by the hardware they belong to, perform the batch write with values in same order as the registers.

Parameters:
connect()

Connect to hardware. Throw HardwareLayerException on error. Virtual method. Implementations must call base method on completed connect.

disconnect()

Disconnect from hardware. Throw HardwareLayerException on error. Virtual method. Implementations must call base method on completed disconnect.

__str__()