diff --git a/doc/index-revpimodio2.html b/doc/index-revpimodio2.html index 421e8fa..c4ef004 100644 --- a/doc/index-revpimodio2.html +++ b/doc/index-revpimodio2.html @@ -23,9 +23,6 @@ fuehrt das Modul bei Datenaenderung aus. Modules - - - @@ -41,6 +38,9 @@ Modules + + + diff --git a/doc/revpimodio2.device.html b/doc/revpimodio2.device.html index 841c06a..9727af0 100644 --- a/doc/revpimodio2.device.html +++ b/doc/revpimodio2.device.html @@ -402,13 +402,13 @@ Methods - + - + - +
revpimodio2Stellt alle Klassen fuer den RevolutionPi zur Verfuegung.
app Bildet die App Sektion von piCtory ab.
modio RevPiModIO Hauptklasse.
netio
summary Bildet die Summary-Sektion von piCtory ab.
get_allios Gibt eine Liste aller Inputs und Outputs zurueck, keine MEMs.
get_inpsget_inputs Gibt eine Liste aller Inputs zurueck.
get_memsget_memmories Gibt eine Liste aller mems zurueck.
get_outsget_outputs Gibt eine Liste aller Outputs zurueck.
@@ -520,7 +520,7 @@ Erstellt aus der piCtory-Liste die IOs fuer dieses Device. dict()-Objekt aus piCtory Konfiguration
iotype
-IOType() Wert +io.Type() Wert
Returns:
@@ -555,10 +555,10 @@ Gibt eine Liste aller Inputs und Outputs zurueck, keine MEMs.
list() Input und Output, keine MEMs
-
+

-Device.get_inps

-get_inps() +Device.get_inputs +get_inputs()

Gibt eine Liste aller Inputs zurueck.

@@ -566,10 +566,10 @@ Gibt eine Liste aller Inputs zurueck.
list() Inputs
-
+

-Device.get_mems

-get_mems() +Device.get_memmories +get_memmories()

Gibt eine Liste aller mems zurueck.

@@ -577,10 +577,10 @@ Gibt eine Liste aller mems zurueck.
list() Mems
-
+

-Device.get_outs

-get_outs() +Device.get_outputs +get_outputs()

Gibt eine Liste aller Outputs zurueck.

diff --git a/doc/revpimodio2.io.html b/doc/revpimodio2.io.html index b6f4bf9..4e51ee5 100644 --- a/doc/revpimodio2.io.html +++ b/doc/revpimodio2.io.html @@ -29,6 +29,9 @@ Classes StructIO Klasse fuer den Zugriff auf Daten ueber ein definierten struct(). + +Type +IO Typen.

@@ -58,7 +61,7 @@ object

Class Attributes

- +
address
byteorder
length
name
value
address
byteorder
length
name
type
value

Class Methods

@@ -87,6 +90,9 @@ Methods _get_byteorder Gibt konfigurierte Byteorder zurueck. +_get_iotype +Gibt io.Type zurueck. + _get_length Gibt die Bytelaenge des IO zurueck. @@ -132,7 +138,7 @@ Parentdevice auf dem der IO liegt Datenliste fuer Instantiierung
iotype
-IOType() Wert +io.Type() Wert
byteorder
Byteorder 'little' / 'big' fuer int() Berechnung @@ -195,6 +201,17 @@ Gibt konfigurierte Byteorder zurueck.
str() Byteorder
+
+

+IOBase._get_iotype

+_get_iotype() +

+Gibt io.Type zurueck. +

+
Returns:
+
+int() io.Type +

IOBase._get_length

@@ -791,6 +808,37 @@ Setzt den Wert mit struct Formatierung. Wert vom Typ der struct-Formatierung +
Up
+

+ +

Type

+

+IO Typen. +

+

+Derived from

+object +

+Class Attributes

+ + +
INP
MEM
OUT
+

+Class Methods

+ + +
None
+

+Methods

+ + +
None
+

+Static Methods

+ + +
None
+
Up

\ No newline at end of file diff --git a/eric-revpimodio.api b/eric-revpimodio.api index b06c493..cc557b1 100644 --- a/eric-revpimodio.api +++ b/eric-revpimodio.api @@ -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() diff --git a/revpimodio2.e4p b/revpimodio2.e4p index 6ac1a3e..a2f5bd7 100644 --- a/revpimodio2.e4p +++ b/revpimodio2.e4p @@ -1,14 +1,14 @@ - + en_US 7ea159534ad3516e9069331120048abf9b00151e Python3 Console - + 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. 2.0.0 Sven Sager akira@narux.de @@ -26,6 +26,7 @@ test/test_dio_mainloop.py test/test_dio_cycleloop.py revpimodio2/net.py + test/test_net_leistung.py @@ -35,6 +36,7 @@ doc .hgignore eric-revpimodio.api + MANIFEST.in Mercurial diff --git a/revpimodio2/__init__.py b/revpimodio2/__init__.py index 3c93f26..476d7b4 100644 --- a/revpimodio2/__init__.py +++ b/revpimodio2/__init__.py @@ -35,12 +35,3 @@ FALLING = 32 BOTH = 33 warnings.simplefilter(action="always") - - -class IOType(object): - - """IO Typen.""" - - INP = 300 - OUT = 301 - MEM = 302 diff --git a/revpimodio2/device.py b/revpimodio2/device.py index 9f6307b..00c28a6 100644 --- a/revpimodio2/device.py +++ b/revpimodio2/device.py @@ -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): diff --git a/revpimodio2/io.py b/revpimodio2/io.py index 06b57ba..5aaaed9 100644 --- a/revpimodio2/io.py +++ b/revpimodio2/io.py @@ -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) diff --git a/revpimodio2/modio.py b/revpimodio2/modio.py index 4b8842c..185127b 100644 --- a/revpimodio2/modio.py +++ b/revpimodio2/modio.py @@ -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 diff --git a/setup.py b/setup.py index 2bc61cc..20a8677 100644 --- a/setup.py +++ b/setup.py @@ -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"