638 wires.sort(lambda x, y: cmp(self.Wires[x], self.Wires[y])) |
638 wires.sort(lambda x, y: cmp(self.Wires[x], self.Wires[y])) |
639 if sort_comments: |
639 if sort_comments: |
640 comments.sort(lambda x, y: cmp(x.GetId(), y.GetId())) |
640 comments.sort(lambda x, y: cmp(x.GetId(), y.GetId())) |
641 return blocks + wires + comments |
641 return blocks + wires + comments |
642 |
642 |
|
643 def GetConnectorByName(self, name): |
|
644 for block in self.Blocks.itervalues(): |
|
645 if isinstance(block, FBD_Connector) and\ |
|
646 block.GetType() == CONNECTOR and\ |
|
647 block.GetName() == name: |
|
648 return block |
|
649 return None |
|
650 |
643 def RefreshVisibleElements(self, xp = None, yp = None): |
651 def RefreshVisibleElements(self, xp = None, yp = None): |
644 x, y = self.CalcUnscrolledPosition(0, 0) |
652 x, y = self.CalcUnscrolledPosition(0, 0) |
645 if xp is not None: |
653 if xp is not None: |
646 x = xp * self.GetScrollPixelsPerUnit()[0] |
654 x = xp * self.GetScrollPixelsPerUnit()[0] |
647 if yp is not None: |
655 if yp is not None: |
670 iec_path = "%s.%s%d"%(self.InstancePath, block.GetType(), block.GetId()) |
678 iec_path = "%s.%s%d"%(self.InstancePath, block.GetType(), block.GetId()) |
671 else: |
679 else: |
672 iec_path = "%s.%s%d_%s"%(self.InstancePath, block.GetType(), block.GetId(), connectorname) |
680 iec_path = "%s.%s%d_%s"%(self.InstancePath, block.GetType(), block.GetId(), connectorname) |
673 elif isinstance(block, FBD_Variable): |
681 elif isinstance(block, FBD_Variable): |
674 iec_path = "%s.%s"%(self.InstancePath, block.GetName()) |
682 iec_path = "%s.%s"%(self.InstancePath, block.GetName()) |
|
683 elif isinstance(block, FBD_Connector): |
|
684 connection = self.GetConnectorByName(block.GetName()) |
|
685 if connection is not None: |
|
686 connector = connection.GetConnector() |
|
687 if len(connector.Wires) == 1: |
|
688 iec_path = self.GetElementIECPath(connector.Wires[0][0]) |
675 elif isinstance(element, LD_Contact): |
689 elif isinstance(element, LD_Contact): |
676 iec_path = "%s.%s"%(self.InstancePath, element.GetName()) |
690 iec_path = "%s.%s"%(self.InstancePath, element.GetName()) |
677 elif isinstance(element, SFC_Step): |
691 elif isinstance(element, SFC_Step): |
678 iec_path = "%s.%s.X"%(self.InstancePath, element.GetName()) |
692 iec_path = "%s.%s.X"%(self.InstancePath, element.GetName()) |
679 elif isinstance(element, SFC_Transition): |
693 elif isinstance(element, SFC_Transition): |