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>
<table>
<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>Bildet die App Sektion von piCtory ab.</td>
</tr><tr>
@@ -41,6 +38,9 @@ Modules</h3>
<td><a style="color:#0000FF" href="revpimodio2.modio.html">modio</a></td>
<td>RevPiModIO Hauptklasse.</td>
</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>Bildet die Summary-Sektion von piCtory ab.</td>
</tr>

View File

@@ -402,13 +402,13 @@ Methods</h3>
<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>
</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>
</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>
</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>
</tr>
</table>
@@ -520,7 +520,7 @@ Erstellt aus der piCtory-Liste die IOs fuer dieses Device.
dict()-Objekt aus piCtory Konfiguration
</dd><dt><i>iotype</i></dt>
<dd>
IOType() Wert
io.Type() Wert
</dd>
</dl><dl>
<dt>Returns:</dt>
@@ -555,10 +555,10 @@ Gibt eine Liste aller Inputs und Outputs zurueck, keine MEMs.
<dd>
list() Input und Output, keine MEMs
</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">
Device.get_inps</h3>
<b>get_inps</b>(<i></i>)
Device.get_inputs</h3>
<b>get_inputs</b>(<i></i>)
<p>
Gibt eine Liste aller Inputs zurueck.
</p><dl>
@@ -566,10 +566,10 @@ Gibt eine Liste aller Inputs zurueck.
<dd>
list() Inputs
</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">
Device.get_mems</h3>
<b>get_mems</b>(<i></i>)
Device.get_memmories</h3>
<b>get_memmories</b>(<i></i>)
<p>
Gibt eine Liste aller mems zurueck.
</p><dl>
@@ -577,10 +577,10 @@ Gibt eine Liste aller mems zurueck.
<dd>
list() Mems
</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">
Device.get_outs</h3>
<b>get_outs</b>(<i></i>)
Device.get_outputs</h3>
<b>get_outputs</b>(<i></i>)
<p>
Gibt eine Liste aller Outputs zurueck.
</p><dl>

View File

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

View File

@@ -1,9 +1,6 @@
revpimodio2.BOTH?7
revpimodio2.FALLING?7
revpimodio2.GREEN?7
revpimodio2.IOType.INP?7
revpimodio2.IOType.MEM?7
revpimodio2.IOType.OUT?7
revpimodio2.OFF?7
revpimodio2.RED?7
revpimodio2.RISING?7
@@ -34,9 +31,9 @@ revpimodio2.device.Device._buildio?5(dict_io, iotype)
revpimodio2.device.Device._devconfigure?5()
revpimodio2.device.Device.autorefresh?4(remove=False)
revpimodio2.device.Device.get_allios?4()
revpimodio2.device.Device.get_inps?4()
revpimodio2.device.Device.get_mems?4()
revpimodio2.device.Device.get_outs?4()
revpimodio2.device.Device.get_inputs?4()
revpimodio2.device.Device.get_memmories?4()
revpimodio2.device.Device.get_outputs?4()
revpimodio2.device.Device?1(parentmodio, dict_device, **kwargs)
revpimodio2.device.DeviceList?1()
revpimodio2.device.Gateway.get_rawbytes?4()
@@ -66,6 +63,7 @@ revpimodio2.helper.ProcimgWriter.stop?4()
revpimodio2.helper.ProcimgWriter?1(parentmodio)
revpimodio2.io.IOBase._get_address?5()
revpimodio2.io.IOBase._get_byteorder?5()
revpimodio2.io.IOBase._get_iotype?5()
revpimodio2.io.IOBase._get_length?5()
revpimodio2.io.IOBase._get_name?5()
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.replace_io?4(name, frm, **kwargs)
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.value?7
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.value?7
revpimodio2.io.StructIO?1(parentio, name, frm, **kwargs)
revpimodio2.io.Type.INP?7
revpimodio2.io.Type.MEM?7
revpimodio2.io.Type.OUT?7
revpimodio2.modio.RevPiModIO._configure?5()
revpimodio2.modio.RevPiModIO._create_myfh?5()
revpimodio2.modio.RevPiModIO._get_configrsc?5()

View File

@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Project SYSTEM "Project-5.1.dtd">
<!-- 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 -->
<Project version="5.1">
<Language>en_US</Language>
<Hash>7ea159534ad3516e9069331120048abf9b00151e</Hash>
<ProgLanguage mixed="0">Python3</ProgLanguage>
<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>
<Author>Sven Sager</Author>
<Email>akira@narux.de</Email>
@@ -26,6 +26,7 @@
<Source>test/test_dio_mainloop.py</Source>
<Source>test/test_dio_cycleloop.py</Source>
<Source>revpimodio2/net.py</Source>
<Source>test/test_net_leistung.py</Source>
</Sources>
<Forms/>
<Translations/>
@@ -35,6 +36,7 @@
<Other>doc</Other>
<Other>.hgignore</Other>
<Other>eric-revpimodio.api</Other>
<Other>MANIFEST.in</Other>
</Others>
<Vcs>
<VcsType>Mercurial</VcsType>

View File

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

View File

@@ -7,7 +7,6 @@
# -*- coding: utf-8 -*-
"""Modul fuer die Verwaltung der Devices."""
from threading import Lock
from .__init__ import IOType
from .helper import ProcimgWriter
@@ -99,12 +98,16 @@ class Device(object):
# IOM-Objekte erstellen und Adressen in SLCs speichern
if kwargs.get("simulator", False):
self.slc_inp = self._buildio(dict_device.pop("out"), IOType.INP)
self.slc_out = self._buildio(dict_device.pop("inp"), IOType.OUT)
self.slc_inp = self._buildio(
dict_device.pop("out"), iomodule.Type.INP)
self.slc_out = self._buildio(
dict_device.pop("inp"), iomodule.Type.OUT)
else:
self.slc_inp = self._buildio(dict_device.pop("inp"), IOType.INP)
self.slc_out = self._buildio(dict_device.pop("out"), IOType.OUT)
self.slc_mem = self._buildio(dict_device.pop("mem"), IOType.MEM)
self.slc_inp = self._buildio(
dict_device.pop("inp"), iomodule.Type.INP)
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
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.
@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
"""
@@ -267,7 +270,7 @@ class Device(object):
lst_return += lst_io
return lst_return
def get_inps(self):
def get_inputs(self):
"""Gibt eine Liste aller Inputs zurueck.
@return list() Inputs"""
lst_return = []
@@ -275,7 +278,7 @@ class Device(object):
lst_return += lst_io
return lst_return
def get_outs(self):
def get_outputs(self):
"""Gibt eine Liste aller Outputs zurueck.
@return list() Outputs"""
lst_return = []
@@ -283,7 +286,7 @@ class Device(object):
lst_return += lst_io
return lst_return
def get_mems(self):
def get_memmories(self):
"""Gibt eine Liste aller mems zurueck.
@return list() Mems"""
lst_return = []
@@ -537,9 +540,9 @@ class Gateway(Device):
super().__init__(parent, dict_device, **kwargs)
self._dict_slc = {
IOType.INP: self.slc_inp,
IOType.OUT: self.slc_out,
IOType.MEM: self.slc_mem
iomodule.Type.INP: self.slc_inp,
iomodule.Type.OUT: self.slc_out,
iomodule.Type.MEM: self.slc_mem
}
def get_rawbytes(self):

View File

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

View File

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

View File

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