mirror of
https://github.com/naruxde/revpimodio2.git
synced 2025-11-08 13:53:53 +01:00
Bessere Werte bei _gotioerror
Debugflag um exakte Fehlermeldungen zu bekommen
This commit is contained in:
@@ -535,10 +535,15 @@ Aktuelle Fehleranzahl
|
||||
</dl><a NAME="ProcimgWriter._gotioerror" ID="ProcimgWriter._gotioerror"></a>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
ProcimgWriter._gotioerror</h3>
|
||||
<b>_gotioerror</b>(<i></i>)
|
||||
<b>_gotioerror</b>(<i>e=None</i>)
|
||||
<p>
|
||||
IOError Verwaltung fuer autorefresh.
|
||||
</p><a NAME="ProcimgWriter.get_maxioerrors" ID="ProcimgWriter.get_maxioerrors"></a>
|
||||
</p><dl>
|
||||
<dt><i>e</i></dt>
|
||||
<dd>
|
||||
Exception to log if debug is enabled
|
||||
</dd>
|
||||
</dl><a NAME="ProcimgWriter.get_maxioerrors" ID="ProcimgWriter.get_maxioerrors"></a>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
ProcimgWriter.get_maxioerrors</h3>
|
||||
<b>get_maxioerrors</b>(<i></i>)
|
||||
|
||||
@@ -158,7 +158,7 @@ Static Methods</h3>
|
||||
<a NAME="RevPiModIO.__init__" ID="RevPiModIO.__init__"></a>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
RevPiModIO (Constructor)</h3>
|
||||
<b>RevPiModIO</b>(<i>autorefresh=False, monitoring=False, syncoutputs=True, procimg=None, configrsc=None, simulator=False</i>)
|
||||
<b>RevPiModIO</b>(<i>autorefresh=False, monitoring=False, syncoutputs=True, procimg=None, configrsc=None, simulator=False, debug=False</i>)
|
||||
<p>
|
||||
Instantiiert die Grundfunktionen.
|
||||
</p><dl>
|
||||
@@ -305,10 +305,18 @@ True, wenn als Simulator gestartet
|
||||
</dl><a NAME="RevPiModIO._gotioerror" ID="RevPiModIO._gotioerror"></a>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
RevPiModIO._gotioerror</h3>
|
||||
<b>_gotioerror</b>(<i>action</i>)
|
||||
<b>_gotioerror</b>(<i>action, e=None</i>)
|
||||
<p>
|
||||
IOError Verwaltung fuer Prozessabbildzugriff.
|
||||
</p><a NAME="RevPiModIO._set_cycletime" ID="RevPiModIO._set_cycletime"></a>
|
||||
</p><dl>
|
||||
<dt><i>action</i></dt>
|
||||
<dd>
|
||||
Zusatzinformationen zum loggen
|
||||
</dd><dt><i>e</i></dt>
|
||||
<dd>
|
||||
Exception to log if debug is enabled
|
||||
</dd>
|
||||
</dl><a NAME="RevPiModIO._set_cycletime" ID="RevPiModIO._set_cycletime"></a>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
RevPiModIO._set_cycletime</h3>
|
||||
<b>_set_cycletime</b>(<i>milliseconds</i>)
|
||||
|
||||
@@ -81,7 +81,7 @@ revpimodio2.helper.EventCallback.stop?4()
|
||||
revpimodio2.helper.EventCallback?1(func, name, value)
|
||||
revpimodio2.helper.ProcimgWriter._collect_events?5(value)
|
||||
revpimodio2.helper.ProcimgWriter._get_ioerrors?5()
|
||||
revpimodio2.helper.ProcimgWriter._gotioerror?5()
|
||||
revpimodio2.helper.ProcimgWriter._gotioerror?5(e=None)
|
||||
revpimodio2.helper.ProcimgWriter.get_maxioerrors?4()
|
||||
revpimodio2.helper.ProcimgWriter.get_refresh?4()
|
||||
revpimodio2.helper.ProcimgWriter.ioerrors?7
|
||||
@@ -149,7 +149,7 @@ revpimodio2.modio.RevPiModIO._get_maxioerrors?5()
|
||||
revpimodio2.modio.RevPiModIO._get_monitoring?5()
|
||||
revpimodio2.modio.RevPiModIO._get_procimg?5()
|
||||
revpimodio2.modio.RevPiModIO._get_simulator?5()
|
||||
revpimodio2.modio.RevPiModIO._gotioerror?5(action)
|
||||
revpimodio2.modio.RevPiModIO._gotioerror?5(action, e=None)
|
||||
revpimodio2.modio.RevPiModIO._set_cycletime?5(milliseconds)
|
||||
revpimodio2.modio.RevPiModIO._set_maxioerrors?5(value)
|
||||
revpimodio2.modio.RevPiModIO.autorefresh_all?4()
|
||||
@@ -172,7 +172,7 @@ revpimodio2.modio.RevPiModIO.setdefaultvalues?4(device=None)
|
||||
revpimodio2.modio.RevPiModIO.simulator?7
|
||||
revpimodio2.modio.RevPiModIO.syncoutputs?4(device=None)
|
||||
revpimodio2.modio.RevPiModIO.writeprocimg?4(device=None)
|
||||
revpimodio2.modio.RevPiModIO?1(autorefresh=False, monitoring=False, syncoutputs=True, procimg=None, configrsc=None, simulator=False)
|
||||
revpimodio2.modio.RevPiModIO?1(autorefresh=False, monitoring=False, syncoutputs=True, procimg=None, configrsc=None, simulator=False, debug=False)
|
||||
revpimodio2.modio.RevPiModIODriver?1(virtdev, autorefresh=False, monitoring=False, syncoutputs=True, procimg=None, configrsc=None)
|
||||
revpimodio2.modio.RevPiModIOSelected?1(deviceselection, autorefresh=False, monitoring=False, syncoutputs=True, procimg=None, configrsc=None, simulator=False)
|
||||
revpimodio2.netio.NetFH._connect?5()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE Project SYSTEM "Project-5.1.dtd">
|
||||
<!-- eric project file for project revpimodio2 -->
|
||||
<!-- Saved: 2019-01-25, 13:04:10 -->
|
||||
<!-- Saved: 2019-03-07, 12:49:06 -->
|
||||
<!-- Copyright (C) 2019 Sven Sager, akira@narux.de -->
|
||||
<Project version="5.1">
|
||||
<Language>en_US</Language>
|
||||
|
||||
@@ -961,8 +961,8 @@ class Virtual(Gateway):
|
||||
self._modio._myfh.write(self._ba_devdata[self._slc_inp])
|
||||
if self._modio._buffedwrite:
|
||||
self._modio._myfh.flush()
|
||||
except IOError:
|
||||
self._modio._gotioerror("write")
|
||||
except IOError as e:
|
||||
self._modio._gotioerror("write_inp_def", e)
|
||||
workokay = False
|
||||
finally:
|
||||
self._modio._myfh_lck.release()
|
||||
|
||||
@@ -430,8 +430,10 @@ class ProcimgWriter(Thread):
|
||||
@return Aktuelle Fehleranzahl"""
|
||||
return self._ioerror
|
||||
|
||||
def _gotioerror(self):
|
||||
"""IOError Verwaltung fuer autorefresh."""
|
||||
def _gotioerror(self, e=None):
|
||||
"""IOError Verwaltung fuer autorefresh.
|
||||
@param e Exception to log if debug is enabled
|
||||
"""
|
||||
self._ioerror += 1
|
||||
if self._maxioerrors != 0 and self._ioerror >= self._maxioerrors:
|
||||
raise RuntimeError(
|
||||
@@ -443,6 +445,8 @@ class ProcimgWriter(Thread):
|
||||
"count {0} io errors on process image".format(self._ioerror),
|
||||
RuntimeWarning
|
||||
)
|
||||
if self._modio._debug and e is not None:
|
||||
warnings.warn(str(e))
|
||||
|
||||
def get_maxioerrors(self):
|
||||
"""Gibt die Anzahl der maximal erlaubten Fehler zurueck.
|
||||
@@ -504,8 +508,8 @@ class ProcimgWriter(Thread):
|
||||
if self._modio._buffedwrite:
|
||||
fh.flush()
|
||||
|
||||
except IOError:
|
||||
self._gotioerror()
|
||||
except IOError as e:
|
||||
self._gotioerror(e)
|
||||
self.lck_refresh.release()
|
||||
continue
|
||||
|
||||
|
||||
@@ -836,8 +836,8 @@ class IntIOCounter(IntIO):
|
||||
self._parentdevice._modio._myfh.ioctl(
|
||||
19220, self.__ioctl_arg
|
||||
)
|
||||
except Exception:
|
||||
self._parentdevice._modio._gotioerror("net_ioctl")
|
||||
except Exception as e:
|
||||
self._parentdevice._modio._gotioerror("net_ioctl", e)
|
||||
|
||||
elif self._parentdevice._modio._procimg != "/dev/piControl0":
|
||||
# NOTE: Soll hier eine 0 in den Input geschrieben werden?
|
||||
@@ -855,8 +855,8 @@ class IntIOCounter(IntIO):
|
||||
self._parentdevice._modio._myfh,
|
||||
19220, self.__ioctl_arg
|
||||
)
|
||||
except Exception:
|
||||
self._parentdevice._modio._gotioerror("ioctl")
|
||||
except Exception as e:
|
||||
self._parentdevice._modio._gotioerror("ioctl", e)
|
||||
|
||||
|
||||
class IntIOReplaceable(IntIO):
|
||||
|
||||
@@ -32,11 +32,11 @@ class RevPiModIO(object):
|
||||
"_looprunning", "_lst_devselect", "_lst_refresh", "_maxioerrors", \
|
||||
"_myfh", "_myfh_lck", "_monitoring", "_procimg", "_simulator", \
|
||||
"_syncoutputs", "_th_mainloop", "_waitexit", \
|
||||
"core", "app", "device", "exitsignal", "io", "summary"
|
||||
"core", "app", "device", "exitsignal", "io", "summary", "_debug"
|
||||
|
||||
def __init__(
|
||||
self, autorefresh=False, monitoring=False, syncoutputs=True,
|
||||
procimg=None, configrsc=None, simulator=False):
|
||||
procimg=None, configrsc=None, simulator=False, debug=False):
|
||||
"""Instantiiert die Grundfunktionen.
|
||||
|
||||
@param autorefresh Wenn True, alle Devices zu autorefresh hinzufuegen
|
||||
@@ -59,6 +59,7 @@ class RevPiModIO(object):
|
||||
# Private Variablen
|
||||
self.__cleanupfunc = None
|
||||
self._buffedwrite = False
|
||||
self._debug = debug
|
||||
self._exit = Event()
|
||||
self._imgwriter = None
|
||||
self._ioerror = 0
|
||||
@@ -316,8 +317,13 @@ class RevPiModIO(object):
|
||||
@return True, wenn als Simulator gestartet"""
|
||||
return self._simulator
|
||||
|
||||
def _gotioerror(self, action):
|
||||
"""IOError Verwaltung fuer Prozessabbildzugriff."""
|
||||
def _gotioerror(self, action, e=None):
|
||||
"""IOError Verwaltung fuer Prozessabbildzugriff.
|
||||
|
||||
@param action Zusatzinformationen zum loggen
|
||||
@param e Exception to log if debug is enabled
|
||||
|
||||
"""
|
||||
self._ioerror += 1
|
||||
if self._maxioerrors != 0 and self._ioerror >= self._maxioerrors:
|
||||
raise RuntimeError(
|
||||
@@ -329,6 +335,8 @@ class RevPiModIO(object):
|
||||
"".format(action, self._ioerror),
|
||||
RuntimeWarning
|
||||
)
|
||||
if self._debug and e is not None:
|
||||
warnings.warn(str(e))
|
||||
|
||||
def _set_cycletime(self, milliseconds):
|
||||
"""Setzt Aktualisierungsrate der Prozessabbild-Synchronisierung.
|
||||
@@ -692,8 +700,8 @@ class RevPiModIO(object):
|
||||
try:
|
||||
self._myfh.seek(0)
|
||||
bytesbuff = self._myfh.read(self._length)
|
||||
except IOError:
|
||||
self._gotioerror("read")
|
||||
except IOError as e:
|
||||
self._gotioerror("readprocimg", e)
|
||||
return False
|
||||
finally:
|
||||
self._myfh_lck.release()
|
||||
@@ -769,8 +777,8 @@ class RevPiModIO(object):
|
||||
try:
|
||||
self._myfh.seek(0)
|
||||
bytesbuff = self._myfh.read(self._length)
|
||||
except IOError:
|
||||
self._gotioerror("read")
|
||||
except IOError as e:
|
||||
self._gotioerror("syncoutputs", e)
|
||||
return False
|
||||
finally:
|
||||
self._myfh_lck.release()
|
||||
@@ -811,6 +819,7 @@ class RevPiModIO(object):
|
||||
)
|
||||
mylist = [dev]
|
||||
|
||||
e = None
|
||||
workokay = True
|
||||
for dev in mylist:
|
||||
if not dev._selfupdate:
|
||||
@@ -821,7 +830,8 @@ class RevPiModIO(object):
|
||||
try:
|
||||
self._myfh.seek(dev._slc_outoff.start)
|
||||
self._myfh.write(dev._ba_devdata[dev._slc_out])
|
||||
except IOError:
|
||||
except IOError as e:
|
||||
e = e
|
||||
workokay = False
|
||||
finally:
|
||||
self._myfh_lck.release()
|
||||
@@ -831,11 +841,12 @@ class RevPiModIO(object):
|
||||
if self._buffedwrite:
|
||||
try:
|
||||
self._myfh.flush()
|
||||
except IOError:
|
||||
except IOError as e:
|
||||
e = e
|
||||
workokay = False
|
||||
|
||||
if not workokay:
|
||||
self._gotioerror("write")
|
||||
self._gotioerror("writeprocimg", e)
|
||||
|
||||
return workokay
|
||||
|
||||
|
||||
Reference in New Issue
Block a user