PY_EXT: OnChange is now a coma separated list of callables. Updated tests/python accordingly.
--- 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"]])
--- 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>
--- 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>