mirror of
https://github.com/naruxde/revpimodio2.git
synced 2025-11-08 22:03:53 +01:00
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:
@@ -1,13 +1,13 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""Modul fuer die Verwaltung der Devices."""
|
"""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 threading import Event, Lock, Thread
|
||||||
|
|
||||||
from .helper import ProcimgWriter
|
from .helper import ProcimgWriter
|
||||||
|
|
||||||
__author__ = "Sven Sager"
|
|
||||||
__copyright__ = "Copyright (C) 2020 Sven Sager"
|
|
||||||
__license__ = "LGPLv3"
|
|
||||||
|
|
||||||
from .pictory import ProductType
|
from .pictory import ProductType
|
||||||
|
|
||||||
|
|
||||||
@@ -160,6 +160,14 @@ class Device(object):
|
|||||||
self._position = int(dict_device.get("position"))
|
self._position = int(dict_device.get("position"))
|
||||||
self._producttype = int(dict_device.get("productType"))
|
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
|
# IOM-Objekte erstellen und Adressen in SLCs speichern
|
||||||
if simulator:
|
if simulator:
|
||||||
self._slc_inp = self._buildio(
|
self._slc_inp = self._buildio(
|
||||||
@@ -345,6 +353,13 @@ class Device(object):
|
|||||||
self._producttype == ProductType.AIO
|
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
|
# IO registrieren
|
||||||
self._modio.io._private_register_new_io_object(io_new)
|
self._modio.io._private_register_new_io_object(io_new)
|
||||||
|
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ class RevPiModIO(object):
|
|||||||
|
|
||||||
# Devices initialisieren
|
# Devices initialisieren
|
||||||
err_names = []
|
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
|
# VDev alter piCtory Versionen auf Kunbus-Standard ändern
|
||||||
if device["position"] == "adap.":
|
if device["position"] == "adap.":
|
||||||
|
|||||||
Reference in New Issue
Block a user