feat(io): Simplify IO interface hierarchy and unify property handling
Replaced specific IO interface classes (`InterfaceInpBool`, `InterfaceInpInt`, etc.) with generic `InterfaceInput` and `InterfaceOutput` classes to simplify the hierarchy. Signed-off-by: Sven Sager <s.sager@kunbus.com>
This commit is contained in:
@@ -17,10 +17,8 @@ from .interface_devices import (
|
||||
)
|
||||
from .interface_ios import (
|
||||
InterfaceIoManager,
|
||||
InterfaceInpBool,
|
||||
InterfaceOutBool,
|
||||
InterfaceInpInt,
|
||||
InterfaceOutInt,
|
||||
InterfaceInput,
|
||||
InterfaceOutput,
|
||||
)
|
||||
|
||||
log = getLogger(__name__)
|
||||
@@ -56,19 +54,16 @@ class BusProviderIo(Thread):
|
||||
|
||||
for io in self._modio.io:
|
||||
interface = None
|
||||
value_type = type(io.value)
|
||||
if value_type is bool:
|
||||
interface = (
|
||||
InterfaceInpBool(self._bus, io)
|
||||
if io.type == revpimodio2.INP
|
||||
else InterfaceOutBool(self._bus, io)
|
||||
)
|
||||
elif value_type is int:
|
||||
interface = (
|
||||
InterfaceInpInt(self._bus, io)
|
||||
if io.type == revpimodio2.INP
|
||||
else InterfaceOutInt(self._bus, io)
|
||||
)
|
||||
try:
|
||||
if io.type == revpimodio2.INP:
|
||||
interface = InterfaceInput(self._bus, io)
|
||||
elif io.type == revpimodio2.OUT:
|
||||
interface = InterfaceOutput(self._bus, io)
|
||||
elif io.type == revpimodio2.MEM:
|
||||
# todo: Implement memory
|
||||
pass
|
||||
except Exception as e:
|
||||
log.warning(f"can not create dbus interface for {io.name}: {e}")
|
||||
|
||||
if interface is not None:
|
||||
self._dc_io_interfaces[io.name] = interface
|
||||
|
||||
Reference in New Issue
Block a user