Check device offsets in piCtory file and ignore IOs with wrong offsets

The modbus 150 Device has a memory gap and piCtory does not calculate the right offset of the following device - We will warn the user.
This commit is contained in:
2021-07-28 07:38:34 +02:00
parent 498d200e41
commit 0edfb4ef85
2 changed files with 23 additions and 8 deletions

View File

@@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
"""Modul fuer die Verwaltung der Devices."""
__author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2021 Sven Sager"
__license__ = "LGPLv3"
import warnings
from threading import Event, Lock, Thread
from .helper import ProcimgWriter
__author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2020 Sven Sager"
__license__ = "LGPLv3"
from .pictory import ProductType
@@ -160,6 +160,14 @@ class Device(object):
self._position = int(dict_device.get("position"))
self._producttype = int(dict_device.get("productType"))
# Offset-Check for broken piCtory configuration
if self._offset != parentmodio.length:
warnings.warn(
"Device offset ERROR in piCtory configuration! Offset of '{0}' "
"must be {1} but is {2} - Overlapping devices overwrite the "
"same memory, which has unpredictable effects!!!"
"".format(self._name, parentmodio.length, self._offset)
)
# IOM-Objekte erstellen und Adressen in SLCs speichern
if simulator:
self._slc_inp = self._buildio(
@@ -345,6 +353,13 @@ class Device(object):
self._producttype == ProductType.AIO
)
if io_new.address < self._modio.length:
warnings.warn(
"IO {0} is not in the device offset and will be ignored"
"".format(io_new.name),
Warning
)
else:
# IO registrieren
self._modio.io._private_register_new_io_object(io_new)

View File

@@ -227,7 +227,7 @@ class RevPiModIO(object):
# Devices initialisieren
err_names = []
for device in sorted(lst_devices, key=lambda x: x["position"]):
for device in sorted(lst_devices, key=lambda x: x["offset"]):
# VDev alter piCtory Versionen auf Kunbus-Standard ändern
if device["position"] == "adap.":