Fixed bug when debugging wire connected to output connector with modifiers even if connector/continuation is used to replace long wires
authorLaurent Bessard
Thu, 21 Nov 2013 00:33:02 +0100
changeset 1377 cc8f9177d41c
parent 1376 f8acd48e0342
child 1378 cbc0f64a25eb
Fixed bug when debugging wire connected to output connector with modifiers even if connector/continuation is used to replace long wires
editors/Viewer.py
graphics/GraphicCommons.py
--- a/editors/Viewer.py	Wed Nov 20 09:38:13 2013 +0100
+++ b/editors/Viewer.py	Thu Nov 21 00:33:02 2013 +0100
@@ -897,7 +897,23 @@
             next_steps = self.GetNextSteps(connectors["outputs"])
             iec_path = "%s.%s->%s"%(instance_path, ",".join(previous_steps), ",".join(next_steps))
         return iec_path
-       
+    
+    def GetWireModifier(self, wire):
+        connector = wire.EndConnected
+        block = connector.GetParentBlock()
+        if isinstance(block, FBD_Connector):
+            connection = self.GetConnectorByName(block.GetName())
+            if connection is not None:
+                connector = connection.GetConnector()
+                if len(connector.Wires) == 1:
+                    return self.GetWireModifier(connector.Wires[0][0])
+        else:
+            if connector.IsNegated():
+                return "negated"
+            else:
+                return connector.GetEdge()
+        return "none"
+        
 #-------------------------------------------------------------------------------
 #                              Reset functions
 #-------------------------------------------------------------------------------
@@ -1114,6 +1130,8 @@
                         wire.SetValue(True)
                 elif self.AddDataConsumer(iec_path.upper(), wire) is None:
                     wire.SetValue("undefined")
+                else:
+                    wire.SetModifier(self.GetWireModifier(wire))
 
         if self.Debug:
             for block in self.Blocks.itervalues():
--- a/graphics/GraphicCommons.py	Wed Nov 20 09:38:13 2013 +0100
+++ b/graphics/GraphicCommons.py	Thu Nov 21 00:33:02 2013 +0100
@@ -1045,14 +1045,21 @@
         parent_pos = self.ParentBlock.GetPosition()
         x = min(parent_pos[0] + self.Pos.x, parent_pos[0] + self.Pos.x + self.Direction[0] * CONNECTOR_SIZE)
         y = min(parent_pos[1] + self.Pos.y, parent_pos[1] + self.Pos.y + self.Direction[1] * CONNECTOR_SIZE)
+        has_modifier = self.Negated or self.Edge != "none"
         if self.Direction[0] == 0:
-            width = 5
+            width = 10 if has_modifier else 5
         else:
             width = CONNECTOR_SIZE
+            if self.Edge == "rising" and self.Direction[0] == 1:
+                x -= 5
+                width += 5
         if self.Direction[1] == 0:
-            height = 5
+            height = 10 if has_modifier else 5
         else:
             height = CONNECTOR_SIZE
+            if self.Edge == "rising" and self.Direction[1] == 1:
+                y -= 5
+                height += 5
         rect =  wx.Rect(x - abs(movex), y - abs(movey), width + 2 * abs(movex), height + 2 * abs(movey))
         if self.ValueSize is None and isinstance(self.ComputedValue, (StringType, UnicodeType)):
             self.ValueSize = self.ParentBlock.Parent.GetMiniTextExtent(self.ComputedValue)
@@ -1536,6 +1543,8 @@
             self.Segments = []
         self.SelectedSegment = None
         self.Valid = True
+        self.Modifier = "none"
+        self.PreviousValue = None
         self.ValueSize = None
         self.ComputedValue = None
         self.OverStart = False
@@ -1719,7 +1728,16 @@
     def GetToolTipValue(self):
         return self.GetComputedValue()
 
+    def SetModifier(self, modifier):
+        self.Modifier = modifier
+
     def SetValue(self, value):
+        if self.Modifier == "rising":
+            value, self.PreviousValue = value and not self.PreviousValue, value
+        elif self.Modifier == "falling":
+            value, self.PreviousValue = not value and self.PreviousValue, value
+        elif self.Modifier == "negated":
+            value = not value
         if self.Value != value:
             self.Value = value
             computed_value = self.GetComputedValue()