fix issue, when structure data type with array field is created
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Mon, 18 Apr 2016 18:51:59 +0300
changeset 1477 270dba8bf87b
parent 1476 49f1763a5613
child 1478 69fe0b81e951
fix issue, when structure data type with array field is created

Traceback (most recent call last):
File "editors/DataTypeEditor.py", line 669, in ElementArrayTypeFunction
self.RefreshTypeInfos()
File "editors/DataTypeEditor.py", line 761, in RefreshTypeInfos
self.Controler.SetDataTypeInfos(self.TagName, infos)
File "PLCControler.py", line 2075, in SetDataTypeInfos
array.baseType.setcontent(PLCOpenParser.CreateElement(
AttributeError: 'lxml.etree._Element' object has no attribute 'setcontent'
PLCControler.py
--- a/PLCControler.py	Mon Apr 18 18:48:15 2016 +0300
+++ b/PLCControler.py	Mon Apr 18 18:51:59 2016 +0300
@@ -2062,6 +2062,8 @@
                         if element_infos["Type"][0] == "array":
                             array_type, base_type_name, dimensions = element_infos["Type"]
                             array = PLCOpenParser.CreateElement("array", "dataType")
+                            baseType = PLCOpenParser.CreateElement("baseType", "array")
+                            array.setbaseType(baseType)
                             element_type.setcontent(array)
                             for j, dimension in enumerate(dimensions):
                                 dimension_range = PLCOpenParser.CreateElement("dimension", "array")
@@ -2072,7 +2074,7 @@
                                 else:
                                     array.appenddimension(dimension_range)
                             if base_type_name in self.GetBaseTypes():
-                                array.baseType.setcontent(PLCOpenParser.CreateElement(
+                                baseType.setcontent(PLCOpenParser.CreateElement(
                                     base_type_name.lower()
                                     if base_type_name in ["STRING", "WSTRING"]
                                     else base_type_name, "dataType"))