# HG changeset patch # User Edouard Tisserant <edouard.tisserant@gmail.com> # Date 1603146232 -7200 # Node ID 466c3df6783508b4e345b1218718f90ee4b8afe3 # Parent 6ea4b7e1a9ed5c25dfd070227118507b42cf5852 PY_EXT: OnChange is now a coma separated list of callables. Updated tests/python accordingly. diff -r 6ea4b7e1a9ed -r 466c3df67835 py_ext/PythonFileCTNMixin.py --- a/py_ext/PythonFileCTNMixin.py Thu Sep 17 11:30:22 2020 +0200 +++ b/py_ext/PythonFileCTNMixin.py Tue Oct 20 00:23:52 2020 +0200 @@ -111,7 +111,8 @@ configname = self.GetCTRoot().GetProjectConfigNames()[0] def _onchangecode(var): - return var.getonchange() + "('" + var.getname() + "')" + return [onchangecall.strip() + "('" + var.getname() + "')" + for onchangecall in var.getonchange().split(',')] def _onchange(var): return repr(var.getonchange()) \ @@ -159,7 +160,9 @@ if changes.next(): # %(name)s try: - %(onchangecode)s +""" % varinfo + """ + """ + """ + """.join(varinfo['onchangecode'])+""" except Exception as e: errors.append("%(name)s: "+str(e)) """ % varinfo for varinfo in varinfos if varinfo["onchange"]]) diff -r 6ea4b7e1a9ed -r 466c3df67835 tests/python/plc.xml --- a/tests/python/plc.xml Thu Sep 17 11:30:22 2020 +0200 +++ b/tests/python/plc.xml Tue Oct 20 00:23:52 2020 +0200 @@ -1,7 +1,7 @@ <?xml version='1.0' encoding='utf-8'?> <project xmlns="http://www.plcopen.org/xml/tc6_0201" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xsi:schemaLocation="http://www.plcopen.org/xml/tc6_0201"> <fileHeader companyName="" productName="Beremiz" productVersion="0.0" creationDateTime="2008-12-14T16:21:19" contentDescription="This example shows many features in Beremiz: 1. How to implement python extensions. 2. How to implement basic C extension. 3. How to use C code in IEC POUs. 4. How to call C functions from python code. 5. How to avoid race conditions between IEC, C and python code. 6. How to convert betweet different IEC types. "/> - <contentHeader name="Beremiz Python Support Tests" modificationDateTime="2020-06-17T13:19:14"> + <contentHeader name="Beremiz Python Support Tests" modificationDateTime="2020-10-19T23:53:08"> <coordinateInfo> <pageSize x="1024" y="1024"/> <fbd> diff -r 6ea4b7e1a9ed -r 466c3df67835 tests/python/py_ext_0@py_ext/pyfile.xml --- a/tests/python/py_ext_0@py_ext/pyfile.xml Thu Sep 17 11:30:22 2020 +0200 +++ b/tests/python/py_ext_0@py_ext/pyfile.xml Tue Oct 20 00:23:52 2020 +0200 @@ -2,7 +2,7 @@ <PyFile xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <variables> <variable name="SomeVarName" type="DINT" onchange="MyFunc"/> - <variable name="Grumpf" type="STRING" initial="'mhoo'" onchange="MyFunc"/> + <variable name="Grumpf" type="STRING" initial="'mhoo'" onchange="MyFunc, MyOtherFunc"/> </variables> <globals> <xhtml:p><![CDATA[ @@ -12,6 +12,10 @@ def MyFunc(*args): print args +def MyOtherFunc(*args): + print "other", args + + ]]></xhtml:p> </globals> <init>