--- a/editors/Viewer.py Fri May 17 19:33:01 2013 +0200
+++ b/editors/Viewer.py Fri May 17 20:30:02 2013 +0200
@@ -844,11 +844,13 @@
def GetElementIECPath(self, element):
instance_path = self.GetInstancePath(True)
- if isinstance(element, Wire) and element.EndConnected is not None:
- block = element.EndConnected.GetParentBlock()
+ if isinstance(element, (Wire, Connector)): + if isinstance(element, Wire): + element = element.EndConnected + block = element.GetParentBlock() if isinstance(block, FBD_Block):
blockname = block.GetName()
- connectorname = element.EndConnected.GetName()
+ connectorname = element.GetName() iec_path = "%s.%s.%s"%(instance_path, blockname, connectorname)
@@ -1092,9 +1094,16 @@
for block in self.Blocks.itervalues():
- iec_path = self.GetElementIECPath(block)
- if iec_path is not None:
- self.AddDataConsumer(iec_path.upper(), block)
+ if isinstance(block, FBD_Block): + for output_connector in block.GetConnectors()["outputs"]: + if len(output_connector.GetWires()) == 0: + iec_path = self.GetElementIECPath(output_connector) + if iec_path is not None: + self.AddDataConsumer(iec_path.upper(), output_connector) + iec_path = self.GetElementIECPath(block) + if iec_path is not None: + self.AddDataConsumer(iec_path.upper(), block) self.RefreshVisibleElements()
--- a/graphics/GraphicCommons.py Fri May 17 19:33:01 2013 +0200
+++ b/graphics/GraphicCommons.py Fri May 17 20:30:02 2013 +0200
@@ -1514,10 +1514,11 @@
Class that implements a connector for any type of block
+class Connector(DebugDataConsumer): def __init__(self, parent, name, type, position, direction, negated = False, edge = "none", onlyone = False):
+ DebugDataConsumer.__init__(self) self.ParentBlock = parent
@@ -1534,6 +1535,8 @@
+ self.ComputedValue = None @@ -1557,7 +1560,18 @@
- return wx.Rect(x - abs(movex), y - abs(movey), width + 2 * abs(movex), height + 2 * abs(movey))
+ 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) + if self.ValueSize is not None: + width, height = self.ValueSize + rect = rect.Union(wx.Rect( + parent_pos[0] + self.Pos.x + CONNECTOR_SIZE * self.Direction[0] + \ + width * (self.Direction[0] - 1) / 2, + parent_pos[1] + self.Pos.y + CONNECTOR_SIZE * self.Direction[1] + \ + height * (self.Direction[1] - 1), # Change the connector selection
def SetSelected(self, selected):
@@ -1621,6 +1635,31 @@
+ def SetForced(self, forced): + if self.Forced != forced: + self.Parent.ElementNeedRefresh(self) + def SetValue(self, value): + if self.Value != value: + if value is not None and not isinstance(value, BooleanType): + connector_type = self.GetType() + if connector_type == "STRING": + self.ComputedValue = "'%s'"%value + elif connector_type == "WSTRING": + self.ComputedValue = "\"%s\""%value + self.ComputedValue = str(value) + #if self.ToolTip is not None: + # self.ToolTip.SetTip(self.ComputedValue) + if len(self.ComputedValue) > 4: + self.ComputedValue = self.ComputedValue[:4] + "..." + if self.ParentBlock.Visible: + self.ParentBlock.Parent.ElementNeedRefresh(self) for wire, handle in self.Wires:
@@ -1960,6 +1999,21 @@
if not getattr(dc, "printing", False):
DrawHighlightedText(dc, self.Name, self.Highlights, xtext, ytext)
+ if self.Value is not None and not isinstance(self.Value, BooleanType) and self.Value != "undefined": + dc.SetFont(self.ParentBlock.Parent.GetMiniFont()) + dc.SetTextForeground(wx.NamedColour("purple")) + if self.ValueSize is None and isinstance(self.ComputedValue, (StringType, UnicodeType)): + self.ValueSize = self.ParentBlock.Parent.GetMiniTextExtent(self.ComputedValue) + if self.ValueSize is not None: + width, height = self.ValueSize + dc.DrawText(self.ComputedValue, + parent_pos[0] + self.Pos.x + CONNECTOR_SIZE * self.Direction[0] + \ + width * (self.Direction[0] - 1) / 2, + parent_pos[1] + self.Pos.y + CONNECTOR_SIZE * self.Direction[1] + \ + height * (self.Direction[1] - 1)) + dc.SetFont(self.ParentBlock.Parent.GetFont()) + dc.SetTextForeground(wx.BLACK) #-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------