647 for varname, vartype, varmodifier in block_infos["inputs"] + block_infos["outputs"]: |
647 for varname, vartype, varmodifier in block_infos["inputs"] + block_infos["outputs"]: |
648 if varname == parts[0]: |
648 if varname == parts[0]: |
649 return self.RecursiveGetPouInstanceTagName(project, vartype, parts[1:], debug) |
649 return self.RecursiveGetPouInstanceTagName(project, vartype, parts[1:], debug) |
650 return None |
650 return None |
651 |
651 |
|
652 def GetGlobalInstanceTagName(self, project, element, parts, debug = False): |
|
653 for varlist in element.getglobalVars(): |
|
654 for variable in varlist.getvariable(): |
|
655 if variable.getname() == parts[0]: |
|
656 vartype_content = variable.gettype().getcontent() |
|
657 if vartype_content["name"] == "derived": |
|
658 if len(parts) == 1: |
|
659 return self.ComputePouName( |
|
660 vartype_content["value"].getname()) |
|
661 else: |
|
662 return self.RecursiveGetPouInstanceTagName( |
|
663 project, |
|
664 vartype_content["value"].getname(), |
|
665 parts[1:], debug) |
|
666 return None |
|
667 |
652 def GetPouInstanceTagName(self, instance_path, debug = False): |
668 def GetPouInstanceTagName(self, instance_path, debug = False): |
|
669 project = self.GetProject(debug) |
653 parts = instance_path.split(".") |
670 parts = instance_path.split(".") |
654 if len(parts) == 1: |
671 if len(parts) == 1: |
655 return self.ComputeConfigurationName(parts[0]) |
672 return self.ComputeConfigurationName(parts[0]) |
656 elif len(parts) == 2: |
673 elif len(parts) == 2: |
|
674 for config in project.getconfigurations(): |
|
675 if config.getname() == parts[0]: |
|
676 result = self.GetGlobalInstanceTagName(project, |
|
677 config, |
|
678 parts[1:], |
|
679 debug) |
|
680 if result is not None: |
|
681 return result |
657 return self.ComputeConfigurationResourceName(parts[0], parts[1]) |
682 return self.ComputeConfigurationResourceName(parts[0], parts[1]) |
658 else: |
683 else: |
659 project = self.GetProject(debug) |
|
660 for config in project.getconfigurations(): |
684 for config in project.getconfigurations(): |
661 if config.getname() == parts[0]: |
685 if config.getname() == parts[0]: |
662 for resource in config.getresource(): |
686 for resource in config.getresource(): |
663 if resource.getname() == parts[1]: |
687 if resource.getname() == parts[1]: |
664 pou_instances = resource.getpouInstance()[:] |
688 pou_instances = resource.getpouInstance()[:] |
672 else: |
696 else: |
673 return self.RecursiveGetPouInstanceTagName( |
697 return self.RecursiveGetPouInstanceTagName( |
674 project, |
698 project, |
675 pou_instance.gettypeName(), |
699 pou_instance.gettypeName(), |
676 parts[3:], debug) |
700 parts[3:], debug) |
|
701 return self.GetGlobalInstanceTagName(project, |
|
702 resource, |
|
703 parts[2:], |
|
704 debug) |
|
705 return self.GetGlobalInstanceTagName(project, |
|
706 config, |
|
707 parts[1:], |
|
708 debug) |
677 return None |
709 return None |
678 |
710 |
679 def GetInstanceInfos(self, instance_path, debug = False): |
711 def GetInstanceInfos(self, instance_path, debug = False): |
680 tagname = self.GetPouInstanceTagName(instance_path) |
712 tagname = self.GetPouInstanceTagName(instance_path) |
|
713 print instance_path, tagname |
681 if tagname is not None: |
714 if tagname is not None: |
682 infos = self.GetPouVariables(tagname, debug) |
715 infos = self.GetPouVariables(tagname, debug) |
683 infos["type"] = tagname |
716 infos["type"] = tagname |
684 return infos |
717 return infos |
685 else: |
718 else: |
686 pou_path, var_name = instance_path.rsplit(".", 1) |
719 pou_path, var_name = instance_path.rsplit(".", 1) |
|
720 print pou_path, tagname |
687 tagname = self.GetPouInstanceTagName(pou_path) |
721 tagname = self.GetPouInstanceTagName(pou_path) |
688 if tagname is not None: |
722 if tagname is not None: |
689 pou_infos = self.GetPouVariables(tagname, debug) |
723 pou_infos = self.GetPouVariables(tagname, debug) |
690 for var_infos in pou_infos["variables"]: |
724 for var_infos in pou_infos["variables"]: |
691 if var_infos["name"] == var_name: |
725 if var_infos["name"] == var_name: |