reset loaded messages counts on new PLC program trasnfer
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Wed, 05 Apr 2017 14:17:02 +0300
changeset 1672 9298ba0cd70a
parent 1671 0dc834721d8e
child 1673 fab1b8da6eba
reset loaded messages counts on new PLC program trasnfer

This fixes the problem that first message from newer PLC program maybe
lost, if it's issued before first PLC log fetching.

Closes #23
ProjectController.py
controls/LogViewer.py
--- a/ProjectController.py	Tue Apr 04 11:34:31 2017 +0300
+++ b/ProjectController.py	Wed Apr 05 14:17:02 2017 +0300
@@ -1777,6 +1777,7 @@
                         self.AppFrame.CloseObsoleteDebugTabs()
                         self.AppFrame.RefreshPouInstanceVariablesPanel()
                     self.logger.write(_("Transfer completed successfully.\n"))
+                    self.AppFrame.LogViewer.ResetLogCounters();
                 else:
                     self.logger.write_error(_("Transfer failed\n"))
                 self.HidePLCProgress()                    
--- a/controls/LogViewer.py	Tue Apr 04 11:34:31 2017 +0300
+++ b/controls/LogViewer.py	Wed Apr 05 14:17:02 2017 +0300
@@ -379,7 +379,7 @@
         self.ScrollTimer.Stop()
 
     def ResetLogMessages(self):
-        self.previous_log_count = [None]*LogLevelsCount
+        self.ResetLogCounters()
         self.OldestMessages = []
         self.LogMessages = []
         self.LogMessagesTimestamp = numpy.array([])
@@ -401,6 +401,9 @@
                 return LogMessage(tv_sec, tv_nsec, level, self.LevelIcons[level], msg)
         return None
 
+    def ResetLogCounters(self):
+        self.previous_log_count = [None]*LogLevelsCount
+    
     def SetLogCounters(self, log_count):
         new_messages = []
         for level, count, prev in zip(xrange(LogLevelsCount), log_count, self.previous_log_count):