Neue Base Klasse eingefügt von der Core / Connect erben

Sollten neue Base-Devices von Kunbus hinzugefügt werden, wird Base verwendet
IntIOReplaceable Klasse erstellt für IOs von Gateways und virtuellen Devices
Leere IntIOCounter Klasse für Counter IOs hinzugefügt
This commit is contained in:
2018-12-08 17:32:03 +01:00
parent 65a0186efb
commit 1e309091e8
7 changed files with 273 additions and 129 deletions

View File

@@ -253,11 +253,20 @@ class Device(object):
for key in sorted(dict_io, key=lambda x: int(x)):
# Neuen IO anlegen
if bool(dict_io[key][7]) or isinstance(self, Core):
# Bei Bitwerten oder Core RevPiIOBase verwenden
if bool(dict_io[key][7]) or isinstance(self, Base):
# Bei Bitwerten oder Base IOBase verwenden
io_new = IOBase(
self, dict_io[key], iotype, "little", False
)
elif isinstance(self, Gateway) and iotype != MEM:
# Ersetzbare IOs erzeugen
io_new = IntIOReplaceable(
self, dict_io[key],
iotype,
"little",
# Bei AIO (103) signed auf True setzen
self._producttype == 103
)
else:
io_new = IntIO(
self, dict_io[key],
@@ -441,7 +450,16 @@ class Device(object):
producttype = property(_get_producttype)
class Core(Device):
class Base(Device):
"""Klasse fuer alle Base-Devices wie Core / Connect usw."""
__slots__ = ()
pass
class Core(Base):
"""Klasse fuer den RevPi Core.
@@ -849,7 +867,7 @@ class Gateway(Device):
zur verfuegung, ueber die eigene IOs definiert werden, die ein
RevPiStructIO-Objekt abbilden.
Dieser IO-Typ kann Werte ueber mehrere Bytes verarbeiten und zurueckgeben.
@see revpimodio2.io#IOBase.replace_io replace_io(name, frm, **kwargs)
@see revpimodio2.io#IntIOReplaceable.replace_io replace_io(...)
"""
@@ -925,5 +943,5 @@ class Virtual(Gateway):
# Nachträglicher Import
from .io import IOBase, IntIO
from .io import IOBase, IntIO, IntIOReplaceable
from revpimodio2 import INP, OUT, MEM