Mit default zusammenführen

This commit is contained in:
2018-08-14 11:40:01 +02:00
5 changed files with 44 additions and 61 deletions

View File

@@ -26,9 +26,6 @@ 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">
@@ -68,7 +65,7 @@ None
<h3 style="background-color:#FFFFFF;color:#FF0000">
Class Attributes</h3>
<table>
<tr><td>__slots__</td></tr>
<tr><td>None</td></tr>
</table>
<h3 style="background-color:#FFFFFF;color:#FF0000">
Class Methods</h3>
@@ -354,7 +351,7 @@ Thread
<h3 style="background-color:#FFFFFF;color:#FF0000">
Class Attributes</h3>
<table>
<tr><td>__slots__</td></tr>
<tr><td>None</td></tr>
</table>
<h3 style="background-color:#FFFFFF;color:#FF0000">
Class Methods</h3>
@@ -429,7 +426,7 @@ Thread
<h3 style="background-color:#FFFFFF;color:#FF0000">
Class Attributes</h3>
<table>
<tr><td>__slots__</td></tr><tr><td>ioerrors</td></tr><tr><td>maxioerrors</td></tr><tr><td>refresh</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>
@@ -516,6 +513,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>
@@ -590,35 +592,6 @@ 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>

View File

@@ -299,9 +299,8 @@ class Device(object):
self._modio.readprocimg(self)
# Datenkopie anlegen
self._filelock.acquire()
with self._filelock:
self._ba_datacp = self._ba_devdata[:]
self._filelock.release()
self._selfupdate = True

View File

@@ -400,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
@@ -417,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"""
@@ -472,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()
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)
dev._filelock.release()
else:
# Inputs in Puffer, Outputs in Prozessabbild
for dev in self._modio._lst_refresh:
@@ -509,7 +517,7 @@ class ProcimgWriter(Thread):
finally:
# Verzögerte Events prüfen
if self.__eventwork:
for tup_fire in list(self.__dict_delay.keys()):
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]:

View File

@@ -385,6 +385,7 @@ class IOBase(object):
)
if self not in self._parentdevice._dict_events:
with self._parentdevice._filelock:
self._parentdevice._dict_events[self] = \
[IOEvent(func, edge, as_thread, delay, overwrite)]
else:
@@ -418,6 +419,7 @@ class IOBase(object):
)
# Eventfunktion einfügen
with self._parentdevice._filelock:
self._parentdevice._dict_events[self].append(
IOEvent(func, edge, as_thread, delay, overwrite)
)
@@ -627,6 +629,7 @@ class IOBase(object):
"""
if self in self._parentdevice._dict_events:
if func is None:
with self._parentdevice._filelock:
del self._parentdevice._dict_events[self]
else:
newlist = []
@@ -637,6 +640,7 @@ class IOBase(object):
newlist.append(regfunc)
# Wenn Funktionen übrig bleiben, diese übernehmen
with self._parentdevice._filelock:
if len(newlist) > 0:
self._parentdevice._dict_events[self] = newlist
else:

View File

@@ -319,7 +319,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:
@@ -587,9 +587,8 @@ class RevPiModIO(object):
# Beim Eintritt in mainloop Bytecopy erstellen
for dev in self._lst_refresh:
dev._filelock.acquire()
with dev._filelock:
dev._ba_datacp = dev._ba_devdata[:]
dev._filelock.release()
# ImgWriter mit Eventüberwachung aktivieren
self._imgwriter._collect_events(True)