tests/logging/py_ext_0@py_ext/py_ext.xml
changeset 1014 e2f7d6c95db0
parent 944 52a17be9c4d1
--- a/tests/logging/py_ext_0@py_ext/py_ext.xml	Thu Apr 04 11:12:30 2013 +0900
+++ b/tests/logging/py_ext_0@py_ext/py_ext.xml	Thu Apr 04 11:13:28 2013 +0900
@@ -1,23 +1,26 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <Python xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="py_ext_xsd.xsd">
-<![CDATA[import threading
+<![CDATA[import threading, time
 
 MyT = None
 Stop = False
 
+def StartLog():
+    global MyT
+    MyT=threading.Thread(target = DoLog)
+    MyT.start()
+
 def DoLog():
-    global MyT,Stop
-    MyT=threading.Timer(0.3, DoLog)
-    if not Stop : MyT.start()
-    Stop = False
-    PLCObject.LogMessage("Python side Logging")
+    global Stop
+    while not Stop:
+        PLCObject.LogMessage("Python side Logging (PLC is %s)"%PLCObject.PLCStatus)
+        time.sleep(0.3)
 
 def StopLog():
     global MyT,Stop
     Stop=True
-    if MyT is not None: MyT.cancel()
 
-_runtime_begin.append(DoLog)
+_runtime_init.append(StartLog)
 _runtime_cleanup.append(StopLog)
 ]]>
 </Python>