Merge tag '2.6.1' into pkg/debian

Release 2.6.1
This commit is contained in:
2023-09-09 12:04:58 +02:00
8 changed files with 45 additions and 34 deletions

2
.idea/misc.xml generated
View File

@@ -3,7 +3,7 @@
<component name="JavaScriptSettings"> <component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" /> <option name="languageLevel" value="ES6" />
</component> </component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (revpimodio2)" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (revpimodio2)" project-jdk-type="Python SDK" />
<component name="PythonCompatibilityInspectionAdvertiser"> <component name="PythonCompatibilityInspectionAdvertiser">
<option name="version" value="3" /> <option name="version" value="3" />
</component> </component>

2
.idea/revpimodio2.iml generated
View File

@@ -5,7 +5,7 @@
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/venv" /> <excludeFolder url="file://$MODULE_DIR$/venv" />
</content> </content>
<orderEntry type="jdk" jdkName="Python 3.9 (revpimodio2)" jdkType="Python SDK" /> <orderEntry type="jdk" jdkName="Python 3.11 (revpimodio2)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
<component name="PackageRequirementsSettings"> <component name="PackageRequirementsSettings">

View File

@@ -5,23 +5,34 @@ MAKEFLAGS = --no-print-directory --no-builtin-rules
# Variables # Variables
PACKAGE = revpimodio2 PACKAGE = revpimodio2
# If virtualenv exists, use it. If not, use PATH to find, except python3 # Set path to create the virtual environment with package name
SYSTEM_PYTHON = /usr/bin/python3 ifdef PYTHON3_VENV
PYTHON = $(or $(wildcard venv/bin/python), $(SYSTEM_PYTHON)) VENV_PATH = $(PYTHON3_VENV)/$(PACKAGE)
else
VENV_PATH = venv
endif
# If virtualenv exists, use it. If not, use PATH to find commands
SYSTEM_PYTHON = python3
PYTHON = $(or $(wildcard $(VENV_PATH)/bin/python), $(SYSTEM_PYTHON))
all: build docs all: build docs
.PHONY: all .PHONY: all
## Environment ## Environment
venv-info:
echo Using path: "$(VENV_PATH)"
exit 0
venv: venv:
$(SYSTEM_PYTHON) -m venv venv $(SYSTEM_PYTHON) -m venv "$(VENV_PATH)"
source venv/bin/activate && \ source $(VENV_PATH)/bin/activate && \
python3 -m pip install --upgrade pip && \ python3 -m pip install --upgrade pip && \
python3 -m pip install -r requirements.txt python3 -m pip install -r requirements.txt
exit 0 exit 0
.PHONY: venv .PHONY: venv-info venv
## Build, install ## Build, install
build: build:
@@ -41,6 +52,6 @@ clean:
rm -rf build docs/_build dist src/*.egg-info *.spec rm -rf build docs/_build dist src/*.egg-info *.spec
clean-all: clean clean-all: clean
rm -R venv rm -R $(VENV_PATH)
.PHONY: clean clean-all .PHONY: clean clean-all

View File

@@ -3,4 +3,4 @@
__author__ = "Sven Sager <akira@revpimodio.org>" __author__ = "Sven Sager <akira@revpimodio.org>"
__copyright__ = "Copyright (C) 2023 Sven Sager" __copyright__ = "Copyright (C) 2023 Sven Sager"
__license__ = "LGPLv2" __license__ = "LGPLv2"
__version__ = "2.6.0" __version__ = "2.6.1"

View File

@@ -155,8 +155,7 @@ class Device(object):
self.__my_io_list = [] self.__my_io_list = []
self._selfupdate = False self._selfupdate = False
self._shared_procimg = False self._shared_procimg = False
self._shared_write = [] self._shared_write = set()
self.shared_procimg(parentmodio._shared_procimg) # Set with register
# Wertzuweisung aus dict_device # Wertzuweisung aus dict_device
self._name = dict_device.get("name") self._name = dict_device.get("name")
@@ -531,10 +530,6 @@ class Device(object):
with self._filelock: with self._filelock:
self._shared_write.clear() self._shared_write.clear()
self._shared_procimg = True if activate else False self._shared_procimg = True if activate else False
if self._shared_procimg and self not in self._modio._lst_shared:
self._modio._lst_shared.append(self)
elif not self._shared_procimg and self in self._modio._lst_shared:
self._modio._lst_shared.remove(self)
def syncoutputs(self) -> bool: def syncoutputs(self) -> bool:
""" """

View File

@@ -531,18 +531,23 @@ class ProcimgWriter(Thread):
continue continue
try: try:
for dev in self._modio._lst_shared:
# Set shared outputs before reading process image
for io in dev._shared_write:
if not io._write_to_procimg():
raise IOError("error on _write_to_procimg")
dev._shared_write.clear()
fh.seek(0) fh.seek(0)
fh.readinto(bytesbuff) fh.readinto(bytesbuff)
for dev in self._modio._lst_refresh: for dev in self._modio._lst_refresh:
with dev._filelock: with dev._filelock:
if dev._shared_procimg:
# Set modified outputs one by one
for io in dev._shared_write:
if not io._write_to_procimg():
raise IOError("error on _write_to_procimg")
dev._shared_write.clear()
# Read all device bytes, because it is shared
fh.seek(dev.offset)
bytesbuff[dev._slc_devoff] = \
fh.read(len(dev._ba_devdata))
if self._modio._monitoring or dev._shared_procimg: if self._modio._monitoring or dev._shared_procimg:
# Inputs und Outputs in Puffer # Inputs und Outputs in Puffer
dev._ba_devdata[:] = bytesbuff[dev._slc_devoff] dev._ba_devdata[:] = bytesbuff[dev._slc_devoff]
@@ -612,7 +617,7 @@ class ProcimgWriter(Thread):
# Second default_timer call include calculation time from above # Second default_timer call include calculation time from above
if default_timer() - ot > self._refresh: if default_timer() - ot > self._refresh:
warnings.warn( warnings.warn(
"cycle time of {0} ms exceeded - can not hold cycle time!" "io refresh time of {0} ms exceeded!"
"".format(int(self._refresh * 1000)), "".format(int(self._refresh * 1000)),
RuntimeWarning RuntimeWarning
) )

View File

@@ -594,6 +594,7 @@ class IOBase(object):
return False return False
else: else:
# Write one or more bytes to process image
value = bytes(self._parentdevice._ba_devdata[self._slc_address]) value = bytes(self._parentdevice._ba_devdata[self._slc_address])
with self._parentdevice._modio._myfh_lck: with self._parentdevice._modio._myfh_lck:
try: try:
@@ -706,10 +707,9 @@ class IOBase(object):
# Für Bitoperationen sperren # Für Bitoperationen sperren
self._parentdevice._filelock.acquire() self._parentdevice._filelock.acquire()
if self._parentdevice._shared_procimg \ if self._parentdevice._shared_procimg:
and self not in self._parentdevice._shared_write:
# Mark this IO for write operations # Mark this IO for write operations
self._parentdevice._shared_write.append(self) self._parentdevice._shared_write.add(self)
# Hier gibt es immer nur ein byte, als int holen # Hier gibt es immer nur ein byte, als int holen
int_byte = self._parentdevice._ba_devdata[self._slc_address.start] int_byte = self._parentdevice._ba_devdata[self._slc_address.start]
@@ -743,11 +743,10 @@ class IOBase(object):
) )
) )
if self._parentdevice._shared_procimg \ if self._parentdevice._shared_procimg:
and self not in self._parentdevice._shared_write:
with self._parentdevice._filelock: with self._parentdevice._filelock:
# Mark this IO as changed # Mark this IO as changed
self._parentdevice._shared_write.append(self) self._parentdevice._shared_write.add(self)
self._parentdevice._ba_devdata[self._slc_address] = value self._parentdevice._ba_devdata[self._slc_address] = value

View File

@@ -69,10 +69,9 @@ class RevPiModIO(object):
"_autorefresh", "_buffedwrite", "_configrsc", "_debug", "_devselect", \ "_autorefresh", "_buffedwrite", "_configrsc", "_debug", "_devselect", \
"_exit", "_exit_level", "_imgwriter", "_ioerror", \ "_exit", "_exit_level", "_imgwriter", "_ioerror", \
"_length", "_looprunning", "_lst_devselect", "_lst_refresh", \ "_length", "_looprunning", "_lst_devselect", "_lst_refresh", \
"_lst_shared", \
"_maxioerrors", "_monitoring", "_myfh", "_myfh_lck", \ "_maxioerrors", "_monitoring", "_myfh", "_myfh_lck", \
"_procimg", "_replace_io_file", "_run_on_pi", \ "_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", \ "_syncoutputs", "_th_mainloop", "_waitexit", \
"app", "core", "device", "exitsignal", "io", "summary" "app", "core", "device", "exitsignal", "io", "summary"
@@ -118,7 +117,7 @@ class RevPiModIO(object):
self._procimg = "/dev/piControl0" if procimg is None else procimg self._procimg = "/dev/piControl0" if procimg is None else procimg
self._set_device_based_cycle_time = True self._set_device_based_cycle_time = True
self._simulator = simulator self._simulator = simulator
self._shared_procimg = shared_procimg or direct_output self._init_shared_procimg = shared_procimg or direct_output
self._syncoutputs = syncoutputs self._syncoutputs = syncoutputs
# TODO: bei simulator und procimg prüfen ob datei existiert / anlegen? # TODO: bei simulator und procimg prüfen ob datei existiert / anlegen?
@@ -135,7 +134,6 @@ class RevPiModIO(object):
self._length = 0 self._length = 0
self._looprunning = False self._looprunning = False
self._lst_refresh = [] self._lst_refresh = []
self._lst_shared = []
self._maxioerrors = 0 self._maxioerrors = 0
self._myfh = None self._myfh = None
self._myfh_lck = Lock() self._myfh_lck = Lock()
@@ -365,6 +363,9 @@ class RevPiModIO(object):
err_names_check[dev_new.name] = [] err_names_check[dev_new.name] = []
err_names_check[dev_new.name].append(str(dev_new.position)) 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 # DeviceList für direkten Zugriff aufbauen
setattr(self.device, dev_new.name, dev_new) setattr(self.device, dev_new.name, dev_new)