senxor.regmap
Register system for the senxor.
SenxorFieldsManager(regmap)
Bases: Fields
The field system for the senxor.
Attributes:
| Name | Type | Description |
|---|---|---|
regmap |
SenxorRegistersManager
|
The register system for the senxor. |
fields |
dict[FieldName, Field]
|
The dictionary of field instances by name. |
cache |
dict[FieldName, int | None]
|
The cache of the fields values. |
cache_display |
dict[FieldName, str | int | float | None]
|
The cache of the fields display values. |
Examples:
- Iterate over the fields:
>>> fieldmap = SenxorFieldsManager(regmap)
>>> for field in fieldmap:
... print(field.name, field.address)
- Use subscript notation to get a field instance:
- Check if a field exists:
- Use the cache to get the cached field value:
- Use the cache_display to get the cached field display value:
regmap = regmap
instance-attribute
fields = {(field.name): (field(self)) for field in (self.__fields__)}
instance-attribute
cache
property
cache_display
property
set_fields_changed_callback(callback)
get_field(name)
Get a field instance by name.
get_fields_by_addr(addr)
Get the fields by register address.
read_field(name)
Read a field value from the senxor.
set_field(name, value, *, force=False)
Set a field value on the senxor.
SenxorRegistersManager(interface)
Bases: Registers
The register system for the senxor.
Attributes:
| Name | Type | Description |
|---|---|---|
interface |
ISenxorInterface
|
The interface of the senxor. |
registers |
dict[int, Register]
|
The dictionary of registers instance by address. |
fieldmap |
SenxorFieldsManager
|
The field system for the senxor. |
cache |
dict[int, int | None]
|
The cache of the registers values. |
Examples:
- Iterate over the registers:
- Use subscript notation to get a register instance:
- Check if a register exists:
- Use the cache to get the cached register value:
- Refresh the cache of all registers:
Notes
Each register operation should be performed through this class to ensure logging, cache updating and error handling.
interface = interface
instance-attribute
registers = {(register.address): (register(self)) for register in (self.__regs__)}
instance-attribute
fieldmap = SenxorFieldsManager(self)
instance-attribute
cache
property
refresh_all()
Refresh the cache of all registers and fields.
get_reg(name_or_addr)
Get a register instance by name or address.
read_reg(addr)
Read a register value from the senxor.
write_reg(addr, value)
Write a value to a register.
read_regs(addrs)
Read the values from multiple registers at once.
write_regs(regs)
Write the values to multiple registers at once.