Adding support for testing type between element connected with connector/continuation
authorlaurent
Fri, 24 Jul 2009 11:55:46 +0200
changeset 388 7ea1f5094df3
parent 387 fcae4e40f296
child 389 6a72016d721a
Adding support for testing type between element connected with connector/continuation
Viewer.py
graphics/FBD_Objects.py
--- a/Viewer.py	Fri Jul 24 11:45:41 2009 +0200
+++ b/Viewer.py	Fri Jul 24 11:55:46 2009 +0200
@@ -640,6 +640,14 @@
             comments.sort(lambda x, y: cmp(x.GetId(), y.GetId()))
         return blocks + wires + comments
 
+    def GetConnectorByName(self, name):
+        for block in self.Blocks.itervalues():
+            if isinstance(block, FBD_Connector) and\
+               block.GetType() == CONNECTOR and\
+               block.GetName() == name:
+                return block
+        return None
+    
     def RefreshVisibleElements(self, xp = None, yp = None):
         x, y = self.CalcUnscrolledPosition(0, 0)
         if xp is not None:
@@ -672,6 +680,12 @@
                         iec_path = "%s.%s%d_%s"%(self.InstancePath, block.GetType(), block.GetId(), connectorname)
             elif isinstance(block, FBD_Variable):
                 iec_path = "%s.%s"%(self.InstancePath, block.GetName())
+            elif isinstance(block, FBD_Connector):
+                connection = self.GetConnectorByName(block.GetName())
+                if connection is not None:
+                    connector = connection.GetConnector()
+                    if len(connector.Wires) == 1:
+                        iec_path = self.GetElementIECPath(connector.Wires[0][0])
         elif isinstance(element, LD_Contact):
             iec_path = "%s.%s"%(self.InstancePath, element.GetName())
         elif isinstance(element, SFC_Step):
--- a/graphics/FBD_Objects.py	Fri Jul 24 11:45:41 2009 +0200
+++ b/graphics/FBD_Objects.py	Fri Jul 24 11:55:46 2009 +0200
@@ -816,6 +816,10 @@
         return self.Type
     
     def GetConnectionResultType(self, connector, connectortype):
+        if self.Type == CONTINUATION:
+            connector = self.Parent.GetConnectorByName(self.Name)
+            if connector is not None:
+                return connector.Connector.GetConnectedType()
         return connectortype
     
     # Changes the connection name