start/stop from taskbar icon only if PLC is stopped/started
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Wed, 07 Dec 2016 18:15:04 +0300
changeset 1592 c40355f450a5
parent 1591 38e5f8847a45
child 1593 6a27490fed96
start/stop from taskbar icon only if PLC is stopped/started
Beremiz_service.py
--- a/Beremiz_service.py	Wed Dec 07 17:54:41 2016 +0300
+++ b/Beremiz_service.py	Wed Dec 07 18:15:04 2016 +0300
@@ -272,11 +272,18 @@
 
             def OnTaskBarStartPLC(self, evt):
                 if self.pyroserver.plcobj is not None:
-                    self.pyroserver.plcobj.StartPLC()
+                    plcstatus = self.pyroserver.plcobj.GetPLCstatus()[0]
+                    if  plcstatus is "Stopped":
+                        self.pyroserver.plcobj.StartPLC()
+                    else:
+                        print _("PLC is empty or already started.")
 
             def OnTaskBarStopPLC(self, evt):
                 if self.pyroserver.plcobj is not None:
-                    Thread(target=self.pyroserver.plcobj.StopPLC).start()
+                    if self.pyroserver.plcobj.GetPLCstatus()[0] == "Started":
+                        Thread(target=self.pyroserver.plcobj.StopPLC).start()
+                    else:
+                        print _("PLC is not started.")
 
             def OnTaskBarChangeInterface(self, evt):
                 dlg = ParamsEntryDialog(None, _("Enter the IP of the interface to bind"), defaultValue=self.pyroserver.ip_addr)