--- a/ProjectController.py Tue Jan 29 16:22:04 2013 +1100
+++ b/ProjectController.py Tue Jan 29 21:34:43 2013 +1100
@@ -942,7 +942,6 @@
for infos, (start_row, start_col) in chunk_infos:
start = (from_location[0] - start_row, from_location[1] - start_col)
end = (to_location[0] - start_row, to_location[1] - start_col)
- #print from_location, to_location, start_row, start_col, start, end
if self.AppFrame is not None:
self.AppFrame.ShowError(infos, start, end)
@@ -1079,14 +1078,19 @@
def UpdatePLCLog(self, log_count):
if log_count and self.previous_log_count != log_count:
- #self.logger.write("Now log count is "+repr(log_count)+"\n")
+ # XXX replace dump to console with dedicated log panel. - for msgidx in xrange(log_count-1, self.previous_log_count - 1 if self.previous_log_count is not None else 0,-1):
+ dump_end = max( # request message sent after the last one we already got + self.previous_log_count - 1 if self.previous_log_count is not None else -1, + log_count - 100) # 100 is purely arbitrary number + # dedicated panel should only ask for a small range, + # depending on how user navigate in the panel + # and only ask for last one in follow mode + for msgidx in xrange(log_count-1, dump_end,-1): msg = self._connector.GetLogMessage(msgidx)
to_console.insert(0, '#' + repr(msgidx) + ": " + msg)
- #self.logger.write(repr(msgidx) + " : GetLogMessage returned None\n")
to_console.insert(0, 'No log before #'+repr(msgidx))
self.logger.write("\n".join(to_console))
@@ -1143,7 +1147,6 @@
if len(WeakCallableDict) == 0:
# Callable Dict is empty.
# This variable is not needed anymore!
- #print "Unused : " + IECPath
IECPathsToPop.append(IECPath)
elif IECPath != "__tick__":
@@ -1166,9 +1169,6 @@
self._connector.SetTraceVariablesList([])
self.IECdebug_lock.release()
- #for IEC_path, IECdebug_data in self.IECdebug_datas.iteritems():
- # print IEC_path, IECdebug_data[0].keys()
def ReArmDebugRegisterTimer(self):
if self.DebugTimer is not None:
@@ -1213,7 +1213,6 @@
def UnsubscribeDebugIECVariable(self, IECPath, callableobj):
- #print "Unsubscribe", IECPath, callableobj
self.IECdebug_lock.acquire()
IECdebug_data = self.IECdebug_datas.get(IECPath, None)
if IECdebug_data is not None:
@@ -1265,7 +1264,6 @@
WeakCallableDict, data_log, status, fvalue = data_tuple
#data_log.append((debug_tick, value))
for weakcallable,(args,kwargs) in WeakCallableDict.iteritems():
- #print weakcallable, value, args, kwargs
function = getattr(weakcallable, function_name, None)
if status == "Forced" and cargs[1] == fvalue:
@@ -1295,7 +1293,6 @@
- #print debug_tick, debug_vars
if plc_status == "Started":
self.IECdebug_lock.acquire()
if len(debug_vars) == len(self.TracedIECPath):
@@ -1333,6 +1330,8 @@
def _connect_debug(self):
+ self.previous_plcstate = None + self.previous_log_count = None self.AppFrame.ResetGraphicViewers()
self.RegisterDebugVarToConnector()
@@ -1512,6 +1511,8 @@
self.logger.write_error(_("No PLC to transfer (did build succeed ?)\n"))
+ self.previous_log_count = None wx.CallAfter(self.UpdateMethodsFromPLCStatus)
--- a/runtime/PLCObject.py Tue Jan 29 16:22:04 2013 +1100
+++ b/runtime/PLCObject.py Tue Jan 29 21:34:43 2013 +1100
@@ -65,6 +65,7 @@
self.statuschange = statuschange
+ self._loading_error = None # Get the last transfered PLC if connector must be restart
@@ -86,15 +87,20 @@
if self._GetLogCount is not None :
return int(self._GetLogCount())
+ elif self._loading_error is not None: def GetLogMessage(self, msgid):
- maxsz = len(self._log_read_buffer)-1
- sz = self._GetLogMessage(msgid, self._log_read_buffer, maxsz)
- self._log_read_buffer[sz] = '\x00'
- return self._log_read_buffer.value
+ if self._GetLogMessage is not None: + maxsz = len(self._log_read_buffer)-1 + sz = self._GetLogMessage(msgid, self._log_read_buffer, maxsz) + self._log_read_buffer[sz] = '\x00' + return self._log_read_buffer.value + elif self._loading_error is not None : + return self._loading_error def _GetMD5FileName(self):
return os.path.join(self.workingdir, "lasttransferedPLC.md5")
@@ -175,9 +181,11 @@
self._GetLogMessage.restype = ctypes.c_uint32
self._GetLogMessage.argtypes = [ctypes.c_uint32, ctypes.c_char_p, ctypes.c_uint32]
+ self._loading_error = None - PLCprint(traceback.format_exc())
+ self._loading_error = traceback.format_exc() + PLCprint(self._loading_error) @@ -199,7 +207,7 @@
self._PythonIterator = lambda:""
self._LogMessage = lambda m,s:PLCprint("OFF LOG :"+m)
- self._GetLogMessage = lambda i,b,s:None
+ self._GetLogMessage = None self.PLClibraryHandle = None
# Unload library explicitely
if getattr(self,"_PLClibraryHandle",None) is not None:
--- a/tests/logging/plc.xml Tue Jan 29 16:22:04 2013 +1100
+++ b/tests/logging/plc.xml Tue Jan 29 21:34:43 2013 +1100
@@ -8,7 +8,7 @@
creationDateTime="2013-01-29T14:01:00"/>
<contentHeader name="Unnamed"
- modificationDateTime="2013-01-29T15:56:10">
+ modificationDateTime="2013-01-29T21:30:36"> @@ -301,7 +301,7 @@
<configuration name="config">
<resource name="resource1">
- <task name="blob" interval="T#1ms" priority="0">
+ <task name="blob" interval="T#10ms" priority="0"> <pouInstance name="blub" typeName="program0"/>