senxor.regmap
senxor.regmap
¶
Field
¶
Field instance.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the field. |
group |
str
|
The register group that the field belongs to. |
readable |
bool
|
Whether the field is readable. |
writable |
bool
|
Whether the field is writable. |
type |
str
|
The type of the field. |
desc |
str
|
The description of the field. |
help |
str
|
The help of the field. |
value |
int
|
The integer value of the field. |
display |
str
|
The display value of the field, which is the value formatted for display. |
value
property
¶
Return the current value of the field (alias of get).
__init__(descriptor, instance)
¶
Initialize the field instance.
Note: Do not initialize this class directly, this class is designed to be used as a Descriptor Proxy.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
descriptor
|
_FieldDescriptor
|
The field descriptor. |
required |
instance
|
Fields
|
The instance of the field. |
required |
display(value=None)
¶
Return the display value of the field.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
int | None
|
The value to display. If None, will try to get the current value of the field. |
None
|
Returns:
Type | Description |
---|---|
str
|
The display value of the field. |
get()
¶
Return current integer value of this field.
set(value)
¶
Write value to field after validation.
validate(value)
¶
Validate value using custom validator if present.
Fields
¶
fields
property
¶
Return a dict of all field instances.
readable_fields
property
¶
Return a set of all readable field names.
status
property
¶
Return a dictionary of all field values after last operation.
Note: Due to some fields can be auto-reset, this may not reflect the current device state.
Returns:
Type | Description |
---|---|
dict[str, int]
|
The dictionary of field names and their values. |
status_display
property
¶
Return a dictionary of all field names and human-readable representations of last status.
writable_fields
property
¶
Return a set of all writable field names.
__getitem__(key)
¶
Get a field instance by name.
get_field(field)
¶
Return the integer value of a field.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field
|
str | Field
|
Field name (e.g. |
required |
Returns:
Type | Description |
---|---|
int
|
The integer value of the field. |
get_fields(fields)
¶
Get multiple field values.
set_field(field, value)
¶
Set a field value.
set_fields(fields_values)
¶
Set multiple field values.
Register
¶
value
property
¶
The value of the register.
__init__(descriptor, instance)
¶
Initialize the register instance.
Note: Do not initialize this class directly, this class is designed to be used as a Descriptor Proxy.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
descriptor
|
_RegisterDescriptor
|
The register descriptor. |
required |
instance
|
Registers
|
The instance of the register. |
required |
get()
¶
Get the value of the register.
read()
¶
Read the value of the register.
set(value)
¶
Set the value of the register.
Registers
¶
readable_regs
property
¶
Return a set of all readable register names.
regs
property
¶
Return a dictionary of all register instances.
status
property
¶
Return a dictionary of all register values after last operation.
Note: Due to some registers can be auto-reset, this may not reflect the current device state.
Returns:
Type | Description |
---|---|
dict[int, int]
|
The dictionary of register addresses and their values. |
writable_regs
property
¶
Return a set of all writable register names.
get_addr(key)
¶
Get the address of a register.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str | int | Register
|
The key of the register. |
required |
Returns:
Type | Description |
---|---|
int
|
The address of the register. |
get_reg(addr)
¶
Get a register value by address.
This method try to use the cached value instead of reading from the device if possible.
get_regs(addrs)
¶
Get multiple register values by addresses.
This method try to use the cached value instead of reading from the device if possible.
read_all()
¶
Read all registers from the device.
read_reg(addr)
¶
Read a single register from the device.
read_regs(addrs)
¶
Read multiple registers from the device.
write_reg(addr, value)
¶
Write a single register to the device.
write_regs(values_dict)
¶
Write multiple registers to the device.