author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Sun, 10 May 2020 17:01:09 +0200 | |
branch | svghmi |
changeset 2954 | b5dccd0d99ac |
parent 1463 | de311ffe3961 |
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:
1125
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:
1125
diff
changeset
|
2 |
<CFile xmlns:xhtml="http://www.w3.org/1999/xhtml"> |
734 | 3 |
<includes> |
1401
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1125
diff
changeset
|
4 |
<xhtml:p><![CDATA[ |
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1125
diff
changeset
|
5 |
]]></xhtml:p> |
734 | 6 |
</includes> |
859
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
7 |
<variables> |
1099 | 8 |
<variable name="TestInput" type="SINT" initial="0"/> |
9 |
<variable name="TestOutput" type="SINT"/> |
|
859
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
10 |
</variables> |
734 | 11 |
<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:
1125
diff
changeset
|
12 |
<xhtml:p><![CDATA[ |
1125 | 13 |
volatile long Lock=0; |
859
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
14 |
volatile char PtoC=1,CtoP=2; |
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
15 |
|
1086 | 16 |
extern long AtomicCompareExchange(long*,long, long); |
1463
de311ffe3961
Changed runtime's global PLCID to PLC_ID, working around redefinition in windoze' headers.
Edouard Tisserant
parents:
1457
diff
changeset
|
17 |
extern char *PLC_ID; |
1086 | 18 |
|
859
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
19 |
int Simple_C_Call(int val){ |
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
20 |
return val+1; |
734 | 21 |
} |
859
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
22 |
|
862
bb59865db6e6
Introduced FBID in tests/python example. Fixed type error leading to segfault
Edouard Tisserant
parents:
860
diff
changeset
|
23 |
int Python_to_C_Call(char toC, char *fromC){ |
859
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
24 |
/* Code called by python should never touch to |
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
25 |
variables modified by PLC thread directly |
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
26 |
|
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
27 |
AtomicCompareExchange comes from |
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
28 |
beremiz' runtime implementation */ |
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
29 |
|
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
30 |
int res = 0; |
1086 | 31 |
if(!AtomicCompareExchange((long*)&Lock, 0, 1)){ |
859
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
32 |
PtoC=toC; |
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
33 |
*fromC=CtoP; |
1086 | 34 |
AtomicCompareExchange((long*)&Lock, 1, 0); |
859
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
35 |
res=1; |
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
36 |
} |
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
37 |
printf("C code called by Python: toC %d fromC %d\n",toC,*fromC); |
1463
de311ffe3961
Changed runtime's global PLCID to PLC_ID, working around redefinition in windoze' headers.
Edouard Tisserant
parents:
1457
diff
changeset
|
38 |
printf("PLC_ID id %s\n",PLC_ID); |
859
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
39 |
return res; |
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
40 |
} |
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
41 |
|
862
bb59865db6e6
Introduced FBID in tests/python example. Fixed type error leading to segfault
Edouard Tisserant
parents:
860
diff
changeset
|
42 |
int PLC_C_Call(char fromPLC, char *toPLC){ |
859
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
43 |
/* PLC also have to be realy carefull not to |
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
44 |
conflict with asynchronous python access */ |
1086 | 45 |
if(!AtomicCompareExchange((long*)&Lock, 0, 1)){ |
859
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
46 |
CtoP = fromPLC; |
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
47 |
*toPLC = PtoC; |
1086 | 48 |
AtomicCompareExchange((long*)&Lock, 1, 0); |
859
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
49 |
return 1; |
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
50 |
} |
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
51 |
return 0; |
1125 | 52 |
} |
1401
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1125
diff
changeset
|
53 |
]]></xhtml:p> |
734 | 54 |
</globals> |
55 |
<initFunction> |
|
1401
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1125
diff
changeset
|
56 |
<xhtml:p><![CDATA[ |
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1125
diff
changeset
|
57 |
]]></xhtml:p> |
734 | 58 |
</initFunction> |
59 |
<cleanUpFunction> |
|
1401
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1125
diff
changeset
|
60 |
<xhtml:p><![CDATA[ |
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1125
diff
changeset
|
61 |
]]></xhtml:p> |
734 | 62 |
</cleanUpFunction> |
63 |
<retrieveFunction> |
|
1401
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1125
diff
changeset
|
64 |
<xhtml:p><![CDATA[ |
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1125
diff
changeset
|
65 |
]]></xhtml:p> |
734 | 66 |
</retrieveFunction> |
67 |
<publishFunction> |
|
1401
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1125
diff
changeset
|
68 |
<xhtml:p><![CDATA[ |
1125 | 69 |
if(!AtomicCompareExchange((long*)&Lock, 0, 1)){ |
860
8a51046010d7
Even more pedagogical tests/python. Renaming will not help
Edouard Tisserant
parents:
859
diff
changeset
|
70 |
TestInput = CtoP + PtoC + TestOutput; |
1086 | 71 |
AtomicCompareExchange((long*)&Lock, 1, 0); |
1125 | 72 |
} |
1401
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1125
diff
changeset
|
73 |
]]></xhtml:p> |
734 | 74 |
</publishFunction> |
1125 | 75 |
</CFile> |