fix: Set shared_procimg value is stored in the device

Classes have accessed a global shared_procimg value during
instantiation. However, this value is managed directly for each
device individually. There can be no global value.

Signed-off-by: Sven Sager <akira@narux.de>
This commit is contained in:
2023-08-17 08:16:41 +02:00
parent 596658d656
commit 1afe16053d
2 changed files with 5 additions and 3 deletions

View File

@@ -156,7 +156,6 @@ class Device(object):
self._selfupdate = False
self._shared_procimg = False
self._shared_write = set()
self.shared_procimg(parentmodio._shared_procimg) # Set with register
# Wertzuweisung aus dict_device
self._name = dict_device.get("name")

View File

@@ -71,7 +71,7 @@ class RevPiModIO(object):
"_length", "_looprunning", "_lst_devselect", "_lst_refresh", \
"_maxioerrors", "_monitoring", "_myfh", "_myfh_lck", \
"_procimg", "_replace_io_file", "_run_on_pi", \
"_set_device_based_cycle_time", "_simulator", "_shared_procimg", \
"_set_device_based_cycle_time", "_simulator", "_init_shared_procimg", \
"_syncoutputs", "_th_mainloop", "_waitexit", \
"app", "core", "device", "exitsignal", "io", "summary"
@@ -117,7 +117,7 @@ class RevPiModIO(object):
self._procimg = "/dev/piControl0" if procimg is None else procimg
self._set_device_based_cycle_time = True
self._simulator = simulator
self._shared_procimg = shared_procimg or direct_output
self._init_shared_procimg = shared_procimg or direct_output
self._syncoutputs = syncoutputs
# TODO: bei simulator und procimg prüfen ob datei existiert / anlegen?
@@ -363,6 +363,9 @@ class RevPiModIO(object):
err_names_check[dev_new.name] = []
err_names_check[dev_new.name].append(str(dev_new.position))
# Set shared_procimg mode, if requested on instantiation
dev_new.shared_procimg(self._init_shared_procimg)
# DeviceList für direkten Zugriff aufbauen
setattr(self.device, dev_new.name, dev_new)