exemples/python/python@py_ext/pyfile.xml
changeset 3814 ab0afe798428
parent 3318 aee9e98c856a
child 3843 832bcf1b5b60
equal deleted inserted replaced
3813:6f3e20690172 3814:ab0afe798428
    13 
    13 
    14 def MyPythonFunc(arg):
    14 def MyPythonFunc(arg):
    15     i = ctypes.c_int()
    15     i = ctypes.c_int()
    16     if(Python_to_C_Call(arg, i)):
    16     if(Python_to_C_Call(arg, i)):
    17         res = i.value
    17         res = i.value
    18         print "toC:", arg, "from C:", res, "FBID:", FBID
    18         print("toC:", arg, "from C:", res, "FBID:", FBID)
    19     else:
    19     else:
    20         print "Failed Python_to_C_Call failed"
    20         print("Failed Python_to_C_Call failed")
    21         res = None
    21         res = None
    22     print "Python read PLC global :",PLCGlobals.Test_Python_Var
    22     print("Python read PLC global :",PLCGlobals.Test_Python_Var)
    23     print "Python read PLC global Grumpf :",PLCGlobals.Grumpf
    23     print("Python read PLC global Grumpf :",PLCGlobals.Grumpf)
    24     PLCGlobals.Second_Python_Var = 789
    24     PLCGlobals.Second_Python_Var = 789
    25     sys.stdout.flush()
    25     sys.stdout.flush()
    26     return res
    26     return res
    27 
    27 
    28 async_error_test_code = """
    28 async_error_test_code = """
    45   <init>
    45   <init>
    46     <xhtml:p><![CDATA[
    46     <xhtml:p><![CDATA[
    47 global x, y
    47 global x, y
    48 x = 2
    48 x = 2
    49 y = 5
    49 y = 5
    50 print "py_runtime init:", x, ",", y
    50 print("py_runtime init:", x, ",", y)
    51 ]]></xhtml:p>
    51 ]]></xhtml:p>
    52   </init>
    52   </init>
    53   <cleanup>
    53   <cleanup>
    54     <xhtml:p><![CDATA[
    54     <xhtml:p><![CDATA[
    55 print "py_runtime cleanup"
    55 print("py_runtime cleanup")
    56 ]]></xhtml:p>
    56 ]]></xhtml:p>
    57   </cleanup>
    57   </cleanup>
    58   <start>
    58   <start>
    59     <xhtml:p><![CDATA[
    59     <xhtml:p><![CDATA[
    60 global x, y
    60 global x, y
    61 print "py_runtime start", x * x + y * y
    61 print("py_runtime start", x * x + y * y)
    62 ]]></xhtml:p>
    62 ]]></xhtml:p>
    63   </start>
    63   </start>
    64   <stop>
    64   <stop>
    65     <xhtml:p><![CDATA[
    65     <xhtml:p><![CDATA[
    66 print "py_runtime stop"
    66 print("py_runtime stop")
    67 ]]></xhtml:p>
    67 ]]></xhtml:p>
    68   </stop>
    68   </stop>
    69 </PyFile>
    69 </PyFile>