author | Edouard Tisserant |
Mon, 26 Aug 2019 08:54:02 +0200 | |
branch | svghmi |
changeset 2767 | 302347f48193 |
parent 1401 | 611fded24ce4 |
child 2680 | 6bfed6757495 |
permissions | -rw-r--r-- |
1401
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1145
diff
changeset
|
1 |
<?xml version='1.0' encoding='utf-8'?> |
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1145
diff
changeset
|
2 |
<PyFile xmlns:xhtml="http://www.w3.org/1999/xhtml"> |
1099 | 3 |
<variables> |
1145
203f4eff3313
Fixed PLC global var access from python. Added test in tests/python
Edouard Tisserant
parents:
1125
diff
changeset
|
4 |
<variable name="Test_Python_Var" type="INT" initial="4"/> |
203f4eff3313
Fixed PLC global var access from python. Added test in tests/python
Edouard Tisserant
parents:
1125
diff
changeset
|
5 |
<variable name="Second_Python_Var" type="INT" initial="5"/> |
1099 | 6 |
</variables> |
7 |
<globals> |
|
1401
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1145
diff
changeset
|
8 |
<xhtml:p><![CDATA[ |
1125 | 9 |
import time,sys,ctypes |
1099 | 10 |
Python_to_C_Call = PLCBinary.Python_to_C_Call |
11 |
Python_to_C_Call.restype = ctypes.c_int |
|
12 |
Python_to_C_Call.argtypes = [ctypes.c_int, ctypes.POINTER(ctypes.c_int)] |
|
13 |
||
14 |
def MyPythonFunc(arg): |
|
15 |
i = ctypes.c_int() |
|
16 |
if(Python_to_C_Call(arg, i)): |
|
17 |
res = i.value |
|
18 |
print "toC:", arg, "from C:", res, "FBID:", FBID |
|
19 |
else: |
|
20 |
print "Failed Python_to_C_Call failed" |
|
21 |
res = None |
|
1145
203f4eff3313
Fixed PLC global var access from python. Added test in tests/python
Edouard Tisserant
parents:
1125
diff
changeset
|
22 |
print "Python read PLC global :",PLCGlobals.Test_Python_Var |
203f4eff3313
Fixed PLC global var access from python. Added test in tests/python
Edouard Tisserant
parents:
1125
diff
changeset
|
23 |
PLCGlobals.Second_Python_Var = 789 |
1099 | 24 |
sys.stdout.flush() |
25 |
return res |
|
26 |
||
27 |
async_error_test_code = """ |
|
28 |
def badaboom(): |
|
29 |
tuple()[0] |
|
30 |
||
31 |
import wx |
|
32 |
def badaboomwx(): |
|
33 |
wx.CallAfter(badaboom) |
|
34 |
||
35 |
from threading import Timer |
|
36 |
a = Timer(3, badaboom) |
|
37 |
a.start() |
|
38 |
||
39 |
b = Timer(6, badaboomwx) |
|
40 |
b.start() |
|
41 |
""" |
|
1401
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1145
diff
changeset
|
42 |
]]></xhtml:p> |
1099 | 43 |
</globals> |
1125 | 44 |
<init> |
1401
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1145
diff
changeset
|
45 |
<xhtml:p><![CDATA[ |
1125 | 46 |
global x, y |
47 |
x = 2 |
|
48 |
y = 5 |
|
49 |
print "py_runtime init:", x, ",", y |
|
1401
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1145
diff
changeset
|
50 |
]]></xhtml:p> |
1125 | 51 |
</init> |
52 |
<cleanup> |
|
1401
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1145
diff
changeset
|
53 |
<xhtml:p><![CDATA[ |
1125 | 54 |
print "py_runtime cleanup" |
1401
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1145
diff
changeset
|
55 |
]]></xhtml:p> |
1125 | 56 |
</cleanup> |
57 |
<start> |
|
1401
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1145
diff
changeset
|
58 |
<xhtml:p><![CDATA[ |
1125 | 59 |
global x, y |
60 |
print "py_runtime start", x * x + y * y |
|
1401
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1145
diff
changeset
|
61 |
]]></xhtml:p> |
1125 | 62 |
</start> |
63 |
<stop> |
|
1401
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1145
diff
changeset
|
64 |
<xhtml:p><![CDATA[ |
1125 | 65 |
print "py_runtime stop" |
1401
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1145
diff
changeset
|
66 |
]]></xhtml:p> |
1125 | 67 |
</stop> |
68 |
</PyFile> |