openpectus.engine.hardware
Attributes
Exceptions
Raised when hardware connection issues occur. |
Classes
Support for flags |
|
Represents a hardware register or named value. |
|
Base class for hardware layer implementations. |
|
Represents no hardware. Used by tests. |
Module Contents
- openpectus.engine.hardware.logger
- class openpectus.engine.hardware.RegisterDirection(*args, **kwds)
Bases:
enum.FlagSupport for flags
- Read
- Write
- Both
- class openpectus.engine.hardware.Register(name, direction, **options)
Represents a hardware register or named value.
- Parameters:
name (str)
direction (RegisterDirection)
- _name: str
- _direction: RegisterDirection
- _options: dict[str, Any]
- property name
- property direction: RegisterDirection
- Return type:
- property options: dict[str, Any]
- Return type:
dict[str, Any]
- __str__()
- Return type:
str
- __repr__()
- exception openpectus.engine.hardware.HardwareLayerException(message, ex=None)
Bases:
ExceptionRaised when hardware connection issues occur.
- Parameters:
message (str)
ex (Exception | None)
- message
- ex = None
- __str__()
Return str(self).
- Return type:
str
- class openpectus.engine.hardware.HardwareLayerBase
Base class for hardware layer implementations.
- _is_connected: bool = False
- __enter__()
Allow use as context manager.
- __exit__(type, value, traceback)
- tick()
Invoked on each tick by engine.
- __str__()
- Return type:
str
- property is_connected: bool
Returns a value indicating whether there is an active connection to the hardware. Virtual property.
- Return type:
bool
- read_batch(registers)
Read batch of register values. Override to provide efficient implementation. Virtual method.
- Parameters:
registers (Sequence[Register])
- Return type:
list[Any]
- write(value, r)
Write single register value. Abstract method.
- Parameters:
value (Any)
r (Register)
- Return type:
None
- write_batch(values, registers)
Write batch of register values. Override to provide efficient implementation. Virtual method.
- Parameters:
values (Sequence[Any])
registers (Sequence[Register])
- 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.
- reconnect()
Perform a reconnect. The default implementation just disconnects (ignoring any error) and connects. Override to perform a more advanced reconnect, like using a thread.
- 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.
- show_online_register_details()
Displays online register details to use in uod definition.
- class openpectus.engine.hardware.NullHardware
Bases:
HardwareLayerBaseRepresents no hardware. Used by tests.
- _is_connected = True
- __str__()
- Return type:
str
- __getattribute__(name)
- Parameters:
name (str)
- Return type:
Any