mirror of
https://github.com/naruxde/revpimodio2.git
synced 2025-11-08 13:53:53 +01:00
Mit slots zusammenführen
This commit is contained in:
@@ -9,6 +9,8 @@ revpimodio2</h1>
|
||||
<p>
|
||||
Stellt alle Klassen fuer den RevolutionPi zur Verfuegung.
|
||||
</p><p>
|
||||
Webpage: https://revpimodio.org/
|
||||
</p><p>
|
||||
Stellt Klassen fuer die einfache Verwendung des Revolution Pis der
|
||||
Kunbus GmbH (https://revolution.kunbus.de/) zur Verfuegung. Alle I/Os werden
|
||||
aus der piCtory Konfiguration eingelesen und mit deren Namen direkt zugreifbar
|
||||
|
||||
@@ -9,6 +9,8 @@ revpimodio2.__init__</h1>
|
||||
<p>
|
||||
Stellt alle Klassen fuer den RevolutionPi zur Verfuegung.
|
||||
</p><p>
|
||||
Webpage: https://revpimodio.org/
|
||||
</p><p>
|
||||
Stellt Klassen fuer die einfache Verwendung des Revolution Pis der
|
||||
Kunbus GmbH (https://revolution.kunbus.de/) zur Verfuegung. Alle I/Os werden
|
||||
aus der piCtory Konfiguration eingelesen und mit deren Namen direkt zugreifbar
|
||||
@@ -20,7 +22,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>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>
|
||||
<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>__copyright__</td></tr><tr><td>__license__</td></tr><tr><td>__name__</td></tr><tr><td>__version__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Classes</h3>
|
||||
|
||||
@@ -12,7 +12,7 @@ Bildet die App Sektion von piCtory ab.
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Global Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>__author__</td></tr><tr><td>__copyright__</td></tr><tr><td>__license__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Classes</h3>
|
||||
@@ -39,7 +39,7 @@ object
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>__slots__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Methods</h3>
|
||||
|
||||
@@ -12,12 +12,15 @@ Modul fuer die Verwaltung der Devices.
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Global Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>__author__</td></tr><tr><td>__copyright__</td></tr><tr><td>__license__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Classes</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<td><a style="color:#0000FF" href="#Connect">Connect</a></td>
|
||||
<td>Klasse fuer den RevPi Connect.</td>
|
||||
</tr><tr>
|
||||
<td><a style="color:#0000FF" href="#Core">Core</a></td>
|
||||
<td>Klasse fuer den RevPi Core.</td>
|
||||
</tr><tr>
|
||||
@@ -40,6 +43,124 @@ Functions</h3>
|
||||
<tr><td>None</td></tr>
|
||||
</table>
|
||||
<hr /><hr />
|
||||
<a NAME="Connect" ID="Connect"></a>
|
||||
<h2 style="background-color:#FFFFFF;color:#0000FF">Connect</h2>
|
||||
<p>
|
||||
Klasse fuer den RevPi Connect.
|
||||
</p><p>
|
||||
Stellt Funktionen fuer die LEDs, Watchdog und den Status zur Verfuegung.
|
||||
</p><p>
|
||||
|
||||
</p>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Derived from</h3>
|
||||
Core
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>A3</td></tr><tr><td>__slots__</td></tr><tr><td>wdautotoggle</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><a style="color:#0000FF" href="#Connect.__wdtoggle">__wdtoggle</a></td>
|
||||
<td>WD Ausgang alle 10 Sekunden automatisch toggeln.</td>
|
||||
</tr><tr>
|
||||
<td><a style="color:#0000FF" href="#Connect._devconfigure">_devconfigure</a></td>
|
||||
<td>Connect-Klasse vorbereiten.</td>
|
||||
</tr><tr>
|
||||
<td><a style="color:#0000FF" href="#Connect._get_leda3">_get_leda3</a></td>
|
||||
<td>Gibt den Zustand der LED A3 vom Connect zurueck.</td>
|
||||
</tr><tr>
|
||||
<td><a style="color:#0000FF" href="#Connect._get_wdtoggle">_get_wdtoggle</a></td>
|
||||
<td>Ruft den Wert fuer Autowatchdog ab.</td>
|
||||
</tr><tr>
|
||||
<td><a style="color:#0000FF" href="#Connect._set_leda3">_set_leda3</a></td>
|
||||
<td>Setzt den Zustand der LED A3 vom Connect.</td>
|
||||
</tr><tr>
|
||||
<td><a style="color:#0000FF" href="#Connect._set_wdtoggle">_set_wdtoggle</a></td>
|
||||
<td>Setzt den Wert fuer Autowatchdog.</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Static Methods</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
</table>
|
||||
<a NAME="Connect.__wdtoggle" ID="Connect.__wdtoggle"></a>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Connect.__wdtoggle</h3>
|
||||
<b>__wdtoggle</b>(<i></i>)
|
||||
<p>
|
||||
WD Ausgang alle 10 Sekunden automatisch toggeln.
|
||||
</p><a NAME="Connect._devconfigure" ID="Connect._devconfigure"></a>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Connect._devconfigure</h3>
|
||||
<b>_devconfigure</b>(<i></i>)
|
||||
<p>
|
||||
Connect-Klasse vorbereiten.
|
||||
</p><a NAME="Connect._get_leda3" ID="Connect._get_leda3"></a>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Connect._get_leda3</h3>
|
||||
<b>_get_leda3</b>(<i></i>)
|
||||
<p>
|
||||
Gibt den Zustand der LED A3 vom Connect zurueck.
|
||||
</p><dl>
|
||||
<dt>Returns:</dt>
|
||||
<dd>
|
||||
0=aus, 1=gruen, 2=rot
|
||||
</dd>
|
||||
</dl><a NAME="Connect._get_wdtoggle" ID="Connect._get_wdtoggle"></a>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Connect._get_wdtoggle</h3>
|
||||
<b>_get_wdtoggle</b>(<i></i>)
|
||||
<p>
|
||||
Ruft den Wert fuer Autowatchdog ab.
|
||||
</p><dl>
|
||||
<dt>Returns:</dt>
|
||||
<dd>
|
||||
True, wenn Autowatchdog aktiv ist
|
||||
</dd>
|
||||
</dl><a NAME="Connect._set_leda3" ID="Connect._set_leda3"></a>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Connect._set_leda3</h3>
|
||||
<b>_set_leda3</b>(<i>value</i>)
|
||||
<p>
|
||||
Setzt den Zustand der LED A3 vom Connect.
|
||||
</p><dl>
|
||||
<dt><i>value</i></dt>
|
||||
<dd>
|
||||
0=aus, 1=gruen, 2=rot
|
||||
</dd>
|
||||
</dl><a NAME="Connect._set_wdtoggle" ID="Connect._set_wdtoggle"></a>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Connect._set_wdtoggle</h3>
|
||||
<b>_set_wdtoggle</b>(<i>value</i>)
|
||||
<p>
|
||||
Setzt den Wert fuer Autowatchdog.
|
||||
</p><p>
|
||||
Wird dieser Wert auf True gesetzt, wechselt im Hintergrund das noetige
|
||||
Bit zum toggeln des Watchdogs alle 10 Sekunden zwichen True und False.
|
||||
Dieses Bit wird bei autorefresh=True natuerlich automatisch in das
|
||||
Prozessabbild geschrieben.
|
||||
</p><p>
|
||||
WICHTIG: Sollte autorefresh=False sein, muss zyklisch
|
||||
.writeprocimg() aufgerufen werden, um den Wert in das
|
||||
Prozessabbild zu schreiben!!!
|
||||
</p><dl>
|
||||
<dt><i>value</i></dt>
|
||||
<dd>
|
||||
True zum aktivieren, Fals zum beenden
|
||||
</dd>
|
||||
</dl>
|
||||
<div align="right"><a style="color:#0000FF" href="#top">Up</a></div>
|
||||
<hr /><hr />
|
||||
<a NAME="Core" ID="Core"></a>
|
||||
<h2 style="background-color:#FFFFFF;color:#0000FF">Core</h2>
|
||||
<p>
|
||||
@@ -55,7 +176,7 @@ Device
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>A1</td></tr><tr><td>A2</td></tr><tr><td>status</td></tr>
|
||||
<tr><td>A1</td></tr><tr><td>A2</td></tr><tr><td>__slots__</td></tr><tr><td>status</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Methods</h3>
|
||||
@@ -73,19 +194,22 @@ Methods</h3>
|
||||
<td>Core-Klasse vorbereiten.</td>
|
||||
</tr><tr>
|
||||
<td><a style="color:#0000FF" href="#Core._get_leda1">_get_leda1</a></td>
|
||||
<td>Gibt den Zustand der LED A1 vom core zurueck.</td>
|
||||
<td>Gibt den Zustand der LED A1 vom Core zurueck.</td>
|
||||
</tr><tr>
|
||||
<td><a style="color:#0000FF" href="#Core._get_leda2">_get_leda2</a></td>
|
||||
<td>Gibt den Zustand der LED A2 vom core zurueck.</td>
|
||||
<td>Gibt den Zustand der LED A2 vom Core zurueck.</td>
|
||||
</tr><tr>
|
||||
<td><a style="color:#0000FF" href="#Core._get_status">_get_status</a></td>
|
||||
<td>Gibt den RevPi Core Status zurueck.</td>
|
||||
</tr><tr>
|
||||
<td><a style="color:#0000FF" href="#Core._set_calculatedled">_set_calculatedled</a></td>
|
||||
<td>Berechnet und setzt neuen Bytewert fuer LED byte.</td>
|
||||
</tr><tr>
|
||||
<td><a style="color:#0000FF" href="#Core._set_leda1">_set_leda1</a></td>
|
||||
<td>Setzt den Zustand der LED A1 vom core.</td>
|
||||
<td>Setzt den Zustand der LED A1 vom Core.</td>
|
||||
</tr><tr>
|
||||
<td><a style="color:#0000FF" href="#Core._set_leda2">_set_leda2</a></td>
|
||||
<td>Setzt den Zustand der LED A2 vom core.</td>
|
||||
<td>Setzt den Zustand der LED A2 vom Core.</td>
|
||||
</tr><tr>
|
||||
<td><a style="color:#0000FF" href="#Core.errorlimit1">errorlimit1</a></td>
|
||||
<td>Setzt RS485 ErrorLimit1 auf neuen Wert.</td>
|
||||
@@ -132,13 +256,13 @@ Static Methods</h3>
|
||||
<a NAME="Core.__errorlimit" ID="Core.__errorlimit"></a>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Core.__errorlimit</h3>
|
||||
<b>__errorlimit</b>(<i>io_id, errorlimit</i>)
|
||||
<b>__errorlimit</b>(<i>io, errorlimit</i>)
|
||||
<p>
|
||||
Verwaltet das Lesen und Schreiben der ErrorLimits.
|
||||
</p><dl>
|
||||
<dt><i>io_id</i></dt>
|
||||
<dt><i>io</i></dt>
|
||||
<dd>
|
||||
Index des IOs fuer ErrorLimit
|
||||
IOs Objekt fuer ErrorLimit
|
||||
</dd>
|
||||
</dl><dl>
|
||||
<dt>Returns:</dt>
|
||||
@@ -156,7 +280,7 @@ Core-Klasse vorbereiten.
|
||||
Core._get_leda1</h3>
|
||||
<b>_get_leda1</b>(<i></i>)
|
||||
<p>
|
||||
Gibt den Zustand der LED A1 vom core zurueck.
|
||||
Gibt den Zustand der LED A1 vom Core zurueck.
|
||||
</p><dl>
|
||||
<dt>Returns:</dt>
|
||||
<dd>
|
||||
@@ -167,7 +291,7 @@ Gibt den Zustand der LED A1 vom core zurueck.
|
||||
Core._get_leda2</h3>
|
||||
<b>_get_leda2</b>(<i></i>)
|
||||
<p>
|
||||
Gibt den Zustand der LED A2 vom core zurueck.
|
||||
Gibt den Zustand der LED A2 vom Core zurueck.
|
||||
</p><dl>
|
||||
<dt>Returns:</dt>
|
||||
<dd>
|
||||
@@ -184,12 +308,26 @@ Gibt den RevPi Core Status zurueck.
|
||||
<dd>
|
||||
Status als <class 'int'>
|
||||
</dd>
|
||||
</dl><a NAME="Core._set_calculatedled" ID="Core._set_calculatedled"></a>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Core._set_calculatedled</h3>
|
||||
<b>_set_calculatedled</b>(<i>addresslist, shifted_value</i>)
|
||||
<p>
|
||||
Berechnet und setzt neuen Bytewert fuer LED byte.
|
||||
</p><dl>
|
||||
<dt><i>addresslist</i></dt>
|
||||
<dd>
|
||||
Liste der Vergleicher
|
||||
</dd><dt><i>shifed_value</i></dt>
|
||||
<dd>
|
||||
Bits vergleichen
|
||||
</dd>
|
||||
</dl><a NAME="Core._set_leda1" ID="Core._set_leda1"></a>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Core._set_leda1</h3>
|
||||
<b>_set_leda1</b>(<i>value</i>)
|
||||
<p>
|
||||
Setzt den Zustand der LED A1 vom core.
|
||||
Setzt den Zustand der LED A1 vom Core.
|
||||
</p><dl>
|
||||
<dt><i>value</i></dt>
|
||||
<dd>
|
||||
@@ -200,7 +338,7 @@ Setzt den Zustand der LED A1 vom core.
|
||||
Core._set_leda2</h3>
|
||||
<b>_set_leda2</b>(<i>value</i>)
|
||||
<p>
|
||||
Setzt den Zustand der LED A2 vom core.
|
||||
Setzt den Zustand der LED A2 vom Core.
|
||||
</p><dl>
|
||||
<dt><i>value</i></dt>
|
||||
<dd>
|
||||
@@ -358,7 +496,7 @@ object
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>length</td></tr><tr><td>name</td></tr><tr><td>offset</td></tr><tr><td>position</td></tr><tr><td>producttype</td></tr>
|
||||
<tr><td>__slots__</td></tr><tr><td>length</td></tr><tr><td>name</td></tr><tr><td>offset</td></tr><tr><td>position</td></tr><tr><td>producttype</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Methods</h3>
|
||||
@@ -415,7 +553,7 @@ Methods</h3>
|
||||
<td>Gibt eine Liste aller Inputs zurueck.</td>
|
||||
</tr><tr>
|
||||
<td><a style="color:#0000FF" href="#Device.get_memories">get_memories</a></td>
|
||||
<td>Gibt eine Liste aller mems zurueck.</td>
|
||||
<td>Gibt eine Liste aller Memoryobjekte zurueck.</td>
|
||||
</tr><tr>
|
||||
<td><a style="color:#0000FF" href="#Device.get_outputs">get_outputs</a></td>
|
||||
<td>Gibt eine Liste aller Outputs zurueck.</td>
|
||||
@@ -485,13 +623,16 @@ True, wenn IO auf Device vorhanden
|
||||
</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>)
|
||||
<b>__getioiter</b>(<i>ioslc, export</i>)
|
||||
<p>
|
||||
Gibt <class 'iter'> mit allen IOs zurueck.
|
||||
</p><dl>
|
||||
<dt><i>ioslc</i></dt>
|
||||
<dd>
|
||||
IO Abschnitt <class 'slice'>
|
||||
</dd><dt><i>export</i></dt>
|
||||
<dd>
|
||||
Filter fuer 'Export' Flag in piCtory
|
||||
</dd>
|
||||
</dl><dl>
|
||||
<dt>Returns:</dt>
|
||||
@@ -603,10 +744,20 @@ Default True fuegt Device zur Synchronisierung hinzu
|
||||
</dl><a NAME="Device.get_allios" ID="Device.get_allios"></a>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Device.get_allios</h3>
|
||||
<b>get_allios</b>(<i></i>)
|
||||
<b>get_allios</b>(<i>export=None</i>)
|
||||
<p>
|
||||
Gibt eine Liste aller Inputs und Outputs zurueck, keine MEMs.
|
||||
</p><p>
|
||||
Bleibt Parameter 'export' auf None werden alle Inputs und Outputs
|
||||
zurueckgegeben. Wird 'export' auf True/False gesetzt, werden nur Inputs
|
||||
und Outputs zurueckgegeben, bei denen der Wert 'Export' in piCtory
|
||||
uebereinstimmt.
|
||||
</p><dl>
|
||||
<dt><i>export</i></dt>
|
||||
<dd>
|
||||
Nur In-/Outputs mit angegebenen 'Export' Wert in piCtory
|
||||
</dd>
|
||||
</dl><dl>
|
||||
<dt>Returns:</dt>
|
||||
<dd>
|
||||
<class 'list'> Input und Output, keine MEMs
|
||||
@@ -614,10 +765,19 @@ Gibt eine Liste aller Inputs und Outputs zurueck, keine MEMs.
|
||||
</dl><a NAME="Device.get_inputs" ID="Device.get_inputs"></a>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Device.get_inputs</h3>
|
||||
<b>get_inputs</b>(<i></i>)
|
||||
<b>get_inputs</b>(<i>export=None</i>)
|
||||
<p>
|
||||
Gibt eine Liste aller Inputs zurueck.
|
||||
</p><p>
|
||||
Bleibt Parameter 'export' auf None werden alle Inputs zurueckgegeben.
|
||||
Wird 'export' auf True/False gesetzt, werden nur Inputs zurueckgegeben,
|
||||
bei denen der Wert 'Export' in piCtory uebereinstimmt.
|
||||
</p><dl>
|
||||
<dt><i>export</i></dt>
|
||||
<dd>
|
||||
Nur Inputs mit angegebenen 'Export' Wert in piCtory
|
||||
</dd>
|
||||
</dl><dl>
|
||||
<dt>Returns:</dt>
|
||||
<dd>
|
||||
<class 'list'> Inputs
|
||||
@@ -625,10 +785,19 @@ Gibt eine Liste aller Inputs zurueck.
|
||||
</dl><a NAME="Device.get_memories" ID="Device.get_memories"></a>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Device.get_memories</h3>
|
||||
<b>get_memories</b>(<i></i>)
|
||||
<b>get_memories</b>(<i>export=None</i>)
|
||||
<p>
|
||||
Gibt eine Liste aller mems zurueck.
|
||||
Gibt eine Liste aller Memoryobjekte zurueck.
|
||||
</p><p>
|
||||
Bleibt Parameter 'export' auf None werden alle Mems zurueckgegeben.
|
||||
Wird 'export' auf True/False gesetzt, werden nur Mems zurueckgegeben,
|
||||
bei denen der Wert 'Export' in piCtory uebereinstimmt.
|
||||
</p><dl>
|
||||
<dt><i>export</i></dt>
|
||||
<dd>
|
||||
Nur Mems mit angegebenen 'Export' Wert in piCtory
|
||||
</dd>
|
||||
</dl><dl>
|
||||
<dt>Returns:</dt>
|
||||
<dd>
|
||||
<class 'list'> Mems
|
||||
@@ -636,10 +805,19 @@ Gibt eine Liste aller mems zurueck.
|
||||
</dl><a NAME="Device.get_outputs" ID="Device.get_outputs"></a>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Device.get_outputs</h3>
|
||||
<b>get_outputs</b>(<i></i>)
|
||||
<b>get_outputs</b>(<i>export=None</i>)
|
||||
<p>
|
||||
Gibt eine Liste aller Outputs zurueck.
|
||||
</p><p>
|
||||
Bleibt Parameter 'export' auf None werden alle Outputs zurueckgegeben.
|
||||
Wird 'export' auf True/False gesetzt, werden nur Outputs
|
||||
zurueckgegeben, bei denen der Wert 'Export' in piCtory uebereinstimmt.
|
||||
</p><dl>
|
||||
<dt><i>export</i></dt>
|
||||
<dd>
|
||||
Nur Outputs mit angegebenen 'Export' Wert in piCtory
|
||||
</dd>
|
||||
</dl><dl>
|
||||
<dt>Returns:</dt>
|
||||
<dd>
|
||||
<class 'list'> Outputs
|
||||
@@ -886,7 +1064,7 @@ Device
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>__slots__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Methods</h3>
|
||||
@@ -955,7 +1133,7 @@ Gateway
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>__slots__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Methods</h3>
|
||||
|
||||
@@ -12,7 +12,7 @@ RevPiModIO Helperklassen und Tools.
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Global Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>__author__</td></tr><tr><td>__copyright__</td></tr><tr><td>__license__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Classes</h3>
|
||||
@@ -26,6 +26,9 @@ Classes</h3>
|
||||
</tr><tr>
|
||||
<td><a style="color:#0000FF" href="#ProcimgWriter">ProcimgWriter</a></td>
|
||||
<td>Klasse fuer Synchroniseriungs-Thread.</td>
|
||||
</tr><tr>
|
||||
<td><a style="color:#0000FF" href="#Var">Var</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
@@ -65,7 +68,7 @@ None
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>__slots__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Methods</h3>
|
||||
@@ -351,7 +354,7 @@ Thread
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>__slots__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Methods</h3>
|
||||
@@ -426,7 +429,7 @@ Thread
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>ioerrors</td></tr><tr><td>maxioerrors</td></tr><tr><td>refresh</td></tr>
|
||||
<tr><td>__slots__</td></tr><tr><td>ioerrors</td></tr><tr><td>maxioerrors</td></tr><tr><td>refresh</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Methods</h3>
|
||||
@@ -513,6 +516,11 @@ Aktiviert oder Deaktiviert die Eventueberwachung.
|
||||
<dd>
|
||||
True aktiviert / False deaktiviert
|
||||
</dd>
|
||||
</dl><dl>
|
||||
<dt>Returns:</dt>
|
||||
<dd>
|
||||
True, wenn Anforderung erfolgreich war
|
||||
</dd>
|
||||
</dl><a NAME="ProcimgWriter._get_ioerrors" ID="ProcimgWriter._get_ioerrors"></a>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
ProcimgWriter._get_ioerrors</h3>
|
||||
@@ -587,6 +595,35 @@ ProcimgWriter.stop</h3>
|
||||
<p>
|
||||
Beendet die automatische Prozessabbildsynchronisierung.
|
||||
</p>
|
||||
<div align="right"><a style="color:#0000FF" href="#top">Up</a></div>
|
||||
<hr /><hr />
|
||||
<a NAME="Var" ID="Var"></a>
|
||||
<h2 style="background-color:#FFFFFF;color:#0000FF">Var</h2>
|
||||
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Derived from</h3>
|
||||
None
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</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>
|
||||
@@ -12,7 +12,7 @@ RevPiModIO Modul fuer die Verwaltung der IOs.
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Global Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>__author__</td></tr><tr><td>__copyright__</td></tr><tr><td>__license__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Classes</h3>
|
||||
@@ -54,7 +54,7 @@ object
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>_parentdevice</td></tr>
|
||||
<tr><td>__slots__</td></tr><tr><td>_parentdevice</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Methods</h3>
|
||||
@@ -124,7 +124,7 @@ object
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>address</td></tr><tr><td>byteorder</td></tr><tr><td>defaultvalue</td></tr><tr><td>length</td></tr><tr><td>name</td></tr><tr><td>type</td></tr><tr><td>value</td></tr>
|
||||
<tr><td>__slots__</td></tr><tr><td>address</td></tr><tr><td>byteorder</td></tr><tr><td>defaultvalue</td></tr><tr><td>length</td></tr><tr><td>name</td></tr><tr><td>type</td></tr><tr><td>value</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Methods</h3>
|
||||
@@ -202,7 +202,7 @@ Parentdevice auf dem der IO liegt
|
||||
</dd><dt><i>valuelist</i></dt>
|
||||
<dd>
|
||||
Datenliste fuer Instantiierung
|
||||
["name","defval","bitlen","startaddr",exp,"idx","bmk","bitaddr"]
|
||||
["name","defval","bitlen","startaddrdev",exp,"idx","bmk","bitaddr"]
|
||||
</dd><dt><i>iotype</i></dt>
|
||||
<dd>
|
||||
<class 'int'> Wert
|
||||
@@ -520,7 +520,7 @@ object
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>__slots__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Methods</h3>
|
||||
@@ -752,7 +752,7 @@ IOBase
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>byteorder</td></tr><tr><td>defaultvalue</td></tr><tr><td>signed</td></tr><tr><td>value</td></tr>
|
||||
<tr><td>__slots__</td></tr><tr><td>byteorder</td></tr><tr><td>defaultvalue</td></tr><tr><td>signed</td></tr><tr><td>value</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Methods</h3>
|
||||
@@ -889,7 +889,7 @@ IOBase
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>defaultvalue</td></tr><tr><td>frm</td></tr><tr><td>signed</td></tr><tr><td>value</td></tr>
|
||||
<tr><td>__slots__</td></tr><tr><td>defaultvalue</td></tr><tr><td>frm</td></tr><tr><td>signed</td></tr><tr><td>value</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Methods</h3>
|
||||
|
||||
@@ -12,7 +12,7 @@ RevPiModIO Hauptklasse fuer piControl0 Zugriff.
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Global Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>__author__</td></tr><tr><td>__copyright__</td></tr><tr><td>__license__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Classes</h3>
|
||||
@@ -54,7 +54,7 @@ object
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>configrsc</td></tr><tr><td>cycletime</td></tr><tr><td>ioerrors</td></tr><tr><td>length</td></tr><tr><td>maxioerrors</td></tr><tr><td>monitoring</td></tr><tr><td>procimg</td></tr><tr><td>simulator</td></tr>
|
||||
<tr><td>__slots__</td></tr><tr><td>configrsc</td></tr><tr><td>cycletime</td></tr><tr><td>ioerrors</td></tr><tr><td>length</td></tr><tr><td>maxioerrors</td></tr><tr><td>monitoring</td></tr><tr><td>procimg</td></tr><tr><td>simulator</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Methods</h3>
|
||||
@@ -345,7 +345,7 @@ Beendet autorefresh und alle Threads.
|
||||
</p><a NAME="RevPiModIO.cycleloop" ID="RevPiModIO.cycleloop"></a>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
RevPiModIO.cycleloop</h3>
|
||||
<b>cycleloop</b>(<i>func, cycletime=None</i>)
|
||||
<b>cycleloop</b>(<i>func, cycletime=50</i>)
|
||||
<p>
|
||||
Startet den Cycleloop.
|
||||
</p><p>
|
||||
@@ -358,23 +358,24 @@ Startet den Cycleloop.
|
||||
Prozessabbild geschrieben.
|
||||
</p><p>
|
||||
Verlassen wird der Cycleloop, wenn die aufgerufene Funktion einen
|
||||
Rueckgabewert nicht gleich None liefert, oder durch Aufruf von
|
||||
revpimodio.exit().
|
||||
Rueckgabewert nicht gleich None liefert (z.B. return True), oder durch
|
||||
Aufruf von .exit().
|
||||
</p><p>
|
||||
HINWEIS: Die Aktualisierungszeit und die Laufzeit der Funktion duerfen
|
||||
die eingestellte autorefresh Zeit, bzw. uebergebene cycletime nicht
|
||||
ueberschreiten!
|
||||
</p><p>
|
||||
Ueber das Attribut cycletime kann die Aktualisierungsrate fuer das
|
||||
Prozessabbild gesetzt werden.
|
||||
Ueber den Parameter cycletime wird die gewuenschte Zukluszeit der
|
||||
uebergebenen Funktion gesetzt. Der Standardwert betraegt
|
||||
50 Millisekunden, in denen das Prozessabild eingelesen, die uebergebene
|
||||
Funktion ausgefuert und das Prozessabbild geschrieben wird.
|
||||
</p><dl>
|
||||
<dt><i>func</i></dt>
|
||||
<dd>
|
||||
Funktion, die ausgefuehrt werden soll
|
||||
</dd><dt><i>cycletime</i></dt>
|
||||
<dd>
|
||||
Zykluszeit in Millisekunden, bei Nichtangabe wird
|
||||
aktuelle .cycletime Zeit verwendet - Standardwert 50 ms
|
||||
Zykluszeit in Millisekunden - Standardwert 50 ms
|
||||
</dd>
|
||||
</dl><dl>
|
||||
<dt>Returns:</dt>
|
||||
@@ -557,7 +558,7 @@ RevPiModIOSelected
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>__slots__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Methods</h3>
|
||||
@@ -617,7 +618,7 @@ RevPiModIO
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>__slots__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Methods</h3>
|
||||
|
||||
@@ -12,7 +12,7 @@ RevPiModIO Hauptklasse fuer Netzwerkzugriff.
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Global Attributes</h3>
|
||||
<table>
|
||||
<tr><td>_sysdeldirty</td></tr><tr><td>_sysexit</td></tr><tr><td>_sysflush</td></tr><tr><td>_syspictory</td></tr><tr><td>_syssync</td></tr>
|
||||
<tr><td>__author__</td></tr><tr><td>__copyright__</td></tr><tr><td>__license__</td></tr><tr><td>_sysdeldirty</td></tr><tr><td>_sysexit</td></tr><tr><td>_sysflush</td></tr><tr><td>_syspictory</td></tr><tr><td>_syssync</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Classes</h3>
|
||||
@@ -54,7 +54,7 @@ Thread
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>closed</td></tr><tr><td>name</td></tr><tr><td>timeout</td></tr>
|
||||
<tr><td>__slots__</td></tr><tr><td>closed</td></tr><tr><td>name</td></tr><tr><td>timeout</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Methods</h3>
|
||||
@@ -128,7 +128,15 @@ NetFH (Constructor)</h3>
|
||||
<b>NetFH</b>(<i>address, timeout=500</i>)
|
||||
<p>
|
||||
Init NetFH-class.
|
||||
</p><a NAME="NetFH.__del__" ID="NetFH.__del__"></a>
|
||||
</p><dl>
|
||||
<dt><i>address</i></dt>
|
||||
<dd>
|
||||
IP Adresse des RevPi
|
||||
</dd><dt><i>timeout</i></dt>
|
||||
<dd>
|
||||
Timeout in Millisekunden der Verbindung
|
||||
</dd>
|
||||
</dl><a NAME="NetFH.__del__" ID="NetFH.__del__"></a>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
NetFH.__del__</h3>
|
||||
<b>__del__</b>(<i></i>)
|
||||
@@ -315,7 +323,7 @@ _RevPiModIO
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>__slots__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Methods</h3>
|
||||
@@ -440,7 +448,7 @@ RevPiNetIOSelected
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>__slots__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Methods</h3>
|
||||
@@ -503,7 +511,7 @@ RevPiNetIO
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>__slots__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Methods</h3>
|
||||
|
||||
@@ -12,7 +12,7 @@ Bildet die Summary-Sektion von piCtory ab.
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Global Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>__author__</td></tr><tr><td>__copyright__</td></tr><tr><td>__license__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Classes</h3>
|
||||
@@ -39,7 +39,7 @@ object
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Attributes</h3>
|
||||
<table>
|
||||
<tr><td>None</td></tr>
|
||||
<tr><td>__slots__</td></tr>
|
||||
</table>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Class Methods</h3>
|
||||
|
||||
@@ -9,12 +9,20 @@ revpimodio2.RED?7
|
||||
revpimodio2.RISING?7
|
||||
revpimodio2.app.App?1(app)
|
||||
revpimodio2.consttostr?4(value)
|
||||
revpimodio2.device.Connect.A3?7
|
||||
revpimodio2.device.Connect._devconfigure?5()
|
||||
revpimodio2.device.Connect._get_leda3?5()
|
||||
revpimodio2.device.Connect._get_wdtoggle?5()
|
||||
revpimodio2.device.Connect._set_leda3?5(value)
|
||||
revpimodio2.device.Connect._set_wdtoggle?5(value)
|
||||
revpimodio2.device.Connect.wdautotoggle?7
|
||||
revpimodio2.device.Core.A1?7
|
||||
revpimodio2.device.Core.A2?7
|
||||
revpimodio2.device.Core._devconfigure?5()
|
||||
revpimodio2.device.Core._get_leda1?5()
|
||||
revpimodio2.device.Core._get_leda2?5()
|
||||
revpimodio2.device.Core._get_status?5()
|
||||
revpimodio2.device.Core._set_calculatedled?5(addresslist, shifted_value)
|
||||
revpimodio2.device.Core._set_leda1?5(value)
|
||||
revpimodio2.device.Core._set_leda2?5(value)
|
||||
revpimodio2.device.Core.errorlimit1?4(value)
|
||||
@@ -35,10 +43,10 @@ revpimodio2.device.Device._devconfigure?5()
|
||||
revpimodio2.device.Device._get_offset?5()
|
||||
revpimodio2.device.Device._get_producttype?5()
|
||||
revpimodio2.device.Device.autorefresh?4(activate=True)
|
||||
revpimodio2.device.Device.get_allios?4()
|
||||
revpimodio2.device.Device.get_inputs?4()
|
||||
revpimodio2.device.Device.get_memories?4()
|
||||
revpimodio2.device.Device.get_outputs?4()
|
||||
revpimodio2.device.Device.get_allios?4(export=None)
|
||||
revpimodio2.device.Device.get_inputs?4(export=None)
|
||||
revpimodio2.device.Device.get_memories?4(export=None)
|
||||
revpimodio2.device.Device.get_outputs?4(export=None)
|
||||
revpimodio2.device.Device.length?7
|
||||
revpimodio2.device.Device.name?7
|
||||
revpimodio2.device.Device.offset?7
|
||||
@@ -144,7 +152,7 @@ revpimodio2.modio.RevPiModIO._set_maxioerrors?5(value)
|
||||
revpimodio2.modio.RevPiModIO.autorefresh_all?4()
|
||||
revpimodio2.modio.RevPiModIO.cleanup?4()
|
||||
revpimodio2.modio.RevPiModIO.configrsc?7
|
||||
revpimodio2.modio.RevPiModIO.cycleloop?4(func, cycletime=None)
|
||||
revpimodio2.modio.RevPiModIO.cycleloop?4(func, cycletime=50)
|
||||
revpimodio2.modio.RevPiModIO.cycletime?7
|
||||
revpimodio2.modio.RevPiModIO.exit?4(full=True)
|
||||
revpimodio2.modio.RevPiModIO.get_jconfigrsc?4()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
Connect Core
|
||||
Core Device
|
||||
EventCallback Thread
|
||||
Gateway Device
|
||||
|
||||
115
revpimodio2.e4p
115
revpimodio2.e4p
@@ -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: 2018-06-27, 11:30:13 -->
|
||||
<!-- Saved: 2018-08-13, 13:53:52 -->
|
||||
<!-- Copyright (C) 2018 Sven Sager, akira@narux.de -->
|
||||
<Project version="5.1">
|
||||
<Language>en_US</Language>
|
||||
@@ -9,44 +9,45 @@
|
||||
<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.1.6</Version>
|
||||
<Version>2.2.3</Version>
|
||||
<Author>Sven Sager</Author>
|
||||
<Email>akira@narux.de</Email>
|
||||
<Eol index="1"/>
|
||||
<Sources>
|
||||
<Source>setup.py</Source>
|
||||
<Source>revpimodio2/modio.py</Source>
|
||||
<Source>revpimodio2/summary.py</Source>
|
||||
<Source>revpimodio2/app.py</Source>
|
||||
<Source>revpimodio2/io.py</Source>
|
||||
<Source>revpimodio2/__init__.py</Source>
|
||||
<Source>revpimodio2/app.py</Source>
|
||||
<Source>revpimodio2/device.py</Source>
|
||||
<Source>revpimodio2/helper.py</Source>
|
||||
<Source>revpimodio2/io.py</Source>
|
||||
<Source>revpimodio2/modio.py</Source>
|
||||
<Source>revpimodio2/netio.py</Source>
|
||||
<Source>test/test_dio_while2.py</Source>
|
||||
<Source>test/test_dio_mainloop.py</Source>
|
||||
<Source>revpimodio2/summary.py</Source>
|
||||
<Source>setup.py</Source>
|
||||
<Source>test/test_dio_cycleloop.py</Source>
|
||||
<Source>test/test_dio_mainloop.py</Source>
|
||||
<Source>test/test_dio_while2.py</Source>
|
||||
<Source>test/test_net_leistung.py</Source>
|
||||
<Source>test/web_cycleloop.py</Source>
|
||||
<Source>test/web_mainloop.py</Source>
|
||||
<Source>test/web_virtdevdriver.py</Source>
|
||||
<Source>test/test_netio_brett.py</Source>
|
||||
<Source>test/test_unit.py</Source>
|
||||
<Source>test/test_unit_fh.py</Source>
|
||||
<Source>test/test_unitnet.py</Source>
|
||||
<Source>test/web_benniesrun.py</Source>
|
||||
<Source>test/web_benniesrunxxl.py</Source>
|
||||
<Source>test/test_unit.py</Source>
|
||||
<Source>test/test_unitnet.py</Source>
|
||||
<Source>test/test_netio_brett.py</Source>
|
||||
<Source>test/web_startseite.py</Source>
|
||||
<Source>test/web_cycleloop.py</Source>
|
||||
<Source>test/web_mainloop.py</Source>
|
||||
<Source>test/web_rpidaten.py</Source>
|
||||
<Source>test/web_rpii2c.py</Source>
|
||||
<Source>test/web_startseite.py</Source>
|
||||
<Source>test/web_virtdevdriver.py</Source>
|
||||
</Sources>
|
||||
<Forms/>
|
||||
<Translations/>
|
||||
<Resources/>
|
||||
<Interfaces/>
|
||||
<Others>
|
||||
<Other>doc</Other>
|
||||
<Other>.hgignore</Other>
|
||||
<Other>MANIFEST.in</Other>
|
||||
<Other>doc</Other>
|
||||
<Other>eric-revpimodio2.api</Other>
|
||||
</Others>
|
||||
<MainScript>test/test_unit.py</MainScript>
|
||||
@@ -152,9 +153,6 @@
|
||||
</value>
|
||||
</dict>
|
||||
</VcsOptions>
|
||||
<VcsOtherData>
|
||||
<dict/>
|
||||
</VcsOtherData>
|
||||
</Vcs>
|
||||
<FiletypeAssociations>
|
||||
<FiletypeAssociation pattern="*.idl" type="INTERFACES"/>
|
||||
@@ -248,14 +246,6 @@
|
||||
<value>
|
||||
<bool>False</bool>
|
||||
</value>
|
||||
<key>
|
||||
<string>sourceExtensions</string>
|
||||
</key>
|
||||
<value>
|
||||
<list>
|
||||
<string></string>
|
||||
</list>
|
||||
</value>
|
||||
<key>
|
||||
<string>useRecursion</string>
|
||||
</key>
|
||||
@@ -275,6 +265,41 @@
|
||||
</key>
|
||||
<value>
|
||||
<dict>
|
||||
<key>
|
||||
<string>BuiltinsChecker</string>
|
||||
</key>
|
||||
<value>
|
||||
<dict>
|
||||
<key>
|
||||
<string>chr</string>
|
||||
</key>
|
||||
<value>
|
||||
<list>
|
||||
<string>unichr</string>
|
||||
</list>
|
||||
</value>
|
||||
<key>
|
||||
<string>str</string>
|
||||
</key>
|
||||
<value>
|
||||
<list>
|
||||
<string>unicode</string>
|
||||
</list>
|
||||
</value>
|
||||
</dict>
|
||||
</value>
|
||||
<key>
|
||||
<string>CopyrightAuthor</string>
|
||||
</key>
|
||||
<value>
|
||||
<string></string>
|
||||
</value>
|
||||
<key>
|
||||
<string>CopyrightMinFileSize</string>
|
||||
</key>
|
||||
<value>
|
||||
<int>0</int>
|
||||
</value>
|
||||
<key>
|
||||
<string>DocstringType</string>
|
||||
</key>
|
||||
@@ -285,13 +310,13 @@
|
||||
<string>ExcludeFiles</string>
|
||||
</key>
|
||||
<value>
|
||||
<string></string>
|
||||
<string>*/test/*</string>
|
||||
</value>
|
||||
<key>
|
||||
<string>ExcludeMessages</string>
|
||||
</key>
|
||||
<value>
|
||||
<string>E123,E226,E24</string>
|
||||
<string>E123,E226,E24,C101,E402,C111</string>
|
||||
</value>
|
||||
<key>
|
||||
<string>FixCodes</string>
|
||||
@@ -305,6 +330,12 @@
|
||||
<value>
|
||||
<bool>False</bool>
|
||||
</value>
|
||||
<key>
|
||||
<string>FutureChecker</string>
|
||||
</key>
|
||||
<value>
|
||||
<string></string>
|
||||
</value>
|
||||
<key>
|
||||
<string>HangClosing</string>
|
||||
</key>
|
||||
@@ -317,6 +348,24 @@
|
||||
<value>
|
||||
<string></string>
|
||||
</value>
|
||||
<key>
|
||||
<string>LineComplexity</string>
|
||||
</key>
|
||||
<value>
|
||||
<int>15</int>
|
||||
</value>
|
||||
<key>
|
||||
<string>LineComplexityScore</string>
|
||||
</key>
|
||||
<value>
|
||||
<int>10</int>
|
||||
</value>
|
||||
<key>
|
||||
<string>MaxCodeComplexity</string>
|
||||
</key>
|
||||
<value>
|
||||
<int>10</int>
|
||||
</value>
|
||||
<key>
|
||||
<string>MaxLineLength</string>
|
||||
</key>
|
||||
@@ -341,6 +390,12 @@
|
||||
<value>
|
||||
<bool>False</bool>
|
||||
</value>
|
||||
<key>
|
||||
<string>ValidEncodings</string>
|
||||
</key>
|
||||
<value>
|
||||
<string>latin-1, utf-8</string>
|
||||
</value>
|
||||
</dict>
|
||||
</value>
|
||||
</dict>
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# python3-RevPiModIO
|
||||
#
|
||||
# Webpage: https://revpimodio.org/
|
||||
# (c) Sven Sager, License: LGPLv3
|
||||
#
|
||||
"""Stellt alle Klassen fuer den RevolutionPi zur Verfuegung.
|
||||
|
||||
Webpage: https://revpimodio.org/
|
||||
|
||||
Stellt Klassen fuer die einfache Verwendung des Revolution Pis der
|
||||
Kunbus GmbH (https://revolution.kunbus.de/) zur Verfuegung. Alle I/Os werden
|
||||
aus der piCtory Konfiguration eingelesen und mit deren Namen direkt zugreifbar
|
||||
@@ -23,9 +19,10 @@ __all__ = [
|
||||
"RevPiNetIO", "RevPiNetIOSelected", "RevPiNetIODriver"
|
||||
]
|
||||
__author__ = "Sven Sager <akira@revpimodio.org>"
|
||||
__copyright__ = "Copyright (C) 2018 Sven Sager"
|
||||
__license__ = "LGPLv3"
|
||||
__name__ = "revpimodio2"
|
||||
__package__ = "revpimodio2"
|
||||
__version__ = "2.1.6"
|
||||
__version__ = "2.2.3"
|
||||
|
||||
# Global package values
|
||||
OFF = 0
|
||||
@@ -71,6 +68,7 @@ def consttostr(value):
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
||||
# Benötigte Klassen importieren
|
||||
from .modio import RevPiModIO, RevPiModIOSelected, RevPiModIODriver
|
||||
from .netio import RevPiNetIO, RevPiNetIOSelected, RevPiNetIODriver
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# python3-RevPiModIO
|
||||
#
|
||||
# Webpage: https://revpimodio.org/
|
||||
# (c) Sven Sager, License: LGPLv3
|
||||
#
|
||||
"""Bildet die App Sektion von piCtory ab."""
|
||||
__author__ = "Sven Sager"
|
||||
__copyright__ = "Copyright (C) 2018 Sven Sager"
|
||||
__license__ = "LGPLv3"
|
||||
|
||||
|
||||
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"""
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# python3-RevPiModIO
|
||||
#
|
||||
# Webpage: https://revpimodio.org/
|
||||
# (c) Sven Sager, License: LGPLv3
|
||||
#
|
||||
"""Modul fuer die Verwaltung der Devices."""
|
||||
from threading import Lock
|
||||
__author__ = "Sven Sager"
|
||||
__copyright__ = "Copyright (C) 2018 Sven Sager"
|
||||
__license__ = "LGPLv3"
|
||||
|
||||
from threading import Thread, Event, Lock
|
||||
from .helper import ProcimgWriter
|
||||
|
||||
|
||||
@@ -55,7 +53,7 @@ class DeviceList(object):
|
||||
def __delitem__(self, key):
|
||||
"""Entfernt Device an angegebener Position.
|
||||
@param key Deviceposition zum entfernen"""
|
||||
if issubclass(type(key), Device):
|
||||
if isinstance(key, Device):
|
||||
key = key._position
|
||||
self.__delattr__(key)
|
||||
|
||||
@@ -65,7 +63,7 @@ class DeviceList(object):
|
||||
@return Gefundenes <class 'Device'>-Objekt"""
|
||||
if type(key) == int:
|
||||
if key not in self.__dict_position:
|
||||
raise KeyError("no device on position {}".format(key))
|
||||
raise KeyError("no device on position {0}".format(key))
|
||||
return self.__dict_position[key]
|
||||
else:
|
||||
return getattr(self, key)
|
||||
@@ -91,7 +89,7 @@ class DeviceList(object):
|
||||
"""Setzt Attribute nur wenn Device.
|
||||
@param key Attributname
|
||||
@param value Attributobjekt"""
|
||||
if issubclass(type(value), Device):
|
||||
if isinstance(value, Device):
|
||||
object.__setattr__(self, key, value)
|
||||
self.__dict_position[value._position] = value
|
||||
elif key == "_DeviceList__dict_position":
|
||||
@@ -108,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.
|
||||
|
||||
@@ -124,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
|
||||
@@ -164,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()
|
||||
@@ -178,7 +191,7 @@ class Device(object):
|
||||
"""Prueft ob IO auf diesem Device liegt.
|
||||
@param key IO-Name <class 'str'> / IO-Bytenummer <class 'int'>
|
||||
@return True, wenn IO auf Device vorhanden"""
|
||||
if issubclass(type(key), IOBase):
|
||||
if isinstance(key, IOBase):
|
||||
# Umwandlung für key
|
||||
key = key._name
|
||||
|
||||
@@ -200,7 +213,7 @@ class Device(object):
|
||||
def __iter__(self):
|
||||
"""Gibt Iterator aller IOs zurueck.
|
||||
@return <class 'iter'> aller IOs"""
|
||||
return self.__getioiter(self._slc_devoff)
|
||||
return self.__getioiter(self._slc_devoff, None)
|
||||
|
||||
def __len__(self):
|
||||
"""Gibt Anzahl der Bytes zurueck, die dieses Device belegt.
|
||||
@@ -212,13 +225,17 @@ class Device(object):
|
||||
@return Devicename"""
|
||||
return self._name
|
||||
|
||||
def __getioiter(self, ioslc):
|
||||
def __getioiter(self, ioslc, export):
|
||||
"""Gibt <class 'iter'> mit allen IOs zurueck.
|
||||
|
||||
@param ioslc IO Abschnitt <class 'slice'>
|
||||
@return IOs als Iterator"""
|
||||
@param export Filter fuer 'Export' Flag in piCtory
|
||||
@return IOs als Iterator
|
||||
|
||||
"""
|
||||
for lst_io in self._modio.io[ioslc]:
|
||||
for io in lst_io:
|
||||
if io is not None:
|
||||
if io is not None and (export is None or io.export == export):
|
||||
yield io
|
||||
|
||||
def _buildio(self, dict_io, iotype):
|
||||
@@ -236,7 +253,7 @@ class Device(object):
|
||||
for key in sorted(dict_io, key=lambda x: int(x)):
|
||||
|
||||
# Neuen IO anlegen
|
||||
if bool(dict_io[key][7]) or self._producttype == 95:
|
||||
if bool(dict_io[key][7]) or isinstance(self, Core):
|
||||
# Bei Bitwerten oder Core RevPiIOBase verwenden
|
||||
io_new = IOBase(
|
||||
self, dict_io[key], iotype, "little", False
|
||||
@@ -246,6 +263,7 @@ class Device(object):
|
||||
self, dict_io[key],
|
||||
iotype,
|
||||
"little",
|
||||
# Bei AIO (103) signed auf True setzen
|
||||
self._producttype == 103
|
||||
)
|
||||
|
||||
@@ -285,9 +303,8 @@ class Device(object):
|
||||
self._modio.readprocimg(self)
|
||||
|
||||
# Datenkopie anlegen
|
||||
self._filelock.acquire()
|
||||
self._ba_datacp = self._ba_devdata[:]
|
||||
self._filelock.release()
|
||||
with self._filelock:
|
||||
self._ba_datacp = self._ba_devdata[:]
|
||||
|
||||
self._selfupdate = True
|
||||
|
||||
@@ -322,27 +339,60 @@ class Device(object):
|
||||
if not self._modio._monitoring:
|
||||
self._modio.writeprocimg(self)
|
||||
|
||||
def get_allios(self):
|
||||
def get_allios(self, export=None):
|
||||
"""Gibt eine Liste aller Inputs und Outputs zurueck, keine MEMs.
|
||||
@return <class 'list'> Input und Output, keine MEMs"""
|
||||
|
||||
Bleibt Parameter 'export' auf None werden alle Inputs und Outputs
|
||||
zurueckgegeben. Wird 'export' auf True/False gesetzt, werden nur Inputs
|
||||
und Outputs zurueckgegeben, bei denen der Wert 'Export' in piCtory
|
||||
uebereinstimmt.
|
||||
|
||||
@param export Nur In-/Outputs mit angegebenen 'Export' Wert in piCtory
|
||||
@return <class 'list'> Input und Output, keine MEMs
|
||||
|
||||
"""
|
||||
return list(self.__getioiter(
|
||||
slice(self._slc_inpoff.start, self._slc_outoff.stop)
|
||||
slice(self._slc_inpoff.start, self._slc_outoff.stop), export
|
||||
))
|
||||
|
||||
def get_inputs(self):
|
||||
def get_inputs(self, export=None):
|
||||
"""Gibt eine Liste aller Inputs zurueck.
|
||||
@return <class 'list'> Inputs"""
|
||||
return list(self.__getioiter(self._slc_inpoff))
|
||||
|
||||
def get_outputs(self):
|
||||
Bleibt Parameter 'export' auf None werden alle Inputs zurueckgegeben.
|
||||
Wird 'export' auf True/False gesetzt, werden nur Inputs zurueckgegeben,
|
||||
bei denen der Wert 'Export' in piCtory uebereinstimmt.
|
||||
|
||||
@param export Nur Inputs mit angegebenen 'Export' Wert in piCtory
|
||||
@return <class 'list'> Inputs
|
||||
|
||||
"""
|
||||
return list(self.__getioiter(self._slc_inpoff, export))
|
||||
|
||||
def get_outputs(self, export=None):
|
||||
"""Gibt eine Liste aller Outputs zurueck.
|
||||
@return <class 'list'> Outputs"""
|
||||
return list(self.__getioiter(self._slc_outoff))
|
||||
|
||||
def get_memories(self):
|
||||
"""Gibt eine Liste aller mems zurueck.
|
||||
@return <class 'list'> Mems"""
|
||||
return list(self.__getioiter(self._slc_memoff))
|
||||
Bleibt Parameter 'export' auf None werden alle Outputs zurueckgegeben.
|
||||
Wird 'export' auf True/False gesetzt, werden nur Outputs
|
||||
zurueckgegeben, bei denen der Wert 'Export' in piCtory uebereinstimmt.
|
||||
|
||||
@param export Nur Outputs mit angegebenen 'Export' Wert in piCtory
|
||||
@return <class 'list'> Outputs
|
||||
|
||||
"""
|
||||
return list(self.__getioiter(self._slc_outoff, export))
|
||||
|
||||
def get_memories(self, export=None):
|
||||
"""Gibt eine Liste aller Memoryobjekte zurueck.
|
||||
|
||||
Bleibt Parameter 'export' auf None werden alle Mems zurueckgegeben.
|
||||
Wird 'export' auf True/False gesetzt, werden nur Mems zurueckgegeben,
|
||||
bei denen der Wert 'Export' in piCtory uebereinstimmt.
|
||||
|
||||
@param export Nur Mems mit angegebenen 'Export' Wert in piCtory
|
||||
@return <class 'list'> Mems
|
||||
|
||||
"""
|
||||
return list(self.__getioiter(self._slc_memoff, export))
|
||||
|
||||
def readprocimg(self):
|
||||
"""Alle Inputs fuer dieses Device vom Prozessabbild einlesen.
|
||||
@@ -399,64 +449,73 @@ 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
|
||||
lst_io = [x for x in self.__iter__()]
|
||||
|
||||
self._iostatusbyte = lst_io[0]
|
||||
self._iocycle = None
|
||||
self._iotemperature = None
|
||||
self._iofrequency = None
|
||||
self._ioerrorcnt = None
|
||||
self._ioled = 1
|
||||
self._ioled = lst_io[1]
|
||||
self._ioerrorlimit1 = None
|
||||
self._ioerrorlimit2 = None
|
||||
|
||||
# Eigene IO-Liste aufbauen
|
||||
self.__lst_io = [x for x in self.__iter__()]
|
||||
|
||||
int_lenio = len(self.__lst_io)
|
||||
int_lenio = len(lst_io)
|
||||
if int_lenio == 6:
|
||||
# Core 1.1
|
||||
self._iocycle = 1
|
||||
self._ioerrorcnt = 2
|
||||
self._ioled = 3
|
||||
self._ioerrorlimit1 = 4
|
||||
self._ioerrorlimit2 = 5
|
||||
self._iocycle = lst_io[1]
|
||||
self._ioerrorcnt = lst_io[2]
|
||||
self._ioled = lst_io[3]
|
||||
self._ioerrorlimit1 = lst_io[4]
|
||||
self._ioerrorlimit2 = lst_io[5]
|
||||
elif int_lenio == 8:
|
||||
# core 1.2
|
||||
self._iocycle = 1
|
||||
self._ioerrorcnt = 2
|
||||
self._iotemperature = 3
|
||||
self._iofrequency = 4
|
||||
self._ioled = 5
|
||||
self._ioerrorlimit1 = 6
|
||||
self._ioerrorlimit2 = 7
|
||||
# Core 1.2
|
||||
self._iocycle = lst_io[1]
|
||||
self._ioerrorcnt = lst_io[2]
|
||||
self._iotemperature = lst_io[3]
|
||||
self._iofrequency = lst_io[4]
|
||||
self._ioled = lst_io[5]
|
||||
self._ioerrorlimit1 = lst_io[6]
|
||||
self._ioerrorlimit2 = lst_io[7]
|
||||
|
||||
if not (self._modio._monitoring or self._modio._simulator):
|
||||
# Für RS485 errors defaults laden sollte procimg NULL sein
|
||||
if self._ioerrorlimit1 is not None:
|
||||
self.__lst_io[self._ioerrorlimit1].set_value(
|
||||
self.__lst_io[self._ioerrorlimit1]._defaultvalue
|
||||
)
|
||||
if self._ioerrorlimit2 is not None:
|
||||
self.__lst_io[self._ioerrorlimit2].set_value(
|
||||
self.__lst_io[self._ioerrorlimit2]._defaultvalue
|
||||
)
|
||||
# RS485 errors schreiben
|
||||
self._modio.writeprocimg(self)
|
||||
# Echte IOs erzeugen
|
||||
self.a1green = IOBase(self, [
|
||||
"a1green", 0, 1, self._ioled._slc_address.start,
|
||||
False, None, "LED_A1_GREEN", "0"
|
||||
], OUT, "little", False)
|
||||
self.a1red = IOBase(self, [
|
||||
"a1red", 0, 1, self._ioled._slc_address.start,
|
||||
False, None, "LED_A1_RED", "1"
|
||||
], OUT, "little", False)
|
||||
self.a2green = IOBase(self, [
|
||||
"a2green", 0, 1, self._ioled._slc_address.start,
|
||||
False, None, "LED_A2_GREEN", "2"
|
||||
], OUT, "little", False)
|
||||
self.a2red = IOBase(self, [
|
||||
"a2red", 0, 1, self._ioled._slc_address.start,
|
||||
False, None, "LED_A2_RED", "3"
|
||||
], OUT, "little", False)
|
||||
|
||||
def __errorlimit(self, io_id, errorlimit):
|
||||
def __errorlimit(self, io, errorlimit):
|
||||
"""Verwaltet das Lesen und Schreiben der ErrorLimits.
|
||||
@param io_id Index des IOs fuer ErrorLimit
|
||||
@param io IOs Objekt fuer ErrorLimit
|
||||
@return Aktuellen ErrorLimit oder None wenn nicht verfuegbar"""
|
||||
if errorlimit is None:
|
||||
return None if io_id is None else int.from_bytes(
|
||||
self.__lst_io[io_id].get_value(),
|
||||
byteorder=self.__lst_io[io_id]._byteorder
|
||||
return None if io is None else int.from_bytes(
|
||||
io.get_value(), byteorder="little"
|
||||
)
|
||||
else:
|
||||
if 0 <= errorlimit <= 65535:
|
||||
self.__lst_io[io_id].set_value(errorlimit.to_bytes(
|
||||
2, byteorder=self.__lst_io[io_id]._byteorder
|
||||
))
|
||||
io.set_value(
|
||||
errorlimit.to_bytes(2, byteorder="little")
|
||||
)
|
||||
else:
|
||||
raise ValueError(
|
||||
"errorlimit value must be between 0 and 65535"
|
||||
@@ -466,50 +525,63 @@ class Core(Device):
|
||||
"""Gibt den RevPi Core Status zurueck.
|
||||
@return Status als <class 'int'>"""
|
||||
return int.from_bytes(
|
||||
self.__lst_io[0].get_value(), byteorder=self.__lst_io[0]._byteorder
|
||||
self._iostatusbyte.get_value(), byteorder="little"
|
||||
)
|
||||
|
||||
def _get_leda1(self):
|
||||
"""Gibt den Zustand der LED A1 vom core zurueck.
|
||||
"""Gibt den Zustand der LED A1 vom Core zurueck.
|
||||
@return 0=aus, 1=gruen, 2=rot"""
|
||||
int_led = int.from_bytes(
|
||||
self.__lst_io[self._ioled].get_value(),
|
||||
byteorder=self.__lst_io[self._ioled]._byteorder
|
||||
self._ioled.get_value(), byteorder="little"
|
||||
)
|
||||
led = int_led & 1
|
||||
led += int_led & 2
|
||||
return led
|
||||
|
||||
def _get_leda2(self):
|
||||
"""Gibt den Zustand der LED A2 vom core zurueck.
|
||||
"""Gibt den Zustand der LED A2 vom Core zurueck.
|
||||
@return 0=aus, 1=gruen, 2=rot"""
|
||||
int_led = int.from_bytes(
|
||||
self.__lst_io[self._ioled].get_value(),
|
||||
byteorder=self.__lst_io[self._ioled]._byteorder
|
||||
self._ioled.get_value(), byteorder="little"
|
||||
) >> 2
|
||||
led = int_led & 1
|
||||
led += int_led & 2
|
||||
return led
|
||||
|
||||
def _set_calculatedled(self, addresslist, shifted_value):
|
||||
"""Berechnet und setzt neuen Bytewert fuer LED byte.
|
||||
@param addresslist Liste der Vergleicher
|
||||
@param shifed_value Bits vergleichen"""
|
||||
# Byte als int holen
|
||||
int_led = int.from_bytes(
|
||||
self._ioled.get_value(), byteorder="little"
|
||||
)
|
||||
|
||||
for int_bit in addresslist:
|
||||
value = bool(shifted_value & int_bit)
|
||||
if bool(int_led & int_bit) != value:
|
||||
# Berechnen, wenn verändert
|
||||
if value:
|
||||
int_led += int_bit
|
||||
else:
|
||||
int_led -= int_bit
|
||||
|
||||
# Zurückschreiben wenn verändert
|
||||
self._ioled.set_value(int_led.to_bytes(length=1, byteorder="little"))
|
||||
|
||||
def _set_leda1(self, value):
|
||||
"""Setzt den Zustand der LED A1 vom core.
|
||||
"""Setzt den Zustand der LED A1 vom Core.
|
||||
@param value 0=aus, 1=gruen, 2=rot"""
|
||||
if 0 <= value <= 3:
|
||||
int_led = (self._get_leda2() << 2) + value
|
||||
self.__lst_io[self._ioled].set_value(int_led.to_bytes(
|
||||
length=1, byteorder=self.__lst_io[self._ioled]._byteorder
|
||||
))
|
||||
self._set_calculatedled([1, 2], value)
|
||||
else:
|
||||
raise ValueError("led status must be between 0 and 3")
|
||||
|
||||
def _set_leda2(self, value):
|
||||
"""Setzt den Zustand der LED A2 vom core.
|
||||
"""Setzt den Zustand der LED A2 vom Core.
|
||||
@param value 0=aus, 1=gruen, 2=rot"""
|
||||
if 0 <= value <= 3:
|
||||
int_led = (value << 2) + self._get_leda1()
|
||||
self.__lst_io[self._ioled].set_value(int_led.to_bytes(
|
||||
length=1, byteorder=self.__lst_io[self._ioled]._byteorder
|
||||
))
|
||||
self._set_calculatedled([4, 8], value << 2)
|
||||
else:
|
||||
raise ValueError("led status must be between 0 and 3")
|
||||
|
||||
@@ -522,8 +594,7 @@ class Core(Device):
|
||||
"""Statusbit fuer piControl-Treiber laeuft.
|
||||
@return True, wenn Treiber laeuft"""
|
||||
return bool(int.from_bytes(
|
||||
self.__lst_io[0].get_value(),
|
||||
byteorder=self.__lst_io[0]._byteorder
|
||||
self._iostatusbyte.get_value(), byteorder="little"
|
||||
) & 1)
|
||||
|
||||
@property
|
||||
@@ -531,8 +602,7 @@ class Core(Device):
|
||||
"""Statusbit fuer ein IO-Modul nicht mit PiCtory konfiguriert.
|
||||
@return True, wenn IO Modul nicht konfiguriert"""
|
||||
return bool(int.from_bytes(
|
||||
self.__lst_io[0].get_value(),
|
||||
byteorder=self.__lst_io[0]._byteorder
|
||||
self._iostatusbyte.get_value(), byteorder="little"
|
||||
) & 2)
|
||||
|
||||
@property
|
||||
@@ -540,8 +610,7 @@ class Core(Device):
|
||||
"""Statusbit fuer ein IO-Modul fehlt oder piGate konfiguriert.
|
||||
@return True, wenn IO-Modul fehlt oder piGate konfiguriert"""
|
||||
return bool(int.from_bytes(
|
||||
self.__lst_io[0].get_value(),
|
||||
byteorder=self.__lst_io[0]._byteorder
|
||||
self._iostatusbyte.get_value(), byteorder="little"
|
||||
) & 4)
|
||||
|
||||
@property
|
||||
@@ -549,8 +618,7 @@ class Core(Device):
|
||||
"""Statusbit Modul belegt mehr oder weniger Speicher als konfiguriert.
|
||||
@return True, wenn falscher Speicher belegt ist"""
|
||||
return bool(int.from_bytes(
|
||||
self.__lst_io[0].get_value(),
|
||||
byteorder=self.__lst_io[0]._byteorder
|
||||
self._iostatusbyte.get_value(), byteorder="little"
|
||||
) & 8)
|
||||
|
||||
@property
|
||||
@@ -558,8 +626,7 @@ class Core(Device):
|
||||
"""Statusbit links vom RevPi ist ein piGate Modul angeschlossen.
|
||||
@return True, wenn piGate links existiert"""
|
||||
return bool(int.from_bytes(
|
||||
self.__lst_io[0].get_value(),
|
||||
byteorder=self.__lst_io[0]._byteorder
|
||||
self._iostatusbyte.get_value(), byteorder="little"
|
||||
) & 16)
|
||||
|
||||
@property
|
||||
@@ -567,8 +634,7 @@ class Core(Device):
|
||||
"""Statusbit rechts vom RevPi ist ein piGate Modul angeschlossen.
|
||||
@return True, wenn piGate rechts existiert"""
|
||||
return bool(int.from_bytes(
|
||||
self.__lst_io[0].get_value(),
|
||||
byteorder=self.__lst_io[0]._byteorder
|
||||
self._iostatusbyte.get_value(), byteorder="little"
|
||||
) & 32)
|
||||
|
||||
@property
|
||||
@@ -576,8 +642,7 @@ class Core(Device):
|
||||
"""Gibt Zykluszeit der Prozessabbildsynchronisierung zurueck.
|
||||
@return Zykluszeit in ms"""
|
||||
return None if self._iocycle is None else int.from_bytes(
|
||||
self.__lst_io[self._iocycle].get_value(),
|
||||
byteorder=self.__lst_io[self._iocycle]._byteorder
|
||||
self._iocycle.get_value(), byteorder="little"
|
||||
)
|
||||
|
||||
@property
|
||||
@@ -585,8 +650,7 @@ class Core(Device):
|
||||
"""Gibt CPU-Temperatur zurueck.
|
||||
@return CPU-Temperatur in Celsius"""
|
||||
return None if self._iotemperature is None else int.from_bytes(
|
||||
self.__lst_io[self._iotemperature].get_value(),
|
||||
byteorder=self.__lst_io[self._iotemperature]._byteorder
|
||||
self._iotemperature.get_value(), byteorder="little"
|
||||
)
|
||||
|
||||
@property
|
||||
@@ -594,8 +658,7 @@ class Core(Device):
|
||||
"""Gibt CPU Taktfrequenz zurueck.
|
||||
@return CPU Taktfrequenz in MHz"""
|
||||
return None if self._iofrequency is None else int.from_bytes(
|
||||
self.__lst_io[self._iofrequency].get_value(),
|
||||
byteorder=self.__lst_io[self._iofrequency]._byteorder
|
||||
self._iofrequency.get_value(), byteorder="little"
|
||||
) * 10
|
||||
|
||||
@property
|
||||
@@ -603,8 +666,7 @@ class Core(Device):
|
||||
"""Gibt Fehleranzahl auf RS485 piBridge Bus zurueck.
|
||||
@return Fehleranzahl der piBridge"""
|
||||
return None if self._ioerrorcnt is None else int.from_bytes(
|
||||
self.__lst_io[self._ioerrorcnt].get_value(),
|
||||
byteorder=self.__lst_io[self._ioerrorcnt]._byteorder
|
||||
self._ioerrorcnt.get_value(), byteorder="little"
|
||||
)
|
||||
|
||||
@property
|
||||
@@ -632,6 +694,111 @@ class Core(Device):
|
||||
self.__errorlimit(self._ioerrorlimit2, value)
|
||||
|
||||
|
||||
class Connect(Core):
|
||||
|
||||
"""Klasse fuer den RevPi Connect.
|
||||
|
||||
Stellt Funktionen fuer die LEDs, Watchdog und den Status zur Verfuegung.
|
||||
|
||||
"""
|
||||
|
||||
__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):
|
||||
self.wd.value = not self.wd.value
|
||||
|
||||
def _devconfigure(self):
|
||||
"""Connect-Klasse vorbereiten."""
|
||||
super()._devconfigure()
|
||||
self.__evt_wdtoggle = Event()
|
||||
self.__th_wdtoggle = None
|
||||
|
||||
# Echte IOs erzeugen
|
||||
self.a3green = IOBase(self, [
|
||||
"a3green", 0, 1, self._ioled._slc_address.start,
|
||||
False, None, "LED_A3_GREEN", "4"
|
||||
], OUT, "little", False)
|
||||
self.a3red = IOBase(self, [
|
||||
"a3red", 0, 1, self._ioled._slc_address.start,
|
||||
False, None, "LED_A3_RED", "5"
|
||||
], OUT, "little", False)
|
||||
|
||||
# IO Objekte für WD und X2 in/out erzeugen
|
||||
self.wd = IOBase(self, [
|
||||
"wd", 0, 1, self._ioled._slc_address.start,
|
||||
False, None, "Connect_WatchDog", "7"
|
||||
], OUT, "little", False)
|
||||
self.x2in = IOBase(self, [
|
||||
"x2in", 0, 1, self._iostatusbyte._slc_address.start,
|
||||
False, None, "Connect_X2_IN", "6"
|
||||
], INP, "little", False)
|
||||
self.x2out = IOBase(self, [
|
||||
"x2out", 0, 1, self._ioled._slc_address.start,
|
||||
False, None, "Connect_X2_OUT", "6"
|
||||
], OUT, "little", False)
|
||||
|
||||
def _get_leda3(self):
|
||||
"""Gibt den Zustand der LED A3 vom Connect zurueck.
|
||||
@return 0=aus, 1=gruen, 2=rot"""
|
||||
int_led = int.from_bytes(
|
||||
self._ioled.get_value(), byteorder="little"
|
||||
) >> 4
|
||||
led = int_led & 1
|
||||
led += int_led & 2
|
||||
return led
|
||||
|
||||
def _get_wdtoggle(self):
|
||||
"""Ruft den Wert fuer Autowatchdog ab.
|
||||
@return True, wenn Autowatchdog aktiv ist"""
|
||||
return self.__th_wdtoggle is not None \
|
||||
and self.__th_wdtoggle.is_alive()
|
||||
|
||||
def _set_leda3(self, value):
|
||||
"""Setzt den Zustand der LED A3 vom Connect.
|
||||
@param value 0=aus, 1=gruen, 2=rot"""
|
||||
if 0 <= value <= 3:
|
||||
self._set_calculatedled([16, 32], value << 4)
|
||||
else:
|
||||
raise ValueError("led status must be between 0 and 3")
|
||||
|
||||
def _set_wdtoggle(self, value):
|
||||
"""Setzt den Wert fuer Autowatchdog.
|
||||
|
||||
Wird dieser Wert auf True gesetzt, wechselt im Hintergrund das noetige
|
||||
Bit zum toggeln des Watchdogs alle 10 Sekunden zwichen True und False.
|
||||
Dieses Bit wird bei autorefresh=True natuerlich automatisch in das
|
||||
Prozessabbild geschrieben.
|
||||
|
||||
WICHTIG: Sollte autorefresh=False sein, muss zyklisch
|
||||
.writeprocimg() aufgerufen werden, um den Wert in das
|
||||
Prozessabbild zu schreiben!!!
|
||||
|
||||
@param value True zum aktivieren, Fals zum beenden"""
|
||||
if self._modio._monitoring:
|
||||
raise RuntimeError(
|
||||
"can not toggle watchdog, while system is in monitoring mode"
|
||||
)
|
||||
if self._modio._simulator:
|
||||
raise RuntimeError(
|
||||
"can not toggle watchdog, while system is in simulator mode"
|
||||
)
|
||||
|
||||
if not value:
|
||||
self.__evt_wdtoggle.set()
|
||||
|
||||
elif not self._get_wdtoggle():
|
||||
# Watchdogtoggler erstellen
|
||||
self.__evt_wdtoggle.clear()
|
||||
self.__th_wdtoggle = Thread(target=self.__wdtoggle, daemon=True)
|
||||
self.__th_wdtoggle.start()
|
||||
|
||||
A3 = property(_get_leda3, _set_leda3)
|
||||
wdautotoggle = property(_get_wdtoggle, _set_wdtoggle)
|
||||
|
||||
|
||||
class Gateway(Device):
|
||||
|
||||
"""Klasse fuer die RevPi Gateway-Devices.
|
||||
@@ -645,6 +812,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__(...)"""
|
||||
@@ -674,6 +843,8 @@ class Virtual(Gateway):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
def writeinputdefaults(self):
|
||||
"""Schreibt fuer ein virtuelles Device piCtory Defaultinputwerte.
|
||||
|
||||
@@ -698,7 +869,7 @@ class Virtual(Gateway):
|
||||
for io in self.get_inputs():
|
||||
self._ba_devdata[io._slc_address] = io._defaultvalue
|
||||
|
||||
# Outpus auf Bus schreiben
|
||||
# Outputs auf Bus schreiben
|
||||
try:
|
||||
self._modio._myfh.seek(self._slc_inpoff.start)
|
||||
self._modio._myfh.write(self._ba_devdata[self._slc_inp])
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# python3-RevPiModIO
|
||||
#
|
||||
# Webpage: https://revpimodio.org/
|
||||
# (c) Sven Sager, License: LGPLv3
|
||||
#
|
||||
"""RevPiModIO Helperklassen und Tools."""
|
||||
__author__ = "Sven Sager"
|
||||
__copyright__ = "Copyright (C) 2018 Sven Sager"
|
||||
__license__ = "LGPLv3"
|
||||
|
||||
import queue
|
||||
import warnings
|
||||
from math import ceil
|
||||
@@ -39,6 +37,8 @@ class EventCallback(Thread):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = "daemon", "exit", "func", "ioname", "iovalue"
|
||||
|
||||
def __init__(self, func, name, value):
|
||||
"""Init EventCallback class.
|
||||
|
||||
@@ -87,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
|
||||
@@ -110,6 +115,11 @@ class Cycletools():
|
||||
self.flank15c = True
|
||||
self.flank20c = True
|
||||
|
||||
# Benutzerdaten
|
||||
class Var:
|
||||
pass
|
||||
self.var = Var()
|
||||
|
||||
def _docycle(self):
|
||||
"""Zyklusarbeiten."""
|
||||
# Einschaltverzoegerung
|
||||
@@ -279,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"""
|
||||
@@ -386,10 +400,16 @@ class ProcimgWriter(Thread):
|
||||
|
||||
def _collect_events(self, value):
|
||||
"""Aktiviert oder Deaktiviert die Eventueberwachung.
|
||||
@param value True aktiviert / False deaktiviert"""
|
||||
@param value True aktiviert / False deaktiviert
|
||||
@return True, wenn Anforderung erfolgreich war"""
|
||||
if type(value) != bool:
|
||||
raise ValueError("value must be <class 'bool'>")
|
||||
|
||||
# Nur starten, wenn System läuft
|
||||
if not self.is_alive():
|
||||
self.__eventwork = False
|
||||
return False
|
||||
|
||||
if self.__eventwork != value:
|
||||
with self.lck_refresh:
|
||||
self.__eventwork = value
|
||||
@@ -403,6 +423,8 @@ class ProcimgWriter(Thread):
|
||||
self.__eventth.daemon = True
|
||||
self.__eventth.start()
|
||||
|
||||
return True
|
||||
|
||||
def _get_ioerrors(self):
|
||||
"""Ruft aktuelle Anzahl der Fehler ab.
|
||||
@return Aktuelle Fehleranzahl"""
|
||||
@@ -413,12 +435,12 @@ class ProcimgWriter(Thread):
|
||||
self._ioerror += 1
|
||||
if self._maxioerrors != 0 and self._ioerror >= self._maxioerrors:
|
||||
raise RuntimeError(
|
||||
"reach max io error count {} on process image".format(
|
||||
"reach max io error count {0} on process image".format(
|
||||
self._maxioerrors
|
||||
)
|
||||
)
|
||||
warnings.warn(
|
||||
"count {} io errors on process image".format(self._ioerror),
|
||||
"count {0} io errors on process image".format(self._ioerror),
|
||||
RuntimeWarning
|
||||
)
|
||||
|
||||
@@ -443,7 +465,7 @@ class ProcimgWriter(Thread):
|
||||
# Lockobjekt holen und Fehler werfen, wenn nicht schnell genug
|
||||
if not self.lck_refresh.acquire(timeout=self._adjwait):
|
||||
warnings.warn(
|
||||
"cycle time of {} ms exceeded on lock".format(
|
||||
"cycle time of {0} ms exceeded on lock".format(
|
||||
int(self._refresh * 1000)
|
||||
),
|
||||
RuntimeWarning
|
||||
@@ -458,13 +480,13 @@ class ProcimgWriter(Thread):
|
||||
if self._modio._monitoring:
|
||||
# Inputs und Outputs in Puffer
|
||||
for dev in self._modio._lst_refresh:
|
||||
dev._filelock.acquire()
|
||||
dev._ba_devdata[:] = bytesbuff[dev._slc_devoff]
|
||||
if self.__eventwork \
|
||||
and len(dev._dict_events) > 0 \
|
||||
and dev._ba_datacp != dev._ba_devdata:
|
||||
self.__check_change(dev)
|
||||
dev._filelock.release()
|
||||
with dev._filelock:
|
||||
dev._ba_devdata[:] = bytesbuff[dev._slc_devoff]
|
||||
if self.__eventwork \
|
||||
and len(dev._dict_events) > 0 \
|
||||
and dev._ba_datacp != dev._ba_devdata:
|
||||
self.__check_change(dev)
|
||||
|
||||
else:
|
||||
# Inputs in Puffer, Outputs in Prozessabbild
|
||||
for dev in self._modio._lst_refresh:
|
||||
@@ -495,9 +517,9 @@ class ProcimgWriter(Thread):
|
||||
finally:
|
||||
# Verzögerte Events prüfen
|
||||
if self.__eventwork:
|
||||
for tup_fire in list(self.__dict_delay.keys()):
|
||||
if tup_fire[0].overwrite \
|
||||
and getattr(self._modio.io, tup_fire[1]).value != \
|
||||
for tup_fire in tuple(self.__dict_delay.keys()):
|
||||
if tup_fire[0].overwrite and \
|
||||
getattr(self._modio.io, tup_fire[1]).value != \
|
||||
tup_fire[2]:
|
||||
del self.__dict_delay[tup_fire]
|
||||
else:
|
||||
@@ -518,7 +540,7 @@ class ProcimgWriter(Thread):
|
||||
self._adjwait -= 0.001
|
||||
if self._adjwait < 0:
|
||||
warnings.warn(
|
||||
"cycle time of {} ms exceeded".format(
|
||||
"cycle time of {0} ms exceeded".format(
|
||||
int(self._refresh * 1000)
|
||||
),
|
||||
RuntimeWarning
|
||||
@@ -534,7 +556,6 @@ class ProcimgWriter(Thread):
|
||||
|
||||
def stop(self):
|
||||
"""Beendet die automatische Prozessabbildsynchronisierung."""
|
||||
self._collect_events(False)
|
||||
self._work.set()
|
||||
|
||||
def set_maxioerrors(self, value):
|
||||
@@ -548,13 +569,13 @@ class ProcimgWriter(Thread):
|
||||
def set_refresh(self, value):
|
||||
"""Setzt die Zykluszeit in Millisekunden.
|
||||
@param value <class 'int'> Millisekunden"""
|
||||
if type(value) == int and 10 <= value <= 2000:
|
||||
if type(value) == int and 5 <= value <= 2000:
|
||||
waitdiff = self._refresh - self._adjwait
|
||||
self._refresh = value / 1000
|
||||
self._adjwait = self._refresh - waitdiff
|
||||
self._adjwait = 0 if waitdiff < 0 else self._refresh - waitdiff
|
||||
else:
|
||||
raise ValueError(
|
||||
"refresh time must be 10 to 2000 milliseconds"
|
||||
"refresh time must be 5 to 2000 milliseconds"
|
||||
)
|
||||
|
||||
ioerrors = property(_get_ioerrors)
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# python3-RevPiModIO
|
||||
#
|
||||
# Webpage: https://revpimodio.org/
|
||||
# (c) Sven Sager, License: LGPLv3
|
||||
#
|
||||
"""RevPiModIO Modul fuer die Verwaltung der IOs."""
|
||||
__author__ = "Sven Sager"
|
||||
__copyright__ = "Copyright (C) 2018 Sven Sager"
|
||||
__license__ = "LGPLv3"
|
||||
|
||||
import struct
|
||||
from re import match as rematch
|
||||
from threading import Event
|
||||
@@ -16,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
|
||||
@@ -69,7 +69,7 @@ class IOList(object):
|
||||
if key in self.__dict_iorefname:
|
||||
return self.__dict_iorefname[key]
|
||||
else:
|
||||
raise AttributeError("can not find io '{}'".format(key))
|
||||
raise AttributeError("can not find io '{0}'".format(key))
|
||||
|
||||
def __getitem__(self, key):
|
||||
"""Ruft angegebenen IO ab.
|
||||
@@ -86,7 +86,7 @@ class IOList(object):
|
||||
"""
|
||||
if type(key) == int:
|
||||
if key not in self.__dict_iobyte:
|
||||
raise KeyError("byte '{}' does not exist".format(key))
|
||||
raise KeyError("byte '{0}' does not exist".format(key))
|
||||
return self.__dict_iobyte[key]
|
||||
elif type(key) == slice:
|
||||
return [
|
||||
@@ -151,14 +151,14 @@ class IOList(object):
|
||||
if oldio._bitaddress >= 0:
|
||||
if io._bitaddress == oldio._bitaddress:
|
||||
raise MemoryError(
|
||||
"bit {} already assigned to '{}'".format(
|
||||
"bit {0} already assigned to '{1}'".format(
|
||||
io._bitaddress, oldio._name
|
||||
)
|
||||
)
|
||||
else:
|
||||
# Bereits überschriebene bytes sind ungültig
|
||||
raise MemoryError(
|
||||
"new io '{}' overlaps memory of '{}'".format(
|
||||
"new io '{0}' overlaps memory of '{1}'".format(
|
||||
io._name, oldio._name
|
||||
)
|
||||
)
|
||||
@@ -191,10 +191,10 @@ class IOList(object):
|
||||
def _private_register_new_io_object(self, new_io):
|
||||
"""Registriert neues IO Objekt unabhaenging von __setattr__.
|
||||
@param new_io Neues IO Objekt"""
|
||||
if issubclass(type(new_io), IOBase):
|
||||
if isinstance(new_io, IOBase):
|
||||
if hasattr(self, new_io._name):
|
||||
raise AttributeError(
|
||||
"attribute {} already exists - can not set io".format(
|
||||
"attribute {0} already exists - can not set io".format(
|
||||
new_io._name
|
||||
)
|
||||
)
|
||||
@@ -222,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"""
|
||||
@@ -250,19 +252,23 @@ class IOBase(object):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = "_bitaddress", "_bitlength", "_byteorder", "_defaultvalue", \
|
||||
"_iotype", "_length", "_name", "_parentdevice", \
|
||||
"_signed", "_slc_address", "bmk", "export"
|
||||
|
||||
def __init__(self, parentdevice, valuelist, iotype, byteorder, signed):
|
||||
"""Instantiierung der IOBase-Klasse.
|
||||
|
||||
@param parentdevice Parentdevice auf dem der IO liegt
|
||||
@param valuelist Datenliste fuer Instantiierung
|
||||
["name","defval","bitlen","startaddr",exp,"idx","bmk","bitaddr"]
|
||||
["name","defval","bitlen","startaddrdev",exp,"idx","bmk","bitaddr"]
|
||||
@param iotype <class 'int'> Wert
|
||||
@param byteorder Byteorder 'little'/'big' fuer <class 'int'> Berechnung
|
||||
@param sigend Intberechnung mit Vorzeichen durchfuehren
|
||||
|
||||
"""
|
||||
# ["name","defval","bitlen","startaddr",exp,"idx","bmk","bitaddr"]
|
||||
# [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ]
|
||||
# ["name","defval","bitlen","startaddrdev",exp,"idx","bmk","bitaddr"]
|
||||
# [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ]
|
||||
self._parentdevice = parentdevice
|
||||
|
||||
# Bitadressen auf Bytes aufbrechen und umrechnen
|
||||
@@ -277,6 +283,7 @@ class IOBase(object):
|
||||
self._name = valuelist[0]
|
||||
self._signed = signed
|
||||
self.bmk = valuelist[6]
|
||||
self.export = bool(valuelist[4])
|
||||
|
||||
int_startaddress = int(valuelist[3])
|
||||
if self._bitaddress == -1:
|
||||
@@ -298,7 +305,7 @@ class IOBase(object):
|
||||
else:
|
||||
raise ValueError(
|
||||
"given bytes for default value must have a length "
|
||||
"of {} but {} was given"
|
||||
"of {0} but {1} was given"
|
||||
"".format(self._length, len(valuelist[1]))
|
||||
)
|
||||
else:
|
||||
@@ -312,12 +319,12 @@ class IOBase(object):
|
||||
if len(buff) <= self._length:
|
||||
self._defaultvalue = \
|
||||
buff + bytes(self._length - len(buff))
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
else:
|
||||
# Höhere Bits als 7 auf nächste Bytes umbrechen
|
||||
int_startaddress += int((int(valuelist[7]) % 16) / 8)
|
||||
int_startaddress += int(int(valuelist[7]) / 8)
|
||||
self._slc_address = slice(
|
||||
int_startaddress, int_startaddress + 1
|
||||
)
|
||||
@@ -328,7 +335,7 @@ class IOBase(object):
|
||||
else:
|
||||
try:
|
||||
self._defaultvalue = bool(int(valuelist[1]))
|
||||
except:
|
||||
except Exception:
|
||||
self._defaultvalue = False
|
||||
|
||||
def __bool__(self):
|
||||
@@ -367,7 +374,7 @@ class IOBase(object):
|
||||
# Prüfen ob Funktion callable ist
|
||||
if not callable(func):
|
||||
raise AttributeError(
|
||||
"registered function '{}' is not callable".format(func)
|
||||
"registered function '{0}' is not callable".format(func)
|
||||
)
|
||||
if type(delay) != int or delay < 0:
|
||||
raise AttributeError(
|
||||
@@ -379,8 +386,9 @@ class IOBase(object):
|
||||
)
|
||||
|
||||
if self not in self._parentdevice._dict_events:
|
||||
self._parentdevice._dict_events[self] = \
|
||||
[IOEvent(func, edge, as_thread, delay, overwrite)]
|
||||
with self._parentdevice._filelock:
|
||||
self._parentdevice._dict_events[self] = \
|
||||
[IOEvent(func, edge, as_thread, delay, overwrite)]
|
||||
else:
|
||||
# Prüfen ob Funktion schon registriert ist
|
||||
for regfunc in self._parentdevice._dict_events[self]:
|
||||
@@ -391,29 +399,31 @@ class IOBase(object):
|
||||
if edge == BOTH or regfunc.edge == BOTH:
|
||||
if self._bitaddress < 0:
|
||||
raise AttributeError(
|
||||
"io '{}' with function '{}' already in list."
|
||||
"io '{0}' with function '{1}' already in list."
|
||||
"".format(self._name, func)
|
||||
)
|
||||
else:
|
||||
raise AttributeError(
|
||||
"io '{}' with function '{}' already in list with "
|
||||
"edge '{}' - edge '{}' not allowed anymore".format(
|
||||
"io '{0}' with function '{1}' already in list "
|
||||
"with edge '{2}' - edge '{3}' not allowed anymore"
|
||||
"".format(
|
||||
self._name, func,
|
||||
consttostr(regfunc.edge), consttostr(edge)
|
||||
)
|
||||
)
|
||||
elif regfunc.edge == edge:
|
||||
raise AttributeError(
|
||||
"io '{}' with function '{}' for given edge '{}' "
|
||||
"io '{0}' with function '{1}' for given edge '{2}' "
|
||||
"already in list".format(
|
||||
self._name, func, consttostr(edge)
|
||||
)
|
||||
)
|
||||
|
||||
# Eventfunktion einfügen
|
||||
self._parentdevice._dict_events[self].append(
|
||||
IOEvent(func, edge, as_thread, delay, overwrite)
|
||||
)
|
||||
with self._parentdevice._filelock:
|
||||
self._parentdevice._dict_events[self].append(
|
||||
IOEvent(func, edge, as_thread, delay, overwrite)
|
||||
)
|
||||
|
||||
def _get_address(self):
|
||||
"""Gibt die absolute Byteadresse im Prozessabbild zurueck.
|
||||
@@ -519,7 +529,7 @@ class IOBase(object):
|
||||
>Python3 struct</a>
|
||||
|
||||
"""
|
||||
if not issubclass(type(self._parentdevice), Gateway):
|
||||
if not isinstance(self._parentdevice, Gateway):
|
||||
raise RuntimeError(
|
||||
"this function can be used for ios on gatway or virtual "
|
||||
"devices only"
|
||||
@@ -584,31 +594,31 @@ class IOBase(object):
|
||||
value
|
||||
else:
|
||||
raise ValueError(
|
||||
"'{}' requires a <class 'bytes'> object of length "
|
||||
"{}, but {} was given".format(
|
||||
"'{0}' requires a <class 'bytes'> object of "
|
||||
"length {1}, but {2} was given".format(
|
||||
self._name, self._length, len(value)
|
||||
)
|
||||
)
|
||||
else:
|
||||
raise ValueError(
|
||||
"'{}' requires a <class 'bytes'> object, not {}"
|
||||
"'{0}' requires a <class 'bytes'> object, not {1}"
|
||||
"".format(self._name, type(value))
|
||||
)
|
||||
|
||||
elif self._iotype == INP:
|
||||
if self._parentdevice._modio._simulator:
|
||||
raise AttributeError(
|
||||
"can not write to output '{}' in simulator mode"
|
||||
"can not write to output '{0}' in simulator mode"
|
||||
"".format(self._name)
|
||||
)
|
||||
else:
|
||||
raise AttributeError(
|
||||
"can not write to input '{}'".format(self._name)
|
||||
"can not write to input '{0}'".format(self._name)
|
||||
)
|
||||
|
||||
elif self._iotype == MEM:
|
||||
raise AttributeError(
|
||||
"can not write to memory '{}'".format(self._name)
|
||||
"can not write to memory '{0}'".format(self._name)
|
||||
)
|
||||
|
||||
def unreg_event(self, func=None, edge=None):
|
||||
@@ -620,7 +630,8 @@ class IOBase(object):
|
||||
"""
|
||||
if self in self._parentdevice._dict_events:
|
||||
if func is None:
|
||||
del self._parentdevice._dict_events[self]
|
||||
with self._parentdevice._filelock:
|
||||
del self._parentdevice._dict_events[self]
|
||||
else:
|
||||
newlist = []
|
||||
for regfunc in self._parentdevice._dict_events[self]:
|
||||
@@ -630,10 +641,11 @@ class IOBase(object):
|
||||
newlist.append(regfunc)
|
||||
|
||||
# Wenn Funktionen übrig bleiben, diese übernehmen
|
||||
if len(newlist) > 0:
|
||||
self._parentdevice._dict_events[self] = newlist
|
||||
else:
|
||||
del self._parentdevice._dict_events[self]
|
||||
with self._parentdevice._filelock:
|
||||
if len(newlist) > 0:
|
||||
self._parentdevice._dict_events[self] = newlist
|
||||
else:
|
||||
del self._parentdevice._dict_events[self]
|
||||
|
||||
def wait(self, edge=BOTH, exitevent=None, okvalue=None, timeout=0):
|
||||
"""Wartet auf Wertaenderung eines IOs.
|
||||
@@ -679,7 +691,7 @@ class IOBase(object):
|
||||
# Prüfen ob Device in autorefresh ist
|
||||
if not self._parentdevice._selfupdate:
|
||||
raise RuntimeError(
|
||||
"autorefresh is not activated for device '{}|{}' - there "
|
||||
"autorefresh is not activated for device '{0}|{1}' - there "
|
||||
"will never be new data".format(
|
||||
self._parentdevice._position, self._parentdevice._name
|
||||
)
|
||||
@@ -768,6 +780,8 @@ class IntIO(IOBase):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
def __int__(self):
|
||||
"""Gibt IO-Wert zurueck mit Beachtung byteorder/signed.
|
||||
@return IO-Wert als <class 'int'>"""
|
||||
@@ -825,7 +839,7 @@ class IntIO(IOBase):
|
||||
))
|
||||
else:
|
||||
raise ValueError(
|
||||
"'{}' need a <class 'int'> value, but {} was given"
|
||||
"'{0}' need a <class 'int'> value, but {1} was given"
|
||||
"".format(self._name, type(value))
|
||||
)
|
||||
|
||||
@@ -845,6 +859,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.
|
||||
|
||||
@@ -873,7 +890,7 @@ class StructIO(IOBase):
|
||||
max_bits = parentio._length * 8
|
||||
if not (0 <= bitaddress < max_bits):
|
||||
raise AttributeError(
|
||||
"bitaddress must be a value between 0 and {}"
|
||||
"bitaddress must be a value between 0 and {0}"
|
||||
"".format(max_bits - 1)
|
||||
)
|
||||
bitlength = 1
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# python3-RevPiModIO
|
||||
#
|
||||
# Webpage: https://revpimodio.org/
|
||||
# (c) Sven Sager, License: LGPLv3
|
||||
#
|
||||
"""RevPiModIO Hauptklasse fuer piControl0 Zugriff."""
|
||||
__author__ = "Sven Sager"
|
||||
__copyright__ = "Copyright (C) 2018 Sven Sager"
|
||||
__license__ = "LGPLv3"
|
||||
|
||||
import warnings
|
||||
from json import load as jload
|
||||
from multiprocessing import cpu_count
|
||||
from os import access, F_OK, R_OK
|
||||
from queue import Empty
|
||||
from signal import signal, SIG_DFL, SIGINT, SIGTERM
|
||||
from threading import Thread, Event
|
||||
from timeit import default_timer
|
||||
|
||||
from . import app as appmodule
|
||||
from . import device as devicemodule
|
||||
@@ -33,6 +33,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):
|
||||
@@ -79,6 +86,9 @@ class RevPiModIO(object):
|
||||
self.io = None
|
||||
self.summary = None
|
||||
|
||||
# Event für Benutzeraktionen
|
||||
self.exitsignal = Event()
|
||||
|
||||
# Nur Konfigurieren, wenn nicht vererbt
|
||||
if type(self) == RevPiModIO:
|
||||
self._configure(self.get_jconfigrsc())
|
||||
@@ -100,7 +110,8 @@ class RevPiModIO(object):
|
||||
if self.__cleanupfunc is not None:
|
||||
self.readprocimg()
|
||||
self.__cleanupfunc()
|
||||
self.writeprocimg()
|
||||
if not self._monitoring:
|
||||
self.writeprocimg()
|
||||
|
||||
def _configure(self, jconfigrsc):
|
||||
"""Verarbeitet die piCtory Konfigurationsdatei."""
|
||||
@@ -150,10 +161,17 @@ class RevPiModIO(object):
|
||||
device["position"] += 1
|
||||
|
||||
if device["type"] == "BASE":
|
||||
# Core
|
||||
dev_new = devicemodule.Core(
|
||||
self, device, simulator=self._simulator
|
||||
)
|
||||
pt = int(device["productType"])
|
||||
if pt == 105:
|
||||
# RevPi Connect
|
||||
dev_new = devicemodule.Connect(
|
||||
self, device, simulator=self._simulator
|
||||
)
|
||||
else:
|
||||
# RevPi Core immer als Fallback verwenden
|
||||
dev_new = devicemodule.Core(
|
||||
self, device, simulator=self._simulator
|
||||
)
|
||||
self.core = dev_new
|
||||
elif device["type"] == "LEFT_RIGHT":
|
||||
# IOs
|
||||
@@ -170,10 +188,13 @@ class RevPiModIO(object):
|
||||
dev_new = devicemodule.Gateway(
|
||||
self, device, simulator=self._simulator
|
||||
)
|
||||
elif device["type"] == "RIGHT":
|
||||
# Connectdevice
|
||||
dev_new = None
|
||||
else:
|
||||
# Device-Type nicht gefunden
|
||||
warnings.warn(
|
||||
"device type '{}' unknown".format(device["type"]),
|
||||
"device type '{0}' unknown".format(device["type"]),
|
||||
Warning
|
||||
)
|
||||
dev_new = None
|
||||
@@ -205,10 +226,28 @@ class RevPiModIO(object):
|
||||
# ImgWriter erstellen
|
||||
self._imgwriter = helpermodule.ProcimgWriter(self)
|
||||
|
||||
# Refreshzeit CM1 25 Hz / CM3 50 Hz
|
||||
if not isinstance(self, RevPiNetIO):
|
||||
self._imgwriter.refresh = 20 if cpu_count() > 1 else 40
|
||||
|
||||
# Aktuellen Outputstatus von procimg einlesen
|
||||
if self._syncoutputs:
|
||||
self.syncoutputs()
|
||||
|
||||
# Für RS485 errors am core defaults laden sollte procimg NULL sein
|
||||
if not (self.core is None or self._monitoring or self._simulator):
|
||||
if self.core._ioerrorlimit1 is not None:
|
||||
self.core._ioerrorlimit1.set_value(
|
||||
self.core._ioerrorlimit1._defaultvalue
|
||||
)
|
||||
if self.core._ioerrorlimit2 is not None:
|
||||
self.core._ioerrorlimit2.set_value(
|
||||
self.core._ioerrorlimit2._defaultvalue
|
||||
)
|
||||
|
||||
# RS485 errors schreiben
|
||||
self.writeprocimg(self.core)
|
||||
|
||||
# Optional ins autorefresh aufnehmen
|
||||
if self._autorefresh:
|
||||
self.autorefresh_all()
|
||||
@@ -270,12 +309,12 @@ class RevPiModIO(object):
|
||||
self._ioerror += 1
|
||||
if self._maxioerrors != 0 and self._ioerror >= self._maxioerrors:
|
||||
raise RuntimeError(
|
||||
"reach max io error count {} on process image".format(
|
||||
"reach max io error count {0} on process image".format(
|
||||
self._maxioerrors
|
||||
)
|
||||
)
|
||||
warnings.warn(
|
||||
"got io error during {} and count {} errors now".format(
|
||||
"got io error during {0} and count {1} errors now".format(
|
||||
action, self._ioerror
|
||||
),
|
||||
RuntimeWarning
|
||||
@@ -286,7 +325,7 @@ class RevPiModIO(object):
|
||||
@param milliseconds <class 'int'> in Millisekunden"""
|
||||
if self._looprunning:
|
||||
raise RuntimeError(
|
||||
"can not change cycletime when cycleloop or mainloop are "
|
||||
"can not change cycletime when cycleloop or mainloop is "
|
||||
"running"
|
||||
)
|
||||
else:
|
||||
@@ -316,7 +355,7 @@ class RevPiModIO(object):
|
||||
self.io = None
|
||||
self.summary = None
|
||||
|
||||
def cycleloop(self, func, cycletime=None):
|
||||
def cycleloop(self, func, cycletime=50):
|
||||
"""Startet den Cycleloop.
|
||||
|
||||
Der aktuelle Programmthread wird hier bis Aufruf von
|
||||
@@ -328,19 +367,20 @@ class RevPiModIO(object):
|
||||
Prozessabbild geschrieben.
|
||||
|
||||
Verlassen wird der Cycleloop, wenn die aufgerufene Funktion einen
|
||||
Rueckgabewert nicht gleich None liefert, oder durch Aufruf von
|
||||
revpimodio.exit().
|
||||
Rueckgabewert nicht gleich None liefert (z.B. return True), oder durch
|
||||
Aufruf von .exit().
|
||||
|
||||
HINWEIS: Die Aktualisierungszeit und die Laufzeit der Funktion duerfen
|
||||
die eingestellte autorefresh Zeit, bzw. uebergebene cycletime nicht
|
||||
ueberschreiten!
|
||||
|
||||
Ueber das Attribut cycletime kann die Aktualisierungsrate fuer das
|
||||
Prozessabbild gesetzt werden.
|
||||
Ueber den Parameter cycletime wird die gewuenschte Zukluszeit der
|
||||
uebergebenen Funktion gesetzt. Der Standardwert betraegt
|
||||
50 Millisekunden, in denen das Prozessabild eingelesen, die uebergebene
|
||||
Funktion ausgefuert und das Prozessabbild geschrieben wird.
|
||||
|
||||
@param func Funktion, die ausgefuehrt werden soll
|
||||
@param cycletime Zykluszeit in Millisekunden, bei Nichtangabe wird
|
||||
aktuelle .cycletime Zeit verwendet - Standardwert 50 ms
|
||||
@param cycletime Zykluszeit in Millisekunden - Standardwert 50 ms
|
||||
@return None
|
||||
|
||||
"""
|
||||
@@ -352,21 +392,28 @@ class RevPiModIO(object):
|
||||
|
||||
# Prüfen ob Devices in autorefresh sind
|
||||
if len(self._lst_refresh) == 0:
|
||||
raise RuntimeError("no device with autorefresh activated")
|
||||
raise RuntimeError(
|
||||
"no device with autorefresh activated - use autorefresh=True "
|
||||
"or call .autorefresh_all() before entering cycleloop"
|
||||
)
|
||||
|
||||
# Prüfen ob Funktion callable ist
|
||||
if not callable(func):
|
||||
raise RuntimeError(
|
||||
"registered function '{}' ist not callable".format(func)
|
||||
"registered function '{0}' ist not callable".format(func)
|
||||
)
|
||||
|
||||
# Zykluszeit übernehmen
|
||||
if not (cycletime is None or cycletime == self._imgwriter.refresh):
|
||||
old_cycletime = self._imgwriter.refresh
|
||||
if not cycletime == self._imgwriter.refresh:
|
||||
self._imgwriter.refresh = cycletime
|
||||
|
||||
# Zeitänderung in _imgwriter neuladen
|
||||
self._imgwriter.newdata.clear()
|
||||
|
||||
# Benutzerevent
|
||||
self.exitsignal.clear()
|
||||
|
||||
# Cycleloop starten
|
||||
self._exit.clear()
|
||||
self._looprunning = True
|
||||
@@ -403,6 +450,9 @@ class RevPiModIO(object):
|
||||
# Cycleloop beenden
|
||||
self._looprunning = False
|
||||
|
||||
# Alte autorefresh Zeit setzen
|
||||
self._imgwriter.refresh = old_cycletime
|
||||
|
||||
return ec
|
||||
|
||||
def exit(self, full=True):
|
||||
@@ -416,6 +466,10 @@ class RevPiModIO(object):
|
||||
wird dann gestoppt und das Programm kann sauber beendet werden.
|
||||
|
||||
@param full Entfernt auch alle Devices aus autorefresh"""
|
||||
|
||||
# Benutzerevent
|
||||
self.exitsignal.set()
|
||||
|
||||
self._exit.set()
|
||||
self._waitexit.set()
|
||||
|
||||
@@ -425,7 +479,7 @@ class RevPiModIO(object):
|
||||
self._imgwriter.stop()
|
||||
self._imgwriter.join(self._imgwriter._refresh)
|
||||
|
||||
# Mainloop beenden und darauf waretn
|
||||
# Mainloop beenden und darauf 1 Sekunde warten
|
||||
if self._th_mainloop is not None and self._th_mainloop.is_alive():
|
||||
self._th_mainloop.join(1)
|
||||
|
||||
@@ -443,7 +497,7 @@ class RevPiModIO(object):
|
||||
if self._configrsc is not None:
|
||||
if not access(self._configrsc, F_OK | R_OK):
|
||||
raise RuntimeError(
|
||||
"can not access pictory configuration at {}".format(
|
||||
"can not access pictory configuration at {0}".format(
|
||||
self._configrsc))
|
||||
else:
|
||||
# piCtory Konfiguration an bekannten Stellen prüfen
|
||||
@@ -454,7 +508,7 @@ class RevPiModIO(object):
|
||||
break
|
||||
if self._configrsc is None:
|
||||
raise RuntimeError(
|
||||
"can not access known pictory configurations at {} - "
|
||||
"can not access known pictory configurations at {0} - "
|
||||
"use 'configrsc' parameter so specify location"
|
||||
"".format(", ".join(lst_rsc))
|
||||
)
|
||||
@@ -462,7 +516,7 @@ class RevPiModIO(object):
|
||||
with open(self._configrsc, "r") as fhconfigrsc:
|
||||
try:
|
||||
jdata = jload(fhconfigrsc)
|
||||
except:
|
||||
except Exception:
|
||||
raise RuntimeError(
|
||||
"can not read piCtory configuration - check your hardware "
|
||||
"configuration http://revpi_ip/"
|
||||
@@ -494,7 +548,8 @@ class RevPiModIO(object):
|
||||
# Prüfen ob Funktion callable ist
|
||||
if not (cleanupfunc is None or callable(cleanupfunc)):
|
||||
raise RuntimeError(
|
||||
"registered function '{}' ist not callable".format(cleanupfunc)
|
||||
"registered function '{0}' ist not callable"
|
||||
"".format(cleanupfunc)
|
||||
)
|
||||
self.__cleanupfunc = cleanupfunc
|
||||
signal(SIGINT, self.__evt_exit)
|
||||
@@ -527,7 +582,10 @@ class RevPiModIO(object):
|
||||
|
||||
# Prüfen ob Devices in autorefresh sind
|
||||
if len(self._lst_refresh) == 0:
|
||||
raise RuntimeError("no device with autorefresh activated")
|
||||
raise RuntimeError(
|
||||
"no device with autorefresh activated - use autorefresh=True "
|
||||
"or call .autorefresh_all() before entering mainloop"
|
||||
)
|
||||
|
||||
# Thread erstellen, wenn nicht blockieren soll
|
||||
if not blocking:
|
||||
@@ -537,25 +595,48 @@ class RevPiModIO(object):
|
||||
self._th_mainloop.start()
|
||||
return
|
||||
|
||||
# Benutzerevent
|
||||
self.exitsignal.clear()
|
||||
|
||||
# Event säubern vor Eintritt in Mainloop
|
||||
self._exit.clear()
|
||||
self._looprunning = True
|
||||
|
||||
# Beim Eintritt in mainloop Bytecopy erstellen
|
||||
for dev in self._lst_refresh:
|
||||
dev._filelock.acquire()
|
||||
dev._ba_datacp = dev._ba_devdata[:]
|
||||
dev._filelock.release()
|
||||
with dev._filelock:
|
||||
dev._ba_datacp = dev._ba_devdata[:]
|
||||
|
||||
# ImgWriter mit Eventüberwachung aktivieren
|
||||
self._imgwriter._collect_events(True)
|
||||
e = None
|
||||
runtime = 0
|
||||
|
||||
while not self._exit.is_set():
|
||||
|
||||
# Laufzeit der Eventqueue auf 0 setzen
|
||||
if self._imgwriter._eventq.qsize() == 0:
|
||||
runtime = 0
|
||||
|
||||
try:
|
||||
tup_fire = self._imgwriter._eventq.get(timeout=1)
|
||||
|
||||
# Messung Laufzeit der Queue starten
|
||||
if runtime == 0:
|
||||
runtime = default_timer()
|
||||
|
||||
# Direct callen da Prüfung in io.IOBase.reg_event ist
|
||||
tup_fire[0].func(tup_fire[1], tup_fire[2])
|
||||
|
||||
# Laufzeitprüfung
|
||||
if runtime != -1 and \
|
||||
default_timer() - runtime > self._imgwriter._refresh:
|
||||
runtime = -1
|
||||
warnings.warn(
|
||||
"can not execute all event functions in one cycle - "
|
||||
"rise .cycletime or optimize your event functions",
|
||||
RuntimeWarning
|
||||
)
|
||||
except Empty:
|
||||
if not self._exit.is_set() and not self._imgwriter.is_alive():
|
||||
self.exit(full=False)
|
||||
@@ -585,12 +666,12 @@ class RevPiModIO(object):
|
||||
if device is None:
|
||||
mylist = self.device
|
||||
else:
|
||||
dev = device if issubclass(type(device), devicemodule.Device) \
|
||||
dev = device if isinstance(device, devicemodule.Device) \
|
||||
else self.device.__getitem__(device)
|
||||
|
||||
if dev._selfupdate:
|
||||
raise RuntimeError(
|
||||
"can not read process image, while device '{}|{}'"
|
||||
"can not read process image, while device '{0}|{1}'"
|
||||
"is in autorefresh mode".format(dev._position, dev._name)
|
||||
)
|
||||
mylist = [dev]
|
||||
@@ -640,7 +721,7 @@ class RevPiModIO(object):
|
||||
if device is None:
|
||||
mylist = self.device
|
||||
else:
|
||||
dev = device if issubclass(type(device), devicemodule.Device) \
|
||||
dev = device if isinstance(device, devicemodule.Device) \
|
||||
else self.device.__getitem__(device)
|
||||
mylist = [dev]
|
||||
|
||||
@@ -660,12 +741,12 @@ class RevPiModIO(object):
|
||||
if device is None:
|
||||
mylist = self.device
|
||||
else:
|
||||
dev = device if issubclass(type(device), devicemodule.Device) \
|
||||
dev = device if isinstance(device, devicemodule.Device) \
|
||||
else self.device.__getitem__(device)
|
||||
|
||||
if dev._selfupdate:
|
||||
raise RuntimeError(
|
||||
"can not sync process image, while device '{}|{}'"
|
||||
"can not sync outputs, while device '{0}|{1}'"
|
||||
"is in autorefresh mode".format(dev._position, dev._name)
|
||||
)
|
||||
mylist = [dev]
|
||||
@@ -703,12 +784,12 @@ class RevPiModIO(object):
|
||||
if device is None:
|
||||
mylist = self.device
|
||||
else:
|
||||
dev = device if issubclass(type(device), devicemodule.Device) \
|
||||
dev = device if isinstance(device, devicemodule.Device) \
|
||||
else self.device.__getitem__(device)
|
||||
|
||||
if dev._selfupdate:
|
||||
raise RuntimeError(
|
||||
"can not write process image, while device '{}|{}'"
|
||||
"can not write process image, while device '{0}|{1}'"
|
||||
"is in autorefresh mode".format(dev._position, dev._name)
|
||||
)
|
||||
mylist = [dev]
|
||||
@@ -759,6 +840,8 @@ class RevPiModIOSelected(RevPiModIO):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
def __init__(
|
||||
self, deviceselection, autorefresh=False, monitoring=False,
|
||||
syncoutputs=True, procimg=None, configrsc=None, simulator=False):
|
||||
@@ -823,6 +906,8 @@ class RevPiModIODriver(RevPiModIOSelected):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
def __init__(
|
||||
self, virtdev, autorefresh=False, monitoring=False,
|
||||
syncoutputs=True, procimg=None, configrsc=None):
|
||||
@@ -842,4 +927,4 @@ class RevPiModIODriver(RevPiModIOSelected):
|
||||
|
||||
|
||||
# Nachträglicher Import
|
||||
from .netio import RevPiNetIODriver
|
||||
from .netio import RevPiNetIODriver, RevPiNetIO
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# python3-RevPiModIO
|
||||
#
|
||||
# Webpage: https://revpimodio.org/
|
||||
# (c) Sven Sager, License: LGPLv3
|
||||
#
|
||||
"""RevPiModIO Hauptklasse fuer Netzwerkzugriff."""
|
||||
__author__ = "Sven Sager"
|
||||
__copyright__ = "Copyright (C) 2018 Sven Sager"
|
||||
__license__ = "LGPLv3"
|
||||
|
||||
import socket
|
||||
import warnings
|
||||
from json import loads as jloads
|
||||
@@ -37,10 +35,16 @@ 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 RevPis
|
||||
@param timeout Verbindungstimeout in Millisekunden"""
|
||||
@param address IP Adresse des RevPi
|
||||
@param timeout Timeout in Millisekunden der Verbindung"""
|
||||
super().__init__()
|
||||
self.daemon = True
|
||||
|
||||
@@ -94,7 +98,7 @@ class NetFH(Thread):
|
||||
so = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
try:
|
||||
so.connect(self._address)
|
||||
except:
|
||||
except Exception:
|
||||
so.close()
|
||||
else:
|
||||
# Alten Socket trennen
|
||||
@@ -156,7 +160,7 @@ class NetFH(Thread):
|
||||
self._slavesock.send(_sysexit)
|
||||
else:
|
||||
self._slavesock.shutdown(socket.SHUT_RDWR)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
self._slavesock.close()
|
||||
|
||||
@@ -193,7 +197,7 @@ class NetFH(Thread):
|
||||
def get_name(self):
|
||||
"""Verbindugnsnamen zurueckgeben.
|
||||
@return <class 'str'> IP:PORT"""
|
||||
return "{}:{}".format(*self._address)
|
||||
return "{0}:{1}".format(*self._address)
|
||||
|
||||
def get_timeout(self):
|
||||
"""Gibt aktuellen Timeout zurueck.
|
||||
@@ -391,6 +395,8 @@ class RevPiNetIO(_RevPiModIO):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = "_address"
|
||||
|
||||
def __init__(
|
||||
self, address, autorefresh=False, monitoring=False,
|
||||
syncoutputs=True, simulator=False):
|
||||
@@ -445,7 +451,7 @@ class RevPiNetIO(_RevPiModIO):
|
||||
autorefresh,
|
||||
monitoring,
|
||||
syncoutputs,
|
||||
"{}:{}".format(*self._address),
|
||||
"{0}:{1}".format(*self._address),
|
||||
None,
|
||||
simulator
|
||||
)
|
||||
@@ -488,7 +494,7 @@ class RevPiNetIO(_RevPiModIO):
|
||||
if device is None:
|
||||
self._myfh.clear_dirtybytes()
|
||||
else:
|
||||
dev = device if issubclass(type(device), Device) \
|
||||
dev = device if isinstance(device, Device) \
|
||||
else self.device.__getitem__(device)
|
||||
mylist = [dev]
|
||||
|
||||
@@ -508,7 +514,7 @@ class RevPiNetIO(_RevPiModIO):
|
||||
if device is None:
|
||||
mylist = self.device
|
||||
else:
|
||||
dev = device if issubclass(type(device), Device) \
|
||||
dev = device if isinstance(device, Device) \
|
||||
else self.device.__getitem__(device)
|
||||
mylist = [dev]
|
||||
|
||||
@@ -554,6 +560,8 @@ class RevPiNetIOSelected(RevPiNetIO):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
def __init__(
|
||||
self, address, deviceselection, autorefresh=False,
|
||||
monitoring=False, syncoutputs=True, simulator=False):
|
||||
@@ -619,6 +627,8 @@ class RevPiNetIODriver(RevPiNetIOSelected):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
def __init__(
|
||||
self, address, virtdev, autorefresh=False, monitoring=False,
|
||||
syncoutputs=True):
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# python3-RevPiModIO
|
||||
#
|
||||
# Webpage: https://revpimodio.org/
|
||||
# (c) Sven Sager, License: LGPLv3
|
||||
#
|
||||
"""Bildet die Summary-Sektion von piCtory ab."""
|
||||
__author__ = "Sven Sager"
|
||||
__copyright__ = "Copyright (C) 2018 Sven Sager"
|
||||
__license__ = "LGPLv3"
|
||||
|
||||
|
||||
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"""
|
||||
|
||||
9
setup.py
9
setup.py
@@ -1,9 +1,10 @@
|
||||
#! /usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# (c) Sven Sager, License: LGPLv3
|
||||
#
|
||||
"""Setupscript fuer python3-revpimodio."""
|
||||
__author__ = "Sven Sager"
|
||||
__copyright__ = "Copyright (C) 2018 Sven Sager"
|
||||
__license__ = "LGPLv3"
|
||||
|
||||
from distutils.core import setup
|
||||
|
||||
setup(
|
||||
@@ -16,7 +17,7 @@ setup(
|
||||
|
||||
license="LGPLv3",
|
||||
name="revpimodio2",
|
||||
version="2.1.6",
|
||||
version="2.2.3",
|
||||
|
||||
packages=["revpimodio2"],
|
||||
python_requires="~=3.2",
|
||||
|
||||
Reference in New Issue
Block a user