editors/Viewer.py
changeset 1166 2ed9675be08d
parent 1141 5069a28486b9
child 1170 074e46cdedbc
equal deleted inserted replaced
1165:99972084890d 1166:2ed9675be08d
   842             block.TestVisible(screen)
   842             block.TestVisible(screen)
   843     
   843     
   844     def GetElementIECPath(self, element):
   844     def GetElementIECPath(self, element):
   845         iec_path = None
   845         iec_path = None
   846         instance_path = self.GetInstancePath(True)
   846         instance_path = self.GetInstancePath(True)
   847         if isinstance(element, Wire) and element.EndConnected is not None:
   847         if isinstance(element, (Wire, Connector)):
   848             block = element.EndConnected.GetParentBlock()
   848             if isinstance(element, Wire):
       
   849                 element = element.EndConnected
       
   850             block = element.GetParentBlock()
   849             if isinstance(block, FBD_Block):
   851             if isinstance(block, FBD_Block):
   850                 blockname = block.GetName()
   852                 blockname = block.GetName()
   851                 connectorname = element.EndConnected.GetName()
   853                 connectorname = element.GetName()
   852                 if blockname != "":
   854                 if blockname != "":
   853                     iec_path = "%s.%s.%s"%(instance_path, blockname, connectorname)
   855                     iec_path = "%s.%s.%s"%(instance_path, blockname, connectorname)
   854                 else:
   856                 else:
   855                     if connectorname == "":
   857                     if connectorname == "":
   856                         iec_path = "%s.%s%d"%(instance_path, block.GetType(), block.GetId())
   858                         iec_path = "%s.%s%d"%(instance_path, block.GetType(), block.GetId())
  1090                     wire.SetValue("undefined")
  1092                     wire.SetValue("undefined")
  1091 
  1093 
  1092         if self.Debug:
  1094         if self.Debug:
  1093             for block in self.Blocks.itervalues():
  1095             for block in self.Blocks.itervalues():
  1094                 block.SpreadCurrent()
  1096                 block.SpreadCurrent()
  1095                 iec_path = self.GetElementIECPath(block)
  1097                 if isinstance(block, FBD_Block):
  1096                 if iec_path is not None:
  1098                     for output_connector in block.GetConnectors()["outputs"]:
  1097                     self.AddDataConsumer(iec_path.upper(), block)
  1099                         if len(output_connector.GetWires()) == 0:
       
  1100                             iec_path = self.GetElementIECPath(output_connector)
       
  1101                             if iec_path is not None:
       
  1102                                 self.AddDataConsumer(iec_path.upper(), output_connector)
       
  1103                 else:
       
  1104                     iec_path = self.GetElementIECPath(block)
       
  1105                     if iec_path is not None:
       
  1106                         self.AddDataConsumer(iec_path.upper(), block)
  1098 
  1107 
  1099         self.Inhibit(False)
  1108         self.Inhibit(False)
  1100         self.RefreshVisibleElements()
  1109         self.RefreshVisibleElements()
  1101         self.ShowHighlights()
  1110         self.ShowHighlights()
  1102         self.Refresh(False)
  1111         self.Refresh(False)