XML cmd plcslavestart angepasst

XML cmd plcslaverunning eingefügt
Thradkontrolle für plc slave angepasst, wenn über xml gestoppt
This commit is contained in:
2017-12-03 16:37:35 +01:00
parent afcbe9d754
commit bf36c5b560
3 changed files with 32 additions and 4 deletions

View File

@@ -132,6 +132,9 @@ Methods</h3>
<td><a style="color:#0000FF" href="#RevPiPyLoad.xml_plcrunning">xml_plcrunning</a></td>
<td>Prueft ob das PLC Programm noch lauft.</td>
</tr><tr>
<td><a style="color:#0000FF" href="#RevPiPyLoad.xml_plcslaverunning">xml_plcslaverunning</a></td>
<td>Prueft ob PLC-Slave noch lauft.</td>
</tr><tr>
<td><a style="color:#0000FF" href="#RevPiPyLoad.xml_plcslavestart">xml_plcslavestart</a></td>
<td>Startet den PLC Slave Server.</td>
</tr><tr>
@@ -342,6 +345,17 @@ Prueft ob das PLC Programm noch lauft.
<dd>
True, wenn das PLC Programm noch lauft
</dd>
</dl><a NAME="RevPiPyLoad.xml_plcslaverunning" ID="RevPiPyLoad.xml_plcslaverunning"></a>
<h3 style="background-color:#FFFFFF;color:#FF0000">
RevPiPyLoad.xml_plcslaverunning</h3>
<b>xml_plcslaverunning</b>(<i></i>)
<p>
Prueft ob PLC-Slave noch lauft.
</p><dl>
<dt>Returns:</dt>
<dd>
True, wenn PLC-Slave noch lauft
</dd>
</dl><a NAME="RevPiPyLoad.xml_plcslavestart" ID="RevPiPyLoad.xml_plcslavestart"></a>
<h3 style="background-color:#FFFFFF;color:#FF0000">
RevPiPyLoad.xml_plcslavestart</h3>

View File

@@ -61,6 +61,7 @@ revpipyload.RevPiPyLoad.xml_getprocimg?4()
revpipyload.RevPiPyLoad.xml_plcdownload?4(mode="tar", pictory=False)
revpipyload.RevPiPyLoad.xml_plcexitcode?4()
revpipyload.RevPiPyLoad.xml_plcrunning?4()
revpipyload.RevPiPyLoad.xml_plcslaverunning?4()
revpipyload.RevPiPyLoad.xml_plcslavestart?4()
revpipyload.RevPiPyLoad.xml_plcslavestop?4()
revpipyload.RevPiPyLoad.xml_plcstart?4()

View File

@@ -101,6 +101,7 @@ class RevPiPyLoad():
self.globalconfig = ConfigParser()
self.logr = logsystem.LogReader()
self.plc = None
self.plc_pause = False
self.tfile = {}
self.tpe = None
self.xsrv = None
@@ -217,6 +218,9 @@ class RevPiPyLoad():
self.xsrv.register_function(self.xml_plcstart, "plcstart")
self.xsrv.register_function(self.xml_plcstop, "plcstop")
self.xsrv.register_function(self.xml_reload, "reload")
self.xsrv.register_function(
self.xml_plcslaverunning, "plcslaverunning"
)
# Erweiterte Funktionen anmelden
try:
@@ -258,10 +262,9 @@ class RevPiPyLoad():
lambda: os.system(proginit.picontrolreset),
"resetpicontrol")
self.xsrv.register_function(
self.xml_plcslavestop, "plcslavestop")
self.xml_plcslavestart, "plcslavestart")
self.xsrv.register_function(
lambda: os.system(proginit.picontrolreset),
"resetpicontrol")
self.xml_plcslavestop, "plcslavestop")
self.xsrv.register_function(
self.xml_setconfig, "set_config")
self.xsrv.register_function(
@@ -427,7 +430,8 @@ class RevPiPyLoad():
and not self.evt_loadconfig.is_set():
# PLC Server Thread prüfen
if self.plcslave and not self.th_plcslave.is_alive():
if self.plcslave \
and not (self.plc_pause or self.th_plcslave.is_alive()):
proginit.logger.warning(
"restart plc slave after thread was not running"
)
@@ -776,6 +780,13 @@ class RevPiPyLoad():
else:
return False
def xml_plcslaverunning(self):
"""Prueft ob PLC-Slave noch lauft.
@return True, wenn PLC-Slave noch lauft"""
proginit.logger.debug("xmlrpc call plcslaverunning")
return False if self.th_plcslave is None \
else self.th_plcslave.is_alive()
def xml_plcslavestart(self):
"""Startet den PLC Slave Server.
@@ -785,6 +796,7 @@ class RevPiPyLoad():
-2: Laeuft bereits
"""
self.plc_pause = False
if self.th_plcslave is not None and self.th_plcslave.is_alive():
return -2
else:
@@ -798,6 +810,7 @@ class RevPiPyLoad():
def xml_plcslavestop(self):
"""Stoppt den PLC Slave Server.
@return True, wenn stop erfolgreich"""
self.plc_pause = True
if self.th_plcslave is not None:
self.th_plcslave.stop()
return True