Edouard@1401: <?xml version='1.0' encoding='utf-8'?> Edouard@1401: <PyFile xmlns:xhtml="http://www.w3.org/1999/xhtml"> Laurent@1099: <variables> Edouard@1145: <variable name="Test_Python_Var" type="INT" initial="4"/> Edouard@1145: <variable name="Second_Python_Var" type="INT" initial="5"/> Laurent@1099: </variables> Laurent@1099: <globals> Edouard@1401: <xhtml:p><![CDATA[ Laurent@1125: import time,sys,ctypes Laurent@1099: Python_to_C_Call = PLCBinary.Python_to_C_Call Laurent@1099: Python_to_C_Call.restype = ctypes.c_int Laurent@1099: Python_to_C_Call.argtypes = [ctypes.c_int, ctypes.POINTER(ctypes.c_int)] Laurent@1099: Laurent@1099: def MyPythonFunc(arg): Laurent@1099: i = ctypes.c_int() Laurent@1099: if(Python_to_C_Call(arg, i)): Laurent@1099: res = i.value Laurent@1099: print "toC:", arg, "from C:", res, "FBID:", FBID Laurent@1099: else: Laurent@1099: print "Failed Python_to_C_Call failed" Laurent@1099: res = None Edouard@1145: print "Python read PLC global :",PLCGlobals.Test_Python_Var Edouard@2680: print "Python read PLC global Grumpf :",PLCGlobals.Grumpf Edouard@1145: PLCGlobals.Second_Python_Var = 789 Laurent@1099: sys.stdout.flush() Laurent@1099: return res Laurent@1099: Laurent@1099: async_error_test_code = """ Laurent@1099: def badaboom(): Laurent@1099: tuple()[0] Laurent@1099: Laurent@1099: import wx Laurent@1099: def badaboomwx(): Laurent@1099: wx.CallAfter(badaboom) Laurent@1099: Laurent@1099: from threading import Timer Laurent@1099: a = Timer(3, badaboom) Laurent@1099: a.start() Laurent@1099: Laurent@1099: b = Timer(6, badaboomwx) Laurent@1099: b.start() Laurent@1099: """ Edouard@1401: ]]></xhtml:p> Laurent@1099: </globals> Laurent@1125: <init> Edouard@1401: <xhtml:p><![CDATA[ Laurent@1125: global x, y Laurent@1125: x = 2 Laurent@1125: y = 5 Laurent@1125: print "py_runtime init:", x, ",", y Edouard@1401: ]]></xhtml:p> Laurent@1125: </init> Laurent@1125: <cleanup> Edouard@1401: <xhtml:p><![CDATA[ Laurent@1125: print "py_runtime cleanup" Edouard@1401: ]]></xhtml:p> Laurent@1125: </cleanup> Laurent@1125: <start> Edouard@1401: <xhtml:p><![CDATA[ Laurent@1125: global x, y Laurent@1125: print "py_runtime start", x * x + y * y Edouard@1401: ]]></xhtml:p> Laurent@1125: </start> Laurent@1125: <stop> Edouard@1401: <xhtml:p><![CDATA[ Laurent@1125: print "py_runtime stop" Edouard@1401: ]]></xhtml:p> Laurent@1125: </stop> Laurent@1125: </PyFile>