Sync the first cycle with imgwriter after calling .cycleloop

This commit is contained in:
2021-10-24 14:28:33 +02:00
parent bc8a13da1b
commit 36ff69aaa6
2 changed files with 3 additions and 5 deletions

View File

@@ -516,9 +516,6 @@ class ProcimgWriter(Thread):
mrk_warn = True
bytesbuff = bytearray(self._modio._length)
# First sync of cycle time to start the main loop and match exact time
sleep(self._refresh - (default_timer() % self._refresh))
while not self._work.is_set():
ot = default_timer()

View File

@@ -767,10 +767,10 @@ class RevPiModIO(object):
# Zykluszeit übernehmen
old_cycletime = self._imgwriter.refresh
if not cycletime == self._imgwriter.refresh:
# Set new cycle time and wait one imgwriter cycle to sync fist cycle
self._imgwriter.refresh = cycletime
# Zeitänderung in _imgwriter neuladen
self._imgwriter.newdata.clear()
self._imgwriter.newdata.wait(self._imgwriter._refresh)
# Benutzerevent
self.exitsignal.clear()
@@ -781,6 +781,7 @@ class RevPiModIO(object):
cycleinfo = helpermodule.Cycletools(self._imgwriter.refresh, self)
e = None # Exception
ec = None # Return value of cycle_function
self._imgwriter.newdata.clear()
try:
while ec is None and not cycleinfo.last:
# Auf neue Daten warten und nur ausführen wenn set()