If call to GetPLCstatus can't be executed in PLC, then obtained status is disconnected. Status on "None" is not relevant anymore, and is replaced by Disconnected. fix_PLC_runtime_shutdown
authorEdouard Tisserant
Thu, 18 Apr 2019 14:32:43 +0200
branchfix_PLC_runtime_shutdown
changeset 2602 19dc6b830e7d
parent 2601 9c5b20dc2b2e
child 2603 1ffdc62784cf
If call to GetPLCstatus can't be executed in PLC, then obtained status is disconnected. Status on "None" is not relevant anymore, and is replaced by Disconnected.
ProjectController.py
runtime/PLCObject.py
--- a/ProjectController.py	Thu Apr 18 14:29:55 2019 +0200
+++ b/ProjectController.py	Thu Apr 18 14:32:43 2019 +0200
@@ -1446,13 +1446,13 @@
 
     def UpdateMethodsFromPLCStatus(self):
         updated = False
-        status = None
+        status = PlcStatus.Disconnected
         if self._connector is not None:
             PLCstatus = self._connector.GetPLCstatus()
             if PLCstatus is not None:
                 status, log_count = PLCstatus
                 self.UpdatePLCLog(log_count)
-        if status is None:
+        if status == PlcStatus.Disconnected:
             self._SetConnector(None, False)
             status = PlcStatus.Disconnected
         if self.previous_plcstate != status:
--- a/runtime/PLCObject.py	Thu Apr 18 14:29:55 2019 +0200
+++ b/runtime/PLCObject.py	Thu Apr 18 14:32:43 2019 +0200
@@ -477,8 +477,14 @@
             return True
         return False
 
-    @RunInMain
     def GetPLCstatus(self):
+        try:
+            return self._GetPLCstatus()
+        except EOFError:
+            return (PlcStatus.Disconnected, None)
+
+    @RunInMain
+    def _GetPLCstatus(self):
         return self.PLCStatus, map(self.GetLogCount, xrange(LogLevelsCount))
 
     @RunInMain