1099
|
1 |
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
1125
|
2 |
<PyFile>
|
1099
|
3 |
<variables>
|
|
4 |
<variable name="Test_Python_Var" type="INT" initial="0"/>
|
|
5 |
</variables>
|
|
6 |
<globals>
|
1125
|
7 |
<![CDATA[
|
|
8 |
import time,sys,ctypes
|
1099
|
9 |
Python_to_C_Call = PLCBinary.Python_to_C_Call
|
|
10 |
Python_to_C_Call.restype = ctypes.c_int
|
|
11 |
Python_to_C_Call.argtypes = [ctypes.c_int, ctypes.POINTER(ctypes.c_int)]
|
|
12 |
|
|
13 |
def MyPythonFunc(arg):
|
|
14 |
i = ctypes.c_int()
|
|
15 |
if(Python_to_C_Call(arg, i)):
|
|
16 |
res = i.value
|
|
17 |
print "toC:", arg, "from C:", res, "FBID:", FBID
|
|
18 |
else:
|
|
19 |
print "Failed Python_to_C_Call failed"
|
|
20 |
res = None
|
|
21 |
sys.stdout.flush()
|
|
22 |
return res
|
|
23 |
|
|
24 |
async_error_test_code = """
|
|
25 |
def badaboom():
|
|
26 |
tuple()[0]
|
|
27 |
|
|
28 |
import wx
|
|
29 |
def badaboomwx():
|
|
30 |
wx.CallAfter(badaboom)
|
|
31 |
|
|
32 |
from threading import Timer
|
|
33 |
a = Timer(3, badaboom)
|
|
34 |
a.start()
|
|
35 |
|
|
36 |
b = Timer(6, badaboomwx)
|
|
37 |
b.start()
|
|
38 |
"""
|
|
39 |
]]>
|
|
40 |
</globals>
|
1125
|
41 |
<init>
|
|
42 |
<![CDATA[
|
|
43 |
global x, y
|
|
44 |
x = 2
|
|
45 |
y = 5
|
|
46 |
print "py_runtime init:", x, ",", y
|
|
47 |
]]>
|
|
48 |
</init>
|
|
49 |
<cleanup>
|
|
50 |
<![CDATA[
|
|
51 |
print "py_runtime cleanup"
|
|
52 |
]]>
|
|
53 |
</cleanup>
|
|
54 |
<start>
|
|
55 |
<![CDATA[
|
|
56 |
global x, y
|
|
57 |
print "py_runtime start", x * x + y * y
|
|
58 |
]]>
|
|
59 |
</start>
|
|
60 |
<stop>
|
|
61 |
<![CDATA[
|
|
62 |
print "py_runtime stop"
|
|
63 |
]]>
|
|
64 |
</stop>
|
|
65 |
</PyFile>
|