tests/python/python@py_ext/pyfile.xml
author Laurent Bessard
Wed, 08 May 2013 23:31:12 +0200
changeset 1101 5a0b439cf576
parent 1099 d9c28879e55b
child 1125 1b1472e76f07
permissions -rw-r--r--
Fixed search in CodeFileEditor STC panel
1099
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
     1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
     2
<CodeFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="codefile.xsd">
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
     3
  <includes>
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
     4
<![CDATA[]]>
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
     5
  </includes>
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
     6
  <variables>
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
     7
    <variable name="Test_Python_Var" type="INT" initial="0"/>
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
     8
  </variables>
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
     9
  <globals>
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    10
<![CDATA[import time,sys,ctypes
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    11
Python_to_C_Call = PLCBinary.Python_to_C_Call
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    12
Python_to_C_Call.restype = ctypes.c_int
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    13
Python_to_C_Call.argtypes = [ctypes.c_int, ctypes.POINTER(ctypes.c_int)]
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    14
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    15
def MyPythonFunc(arg):
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    16
    i = ctypes.c_int()
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    17
    if(Python_to_C_Call(arg, i)):
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    18
        res = i.value
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    19
        print "toC:", arg, "from C:", res, "FBID:", FBID
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    20
    else:
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    21
        print "Failed Python_to_C_Call failed"
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    22
        res = None
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    23
    sys.stdout.flush()
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    24
    return res
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    25
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    26
async_error_test_code = """
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    27
def badaboom():
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    28
    tuple()[0]
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    29
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    30
import wx
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    31
def badaboomwx():
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    32
    wx.CallAfter(badaboom)
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    33
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    34
from threading import Timer
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    35
a = Timer(3, badaboom)
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    36
a.start()
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    37
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    38
b = Timer(6, badaboomwx)
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    39
b.start()
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    40
"""
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    41
]]>
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    42
  </globals>
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    43
  <initFunction>
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    44
<![CDATA[]]>
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    45
  </initFunction>
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    46
  <cleanUpFunction>
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    47
<![CDATA[]]>
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    48
  </cleanUpFunction>
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    49
  <retrieveFunction>
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    50
<![CDATA[]]>
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    51
  </retrieveFunction>
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    52
  <publishFunction>
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    53
<![CDATA[]]>
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    54
  </publishFunction>
d9c28879e55b Updated python test
Laurent Bessard
parents:
diff changeset
    55
</CodeFile>