SVGHMI: filter out temporary variables created while generating ST code out of FBD.
--- a/PLCGenerator.py Tue Aug 13 14:04:13 2019 +0200
+++ b/PLCGenerator.py Wed Aug 14 11:05:17 2019 +0200
@@ -1160,7 +1160,7 @@
if variable.getformalParameter() == "":
variable_name = "%s%d" % (type, block.getlocalId())
else:
- variable_name = "%s%d_%s" % (type, block.getlocalId(), parameter)
+ variable_name = "_TMP_%s%d_%s" % (type, block.getlocalId(), parameter)
if self.Interface[-1][0] != "VAR" or self.Interface[-1][1] is not None or self.Interface[-1][2]:
self.Interface.append(("VAR", None, False, []))
if variable.connectionPointOut in self.ConnectionTypes:
@@ -1253,7 +1253,7 @@
if output_parameter == "":
output_name = "%s%d" % (type, block.getlocalId())
else:
- output_name = "%s%d_%s" % (type, block.getlocalId(), output_parameter)
+ output_name = "_TMP_%s%d_%s" % (type, block.getlocalId(), output_parameter)
output_value = [(output_name, output_info)]
return self.ExtractModifier(output_variable, output_value, output_info)
if block_infos["type"] == "functionBlock":
--- a/svghmi/svghmi.py Tue Aug 13 14:04:13 2019 +0200
+++ b/svghmi/svghmi.py Wed Aug 14 11:05:17 2019 +0200
@@ -113,9 +113,8 @@
# Filter known HMI types
hmi_types_instances = [v for v in varlist if v["derived"] in HMI_TYPES]
- # TODO XXX !!! filter intermediate variables added for FBD feedback loop
-
- hmi_tree_root = HMITreeNode(None, "hmi0", "HMI_ROOT")
+
+ hmi_tree_root = HMITreeNode(None, "/", "HMI_ROOT")
# TODO add always available variables here ?
# - plc status
@@ -125,6 +124,9 @@
# deduce HMI tree from PLC HMI_* instances
for v in hmi_types_instances:
path = v["IEC_path"].split(".")
+ # ignores variables starting with _TMP_
+ if path[-1].startswith("_TMP_"):
+ continue
new_node = HMITreeNode(path, path[-1], v["derived"])
hmi_tree_root.place_node(new_node)
--- a/tests/svghmi/plc.xml Tue Aug 13 14:04:13 2019 +0200
+++ b/tests/svghmi/plc.xml Wed Aug 14 11:05:17 2019 +0200
@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<project xmlns:ns1="http://www.plcopen.org/xml/tc6_0201" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.plcopen.org/xml/tc6_0201">
<fileHeader companyName="Unknown" productName="Unnamed" productVersion="1" creationDateTime="2019-08-06T14:23:42"/>
- <contentHeader name="Unnamed" modificationDateTime="2019-08-13T10:34:09">
+ <contentHeader name="Unnamed" modificationDateTime="2019-08-14T10:55:12">
<coordinateInfo>
<fbd>
<scaling x="5" y="5"/>
@@ -27,7 +27,7 @@
</variable>
<variable name="Pump0">
<type>
- <derived name="Pump"/>
+ <derived name="PumpControl"/>
</type>
</variable>
</localVars>
@@ -92,7 +92,7 @@
</connectionPointOut>
<expression>1</expression>
</inVariable>
- <block localId="4" typeName="Pump" instanceName="Pump0" executionOrderId="0" height="20" width="45">
+ <block localId="4" typeName="PumpControl" instanceName="Pump0" executionOrderId="0" height="20" width="98">
<position x="595" y="50"/>
<inputVariables/>
<inOutVariables/>
@@ -101,10 +101,10 @@
</FBD>
</body>
</pou>
- <pou name="Pump" pouType="functionBlock">
+ <pou name="PumpControl" pouType="functionBlock">
<interface>
<localVars>
- <variable name="hmi">
+ <variable name="Pump">
<type>
<derived name="HMI_LABEL"/>
</type>
@@ -114,6 +114,11 @@
<derived name="HMI_INT"/>
</type>
</variable>
+ <variable name="AddOut">
+ <type>
+ <derived name="HMI_INT"/>
+ </type>
+ </variable>
</localVars>
</interface>
<body>
@@ -178,6 +183,19 @@
</connectionPointOut>
<expression>23</expression>
</inVariable>
+ <outVariable localId="4" executionOrderId="0" height="30" width="60" negated="false">
+ <position x="640" y="135"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="2" formalParameter="OUT">
+ <position x="640" y="150"/>
+ <position x="590" y="150"/>
+ <position x="590" y="135"/>
+ <position x="540" y="135"/>
+ </connection>
+ </connectionPointIn>
+ <expression>AddOut</expression>
+ </outVariable>
</FBD>
</body>
</pou>
@@ -190,6 +208,13 @@
<task name="task0" priority="0" interval="T#20ms">
<pouInstance name="instance0" typeName="program0"/>
</task>
+ <globalVars>
+ <variable name="LocalVar0">
+ <type>
+ <derived name="HMI_LABEL"/>
+ </type>
+ </variable>
+ </globalVars>
</resource>
</configuration>
</configurations>