equal
deleted
inserted
replaced
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
2 <Python xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="py_ext_xsd.xsd"> |
2 <Python xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="py_ext_xsd.xsd"> |
3 <![CDATA[import threading |
3 <![CDATA[import threading, time |
4 |
4 |
5 MyT = None |
5 MyT = None |
6 Stop = False |
6 Stop = False |
7 |
7 |
|
8 def StartLog(): |
|
9 global MyT |
|
10 MyT=threading.Thread(target = DoLog) |
|
11 MyT.start() |
|
12 |
8 def DoLog(): |
13 def DoLog(): |
9 global MyT,Stop |
14 global Stop |
10 MyT=threading.Timer(0.3, DoLog) |
15 while not Stop: |
11 if not Stop : MyT.start() |
16 PLCObject.LogMessage("Python side Logging (PLC is %s)"%PLCObject.PLCStatus) |
12 Stop = False |
17 time.sleep(0.3) |
13 PLCObject.LogMessage("Python side Logging") |
|
14 |
18 |
15 def StopLog(): |
19 def StopLog(): |
16 global MyT,Stop |
20 global MyT,Stop |
17 Stop=True |
21 Stop=True |
18 if MyT is not None: MyT.cancel() |
|
19 |
22 |
20 _runtime_begin.append(DoLog) |
23 _runtime_init.append(StartLog) |
21 _runtime_cleanup.append(StopLog) |
24 _runtime_cleanup.append(StopLog) |
22 ]]> |
25 ]]> |
23 </Python> |
26 </Python> |