feat(io): Add min_value and max_value properties to IOs
Added `min_value` and `max_value` properties to integer IOs for determining value ranges. Updated D-Bus interface with corresponding properties. Signed-off-by: Sven Sager <s.sager@kunbus.com>
This commit is contained in:
@@ -140,6 +140,8 @@ class InterfaceInpInt(DbusInterfaceIo):
|
||||
<property name="byteorder" type="s" access="readwrite"/>
|
||||
<property name="defaultvalue" type="i" access="read"/>
|
||||
<property name="length" type="i" access="read"/>
|
||||
<property name="min_value" type="i" access="read"/>
|
||||
<property name="max_value" type="i" access="read"/>
|
||||
<property name="name" type="s" access="read"/>
|
||||
<property name="signed" type="b" access="readwrite"/>
|
||||
<property name="value" type="i" access="read"/>
|
||||
@@ -158,6 +160,19 @@ class InterfaceInpInt(DbusInterfaceIo):
|
||||
def byteorder(self, value: str) -> None:
|
||||
self.io.byteorder = value
|
||||
|
||||
@property
|
||||
def min_value(self) -> int:
|
||||
if self.io.signed:
|
||||
return -(1 << (self.io.length * 8 - 1))
|
||||
return 0
|
||||
|
||||
@property
|
||||
def max_value(self) -> int:
|
||||
bit_length = self.io.length * 8
|
||||
if self.io.signed:
|
||||
return (1 << (bit_length - 1)) - 1
|
||||
return (1 << bit_length) - 1
|
||||
|
||||
@property
|
||||
def signed(self) -> bool:
|
||||
return self.io.signed
|
||||
@@ -180,6 +195,8 @@ class InterfaceOutInt(InterfaceInpInt):
|
||||
<property name="byteorder" type="s" access="readwrite"/>
|
||||
<property name="defaultvalue" type="i" access="read"/>
|
||||
<property name="length" type="i" access="read"/>
|
||||
<property name="min_value" type="i" access="read"/>
|
||||
<property name="max_value" type="i" access="read"/>
|
||||
<property name="name" type="s" access="read"/>
|
||||
<property name="signed" type="b" access="readwrite"/>
|
||||
<property name="value" type="i" access="readwrite"/>
|
||||
|
||||
Reference in New Issue
Block a user