graphics/FBD_Objects.py
changeset 625 b7062a7018ec
parent 566 6014ef82a98a
child 633 3536f4469cde
equal deleted inserted replaced
624:efedc9d06a59 625:b7062a7018ec
    39     
    39     
    40     # Create a new block
    40     # Create a new block
    41     def __init__(self, parent, type, name, id = None, extension = 0, inputs = None, connectors = {}, executionControl = False, executionOrder = 0):
    41     def __init__(self, parent, type, name, id = None, extension = 0, inputs = None, connectors = {}, executionControl = False, executionOrder = 0):
    42         Graphic_Element.__init__(self, parent)
    42         Graphic_Element.__init__(self, parent)
    43         self.Type = None
    43         self.Type = None
       
    44         self.Description = None
    44         self.Extension = None
    45         self.Extension = None
    45         self.ExecutionControl = False
    46         self.ExecutionControl = False
    46         self.Id = id
    47         self.Id = id
    47         self.SetName(name)
    48         self.SetName(name)
    48         self.SetExecutionOrder(executionOrder)
    49         self.SetExecutionOrder(executionOrder)
   231                 if blocktype["extensible"]:
   232                 if blocktype["extensible"]:
   232                     start = int(inputs[-1][0].replace("IN", ""))
   233                     start = int(inputs[-1][0].replace("IN", ""))
   233                     for i in xrange(self.Extension - len(blocktype["inputs"])):
   234                     for i in xrange(self.Extension - len(blocktype["inputs"])):
   234                         start += 1
   235                         start += 1
   235                         inputs.append(("IN%d"%start, inputs[-1][1], inputs[-1][2]))
   236                         inputs.append(("IN%d"%start, inputs[-1][1], inputs[-1][2]))
       
   237                 comment = blocktype["comment"]
       
   238                 self.Description = _(comment) + blocktype.get("usage", "")
   236             else:
   239             else:
   237                 self.Colour = wx.RED
   240                 self.Colour = wx.RED
   238                 inputs = connectors.get("inputs", [])
   241                 inputs = connectors.get("inputs", [])
   239                 outputs = connectors.get("outputs", [])
   242                 outputs = connectors.get("outputs", [])
       
   243                 self.Description = None
   240             if self.ExecutionControl:
   244             if self.ExecutionControl:
   241                 inputs.insert(0, ("EN","BOOL","none"))
   245                 inputs.insert(0, ("EN","BOOL","none"))
   242                 outputs.insert(0, ("ENO","BOOL","none"))
   246                 outputs.insert(0, ("ENO","BOOL","none"))
   243             self.Pen = MiterPen(self.Colour)
   247             self.Pen = MiterPen(self.Colour)
   244             self.Clean()
   248             self.Clean()
   366         # If block has moved, refresh the model of wires connected to outputs
   370         # If block has moved, refresh the model of wires connected to outputs
   367         if move:
   371         if move:
   368             for output in self.Outputs:
   372             for output in self.Outputs:
   369                 output.RefreshWires()
   373                 output.RefreshWires()
   370     
   374     
       
   375     def GetToolTipValue(self):
       
   376         return self.Description
       
   377     
   371     # Adds an highlight to the block
   378     # Adds an highlight to the block
   372     def AddHighlight(self, infos, start, end ,highlight_type):
   379     def AddHighlight(self, infos, start, end ,highlight_type):
   373         if infos[0] in ["type", "name"] and start[0] == 0 and end[0] == 0:
   380         if infos[0] in ["type", "name"] and start[0] == 0 and end[0] == 0:
   374             highlights = self.Highlights.setdefault(infos[0], [])
   381             highlights = self.Highlights.setdefault(infos[0], [])
   375             AddHighlight(highlights, (start, end, highlight_type))
   382             AddHighlight(highlights, (start, end, highlight_type))