tests/python/c_code@c_ext/cfile.xml
author Edouard Tisserant
Fri, 20 Jun 2014 21:36:23 +0200
changeset 1420 71b1545d746f
parent 1401 611fded24ce4
child 1457 ff7cfce737ca
permissions -rw-r--r--
Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
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
5c42cafaee15 Moved LPC sources to a separate project
Edouard Tisserant
parents:
diff changeset
     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
5c42cafaee15 Moved LPC sources to a separate project
Edouard Tisserant
parents:
diff changeset
     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
d9c28879e55b Updated python test
Laurent Bessard
parents: 1086
diff changeset
     8
    <variable name="TestInput" type="SINT" initial="0"/>
d9c28879e55b Updated python test
Laurent Bessard
parents: 1086
diff changeset
     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
5c42cafaee15 Moved LPC sources to a separate project
Edouard Tisserant
parents:
diff changeset
    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
1b1472e76f07 Updated python example
Laurent Bessard
parents: 1099
diff changeset
    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
b566ab5556ab Fixed warnings in python test
Laurent Bessard
parents: 953
diff changeset
    16
extern long AtomicCompareExchange(long*,long, long);
b566ab5556ab Fixed warnings in python test
Laurent Bessard
parents: 953
diff changeset
    17
859
dbf82971f09d More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents: 734
diff changeset
    18
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
    19
  return val+1;
734
5c42cafaee15 Moved LPC sources to a separate project
Edouard Tisserant
parents:
diff changeset
    20
}
859
dbf82971f09d More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents: 734
diff changeset
    21
862
bb59865db6e6 Introduced FBID in tests/python example. Fixed type error leading to segfault
Edouard Tisserant
parents: 860
diff changeset
    22
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
    23
  /* 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
    24
     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
    25
dbf82971f09d More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents: 734
diff changeset
    26
     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
    27
     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
    28
dbf82971f09d More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents: 734
diff changeset
    29
  int res = 0;
1086
b566ab5556ab Fixed warnings in python test
Laurent Bessard
parents: 953
diff changeset
    30
  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
    31
    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
    32
    *fromC=CtoP;
1086
b566ab5556ab Fixed warnings in python test
Laurent Bessard
parents: 953
diff changeset
    33
    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
    34
    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
    35
  }
dbf82971f09d More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents: 734
diff changeset
    36
  printf("C code called by Python: toC %d fromC %d\n",toC,*fromC);
dbf82971f09d More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents: 734
diff changeset
    37
  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
    38
}
dbf82971f09d More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents: 734
diff changeset
    39
862
bb59865db6e6 Introduced FBID in tests/python example. Fixed type error leading to segfault
Edouard Tisserant
parents: 860
diff changeset
    40
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
    41
  /* 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
    42
     conflict with asynchronous python access */
1086
b566ab5556ab Fixed warnings in python test
Laurent Bessard
parents: 953
diff changeset
    43
  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
    44
      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
    45
      *toPLC = PtoC;
1086
b566ab5556ab Fixed warnings in python test
Laurent Bessard
parents: 953
diff changeset
    46
      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
    47
      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
    48
  }
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 0;
1125
1b1472e76f07 Updated python example
Laurent Bessard
parents: 1099
diff changeset
    50
}
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
    51
]]></xhtml:p>
734
5c42cafaee15 Moved LPC sources to a separate project
Edouard Tisserant
parents:
diff changeset
    52
  </globals>
5c42cafaee15 Moved LPC sources to a separate project
Edouard Tisserant
parents:
diff changeset
    53
  <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
    54
    <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
    55
]]></xhtml:p>
734
5c42cafaee15 Moved LPC sources to a separate project
Edouard Tisserant
parents:
diff changeset
    56
  </initFunction>
5c42cafaee15 Moved LPC sources to a separate project
Edouard Tisserant
parents:
diff changeset
    57
  <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
    58
    <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
    59
]]></xhtml:p>
734
5c42cafaee15 Moved LPC sources to a separate project
Edouard Tisserant
parents:
diff changeset
    60
  </cleanUpFunction>
5c42cafaee15 Moved LPC sources to a separate project
Edouard Tisserant
parents:
diff changeset
    61
  <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
    62
    <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
    63
]]></xhtml:p>
734
5c42cafaee15 Moved LPC sources to a separate project
Edouard Tisserant
parents:
diff changeset
    64
  </retrieveFunction>
5c42cafaee15 Moved LPC sources to a separate project
Edouard Tisserant
parents:
diff changeset
    65
  <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
    66
    <xhtml:p><![CDATA[
1125
1b1472e76f07 Updated python example
Laurent Bessard
parents: 1099
diff changeset
    67
if(!AtomicCompareExchange((long*)&Lock, 0, 1)){
860
8a51046010d7 Even more pedagogical tests/python. Renaming will not help
Edouard Tisserant
parents: 859
diff changeset
    68
    TestInput = CtoP + PtoC + TestOutput;
1086
b566ab5556ab Fixed warnings in python test
Laurent Bessard
parents: 953
diff changeset
    69
    AtomicCompareExchange((long*)&Lock, 1, 0);
1125
1b1472e76f07 Updated python example
Laurent Bessard
parents: 1099
diff changeset
    70
}
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
    71
]]></xhtml:p>
734
5c42cafaee15 Moved LPC sources to a separate project
Edouard Tisserant
parents:
diff changeset
    72
  </publishFunction>
1125
1b1472e76f07 Updated python example
Laurent Bessard
parents: 1099
diff changeset
    73
</CFile>