--- a/ProjectController.py Thu Jan 17 00:22:35 2013 +0100
+++ b/ProjectController.py Tue Jan 22 19:03:25 2013 +1100
@@ -113,6 +113,7 @@
self.previous_plcstate = None
+ self.previous_log_count = -1 # copy ConfNodeMethods so that it can be later customized
self.StatusMethods = [dic.copy() for dic in self.StatusMethods]
@@ -1078,11 +1079,9 @@
############# Real PLC object access #############
def UpdateMethodsFromPLCStatus(self):
- # Get PLC state : Running or Stopped
- # TODO : use explicit status instead of boolean
if self._connector is not None:
- status = self._connector.GetPLCstatus()
+ status, log_count = self._connector.GetPLCstatus() @@ -1104,6 +1103,9 @@
self.previous_plcstate = status
+ if(self.previous_log_count != log_count): + self.logger.write("Now log count is %d"%log_count) + self.previous_log_count = log_count def PullPLCStatusProc(self, event):
@@ -1277,7 +1279,7 @@
while (not self.debug_break) and (self._connector is not None):
Trace = self._connector.GetTraceVariables()
- plc_status, debug_tick, debug_vars = Trace
+ plc_status, log_count, debug_tick, debug_vars = Trace --- a/connectors/PYRO/__init__.py Thu Jan 17 00:22:35 2013 +0100
+++ b/connectors/PYRO/__init__.py Tue Jan 22 19:03:25 2013 +1100
@@ -140,11 +140,11 @@
if self.RemotePLCObjectProxyCopy is None:
self.RemotePLCObjectProxyCopy = copy.copy(confnodesroot._connector.GetPyroProxy())
return self.RemotePLCObjectProxyCopy.GetTraceVariables()
- GetTraceVariables = PyroCatcher(_PyroGetTraceVariables,("Broken",None,None))
+ GetTraceVariables = PyroCatcher(_PyroGetTraceVariables,("Broken",-1,None,None)) def _PyroGetPLCstatus(self):
return RemotePLCObjectProxy.GetPLCstatus()
- GetPLCstatus = PyroCatcher(_PyroGetPLCstatus, "Broken")
+ GetPLCstatus = PyroCatcher(_PyroGetPLCstatus, ("Broken",-1)) def _PyroRemoteExec(self, script, **kwargs):
return RemotePLCObjectProxy.RemoteExec(script, **kwargs)
--- a/runtime/PLCObject.py Thu Jan 17 00:22:35 2013 +0100
+++ b/runtime/PLCObject.py Tue Jan 22 19:03:25 2013 +1100
@@ -145,7 +145,10 @@
self._resumeDebug = self.PLClibraryHandle.resumeDebug
self._resumeDebug.restype = None
+ self._GetLogCount = self.PLClibraryHandle.GetLogCount + self._GetLogCount.restype = ctypes.c_uint32 PLCprint(traceback.format_exc())
@@ -168,6 +171,7 @@
self._suspendDebug = lambda x:-1
self._resumeDebug = lambda:None
self._PythonIterator = lambda:""
+ self._GetLogCount = lambda:-1 self.PLClibraryHandle = None
# Unload library explicitely
if getattr(self,"_PLClibraryHandle",None) is not None:
@@ -257,28 +261,22 @@
if self.CurrentPLCFilename is not None and self.PLCStatus == "Stopped":
c_argv = ctypes.c_char_p * len(self.argv)
- if self._startPLC(len(self.argv),c_argv(*self.argv)) == 0:
- self.StartSem=Semaphore(0)
- self.PythonThread = Thread(target=self.PythonThreadProc)
- self.PythonThread.start()
- self.StartSem.acquire()
+ res = self._startPLC(len(self.argv),c_argv(*self.argv)) + self.StartSem=Semaphore(0) + self.PythonThread = Thread(target=self.PythonThreadProc) + self.PythonThread.start() + self.StartSem.acquire()
- PLCprint("Problem %s PLC"%error)
+ PLCprint(_("Problem starting PLC : error %d" % res)) self.PLCStatus = "Broken"
if self.PLCStatus == "Started":
@@ -295,13 +293,17 @@
+ return self.PLCStatus, self._GetLogCount() def NewPLC(self, md5sum, data, extrafiles):
PLCprint("NewPLC (%s)"%md5sum)
if self.PLCStatus in ["Stopped", "Empty", "Broken"]:
NewFileName = md5sum + lib_ext
extra_files_log = os.path.join(self.workingdir,"extra_files.txt")
+ self.PLCStatus = "Empty" os.remove(os.path.join(self.workingdir,
self.CurrentPLCFilename))
@@ -331,11 +333,18 @@
self.CurrentPLCFilename = NewFileName
+ self.PLCStatus = "Broken" PLCprint(traceback.format_exc())
- if self.PLCStatus == "Empty":
self.PLCStatus = "Stopped"
+ return self.PLCStatus == "Stopped" @@ -405,10 +414,10 @@
self.PLClibraryLock.release()
if offset and offset == size.value:
- return self.PLCStatus, tick.value, res
+ return self.PLCStatus, self._GetLogCount(), tick.value, res #PLCprint("Debug error - wrong buffer unpack ! %d != %d"%(offset, size.value))
- return self.PLCStatus, None, []
+ return self.PLCStatus, self._GetLogCount(), None, [] def RemoteExec(self, script, **kwargs):
--- a/targets/plc_debug.c Thu Jan 17 00:22:35 2013 +0100
+++ b/targets/plc_debug.c Tue Jan 22 19:03:25 2013 +1100
@@ -302,3 +302,15 @@
+uint32_t LogMessageCount = 0; + return LogMessageCount; +int LogMessage(char* Message){ + LogMessageCount = __sync_add_and_fetch(&LogMessageCount, 1);