mirror of
https://github.com/naruxde/revpimodio2.git
synced 2025-11-08 22:03:53 +01:00
__slots__ für alle möglichen Klassen implementiert
This commit is contained in:
@@ -22,7 +22,7 @@ __author__ = "Sven Sager <akira@revpimodio.org>"
|
||||
__copyright__ = "Copyright (C) 2018 Sven Sager"
|
||||
__license__ = "LGPLv3"
|
||||
__name__ = "revpimodio2"
|
||||
__version__ = "2.2.2"
|
||||
__version__ = "2.2.3"
|
||||
|
||||
# Global package values
|
||||
OFF = 0
|
||||
|
||||
@@ -9,6 +9,8 @@ class App(object):
|
||||
|
||||
"""Bildet die App Sektion der config.rsc ab."""
|
||||
|
||||
__slots__ = "name", "version", "language", "layout"
|
||||
|
||||
def __init__(self, app):
|
||||
"""Instantiiert die App-Klasse.
|
||||
@param app piCtory Appinformationen"""
|
||||
|
||||
@@ -106,6 +106,13 @@ class Device(object):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = "_ba_devdata", "_ba_datacp", \
|
||||
"_dict_events", "_filelock", "_length", "_modio", "_name", "_offset", \
|
||||
"_position", "_producttype", "_selfupdate", "_slc_devoff", \
|
||||
"_slc_inp", "_slc_inpoff", "_slc_mem", "_slc_memoff", \
|
||||
"_slc_out", "_slc_outoff", "bmk", "catalognr", "comment", "extend", \
|
||||
"guid", "id", "inpvariant", "outvariant", "type"
|
||||
|
||||
def __init__(self, parentmodio, dict_device, simulator=False):
|
||||
"""Instantiierung der Device-Klasse.
|
||||
|
||||
@@ -122,24 +129,24 @@ class Device(object):
|
||||
self._selfupdate = False
|
||||
|
||||
# Wertzuweisung aus dict_device
|
||||
self._name = dict_device.pop("name")
|
||||
self._offset = int(dict_device.pop("offset"))
|
||||
self._position = int(dict_device.pop("position"))
|
||||
self._producttype = int(dict_device.pop("productType"))
|
||||
self._name = dict_device.get("name")
|
||||
self._offset = int(dict_device.get("offset"))
|
||||
self._position = int(dict_device.get("position"))
|
||||
self._producttype = int(dict_device.get("productType"))
|
||||
|
||||
# IOM-Objekte erstellen und Adressen in SLCs speichern
|
||||
if simulator:
|
||||
self._slc_inp = self._buildio(
|
||||
dict_device.pop("out"), INP)
|
||||
dict_device.get("out"), INP)
|
||||
self._slc_out = self._buildio(
|
||||
dict_device.pop("inp"), OUT)
|
||||
dict_device.get("inp"), OUT)
|
||||
else:
|
||||
self._slc_inp = self._buildio(
|
||||
dict_device.pop("inp"), INP)
|
||||
dict_device.get("inp"), INP)
|
||||
self._slc_out = self._buildio(
|
||||
dict_device.pop("out"), OUT)
|
||||
dict_device.get("out"), OUT)
|
||||
self._slc_mem = self._buildio(
|
||||
dict_device.pop("mem"), MEM
|
||||
dict_device.get("mem"), MEM
|
||||
)
|
||||
|
||||
# SLCs mit offset berechnen
|
||||
@@ -162,7 +169,15 @@ class Device(object):
|
||||
self._ba_datacp = bytearray()
|
||||
|
||||
# Alle restlichen attribute an Klasse anhängen
|
||||
self.__dict__.update(dict_device)
|
||||
self.bmk = dict_device.get("bmk", "")
|
||||
self.catalognr = dict_device.get("catalogNr", "")
|
||||
self.comment = dict_device.get("comment", "")
|
||||
self.extend = dict_device.get("extend", {})
|
||||
self.guid = dict_device.get("GUID", "")
|
||||
self.id = dict_device.get("id", "")
|
||||
self.inpvariant = dict_device.get("inpVariant", 0)
|
||||
self.outvariant = dict_device.get("outVariant", 0)
|
||||
self.type = dict_device.get("type", "")
|
||||
|
||||
# Spezielle Konfiguration von abgeleiteten Klassen durchführen
|
||||
self._devconfigure()
|
||||
@@ -398,6 +413,10 @@ class Core(Device):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = "_iocycle", "_ioerrorcnt", "_iostatusbyte", "_iotemperature", \
|
||||
"_ioerrorlimit1", "_ioerrorlimit2", "_iofrequency", "_ioled", \
|
||||
"a1green", "a1red", "a2green", "a2red"
|
||||
|
||||
def _devconfigure(self):
|
||||
"""Core-Klasse vorbereiten."""
|
||||
# Eigene IO-Liste aufbauen
|
||||
@@ -647,6 +666,9 @@ class Connect(Core):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = "__evt_wdtoggle", "__th_wdtoggle", "a3green", "a3red", "wd", \
|
||||
"x2in", "x2out"
|
||||
|
||||
def __wdtoggle(self):
|
||||
"""WD Ausgang alle 10 Sekunden automatisch toggeln."""
|
||||
while not self.__evt_wdtoggle.wait(10):
|
||||
@@ -754,6 +776,8 @@ class Gateway(Device):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = "_dict_slc"
|
||||
|
||||
def __init__(self, parent, dict_device, simulator=False):
|
||||
"""Erweitert Device-Klasse um get_rawbytes-Funktionen.
|
||||
@see #Device.__init__ Device.__init__(...)"""
|
||||
@@ -783,6 +807,8 @@ class Virtual(Gateway):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
def writeinputdefaults(self):
|
||||
"""Schreibt fuer ein virtuelles Device piCtory Defaultinputwerte.
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ class EventCallback(Thread):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = "daemon", "exit", "func", "ioname", "iovalue"
|
||||
|
||||
def __init__(self, func, name, value):
|
||||
"""Init EventCallback class.
|
||||
|
||||
@@ -85,6 +87,11 @@ class Cycletools():
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = "__cycle", "__cycletime", "__ucycle", \
|
||||
"__dict_ton", "__dict_tof", "__dict_tp", "first", \
|
||||
"flag1c", "flag5c", "flag10c", "flag15c", "flag20c", \
|
||||
"flank5c", "flank10c", "flank15c", "flank20c", "var"
|
||||
|
||||
def __init__(self, cycletime):
|
||||
"""Init Cycletools class."""
|
||||
self.__cycle = 0
|
||||
@@ -108,6 +115,11 @@ class Cycletools():
|
||||
self.flank15c = True
|
||||
self.flank20c = True
|
||||
|
||||
# Benutzerdaten
|
||||
class Var:
|
||||
pass
|
||||
self.var = Var()
|
||||
|
||||
def _docycle(self):
|
||||
"""Zyklusarbeiten."""
|
||||
# Einschaltverzoegerung
|
||||
@@ -277,6 +289,10 @@ class ProcimgWriter(Thread):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = "__dict_delay", "__eventth", "__eventqth", "__eventwork", \
|
||||
"_adjwait", "_eventq", "_ioerror", "_maxioerrors", "_modio", \
|
||||
"_refresh", "_work", "daemon", "lck_refresh", "newdata"
|
||||
|
||||
def __init__(self, parentmodio):
|
||||
"""Init ProcimgWriter class.
|
||||
@param parentmodio Parent Object"""
|
||||
|
||||
@@ -14,6 +14,8 @@ class IOEvent(object):
|
||||
|
||||
"""Basisklasse fuer IO-Events."""
|
||||
|
||||
__slots__ = "as_thread", "delay", "edge", "func", "overwrite"
|
||||
|
||||
def __init__(self, func, edge, as_thread, delay, overwrite):
|
||||
"""Init IOEvent class."""
|
||||
self.as_thread = as_thread
|
||||
@@ -220,6 +222,8 @@ class DeadIO(object):
|
||||
|
||||
"""Klasse, mit der ersetzte IOs verwaltet werden."""
|
||||
|
||||
__slots__ = "__deadio"
|
||||
|
||||
def __init__(self, deadio):
|
||||
"""Instantiierung der DeadIO-Klasse.
|
||||
@param deadio IO, der ersetzt wurde"""
|
||||
@@ -248,6 +252,10 @@ class IOBase(object):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = "_bitaddress", "_bitlength", "_byteorder", "_defaultvalue", \
|
||||
"_iotype", "_length", "_name", "_parentdevice", \
|
||||
"_signed", "_slc_address", "bmk"
|
||||
|
||||
def __init__(self, parentdevice, valuelist, iotype, byteorder, signed):
|
||||
"""Instantiierung der IOBase-Klasse.
|
||||
|
||||
@@ -767,6 +775,8 @@ class IntIO(IOBase):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
def __int__(self):
|
||||
"""Gibt IO-Wert zurueck mit Beachtung byteorder/signed.
|
||||
@return IO-Wert als <class 'int'>"""
|
||||
@@ -844,6 +854,9 @@ class StructIO(IOBase):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = "__frm", "_parentio_address", "_parentio_defaultvalue", \
|
||||
"_parentio_length"
|
||||
|
||||
def __init__(self, parentio, name, frm, **kwargs):
|
||||
"""Erstellt einen IO mit struct-Formatierung.
|
||||
|
||||
|
||||
@@ -31,6 +31,13 @@ class RevPiModIO(object):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = "__cleanupfunc", "_autorefresh", "_buffedwrite", \
|
||||
"_configrsc", "_exit", "_imgwriter", "_ioerror", "_length", \
|
||||
"_looprunning", "_lst_devselect", "_lst_refresh", "_maxioerrors", \
|
||||
"_myfh", "_monitoring", "_procimg", "_simulator", "_syncoutputs", \
|
||||
"_th_mainloop", "_waitexit", \
|
||||
"core", "app", "device", "exitsignal", "io", "summary"
|
||||
|
||||
def __init__(
|
||||
self, autorefresh=False, monitoring=False, syncoutputs=True,
|
||||
procimg=None, configrsc=None, simulator=False):
|
||||
@@ -796,6 +803,8 @@ class RevPiModIOSelected(RevPiModIO):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
def __init__(
|
||||
self, deviceselection, autorefresh=False, monitoring=False,
|
||||
syncoutputs=True, procimg=None, configrsc=None, simulator=False):
|
||||
@@ -860,6 +869,8 @@ class RevPiModIODriver(RevPiModIOSelected):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
def __init__(
|
||||
self, virtdev, autorefresh=False, monitoring=False,
|
||||
syncoutputs=True, procimg=None, configrsc=None):
|
||||
|
||||
@@ -34,6 +34,12 @@ class NetFH(Thread):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = "__by_buff", "__int_buff", "__dictdirty", "__flusherr", \
|
||||
"__position", "__sockact", "__sockerr", "__sockend", "__socklock", \
|
||||
"__timeout", "__trigger", "__waitsync", \
|
||||
"_address", "_slavesock", \
|
||||
"daemon"
|
||||
|
||||
def __init__(self, address, timeout=500):
|
||||
"""Init NetFH-class.
|
||||
@param address IP Adresse des RevPi
|
||||
@@ -379,6 +385,8 @@ class RevPiNetIO(_RevPiModIO):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = "_address"
|
||||
|
||||
def __init__(
|
||||
self, address, autorefresh=False, monitoring=False,
|
||||
syncoutputs=True, simulator=False):
|
||||
@@ -530,6 +538,8 @@ class RevPiNetIOSelected(RevPiNetIO):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
def __init__(
|
||||
self, address, deviceselection, autorefresh=False,
|
||||
monitoring=False, syncoutputs=True, simulator=False):
|
||||
@@ -595,6 +605,8 @@ class RevPiNetIODriver(RevPiNetIOSelected):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
def __init__(
|
||||
self, address, virtdev, autorefresh=False, monitoring=False,
|
||||
syncoutputs=True):
|
||||
|
||||
@@ -9,6 +9,8 @@ class Summary(object):
|
||||
|
||||
"""Bildet die Summary-Sektion der config.rsc ab."""
|
||||
|
||||
__slots__ = "inptotal", "outtotal"
|
||||
|
||||
def __init__(self, summary):
|
||||
"""Instantiiert die RevPiSummary-Klasse.
|
||||
@param summary piCtory Summaryinformationen"""
|
||||
|
||||
Reference in New Issue
Block a user