author | Edouard Tisserant |
Fri, 22 Jan 2021 11:30:37 +0100 | |
branch | svghmi |
changeset 3116 | 6da94ec04325 |
parent 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 |
2680
6bfed6757495
tests/python : add some STRING PLC Python globals with OnChange.
Edouard Tisserant
parents:
1401
diff
changeset
|
23 |
print "Python read PLC global Grumpf :",PLCGlobals.Grumpf |
1145
203f4eff3313
Fixed PLC global var access from python. Added test in tests/python
Edouard Tisserant
parents:
1125
diff
changeset
|
24 |
PLCGlobals.Second_Python_Var = 789 |
1099 | 25 |
sys.stdout.flush() |
26 |
return res |
|
27 |
||
28 |
async_error_test_code = """ |
|
29 |
def badaboom(): |
|
30 |
tuple()[0] |
|
31 |
||
32 |
import wx |
|
33 |
def badaboomwx(): |
|
34 |
wx.CallAfter(badaboom) |
|
35 |
||
36 |
from threading import Timer |
|
37 |
a = Timer(3, badaboom) |
|
38 |
a.start() |
|
39 |
||
40 |
b = Timer(6, badaboomwx) |
|
41 |
b.start() |
|
42 |
""" |
|
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
|
43 |
]]></xhtml:p> |
1099 | 44 |
</globals> |
1125 | 45 |
<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
|
46 |
<xhtml:p><![CDATA[ |
1125 | 47 |
global x, y |
48 |
x = 2 |
|
49 |
y = 5 |
|
50 |
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
|
51 |
]]></xhtml:p> |
1125 | 52 |
</init> |
53 |
<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
|
54 |
<xhtml:p><![CDATA[ |
1125 | 55 |
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
|
56 |
]]></xhtml:p> |
1125 | 57 |
</cleanup> |
58 |
<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
|
59 |
<xhtml:p><![CDATA[ |
1125 | 60 |
global x, y |
61 |
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
|
62 |
]]></xhtml:p> |
1125 | 63 |
</start> |
64 |
<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
|
65 |
<xhtml:p><![CDATA[ |
1125 | 66 |
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
|
67 |
]]></xhtml:p> |
1125 | 68 |
</stop> |
69 |
</PyFile> |