diff --git a/doc/revpimodio2.device.html b/doc/revpimodio2.device.html
index d88c158..0753f3b 100644
--- a/doc/revpimodio2.device.html
+++ b/doc/revpimodio2.device.html
@@ -556,6 +556,9 @@ Methods
__getioiter |
Gibt mit allen IOs zurueck. |
+| __getitem__ |
+Gibt IO an angegebener Stelle zurueck. |
+
| __int__ |
Gibt die Positon im RevPi Bus zurueck. |
@@ -580,6 +583,9 @@ Methods
| _get_producttype |
Gibt den Produkttypen des device zurueck. |
+| _update_my_io_list |
+Erzeugt eine neue IO Liste fuer schnellen Zugriff. |
+
| autorefresh |
Registriert dieses Device fuer die automatische Synchronisierung. |
@@ -676,6 +682,22 @@ Filter fuer 'Export' Flag in piCtory
IOs als Iterator
+
+
+Device.__getitem__
+__getitem__(key)
+
+Gibt IO an angegebener Stelle zurueck.
+
+- key
+-
+Index des IOs auf dem device als
+
+
+- Returns:
+-
+Gefundenes IO-Objekt
+
Device.__int__
@@ -767,7 +789,13 @@ Gibt den Produkttypen des device zurueck.
Deviceprodukttyp
-
+
+
+Device._update_my_io_list
+_update_my_io_list()
+
+Erzeugt eine neue IO Liste fuer schnellen Zugriff.
+
Device.autorefresh
autorefresh(activate=True)
@@ -1049,7 +1077,7 @@ DeviceList.__iter__
Gibt Iterator aller Devices zurueck.
Die Reihenfolge ist nach Position im Prozessabbild sortiert und nicht
- nach Position (Dies entspricht der Positionierung aus piCtory)!
+ nach Positionsnummer (Dies entspricht der Positionierung aus piCtory)!
- Returns:
-
diff --git a/eric-revpimodio2.api b/eric-revpimodio2.api
index 889636a..a6a10cb 100644
--- a/eric-revpimodio2.api
+++ b/eric-revpimodio2.api
@@ -43,6 +43,7 @@ revpimodio2.device.Device._buildio?5(dict_io, iotype)
revpimodio2.device.Device._devconfigure?5()
revpimodio2.device.Device._get_offset?5()
revpimodio2.device.Device._get_producttype?5()
+revpimodio2.device.Device._update_my_io_list?5()
revpimodio2.device.Device.autorefresh?4(activate=True)
revpimodio2.device.Device.get_allios?4(export=None)
revpimodio2.device.Device.get_inputs?4(export=None)
diff --git a/revpimodio2/device.py b/revpimodio2/device.py
index 0941f29..a668c62 100644
--- a/revpimodio2/device.py
+++ b/revpimodio2/device.py
@@ -72,7 +72,7 @@ class DeviceList(object):
"""Gibt Iterator aller Devices zurueck.
Die Reihenfolge ist nach Position im Prozessabbild sortiert und nicht
- nach Position (Dies entspricht der Positionierung aus piCtory)!
+ nach Positionsnummer (Dies entspricht der Positionierung aus piCtory)!
@return aller Devices"""
for dev in sorted(
@@ -106,7 +106,7 @@ class Device(object):
"""
- __slots__ = "_ba_devdata", "_ba_datacp", \
+ __slots__ = "__my_io_list", "_ba_devdata", "_ba_datacp", \
"_dict_events", "_filelock", "_length", "_modio", "_name", "_offset", \
"_position", "_producttype", "_selfupdate", "_slc_devoff", \
"_slc_inp", "_slc_inpoff", "_slc_mem", "_slc_memoff", \
@@ -126,6 +126,7 @@ class Device(object):
self._dict_events = {}
self._filelock = Lock()
self._length = 0
+ self.__my_io_list = []
self._selfupdate = False
# Wertzuweisung aus dict_device
@@ -182,6 +183,9 @@ class Device(object):
# Spezielle Konfiguration von abgeleiteten Klassen durchführen
self._devconfigure()
+ # IO Liste aktualisieren für schnellen Indexzugriff
+ self._update_my_io_list()
+
def __bytes__(self):
"""Gibt alle Daten des Devices als zurueck.
@return Devicedaten als """
@@ -205,6 +209,12 @@ class Device(object):
return key in self._modio.io \
and getattr(self._modio.io, key)._parentdevice == self
+ def __getitem__(self, key):
+ """Gibt IO an angegebener Stelle zurueck.
+ @param key Index des IOs auf dem device als
+ @return Gefundenes IO-Objekt"""
+ return self.__my_io_list[key]
+
def __int__(self):
"""Gibt die Positon im RevPi Bus zurueck.
@return Positionsnummer"""
@@ -312,6 +322,10 @@ class Device(object):
@return Deviceprodukttyp"""
return self._producttype
+ def _update_my_io_list(self):
+ """Erzeugt eine neue IO Liste fuer schnellen Zugriff."""
+ self.__my_io_list = list(self.__iter__())
+
def autorefresh(self, activate=True):
"""Registriert dieses Device fuer die automatische Synchronisierung.
@param activate Default True fuegt Device zur Synchronisierung hinzu"""
diff --git a/revpimodio2/io.py b/revpimodio2/io.py
index ce3ba20..e274894 100644
--- a/revpimodio2/io.py
+++ b/revpimodio2/io.py
@@ -68,6 +68,7 @@ class IOList(object):
self.__dict_iobyte[io_del.address] = []
object.__delattr__(self, key)
+ io_del._parentdevice._update_my_io_list()
def __getattr__(self, key):
"""Verwaltet geloeschte IOs (Attribute, die nicht existieren).
@@ -125,10 +126,10 @@ class IOList(object):
def __setattr__(self, key, value):
"""Verbietet aus Leistungsguenden das direkte Setzen von Attributen."""
- if key in [
+ if key in (
"_IOList__dict_iobyte",
"_IOList__dict_iorefname"
- ]:
+ ):
object.__setattr__(self, key, value)
else:
raise AttributeError(
@@ -221,6 +222,9 @@ class IOList(object):
None, None, None, None, None, None, None, None
]
self.__dict_iobyte[new_io.address][new_io._bitaddress] = new_io
+
+ if type(new_io) is StructIO:
+ new_io._parentdevice._update_my_io_list()
else:
raise TypeError("io must be or sub class")