setup.py für Package angepasst

get_inps _outs _mems umbenannt in get_inputs _outputs _memmories
IOType von __init__ auf io.Type geändert
IOBase.type eingefügt
This commit is contained in:
2017-08-18 18:41:43 +02:00
parent e124da758f
commit 37eb012e16
10 changed files with 138 additions and 65 deletions

View File

@@ -23,9 +23,6 @@ fuehrt das Modul bei Datenaenderung aus.
Modules</h3> Modules</h3>
<table> <table>
<tr> <tr>
<td><a style="color:#0000FF" href="revpimodio2.__init__.html">revpimodio2</a></td>
<td>Stellt alle Klassen fuer den RevolutionPi zur Verfuegung.</td>
</tr><tr>
<td><a style="color:#0000FF" href="revpimodio2.app.html">app</a></td> <td><a style="color:#0000FF" href="revpimodio2.app.html">app</a></td>
<td>Bildet die App Sektion von piCtory ab.</td> <td>Bildet die App Sektion von piCtory ab.</td>
</tr><tr> </tr><tr>
@@ -41,6 +38,9 @@ Modules</h3>
<td><a style="color:#0000FF" href="revpimodio2.modio.html">modio</a></td> <td><a style="color:#0000FF" href="revpimodio2.modio.html">modio</a></td>
<td>RevPiModIO Hauptklasse.</td> <td>RevPiModIO Hauptklasse.</td>
</tr><tr> </tr><tr>
<td><a style="color:#0000FF" href="revpimodio2.netio.html">netio</a></td>
<td></td>
</tr><tr>
<td><a style="color:#0000FF" href="revpimodio2.summary.html">summary</a></td> <td><a style="color:#0000FF" href="revpimodio2.summary.html">summary</a></td>
<td>Bildet die Summary-Sektion von piCtory ab.</td> <td>Bildet die Summary-Sektion von piCtory ab.</td>
</tr> </tr>

View File

@@ -402,13 +402,13 @@ Methods</h3>
<td><a style="color:#0000FF" href="#Device.get_allios">get_allios</a></td> <td><a style="color:#0000FF" href="#Device.get_allios">get_allios</a></td>
<td>Gibt eine Liste aller Inputs und Outputs zurueck, keine MEMs.</td> <td>Gibt eine Liste aller Inputs und Outputs zurueck, keine MEMs.</td>
</tr><tr> </tr><tr>
<td><a style="color:#0000FF" href="#Device.get_inps">get_inps</a></td> <td><a style="color:#0000FF" href="#Device.get_inputs">get_inputs</a></td>
<td>Gibt eine Liste aller Inputs zurueck.</td> <td>Gibt eine Liste aller Inputs zurueck.</td>
</tr><tr> </tr><tr>
<td><a style="color:#0000FF" href="#Device.get_mems">get_mems</a></td> <td><a style="color:#0000FF" href="#Device.get_memmories">get_memmories</a></td>
<td>Gibt eine Liste aller mems zurueck.</td> <td>Gibt eine Liste aller mems zurueck.</td>
</tr><tr> </tr><tr>
<td><a style="color:#0000FF" href="#Device.get_outs">get_outs</a></td> <td><a style="color:#0000FF" href="#Device.get_outputs">get_outputs</a></td>
<td>Gibt eine Liste aller Outputs zurueck.</td> <td>Gibt eine Liste aller Outputs zurueck.</td>
</tr> </tr>
</table> </table>
@@ -520,7 +520,7 @@ Erstellt aus der piCtory-Liste die IOs fuer dieses Device.
dict()-Objekt aus piCtory Konfiguration dict()-Objekt aus piCtory Konfiguration
</dd><dt><i>iotype</i></dt> </dd><dt><i>iotype</i></dt>
<dd> <dd>
IOType() Wert io.Type() Wert
</dd> </dd>
</dl><dl> </dl><dl>
<dt>Returns:</dt> <dt>Returns:</dt>
@@ -555,10 +555,10 @@ Gibt eine Liste aller Inputs und Outputs zurueck, keine MEMs.
<dd> <dd>
list() Input und Output, keine MEMs list() Input und Output, keine MEMs
</dd> </dd>
</dl><a NAME="Device.get_inps" ID="Device.get_inps"></a> </dl><a NAME="Device.get_inputs" ID="Device.get_inputs"></a>
<h3 style="background-color:#FFFFFF;color:#FF0000"> <h3 style="background-color:#FFFFFF;color:#FF0000">
Device.get_inps</h3> Device.get_inputs</h3>
<b>get_inps</b>(<i></i>) <b>get_inputs</b>(<i></i>)
<p> <p>
Gibt eine Liste aller Inputs zurueck. Gibt eine Liste aller Inputs zurueck.
</p><dl> </p><dl>
@@ -566,10 +566,10 @@ Gibt eine Liste aller Inputs zurueck.
<dd> <dd>
list() Inputs list() Inputs
</dd> </dd>
</dl><a NAME="Device.get_mems" ID="Device.get_mems"></a> </dl><a NAME="Device.get_memmories" ID="Device.get_memmories"></a>
<h3 style="background-color:#FFFFFF;color:#FF0000"> <h3 style="background-color:#FFFFFF;color:#FF0000">
Device.get_mems</h3> Device.get_memmories</h3>
<b>get_mems</b>(<i></i>) <b>get_memmories</b>(<i></i>)
<p> <p>
Gibt eine Liste aller mems zurueck. Gibt eine Liste aller mems zurueck.
</p><dl> </p><dl>
@@ -577,10 +577,10 @@ Gibt eine Liste aller mems zurueck.
<dd> <dd>
list() Mems list() Mems
</dd> </dd>
</dl><a NAME="Device.get_outs" ID="Device.get_outs"></a> </dl><a NAME="Device.get_outputs" ID="Device.get_outputs"></a>
<h3 style="background-color:#FFFFFF;color:#FF0000"> <h3 style="background-color:#FFFFFF;color:#FF0000">
Device.get_outs</h3> Device.get_outputs</h3>
<b>get_outs</b>(<i></i>) <b>get_outputs</b>(<i></i>)
<p> <p>
Gibt eine Liste aller Outputs zurueck. Gibt eine Liste aller Outputs zurueck.
</p><dl> </p><dl>

View File

@@ -29,6 +29,9 @@ Classes</h3>
</tr><tr> </tr><tr>
<td><a style="color:#0000FF" href="#StructIO">StructIO</a></td> <td><a style="color:#0000FF" href="#StructIO">StructIO</a></td>
<td>Klasse fuer den Zugriff auf Daten ueber ein definierten struct().</td> <td>Klasse fuer den Zugriff auf Daten ueber ein definierten struct().</td>
</tr><tr>
<td><a style="color:#0000FF" href="#Type">Type</a></td>
<td>IO Typen.</td>
</tr> </tr>
</table> </table>
<h3 style="background-color:#FFFFFF;color:#FF0000"> <h3 style="background-color:#FFFFFF;color:#FF0000">
@@ -58,7 +61,7 @@ object
<h3 style="background-color:#FFFFFF;color:#FF0000"> <h3 style="background-color:#FFFFFF;color:#FF0000">
Class Attributes</h3> Class Attributes</h3>
<table> <table>
<tr><td>address</td></tr><tr><td>byteorder</td></tr><tr><td>length</td></tr><tr><td>name</td></tr><tr><td>value</td></tr> <tr><td>address</td></tr><tr><td>byteorder</td></tr><tr><td>length</td></tr><tr><td>name</td></tr><tr><td>type</td></tr><tr><td>value</td></tr>
</table> </table>
<h3 style="background-color:#FFFFFF;color:#FF0000"> <h3 style="background-color:#FFFFFF;color:#FF0000">
Class Methods</h3> Class Methods</h3>
@@ -87,6 +90,9 @@ Methods</h3>
<td><a style="color:#0000FF" href="#IOBase._get_byteorder">_get_byteorder</a></td> <td><a style="color:#0000FF" href="#IOBase._get_byteorder">_get_byteorder</a></td>
<td>Gibt konfigurierte Byteorder zurueck.</td> <td>Gibt konfigurierte Byteorder zurueck.</td>
</tr><tr> </tr><tr>
<td><a style="color:#0000FF" href="#IOBase._get_iotype">_get_iotype</a></td>
<td>Gibt io.Type zurueck.</td>
</tr><tr>
<td><a style="color:#0000FF" href="#IOBase._get_length">_get_length</a></td> <td><a style="color:#0000FF" href="#IOBase._get_length">_get_length</a></td>
<td>Gibt die Bytelaenge des IO zurueck.</td> <td>Gibt die Bytelaenge des IO zurueck.</td>
</tr><tr> </tr><tr>
@@ -132,7 +138,7 @@ Parentdevice auf dem der IO liegt
Datenliste fuer Instantiierung Datenliste fuer Instantiierung
</dd><dt><i>iotype</i></dt> </dd><dt><i>iotype</i></dt>
<dd> <dd>
IOType() Wert io.Type() Wert
</dd><dt><i>byteorder</i></dt> </dd><dt><i>byteorder</i></dt>
<dd> <dd>
Byteorder 'little' / 'big' fuer int() Berechnung Byteorder 'little' / 'big' fuer int() Berechnung
@@ -195,6 +201,17 @@ Gibt konfigurierte Byteorder zurueck.
<dd> <dd>
str() Byteorder str() Byteorder
</dd> </dd>
</dl><a NAME="IOBase._get_iotype" ID="IOBase._get_iotype"></a>
<h3 style="background-color:#FFFFFF;color:#FF0000">
IOBase._get_iotype</h3>
<b>_get_iotype</b>(<i></i>)
<p>
Gibt io.Type zurueck.
</p><dl>
<dt>Returns:</dt>
<dd>
int() io.Type
</dd>
</dl><a NAME="IOBase._get_length" ID="IOBase._get_length"></a> </dl><a NAME="IOBase._get_length" ID="IOBase._get_length"></a>
<h3 style="background-color:#FFFFFF;color:#FF0000"> <h3 style="background-color:#FFFFFF;color:#FF0000">
IOBase._get_length</h3> IOBase._get_length</h3>
@@ -791,6 +808,37 @@ Setzt den Wert mit struct Formatierung.
Wert vom Typ der struct-Formatierung Wert vom Typ der struct-Formatierung
</dd> </dd>
</dl> </dl>
<div align="right"><a style="color:#0000FF" href="#top">Up</a></div>
<hr /><hr />
<a NAME="Type" ID="Type"></a>
<h2 style="background-color:#FFFFFF;color:#0000FF">Type</h2>
<p>
IO Typen.
</p>
<h3 style="background-color:#FFFFFF;color:#FF0000">
Derived from</h3>
object
<h3 style="background-color:#FFFFFF;color:#FF0000">
Class Attributes</h3>
<table>
<tr><td>INP</td></tr><tr><td>MEM</td></tr><tr><td>OUT</td></tr>
</table>
<h3 style="background-color:#FFFFFF;color:#FF0000">
Class Methods</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3 style="background-color:#FFFFFF;color:#FF0000">
Methods</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3 style="background-color:#FFFFFF;color:#FF0000">
Static Methods</h3>
<table>
<tr><td>None</td></tr>
</table>
<div align="right"><a style="color:#0000FF" href="#top">Up</a></div> <div align="right"><a style="color:#0000FF" href="#top">Up</a></div>
<hr /> <hr />
</body></html> </body></html>

View File

@@ -1,9 +1,6 @@
revpimodio2.BOTH?7 revpimodio2.BOTH?7
revpimodio2.FALLING?7 revpimodio2.FALLING?7
revpimodio2.GREEN?7 revpimodio2.GREEN?7
revpimodio2.IOType.INP?7
revpimodio2.IOType.MEM?7
revpimodio2.IOType.OUT?7
revpimodio2.OFF?7 revpimodio2.OFF?7
revpimodio2.RED?7 revpimodio2.RED?7
revpimodio2.RISING?7 revpimodio2.RISING?7
@@ -34,9 +31,9 @@ revpimodio2.device.Device._buildio?5(dict_io, iotype)
revpimodio2.device.Device._devconfigure?5() revpimodio2.device.Device._devconfigure?5()
revpimodio2.device.Device.autorefresh?4(remove=False) revpimodio2.device.Device.autorefresh?4(remove=False)
revpimodio2.device.Device.get_allios?4() revpimodio2.device.Device.get_allios?4()
revpimodio2.device.Device.get_inps?4() revpimodio2.device.Device.get_inputs?4()
revpimodio2.device.Device.get_mems?4() revpimodio2.device.Device.get_memmories?4()
revpimodio2.device.Device.get_outs?4() revpimodio2.device.Device.get_outputs?4()
revpimodio2.device.Device?1(parentmodio, dict_device, **kwargs) revpimodio2.device.Device?1(parentmodio, dict_device, **kwargs)
revpimodio2.device.DeviceList?1() revpimodio2.device.DeviceList?1()
revpimodio2.device.Gateway.get_rawbytes?4() revpimodio2.device.Gateway.get_rawbytes?4()
@@ -66,6 +63,7 @@ revpimodio2.helper.ProcimgWriter.stop?4()
revpimodio2.helper.ProcimgWriter?1(parentmodio) revpimodio2.helper.ProcimgWriter?1(parentmodio)
revpimodio2.io.IOBase._get_address?5() revpimodio2.io.IOBase._get_address?5()
revpimodio2.io.IOBase._get_byteorder?5() revpimodio2.io.IOBase._get_byteorder?5()
revpimodio2.io.IOBase._get_iotype?5()
revpimodio2.io.IOBase._get_length?5() revpimodio2.io.IOBase._get_length?5()
revpimodio2.io.IOBase._get_name?5() revpimodio2.io.IOBase._get_name?5()
revpimodio2.io.IOBase.address?7 revpimodio2.io.IOBase.address?7
@@ -76,6 +74,7 @@ revpimodio2.io.IOBase.name?7
revpimodio2.io.IOBase.reg_event?4(func, edge=BOTH, as_thread=False) revpimodio2.io.IOBase.reg_event?4(func, edge=BOTH, as_thread=False)
revpimodio2.io.IOBase.replace_io?4(name, frm, **kwargs) revpimodio2.io.IOBase.replace_io?4(name, frm, **kwargs)
revpimodio2.io.IOBase.set_value?4(value) revpimodio2.io.IOBase.set_value?4(value)
revpimodio2.io.IOBase.type?7
revpimodio2.io.IOBase.unreg_event?4(func=None, edge=None) revpimodio2.io.IOBase.unreg_event?4(func=None, edge=None)
revpimodio2.io.IOBase.value?7 revpimodio2.io.IOBase.value?7
revpimodio2.io.IOBase.wait?4(edge=BOTH, exitevent=None, okvalue=None, timeout=0) revpimodio2.io.IOBase.wait?4(edge=BOTH, exitevent=None, okvalue=None, timeout=0)
@@ -98,6 +97,9 @@ revpimodio2.io.StructIO.set_structvalue?4(value)
revpimodio2.io.StructIO.signed?7 revpimodio2.io.StructIO.signed?7
revpimodio2.io.StructIO.value?7 revpimodio2.io.StructIO.value?7
revpimodio2.io.StructIO?1(parentio, name, frm, **kwargs) revpimodio2.io.StructIO?1(parentio, name, frm, **kwargs)
revpimodio2.io.Type.INP?7
revpimodio2.io.Type.MEM?7
revpimodio2.io.Type.OUT?7
revpimodio2.modio.RevPiModIO._configure?5() revpimodio2.modio.RevPiModIO._configure?5()
revpimodio2.modio.RevPiModIO._create_myfh?5() revpimodio2.modio.RevPiModIO._create_myfh?5()
revpimodio2.modio.RevPiModIO._get_configrsc?5() revpimodio2.modio.RevPiModIO._get_configrsc?5()

View File

@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Project SYSTEM "Project-5.1.dtd"> <!DOCTYPE Project SYSTEM "Project-5.1.dtd">
<!-- eric project file for project revpimodio2 --> <!-- eric project file for project revpimodio2 -->
<!-- Saved: 2017-08-16, 17:05:08 --> <!-- Saved: 2017-08-18, 15:59:48 -->
<!-- Copyright (C) 2017 Sven Sager, akira@narux.de --> <!-- Copyright (C) 2017 Sven Sager, akira@narux.de -->
<Project version="5.1"> <Project version="5.1">
<Language>en_US</Language> <Language>en_US</Language>
<Hash>7ea159534ad3516e9069331120048abf9b00151e</Hash> <Hash>7ea159534ad3516e9069331120048abf9b00151e</Hash>
<ProgLanguage mixed="0">Python3</ProgLanguage> <ProgLanguage mixed="0">Python3</ProgLanguage>
<ProjectType>Console</ProjectType> <ProjectType>Console</ProjectType>
<Description></Description> <Description>Das Modul stellt alle Devices und IOs aus der piCtory Konfiguration in Python3 zur Verfügung. Es ermöglicht den direkten Zugriff auf die Werte über deren vergebenen Namen. Lese- und Schreibaktionen mit dem Prozessabbild werden von dem Modul selbst verwaltet, ohne dass sich der Programmierer um Offsets und Adressen kümmern muss. Für die Gatewaymodule wie ModbusTCP oder Profinet sind eigene 'Inputs' und 'Outputs' über einen bestimmten Adressbereich definierbar. Auf diese IOs kann mit Python3 über den Namen direkt auf die Werte zugegriffen werden.</Description>
<Version>2.0.0</Version> <Version>2.0.0</Version>
<Author>Sven Sager</Author> <Author>Sven Sager</Author>
<Email>akira@narux.de</Email> <Email>akira@narux.de</Email>
@@ -26,6 +26,7 @@
<Source>test/test_dio_mainloop.py</Source> <Source>test/test_dio_mainloop.py</Source>
<Source>test/test_dio_cycleloop.py</Source> <Source>test/test_dio_cycleloop.py</Source>
<Source>revpimodio2/net.py</Source> <Source>revpimodio2/net.py</Source>
<Source>test/test_net_leistung.py</Source>
</Sources> </Sources>
<Forms/> <Forms/>
<Translations/> <Translations/>
@@ -35,6 +36,7 @@
<Other>doc</Other> <Other>doc</Other>
<Other>.hgignore</Other> <Other>.hgignore</Other>
<Other>eric-revpimodio.api</Other> <Other>eric-revpimodio.api</Other>
<Other>MANIFEST.in</Other>
</Others> </Others>
<Vcs> <Vcs>
<VcsType>Mercurial</VcsType> <VcsType>Mercurial</VcsType>

View File

@@ -35,12 +35,3 @@ FALLING = 32
BOTH = 33 BOTH = 33
warnings.simplefilter(action="always") warnings.simplefilter(action="always")
class IOType(object):
"""IO Typen."""
INP = 300
OUT = 301
MEM = 302

View File

@@ -7,7 +7,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
"""Modul fuer die Verwaltung der Devices.""" """Modul fuer die Verwaltung der Devices."""
from threading import Lock from threading import Lock
from .__init__ import IOType
from .helper import ProcimgWriter from .helper import ProcimgWriter
@@ -99,12 +98,16 @@ class Device(object):
# IOM-Objekte erstellen und Adressen in SLCs speichern # IOM-Objekte erstellen und Adressen in SLCs speichern
if kwargs.get("simulator", False): if kwargs.get("simulator", False):
self.slc_inp = self._buildio(dict_device.pop("out"), IOType.INP) self.slc_inp = self._buildio(
self.slc_out = self._buildio(dict_device.pop("inp"), IOType.OUT) dict_device.pop("out"), iomodule.Type.INP)
self.slc_out = self._buildio(
dict_device.pop("inp"), iomodule.Type.OUT)
else: else:
self.slc_inp = self._buildio(dict_device.pop("inp"), IOType.INP) self.slc_inp = self._buildio(
self.slc_out = self._buildio(dict_device.pop("out"), IOType.OUT) dict_device.pop("inp"), iomodule.Type.INP)
self.slc_mem = self._buildio(dict_device.pop("mem"), IOType.MEM) self.slc_out = self._buildio(
dict_device.pop("out"), iomodule.Type.OUT)
self.slc_mem = self._buildio(dict_device.pop("mem"), iomodule.Type.MEM)
# SLCs mit offset berechnen # SLCs mit offset berechnen
self.slc_devoff = slice(self.offset, self.offset + self._length) self.slc_devoff = slice(self.offset, self.offset + self._length)
@@ -174,7 +177,7 @@ class Device(object):
"""Erstellt aus der piCtory-Liste die IOs fuer dieses Device. """Erstellt aus der piCtory-Liste die IOs fuer dieses Device.
@param dict_io dict()-Objekt aus piCtory Konfiguration @param dict_io dict()-Objekt aus piCtory Konfiguration
@param iotype IOType() Wert @param iotype io.Type() Wert
@return slice()-Objekt mit Start und Stop Position dieser IOs @return slice()-Objekt mit Start und Stop Position dieser IOs
""" """
@@ -267,7 +270,7 @@ class Device(object):
lst_return += lst_io lst_return += lst_io
return lst_return return lst_return
def get_inps(self): def get_inputs(self):
"""Gibt eine Liste aller Inputs zurueck. """Gibt eine Liste aller Inputs zurueck.
@return list() Inputs""" @return list() Inputs"""
lst_return = [] lst_return = []
@@ -275,7 +278,7 @@ class Device(object):
lst_return += lst_io lst_return += lst_io
return lst_return return lst_return
def get_outs(self): def get_outputs(self):
"""Gibt eine Liste aller Outputs zurueck. """Gibt eine Liste aller Outputs zurueck.
@return list() Outputs""" @return list() Outputs"""
lst_return = [] lst_return = []
@@ -283,7 +286,7 @@ class Device(object):
lst_return += lst_io lst_return += lst_io
return lst_return return lst_return
def get_mems(self): def get_memmories(self):
"""Gibt eine Liste aller mems zurueck. """Gibt eine Liste aller mems zurueck.
@return list() Mems""" @return list() Mems"""
lst_return = [] lst_return = []
@@ -537,9 +540,9 @@ class Gateway(Device):
super().__init__(parent, dict_device, **kwargs) super().__init__(parent, dict_device, **kwargs)
self._dict_slc = { self._dict_slc = {
IOType.INP: self.slc_inp, iomodule.Type.INP: self.slc_inp,
IOType.OUT: self.slc_out, iomodule.Type.OUT: self.slc_out,
IOType.MEM: self.slc_mem iomodule.Type.MEM: self.slc_mem
} }
def get_rawbytes(self): def get_rawbytes(self):

View File

@@ -8,7 +8,16 @@
"""RevPiModIO Modul fuer die Verwaltung der IOs.""" """RevPiModIO Modul fuer die Verwaltung der IOs."""
import struct import struct
from threading import Event from threading import Event
from .__init__ import RISING, FALLING, BOTH, IOType from .__init__ import RISING, FALLING, BOTH
class Type(object):
"""IO Typen."""
INP = 300
OUT = 301
MEM = 302
class IOList(object): class IOList(object):
@@ -207,7 +216,7 @@ class IOBase(object):
@param parentdevice Parentdevice auf dem der IO liegt @param parentdevice Parentdevice auf dem der IO liegt
@param valuelist Datenliste fuer Instantiierung @param valuelist Datenliste fuer Instantiierung
@param iotype IOType() Wert @param iotype io.Type() Wert
@param byteorder Byteorder 'little' / 'big' fuer int() Berechnung @param byteorder Byteorder 'little' / 'big' fuer int() Berechnung
@param sigend Intberechnung mit Vorzeichen durchfuehren @param sigend Intberechnung mit Vorzeichen durchfuehren
@@ -291,6 +300,11 @@ class IOBase(object):
@return str() Byteorder""" @return str() Byteorder"""
return self._byteorder return self._byteorder
def _get_iotype(self):
"""Gibt io.Type zurueck.
@return int() io.Type"""
return self._iotype
def _get_length(self): def _get_length(self):
"""Gibt die Bytelaenge des IO zurueck. """Gibt die Bytelaenge des IO zurueck.
@return Bytelaenge des IO""" @return Bytelaenge des IO"""
@@ -400,13 +414,13 @@ class IOBase(object):
reg_event = kwargs.get("event", None) reg_event = kwargs.get("event", None)
if reg_event is not None: if reg_event is not None:
as_thread = kwargs.get("as_thread", False) as_thread = kwargs.get("as_thread", False)
edge = kwargs.get("edge", None) edge = kwargs.get("edge", BOTH)
io_new.reg_event(reg_event, as_thread=as_thread, edge=edge) io_new.reg_event(reg_event, as_thread=as_thread, edge=edge)
def set_value(self, value): def set_value(self, value):
"""Setzt den Wert des IOs mit bytes() oder bool(). """Setzt den Wert des IOs mit bytes() oder bool().
@param value IO-Wert als bytes() oder bool()""" @param value IO-Wert als bytes() oder bool()"""
if self._iotype == IOType.OUT: if self._iotype == Type.OUT:
if self._bitaddress >= 0: if self._bitaddress >= 0:
# Versuchen egal welchen Typ in Bool zu konvertieren # Versuchen egal welchen Typ in Bool zu konvertieren
value = bool(value) value = bool(value)
@@ -437,18 +451,25 @@ class IOBase(object):
value value
else: else:
raise ValueError( raise ValueError(
"requires a bytes() object of length {}, but" "'{}' requires a bytes() object of length {}, but "
" {} was given".format(self._length, len(value)) "{} was given".format(
self._name, self._length, len(value)
)
) )
else: else:
raise ValueError( raise ValueError(
"requires a bytes() object, not {}".format(type(value)) "'{}' requires a bytes() object, not {}"
"".format(self._name, type(value))
) )
elif self._iotype == IOType.INP: elif self._iotype == Type.INP:
raise AttributeError("can not write to input") raise AttributeError(
elif self._iotype == IOType.MEM: "can not write to input '{}'".format(self._name)
raise AttributeError("can not write to memory") )
elif self._iotype == Type.MEM:
raise AttributeError(
"can not write to memory '{}'".format(self._name)
)
def unreg_event(self, func=None, edge=None): def unreg_event(self, func=None, edge=None):
"""Entfernt ein Event aus der Eventueberwachung. """Entfernt ein Event aus der Eventueberwachung.
@@ -579,6 +600,7 @@ class IOBase(object):
byteorder = property(_get_byteorder) byteorder = property(_get_byteorder)
length = property(_get_length) length = property(_get_length)
name = property(_get_name) name = property(_get_name)
type = property(_get_iotype)
value = property(get_value, set_value) value = property(get_value, set_value)
@@ -638,7 +660,8 @@ class IntIO(IOBase):
)) ))
else: else:
raise ValueError( raise ValueError(
"need an int() value, but {} was given".format(type(value)) "'{}' need an int() value, but {} was given"
"".format(self._name, type(value))
) )
byteorder = property(IOBase._get_byteorder, _set_byteorder) byteorder = property(IOBase._get_byteorder, _set_byteorder)

View File

@@ -152,7 +152,7 @@ class RevPiModIO(object):
# Für RS485 errors defaults laden und schreiben # Für RS485 errors defaults laden und schreiben
# NOTE: Soll das wirklich gemacht werden? # NOTE: Soll das wirklich gemacht werden?
for io in dev_new.get_outs(): for io in dev_new.get_outputs():
io.set_value(io.defaultvalue) io.set_value(io.defaultvalue)
if not self._monitoring: if not self._monitoring:
self.writeprocimg(True, dev_new) self.writeprocimg(True, dev_new)
@@ -676,7 +676,7 @@ class RevPiModIO(object):
for dev in mylist: for dev in mylist:
if (force or dev.autoupdate): if (force or dev.autoupdate):
for io in dev.get_outs(): for io in dev.get_outputs():
io.set_value(io.defaultvalue) io.set_value(io.defaultvalue)
def syncoutputs(self, force=False, device=None): def syncoutputs(self, force=False, device=None):
@@ -747,7 +747,7 @@ class RevPiModIO(object):
workokay = True workokay = True
dev._filelock.acquire() dev._filelock.acquire()
for io in dev.get_inps(): for io in dev.get_inputs():
dev._ba_devdata[io.slc_address] = io.defaultvalue dev._ba_devdata[io.slc_address] = io.defaultvalue
# Outpus auf Bus schreiben # Outpus auf Bus schreiben

View File

@@ -9,7 +9,8 @@ from distutils.core import setup
setup( setup(
author="Sven Sager", author="Sven Sager",
author_email="akira@narux.de", author_email="akira@narux.de",
url="https://revpimodio.org", url="https://revpimodio.org/",
download_url="https://revpimodio.org/quellen/",
maintainer="Sven Sager", maintainer="Sven Sager",
maintainer_email="akira@revpimodio.org", maintainer_email="akira@revpimodio.org",
@@ -17,7 +18,7 @@ setup(
name="revpimodio2", name="revpimodio2",
version="2.0.0", version="2.0.0",
py_modules=["revpimodio2"], packages=["revpimodio2"],
description="Python3 Programmierung für Kunbus RevolutionPi", description="Python3 Programmierung für Kunbus RevolutionPi",
long_description="" long_description=""
@@ -32,8 +33,11 @@ setup(
"zugegriffen werden.", "zugegriffen werden.",
classifiers=[ classifiers=[
"Environment :: Console",
"License :: OSI Approved :: " "License :: OSI Approved :: "
"GNU Lesser General Public License v3 (LGPLv3)", "GNU Lesser General Public License v3 (LGPLv3)",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux", "Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
"Topic :: Software Development :: Libraries :: Python Modules" "Topic :: Software Development :: Libraries :: Python Modules"