refactor(io): Simplify InterfaceDeviceManager and device handling

Streamlined device management by introducing a dedicated `object_path`
property in `InterfaceDevice`. Refactored `InterfaceDeviceManager` to
use this property and accept a list of `InterfaceDevice` instances,
removing direct `RevPiModIO` dependencies. Updated D-Bus publishing to
reflect the new structure.

Signed-off-by: Sven Sager <s.sager@kunbus.com>
This commit is contained in:
Sven Sager
2026-02-06 08:30:18 +01:00
parent 35dbed0798
commit 0e69ef432b
4 changed files with 65 additions and 56 deletions

View File

@@ -37,6 +37,7 @@ class BusProviderIo(Thread):
self._bus = SystemBus() if use_system_bus else SessionBus()
self._loop = GLib.MainLoop()
self._lst_device_interfaces = []
self._lst_io_interfaces = []
self._modio = revpimodio2.RevPiModIO(
procimg=picontrol_device,
@@ -50,8 +51,14 @@ class BusProviderIo(Thread):
def run(self):
log.debug("enter BusProviderIo.run")
self._lst_device_interfaces.clear()
self._lst_io_interfaces.clear()
for device in self._modio.device:
self._lst_device_interfaces.append(
InterfaceDevice(self._bus, device),
)
for io in self._modio.io:
interface = None
try:
@@ -68,18 +75,18 @@ class BusProviderIo(Thread):
if interface is not None:
self._lst_io_interfaces.append(interface)
lst_interfaces = [
(interface.object_path, interface) for interface in self._lst_io_interfaces
lst_interfaces = []
lst_interfaces += [
(interface.object_path, interface) for interface in self._lst_device_interfaces
]
lst_interfaces += [
(f"device/{device.position}", InterfaceDevice(self._bus, device))
for device in self._modio.device
(interface.object_path, interface) for interface in self._lst_io_interfaces
]
try:
self._bus.publish(
REVPI_DBUS_NAME,
InterfaceDeviceManager(self._modio),
InterfaceIoManager(self._modio, self._lst_io_interfaces),
InterfaceDeviceManager(self._lst_device_interfaces),
InterfaceIoManager(self._lst_io_interfaces, self._modio),
*lst_interfaces,
)
except Exception as e: