647 customblocktypes.append(customblocktype["name"]) |
647 customblocktypes.append(customblocktype["name"]) |
648 return customblocktypes |
648 return customblocktypes |
649 setattr(cls, "GetCustomBlockResource", GetCustomBlockResource) |
649 setattr(cls, "GetCustomBlockResource", GetCustomBlockResource) |
650 |
650 |
651 # Return Data Types checking for recursion |
651 # Return Data Types checking for recursion |
652 def GetCustomDataTypes(self, exclude = ""): |
652 def GetCustomDataTypes(self, exclude = "", only_locatable = False): |
653 customdatatypes = [] |
653 customdatatypes = [] |
654 for customdatatype in self.getdataTypes(): |
654 for customdatatype in self.getdataTypes(): |
655 customdatatype_name = customdatatype.getname() |
655 if not only_locatable or self.IsLocatableType(customdatatype): |
656 if customdatatype_name != exclude and not self.ElementIsUsedBy(exclude, customdatatype_name): |
656 customdatatype_name = customdatatype.getname() |
657 customdatatypes.append(customdatatype_name) |
657 if customdatatype_name != exclude and not self.ElementIsUsedBy(exclude, customdatatype_name): |
|
658 customdatatypes.append(customdatatype_name) |
658 return customdatatypes |
659 return customdatatypes |
659 setattr(cls, "GetCustomDataTypes", GetCustomDataTypes) |
660 setattr(cls, "GetCustomDataTypes", GetCustomDataTypes) |
|
661 |
|
662 # Return if Data Type can be used for located variables |
|
663 def IsLocatableType(self, datatype): |
|
664 basetype_content = datatype.baseType.getcontent() |
|
665 if basetype_content["name"] in ["enum", "struct"]: |
|
666 return False |
|
667 elif basetype_content["name"] == "derived": |
|
668 base_type = self.getdataType(basetype_content["value"].getname()) |
|
669 if base_type is not None: |
|
670 return self.IsLocatableType(base_type) |
|
671 elif basetype_content["name"] == "array": |
|
672 array_base_type = basetype_content["value"].baseType.getcontent() |
|
673 if array_base_type["value"] is not None and array_base_type["name"] not in ["string", "wstring"]: |
|
674 base_type = self.getdataType(array_base_type["value"].getname()) |
|
675 if base_type is not None: |
|
676 return self.IsLocatableType(base_type) |
|
677 return True |
|
678 setattr(cls, "IsLocatableType", IsLocatableType) |
660 |
679 |
661 cls = PLCOpenClasses.get("project_fileHeader", None) |
680 cls = PLCOpenClasses.get("project_fileHeader", None) |
662 if cls: |
681 if cls: |
663 cls.singleLineAttributes = False |
682 cls.singleLineAttributes = False |
664 |
683 |