mirror of
https://github.com/naruxde/revpimodio2.git
synced 2025-11-08 13:53:53 +01:00
VirtualDevices in alter piCtory "adap." mit 64 beginnen (Kunbus Standard)
Konstanten um INP, OUT, MEM erweitert und io.Type gelöscht Änderung der Klassen auf neue Konstanten device.__getioiter angelegt für Rückgabe der IOs ohne None bei BIT-Bytes device.__getioiter in Rückgabefunktionen eingebaut io.DeadIO mit _parentdevice = None erweitert io.IOBase.__bool__ gibt nun False bei leeren Bytes aus io.StructIO.frm gibt nun nur einzelnen Zeichen aus (Byteorder über .byteorder)
This commit is contained in:
@@ -20,7 +20,7 @@ fuehrt das Modul bei Datenaenderung aus.
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Global Attributes</h3>
|
||||
<table>
|
||||
<tr><td>BOTH</td></tr><tr><td>FALLING</td></tr><tr><td>GREEN</td></tr><tr><td>OFF</td></tr><tr><td>RED</td></tr><tr><td>RISING</td></tr><tr><td>__all__</td></tr><tr><td>__author__</td></tr><tr><td>__name__</td></tr><tr><td>__package__</td></tr><tr><td>__version__</td></tr>
|
||||
<tr><td>BOTH</td></tr><tr><td>FALLING</td></tr><tr><td>GREEN</td></tr><tr><td>INP</td></tr><tr><td>MEM</td></tr><tr><td>OFF</td></tr><tr><td>OUT</td></tr><tr><td>RED</td></tr><tr><td>RISING</td></tr><tr><td>__all__</td></tr><tr><td>__author__</td></tr><tr><td>__name__</td></tr><tr><td>__package__</td></tr><tr><td>__version__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Classes</h3>
|
||||
|
||||
@@ -378,6 +378,9 @@ Methods</h3>
|
||||
<td><a style="color:#0000FF" href="#Device.__contains__">__contains__</a></td>
|
||||
<td>Prueft ob IO auf diesem Device liegt.</td>
|
||||
</tr><tr>
|
||||
<td><a style="color:#0000FF" href="#Device.__getioiter">__getioiter</a></td>
|
||||
<td>Gibt <class 'iter'> mit allen IOs zurueck.</td>
|
||||
</tr><tr>
|
||||
<td><a style="color:#0000FF" href="#Device.__int__">__int__</a></td>
|
||||
<td>Gibt die Positon im RevPi Bus zurueck.</td>
|
||||
</tr><tr>
|
||||
@@ -479,6 +482,22 @@ IO-Name <class 'str'> / IO-Bytenummer <class 'int'>
|
||||
<dd>
|
||||
True, wenn device vorhanden
|
||||
</dd>
|
||||
</dl><a NAME="Device.__getioiter" ID="Device.__getioiter"></a>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Device.__getioiter</h3>
|
||||
<b>__getioiter</b>(<i>ioslc</i>)
|
||||
<p>
|
||||
Gibt <class 'iter'> mit allen IOs zurueck.
|
||||
</p><dl>
|
||||
<dt><i>ioslc</i></dt>
|
||||
<dd>
|
||||
IO Abschnitt <class 'slice'>
|
||||
</dd>
|
||||
</dl><dl>
|
||||
<dt>Returns:</dt>
|
||||
<dd>
|
||||
IOs als Iterator
|
||||
</dd>
|
||||
</dl><a NAME="Device.__int__" ID="Device.__int__"></a>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Device.__int__</h3>
|
||||
@@ -535,7 +554,7 @@ Erstellt aus der piCtory-Liste die IOs fuer dieses Device.
|
||||
<class 'dict'>-Objekt aus piCtory Konfiguration
|
||||
</dd><dt><i>iotype</i></dt>
|
||||
<dd>
|
||||
<class 'Type'> Wert
|
||||
<class 'int'> Wert
|
||||
</dd>
|
||||
</dl><dl>
|
||||
<dt>Returns:</dt>
|
||||
@@ -632,6 +651,11 @@ Device.readprocimg</h3>
|
||||
<p>
|
||||
Alle Inputs fuer dieses Device vom Prozessabbild einlesen.
|
||||
</p><dl>
|
||||
<dt>Returns:</dt>
|
||||
<dd>
|
||||
True, wenn erfolgreich ausgefuehrt
|
||||
</dd>
|
||||
</dl><dl>
|
||||
<dt><b>See Also:</b></dt>
|
||||
<dd>
|
||||
<a style="color:#0000FF" href="revpimodio2.modio.html#RevPiModIO.readprocimg">RevPiModIO.readprocimg()</a>
|
||||
@@ -643,6 +667,11 @@ Device.setdefaultvalues</h3>
|
||||
<p>
|
||||
Alle Outputbuffer fuer dieses Device auf default Werte setzen.
|
||||
</p><dl>
|
||||
<dt>Returns:</dt>
|
||||
<dd>
|
||||
True, wenn erfolgreich ausgefuehrt
|
||||
</dd>
|
||||
</dl><dl>
|
||||
<dt><b>See Also:</b></dt>
|
||||
<dd>
|
||||
<a style="color:#0000FF" href="revpimodio2.modio.html#RevPiModIO.setdefaultvalues">RevPiModIO.setdefaultvalues()</a>
|
||||
@@ -654,6 +683,11 @@ Device.syncoutputs</h3>
|
||||
<p>
|
||||
Lesen aller Outputs im Prozessabbild fuer dieses Device.
|
||||
</p><dl>
|
||||
<dt>Returns:</dt>
|
||||
<dd>
|
||||
True, wenn erfolgreich ausgefuehrt
|
||||
</dd>
|
||||
</dl><dl>
|
||||
<dt><b>See Also:</b></dt>
|
||||
<dd>
|
||||
<a style="color:#0000FF" href="revpimodio2.modio.html#RevPiModIO.syncoutputs">RevPiModIO.syncoutputs()</a>
|
||||
@@ -665,6 +699,11 @@ Device.writeprocimg</h3>
|
||||
<p>
|
||||
Schreiben aller Outputs dieses Devices ins Prozessabbild.
|
||||
</p><dl>
|
||||
<dt>Returns:</dt>
|
||||
<dd>
|
||||
True, wenn erfolgreich ausgefuehrt
|
||||
</dd>
|
||||
</dl><dl>
|
||||
<dt><b>See Also:</b></dt>
|
||||
<dd>
|
||||
<a style="color:#0000FF" href="revpimodio2.modio.html#RevPiModIO.writeprocimg">RevPiModIO.writeprocimg()</a>
|
||||
|
||||
@@ -32,9 +32,6 @@ Classes</h3>
|
||||
</tr><tr>
|
||||
<td><a style="color:#0000FF" href="#StructIO">StructIO</a></td>
|
||||
<td>Klasse fuer den Zugriff auf Daten ueber ein definierten struct.</td>
|
||||
</tr><tr>
|
||||
<td><a style="color:#0000FF" href="#Type">Type</a></td>
|
||||
<td>IO Typen.</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
@@ -54,7 +51,7 @@ object
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>_parentdevice</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Methods</h3>
|
||||
@@ -154,7 +151,7 @@ Methods</h3>
|
||||
<td>Gibt konfigurierte Byteorder zurueck.</td>
|
||||
</tr><tr>
|
||||
<td><a style="color:#0000FF" href="#IOBase._get_iotype">_get_iotype</a></td>
|
||||
<td>Gibt io.Type zurueck.</td>
|
||||
<td>Gibt io type zurueck.</td>
|
||||
</tr><tr>
|
||||
<td><a style="color:#0000FF" href="#IOBase.get_defaultvalue">get_defaultvalue</a></td>
|
||||
<td>Gibt die Defaultvalue von piCtory zurueck.</td>
|
||||
@@ -201,7 +198,7 @@ Parentdevice auf dem der IO liegt
|
||||
Datenliste fuer Instantiierung
|
||||
</dd><dt><i>iotype</i></dt>
|
||||
<dd>
|
||||
<class 'Type'> Wert
|
||||
<class 'int'> Wert
|
||||
</dd><dt><i>byteorder</i></dt>
|
||||
<dd>
|
||||
Byteorder 'little'/'big' fuer <class 'int'> Berechnung
|
||||
@@ -269,11 +266,11 @@ Gibt konfigurierte Byteorder zurueck.
|
||||
IOBase._get_iotype</h3>
|
||||
<b>_get_iotype</b>(<i></i>)
|
||||
<p>
|
||||
Gibt io.Type zurueck.
|
||||
Gibt io type zurueck.
|
||||
</p><dl>
|
||||
<dt>Returns:</dt>
|
||||
<dd>
|
||||
<class 'int'> io.Type
|
||||
<class 'int'> io type
|
||||
</dd>
|
||||
</dl><a NAME="IOBase.get_defaultvalue" ID="IOBase.get_defaultvalue"></a>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
@@ -926,37 +923,6 @@ Setzt den Wert mit struct Formatierung.
|
||||
Wert vom Typ der struct-Formatierung
|
||||
</dd>
|
||||
</dl>
|
||||
<div align="right"><a style="color:#0000FF" href="#top">Up</a></div>
|
||||
<hr /><hr />
|
||||
<a NAME="Type" ID="Type"></a>
|
||||
<h2 style="background-color:#FFFFFF;color:#0000FF">Type</h2>
|
||||
<p>
|
||||
IO Typen.
|
||||
</p>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Derived from</h3>
|
||||
object
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>INP</td></tr><tr><td>MEM</td></tr><tr><td>OUT</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Methods</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Methods</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Static Methods</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
</table>
|
||||
|
||||
<div align="right"><a style="color:#0000FF" href="#top">Up</a></div>
|
||||
<hr />
|
||||
</body></html>
|
||||
@@ -1,7 +1,10 @@
|
||||
revpimodio2.BOTH?7
|
||||
revpimodio2.FALLING?7
|
||||
revpimodio2.GREEN?7
|
||||
revpimodio2.INP?7
|
||||
revpimodio2.MEM?7
|
||||
revpimodio2.OFF?7
|
||||
revpimodio2.OUT?7
|
||||
revpimodio2.RED?7
|
||||
revpimodio2.RISING?7
|
||||
revpimodio2.app.App?1(app)
|
||||
@@ -79,6 +82,7 @@ revpimodio2.helper.ProcimgWriter.set_maxioerrors?4(value)
|
||||
revpimodio2.helper.ProcimgWriter.set_refresh?4(value)
|
||||
revpimodio2.helper.ProcimgWriter.stop?4()
|
||||
revpimodio2.helper.ProcimgWriter?1(parentmodio)
|
||||
revpimodio2.io.DeadIO._parentdevice?8
|
||||
revpimodio2.io.DeadIO.replace_io?4(name, frm, **kwargs)
|
||||
revpimodio2.io.DeadIO?1(deadio)
|
||||
revpimodio2.io.IOBase._get_address?5()
|
||||
@@ -122,9 +126,6 @@ revpimodio2.io.StructIO.set_structvalue?4(value)
|
||||
revpimodio2.io.StructIO.signed?7
|
||||
revpimodio2.io.StructIO.value?7
|
||||
revpimodio2.io.StructIO?1(parentio, name, frm, **kwargs)
|
||||
revpimodio2.io.Type.INP?7
|
||||
revpimodio2.io.Type.MEM?7
|
||||
revpimodio2.io.Type.OUT?7
|
||||
revpimodio2.modio.RevPiModIO._configure?5(jconfigrsc)
|
||||
revpimodio2.modio.RevPiModIO._create_myfh?5()
|
||||
revpimodio2.modio.RevPiModIO._get_configrsc?5()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE Project SYSTEM "Project-5.1.dtd">
|
||||
<!-- eric project file for project revpimodio2 -->
|
||||
<!-- Saved: 2017-09-17, 15:14:47 -->
|
||||
<!-- Saved: 2017-11-01, 15:30:36 -->
|
||||
<!-- Copyright (C) 2017 Sven Sager, akira@narux.de -->
|
||||
<Project version="5.1">
|
||||
<Language>en_US</Language>
|
||||
@@ -9,7 +9,7 @@
|
||||
<ProgLanguage mixed="0">Python3</ProgLanguage>
|
||||
<ProjectType>Console</ProjectType>
|
||||
<Description>Das Modul stellt alle Devices und IOs aus der piCtory Konfiguration in Python3 zur Verfügung. Es ermöglicht den direkten Zugriff auf die Werte über deren vergebenen Namen. Lese- und Schreibaktionen mit dem Prozessabbild werden von dem Modul selbst verwaltet, ohne dass sich der Programmierer um Offsets und Adressen kümmern muss. Für die Gatewaymodule wie ModbusTCP oder Profinet sind eigene 'Inputs' und 'Outputs' über einen bestimmten Adressbereich definierbar. Auf diese IOs kann mit Python3 über den Namen direkt auf die Werte zugegriffen werden.</Description>
|
||||
<Version>2.0.5</Version>
|
||||
<Version>2.0.6</Version>
|
||||
<Author>Sven Sager</Author>
|
||||
<Email>akira@narux.de</Email>
|
||||
<Eol index="1"/>
|
||||
@@ -31,7 +31,7 @@
|
||||
<Source>test/web_virtdevdriver.py</Source>
|
||||
<Source>test/web_benniesrun.py</Source>
|
||||
<Source>test/web_benniesrunxxl.py</Source>
|
||||
<Source>test_trace.py</Source>
|
||||
<Source>test_unit.py</Source>
|
||||
</Sources>
|
||||
<Forms/>
|
||||
<Translations/>
|
||||
@@ -43,6 +43,7 @@
|
||||
<Other>MANIFEST.in</Other>
|
||||
<Other>eric-revpimodio2.api</Other>
|
||||
</Others>
|
||||
<MainScript>test_unit.py</MainScript>
|
||||
<Vcs>
|
||||
<VcsType>Mercurial</VcsType>
|
||||
<VcsOptions>
|
||||
@@ -181,7 +182,7 @@
|
||||
<value>
|
||||
<list>
|
||||
<string>setup.py</string>
|
||||
<string>test_trace.py</string>
|
||||
<string>test_unit.py</string>
|
||||
</list>
|
||||
</value>
|
||||
<key>
|
||||
@@ -228,7 +229,7 @@
|
||||
<value>
|
||||
<list>
|
||||
<string>setup.py</string>
|
||||
<string>test_trace.py</string>
|
||||
<string>test_unit.py</string>
|
||||
</list>
|
||||
</value>
|
||||
<key>
|
||||
@@ -280,7 +281,7 @@
|
||||
<string>ExcludeFiles</string>
|
||||
</key>
|
||||
<value>
|
||||
<string>*/test_trace.py</string>
|
||||
<string>*/test_unit.py</string>
|
||||
</value>
|
||||
<key>
|
||||
<string>ExcludeMessages</string>
|
||||
|
||||
@@ -24,7 +24,7 @@ __all__ = [
|
||||
__author__ = "Sven Sager <akira@revpimodio.org>"
|
||||
__name__ = "revpimodio2"
|
||||
__package__ = "revpimodio2"
|
||||
__version__ = "2.0.5"
|
||||
__version__ = "2.0.6"
|
||||
|
||||
# Global package values
|
||||
OFF = 0
|
||||
@@ -33,6 +33,9 @@ RED = 2
|
||||
RISING = 31
|
||||
FALLING = 32
|
||||
BOTH = 33
|
||||
INP = 300
|
||||
OUT = 301
|
||||
MEM = 302
|
||||
|
||||
warnings.simplefilter(action="always")
|
||||
|
||||
@@ -58,6 +61,12 @@ def consttostr(value):
|
||||
return "FALLING"
|
||||
elif value == 33:
|
||||
return "BOTH"
|
||||
elif value == 300:
|
||||
return "INP"
|
||||
elif value == 301:
|
||||
return "OUT"
|
||||
elif value == 302:
|
||||
return "MEM"
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
||||
@@ -114,16 +114,16 @@ class Device(object):
|
||||
# IOM-Objekte erstellen und Adressen in SLCs speichern
|
||||
if simulator:
|
||||
self._slc_inp = self._buildio(
|
||||
dict_device.pop("out"), iomodule.Type.INP)
|
||||
dict_device.pop("out"), INP)
|
||||
self._slc_out = self._buildio(
|
||||
dict_device.pop("inp"), iomodule.Type.OUT)
|
||||
dict_device.pop("inp"), OUT)
|
||||
else:
|
||||
self._slc_inp = self._buildio(
|
||||
dict_device.pop("inp"), iomodule.Type.INP)
|
||||
dict_device.pop("inp"), INP)
|
||||
self._slc_out = self._buildio(
|
||||
dict_device.pop("out"), iomodule.Type.OUT)
|
||||
dict_device.pop("out"), OUT)
|
||||
self._slc_mem = self._buildio(
|
||||
dict_device.pop("mem"), iomodule.Type.MEM
|
||||
dict_device.pop("mem"), MEM
|
||||
)
|
||||
|
||||
# SLCs mit offset berechnen
|
||||
@@ -180,9 +180,7 @@ class Device(object):
|
||||
def __iter__(self):
|
||||
"""Gibt Iterator aller IOs zurueck.
|
||||
@return <class 'iter'> aller IOs"""
|
||||
for lst_io in self._modio.io[self._slc_devoff]:
|
||||
for io in lst_io:
|
||||
yield io
|
||||
return self.__getioiter(self._slc_devoff)
|
||||
|
||||
def __len__(self):
|
||||
"""Gibt Anzahl der Bytes zurueck, die dieses Device belegt.
|
||||
@@ -194,11 +192,20 @@ class Device(object):
|
||||
@return Devicename"""
|
||||
return self._name
|
||||
|
||||
def __getioiter(self, ioslc):
|
||||
"""Gibt <class 'iter'> mit allen IOs zurueck.
|
||||
@param ioslc IO Abschnitt <class 'slice'>
|
||||
@return IOs als Iterator"""
|
||||
for lst_io in self._modio.io[ioslc]:
|
||||
for io in lst_io:
|
||||
if io is not None:
|
||||
yield io
|
||||
|
||||
def _buildio(self, dict_io, iotype):
|
||||
"""Erstellt aus der piCtory-Liste die IOs fuer dieses Device.
|
||||
|
||||
@param dict_io <class 'dict'>-Objekt aus piCtory Konfiguration
|
||||
@param iotype <class 'Type'> Wert
|
||||
@param iotype <class 'int'> Wert
|
||||
@return <class 'slice'> mit Start und Stop Position dieser IOs
|
||||
|
||||
"""
|
||||
@@ -211,11 +218,11 @@ class Device(object):
|
||||
# Neuen IO anlegen
|
||||
if bool(dict_io[key][7]) or self._producttype == 95:
|
||||
# Bei Bitwerten oder Core RevPiIOBase verwenden
|
||||
io_new = iomodule.IOBase(
|
||||
io_new = IOBase(
|
||||
self, dict_io[key], iotype, "little", False
|
||||
)
|
||||
else:
|
||||
io_new = iomodule.IntIO(
|
||||
io_new = IntIO(
|
||||
self, dict_io[key],
|
||||
iotype,
|
||||
"little",
|
||||
@@ -295,59 +302,64 @@ class Device(object):
|
||||
def get_allios(self):
|
||||
"""Gibt eine Liste aller Inputs und Outputs zurueck, keine MEMs.
|
||||
@return <class 'list'> Input und Output, keine MEMs"""
|
||||
lst_return = []
|
||||
for lst_io in self._modio.io[
|
||||
self._slc_inpoff.start:self._slc_outoff.stop]:
|
||||
lst_return += lst_io
|
||||
return lst_return
|
||||
return list(self.__getioiter(
|
||||
slice(self._slc_inpoff.start, self._slc_outoff.stop)
|
||||
))
|
||||
|
||||
def get_inputs(self):
|
||||
"""Gibt eine Liste aller Inputs zurueck.
|
||||
@return <class 'list'> Inputs"""
|
||||
lst_return = []
|
||||
for lst_io in self._modio.io[self._slc_inpoff]:
|
||||
lst_return += lst_io
|
||||
return lst_return
|
||||
return list(self.__getioiter(self._slc_inpoff))
|
||||
|
||||
def get_outputs(self):
|
||||
"""Gibt eine Liste aller Outputs zurueck.
|
||||
@return <class 'list'> Outputs"""
|
||||
lst_return = []
|
||||
for lst_io in self._modio.io[self._slc_outoff]:
|
||||
lst_return += lst_io
|
||||
return lst_return
|
||||
return list(self.__getioiter(self._slc_outoff))
|
||||
|
||||
def get_memories(self):
|
||||
"""Gibt eine Liste aller mems zurueck.
|
||||
@return <class 'list'> Mems"""
|
||||
lst_return = []
|
||||
for lst_io in self._modio.io[self._slc_memoff]:
|
||||
lst_return += lst_io
|
||||
return lst_return
|
||||
return list(self.__getioiter(self._slc_memoff))
|
||||
|
||||
def readprocimg(self):
|
||||
"""Alle Inputs fuer dieses Device vom Prozessabbild einlesen.
|
||||
|
||||
@return True, wenn erfolgreich ausgefuehrt
|
||||
@see revpimodio2.modio#RevPiModIO.readprocimg
|
||||
RevPiModIO.readprocimg()"""
|
||||
self._modio.readprocimg(self)
|
||||
RevPiModIO.readprocimg()
|
||||
|
||||
"""
|
||||
return self._modio.readprocimg(self)
|
||||
|
||||
def setdefaultvalues(self):
|
||||
"""Alle Outputbuffer fuer dieses Device auf default Werte setzen.
|
||||
|
||||
@return True, wenn erfolgreich ausgefuehrt
|
||||
@see revpimodio2.modio#RevPiModIO.setdefaultvalues
|
||||
RevPiModIO.setdefaultvalues()"""
|
||||
RevPiModIO.setdefaultvalues()
|
||||
|
||||
"""
|
||||
self._modio.setdefaultvalues(self)
|
||||
|
||||
def syncoutputs(self):
|
||||
"""Lesen aller Outputs im Prozessabbild fuer dieses Device.
|
||||
|
||||
@return True, wenn erfolgreich ausgefuehrt
|
||||
@see revpimodio2.modio#RevPiModIO.syncoutputs
|
||||
RevPiModIO.syncoutputs()"""
|
||||
self._modio.syncoutputs(self)
|
||||
RevPiModIO.syncoutputs()
|
||||
|
||||
"""
|
||||
return self._modio.syncoutputs(self)
|
||||
|
||||
def writeprocimg(self):
|
||||
"""Schreiben aller Outputs dieses Devices ins Prozessabbild.
|
||||
|
||||
@return True, wenn erfolgreich ausgefuehrt
|
||||
@see revpimodio2.modio#RevPiModIO.writeprocimg
|
||||
RevPiModIO.writeprocimg()"""
|
||||
self._modio.writeprocimg(self)
|
||||
RevPiModIO.writeprocimg()
|
||||
|
||||
"""
|
||||
return self._modio.writeprocimg(self)
|
||||
|
||||
length = property(__len__)
|
||||
name = property(__str__)
|
||||
@@ -616,9 +628,9 @@ class Gateway(Device):
|
||||
super().__init__(parent, dict_device, simulator)
|
||||
|
||||
self._dict_slc = {
|
||||
iomodule.Type.INP: self._slc_inp,
|
||||
iomodule.Type.OUT: self._slc_out,
|
||||
iomodule.Type.MEM: self._slc_mem
|
||||
INP: self._slc_inp,
|
||||
OUT: self._slc_out,
|
||||
MEM: self._slc_mem
|
||||
}
|
||||
|
||||
def get_rawbytes(self):
|
||||
@@ -678,4 +690,5 @@ class Virtual(Gateway):
|
||||
|
||||
|
||||
# Nachträglicher Import
|
||||
from . import io as iomodule
|
||||
from .io import IOBase, IntIO
|
||||
from revpimodio2 import INP, OUT, MEM
|
||||
|
||||
@@ -8,16 +8,7 @@
|
||||
"""RevPiModIO Modul fuer die Verwaltung der IOs."""
|
||||
import struct
|
||||
from threading import Event
|
||||
from revpimodio2 import RISING, FALLING, BOTH, consttostr
|
||||
|
||||
|
||||
class Type(object):
|
||||
|
||||
"""IO Typen."""
|
||||
|
||||
INP = 300
|
||||
OUT = 301
|
||||
MEM = 302
|
||||
from revpimodio2 import RISING, FALLING, BOTH, INP, OUT, MEM, consttostr
|
||||
|
||||
|
||||
class IOList(object):
|
||||
@@ -120,7 +111,7 @@ class IOList(object):
|
||||
]:
|
||||
object.__setattr__(self, key, value)
|
||||
else:
|
||||
raise TypeError(
|
||||
raise ValueError(
|
||||
"direct assignment is not supported - use .value Attribute"
|
||||
)
|
||||
|
||||
@@ -227,6 +218,8 @@ class DeadIO(object):
|
||||
@see #IOBase.replace_io replace_io(...)"""
|
||||
self.__deadio.replace_io(name, frm, **kwargs)
|
||||
|
||||
_parentdevice = property(lambda self: None)
|
||||
|
||||
|
||||
class IOBase(object):
|
||||
|
||||
@@ -248,7 +241,7 @@ class IOBase(object):
|
||||
|
||||
@param parentdevice Parentdevice auf dem der IO liegt
|
||||
@param valuelist Datenliste fuer Instantiierung
|
||||
@param iotype <class 'Type'> Wert
|
||||
@param iotype <class 'int'> Wert
|
||||
@param byteorder Byteorder 'little'/'big' fuer <class 'int'> Berechnung
|
||||
@param sigend Intberechnung mit Vorzeichen durchfuehren
|
||||
|
||||
@@ -312,7 +305,8 @@ class IOBase(object):
|
||||
)
|
||||
return bool(int_byte & 1 << self._bitaddress)
|
||||
else:
|
||||
return bool(self._parentdevice._ba_devdata[self._slc_address])
|
||||
return self._parentdevice._ba_devdata[self._slc_address] != \
|
||||
bytearray(self._length)
|
||||
|
||||
def __len__(self):
|
||||
"""Gibt die Bytelaenge des IO zurueck.
|
||||
@@ -335,8 +329,8 @@ class IOBase(object):
|
||||
return self._byteorder
|
||||
|
||||
def _get_iotype(self):
|
||||
"""Gibt io.Type zurueck.
|
||||
@return <class 'int'> io.Type"""
|
||||
"""Gibt io type zurueck.
|
||||
@return <class 'int'> io type"""
|
||||
return self._iotype
|
||||
|
||||
def get_defaultvalue(self):
|
||||
@@ -549,7 +543,7 @@ class IOBase(object):
|
||||
def set_value(self, value):
|
||||
"""Setzt den Wert des IOs.
|
||||
@param value IO-Wert als <class bytes'> oder <class 'bool'>"""
|
||||
if self._iotype == Type.OUT:
|
||||
if self._iotype == OUT:
|
||||
if self._bitaddress >= 0:
|
||||
# Versuchen egal welchen Typ in Bool zu konvertieren
|
||||
value = bool(value)
|
||||
@@ -591,7 +585,7 @@ class IOBase(object):
|
||||
"".format(self._name, type(value))
|
||||
)
|
||||
|
||||
elif self._iotype == Type.INP:
|
||||
elif self._iotype == INP:
|
||||
if self._parentdevice._modio._simulator:
|
||||
raise AttributeError(
|
||||
"can not write to output '{}' in simulator mode"
|
||||
@@ -601,7 +595,8 @@ class IOBase(object):
|
||||
raise AttributeError(
|
||||
"can not write to input '{}'".format(self._name)
|
||||
)
|
||||
elif self._iotype == Type.MEM:
|
||||
|
||||
elif self._iotype == MEM:
|
||||
raise AttributeError(
|
||||
"can not write to memory '{}'".format(self._name)
|
||||
)
|
||||
@@ -906,7 +901,7 @@ class StructIO(IOBase):
|
||||
def _get_frm(self):
|
||||
"""Ruft die struct Formatierung ab.
|
||||
@return struct Formatierung"""
|
||||
return self.__frm
|
||||
return self.__frm[1]
|
||||
|
||||
def _get_signed(self):
|
||||
"""Ruft ab, ob der Wert Vorzeichenbehaftet behandelt werden soll.
|
||||
|
||||
@@ -142,11 +142,11 @@ class RevPiModIO(object):
|
||||
err_names = []
|
||||
for device in sorted(lst_devices, key=lambda x: x["position"]):
|
||||
|
||||
# Bei VDev in alter piCtory Version, Position eindeutig machen
|
||||
# VDev alter piCtory Versionen auf Kunbus-Standard ändern
|
||||
if device["position"] == "adap.":
|
||||
device["position"] = -1
|
||||
device["position"] = 64
|
||||
while device["position"] in self.device:
|
||||
device["position"] -= 1
|
||||
device["position"] += 1
|
||||
|
||||
if device["type"] == "BASE":
|
||||
# Core
|
||||
@@ -275,7 +275,7 @@ class RevPiModIO(object):
|
||||
)
|
||||
warnings.warn(
|
||||
"got io error during {} and count {} errors now".format(
|
||||
self._ioerror, self._ioerror
|
||||
action, self._ioerror
|
||||
),
|
||||
RuntimeWarning
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user