611 return ["%s.%s" % (instance, words[2]) |
611 return ["%s.%s" % (instance, words[2]) |
612 for instance in self.SearchPouInstances( |
612 for instance in self.SearchPouInstances( |
613 self.ComputePouName(words[1]), debug)] |
613 self.ComputePouName(words[1]), debug)] |
614 return [] |
614 return [] |
615 |
615 |
616 def RecursiveGetPouInstanceTagName(self, project, pou_type, parts): |
616 def RecursiveGetPouInstanceTagName(self, project, pou_type, parts, debug = False): |
617 pou = project.getpou(pou_type) |
617 pou = project.getpou(pou_type) |
618 if pou is not None: |
618 if pou is not None: |
619 if len(parts) == 0: |
619 if len(parts) == 0: |
620 return self.ComputePouName(pou_type) |
620 return self.ComputePouName(pou_type) |
621 |
621 |
625 vartype_content = variable.gettype().getcontent() |
625 vartype_content = variable.gettype().getcontent() |
626 if vartype_content["name"] == "derived": |
626 if vartype_content["name"] == "derived": |
627 return self.RecursiveGetPouInstanceTagName( |
627 return self.RecursiveGetPouInstanceTagName( |
628 project, |
628 project, |
629 vartype_content["value"].getname(), |
629 vartype_content["value"].getname(), |
630 parts[1:]) |
630 parts[1:], debug) |
631 |
631 |
632 if pou.getbodyType() == "SFC" and len(parts) == 1: |
632 if pou.getbodyType() == "SFC" and len(parts) == 1: |
633 for action in pou.getactionList(): |
633 for action in pou.getactionList(): |
634 if action.getname() == parts[0]: |
634 if action.getname() == parts[0]: |
635 return self.ComputePouActionName(pou_type, parts[0]) |
635 return self.ComputePouActionName(pou_type, parts[0]) |
636 for transition in pou.gettransitionList(): |
636 for transition in pou.gettransitionList(): |
637 if transition.getname() == parts[0]: |
637 if transition.getname() == parts[0]: |
638 return self.ComputePouTransitionName(pou_type, parts[0]) |
638 return self.ComputePouTransitionName(pou_type, parts[0]) |
|
639 else: |
|
640 block_infos = self.GetBlockType(pou_type, debug=debug) |
|
641 if (block_infos is not None and |
|
642 block_infos["type"] in ["program", "functionBlock"]): |
|
643 |
|
644 if len(parts) == 0: |
|
645 return self.ComputePouName(pou_type) |
|
646 |
|
647 for varname, vartype, varmodifier in block_infos["inputs"] + block_infos["outputs"]: |
|
648 if varname == parts[0]: |
|
649 return self.RecursiveGetPouInstanceTagName(project, vartype, parts[1:], debug) |
639 return None |
650 return None |
640 |
651 |
641 def GetPouInstanceTagName(self, instance_path, debug = False): |
652 def GetPouInstanceTagName(self, instance_path, debug = False): |
642 parts = instance_path.split(".") |
653 parts = instance_path.split(".") |
643 if len(parts) == 1: |
654 if len(parts) == 1: |
660 pou_instance.gettypeName()) |
671 pou_instance.gettypeName()) |
661 else: |
672 else: |
662 return self.RecursiveGetPouInstanceTagName( |
673 return self.RecursiveGetPouInstanceTagName( |
663 project, |
674 project, |
664 pou_instance.gettypeName(), |
675 pou_instance.gettypeName(), |
665 parts[3:]) |
676 parts[3:], debug) |
666 return None |
677 return None |
667 |
678 |
668 def GetInstanceInfos(self, instance_path, debug = False): |
679 def GetInstanceInfos(self, instance_path, debug = False): |
669 tagname = self.GetPouInstanceTagName(instance_path) |
680 tagname = self.GetPouInstanceTagName(instance_path) |
670 if tagname is not None: |
681 if tagname is not None: |