# HG changeset patch # User Laurent Bessard # Date 1367848877 -7200 # Node ID b5f78cff4459eb6a1180b66b275e396644e899db # Parent e91f2c8d6f51206950e1777c126e8002ec412f50 Added support for resetting log messages diff -r e91f2c8d6f51 -r b5f78cff4459 controls/LogViewer.py --- a/controls/LogViewer.py Mon May 06 11:15:05 2013 +0200 +++ b/controls/LogViewer.py Mon May 06 16:01:17 2013 +0200 @@ -308,7 +308,13 @@ self.OnSearchMessageSearchButtonClick, self.SearchMessage) self.Bind(wx.EVT_SEARCHCTRL_CANCEL_BTN, self.OnSearchMessageCancelButtonClick, self.SearchMessage) - filter_sizer.AddWindow(self.SearchMessage, 3, flag=wx.GROW) + filter_sizer.AddWindow(self.SearchMessage, 3, border=5, flag=wx.RIGHT|wx.GROW) + + self.CleanButton = wx.lib.buttons.GenBitmapButton(self, bitmap=GetBitmap("Clean"), + size=wx.Size(28, 28), style=wx.NO_BORDER) + self.CleanButton.SetToolTipString(_("Clean log messages")) + self.Bind(wx.EVT_BUTTON, self.OnCleanButton, self.CleanButton) + filter_sizer.AddWindow(self.CleanButton) message_panel_sizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0) message_panel_sizer.AddGrowableCol(0) @@ -379,6 +385,7 @@ def SetLogSource(self, log_source): self.LogSource = log_source + self.CleanButton.Enable(self.LogSource is not None) if log_source is not None: self.ResetLogMessages() self.RefreshView() @@ -396,18 +403,21 @@ for level, count, prev in zip(xrange(LogLevelsCount), log_count, self.previous_log_count): if count is not None and prev != count: if prev is None: - dump_end = count - 1 + dump_end = -1 else: dump_end = prev - 1 for msgidx in xrange(count-1, dump_end,-1): new_message = self.GetLogMessageFromSource(msgidx, level) - if new_message is not None: - if prev is None: - self.OldestMessages.append((msgidx, new_message)) - if len(new_messages) == 0 or new_message > new_messages[0]: - new_messages = [new_message] + if new_message is None: + break + if prev is None: + self.OldestMessages.append((msgidx, new_message)) + if len(new_messages) == 0: + new_messages = [new_message] else: new_messages.insert(0, new_message) + else: + new_messages.insert(0, new_message) if prev is None and len(self.OldestMessages) <= level: self.OldestMessages.append((-1, None)) self.previous_log_count[level] = count @@ -608,6 +618,13 @@ self.ResetMessagePanel() event.Skip() + def OnCleanButton(self, event): + if self.LogSource is not None: + self.LogSource.ResetLogCount() + self.ResetLogMessages() + self.RefreshView() + event.Skip() + def GenerateOnDurationButton(self, duration): def OnDurationButton(): self.ScrollMessagePanelByTimestamp(duration) diff -r e91f2c8d6f51 -r b5f78cff4459 runtime/PLCObject.py --- a/runtime/PLCObject.py Mon May 06 11:15:05 2013 +0200 +++ b/runtime/PLCObject.py Mon May 06 16:01:17 2013 +0200 @@ -90,12 +90,15 @@ msg, = args return self._LogMessage(level, msg, len(msg)) + def ResetLogCount(self): + if self._ResetLogCount is not None: + self._ResetLogCount() def GetLogCount(self, level): if self._GetLogCount is not None : return int(self._GetLogCount(level)) elif self._loading_error is not None and level==0: - return 1; + return 1 def GetLogMessage(self, level, msgid): tick = ctypes.c_uint32() @@ -182,6 +185,9 @@ self._resumeDebug = self.PLClibraryHandle.resumeDebug self._resumeDebug.restype = None + self._ResetLogCount = self.PLClibraryHandle.ResetLogCount + self._ResetLogCount.restype = None + self._GetLogCount = self.PLClibraryHandle.GetLogCount self._GetLogCount.restype = ctypes.c_uint32 self._GetLogCount.argtypes = [ctypes.c_uint8] @@ -189,7 +195,7 @@ self._LogMessage = self.PLClibraryHandle.LogMessage self._LogMessage.restype = ctypes.c_int self._LogMessage.argtypes = [ctypes.c_uint8, ctypes.c_char_p, ctypes.c_uint32] - + self._log_read_buffer = ctypes.create_string_buffer(1<<14) #16K self._GetLogMessage = self.PLClibraryHandle.GetLogMessage self._GetLogMessage.restype = ctypes.c_uint32 diff -r e91f2c8d6f51 -r b5f78cff4459 targets/plc_main_tail.c --- a/targets/plc_main_tail.c Mon May 06 11:15:05 2013 +0200 +++ b/targets/plc_main_tail.c Mon May 06 16:01:17 2013 +0200 @@ -54,6 +54,13 @@ | counter | Index | */ static uint64_t LogCursor[LOG_LEVELS] LOG_BUFFER_ATTRS = {0x0,0x0,0x0,0x0}; +void ResetLogCount(void) { + uint8_t level; + for(level=0;level