graphics/LD_Objects.py
changeset 1782 5b6ad7a7fd9d
parent 1744 69dfdb26f600
child 1847 6198190bc121
equal deleted inserted replaced
1781:b112bfdde5cc 1782:5b6ad7a7fd9d
    26 
    26 
    27 from graphics.GraphicCommons import *
    27 from graphics.GraphicCommons import *
    28 from graphics.DebugDataConsumer import DebugDataConsumer
    28 from graphics.DebugDataConsumer import DebugDataConsumer
    29 from plcopen.structures import *
    29 from plcopen.structures import *
    30 
    30 
    31 #-------------------------------------------------------------------------------
    31 
       
    32 # -------------------------------------------------------------------------------
    32 #                         Ladder Diagram PowerRail
    33 #                         Ladder Diagram PowerRail
    33 #-------------------------------------------------------------------------------
    34 # -------------------------------------------------------------------------------
    34 
    35 
    35 
    36 
    36 class LD_PowerRail(Graphic_Element):
    37 class LD_PowerRail(Graphic_Element):
    37     """
    38     """
    38     Class that implements the graphic representation of a power rail
    39     Class that implements the graphic representation of a power rail
   337         # Draw connectors
   338         # Draw connectors
   338         for connector in self.Connectors:
   339         for connector in self.Connectors:
   339             connector.Draw(dc)
   340             connector.Draw(dc)
   340 
   341 
   341 
   342 
   342 #-------------------------------------------------------------------------------
   343 # -------------------------------------------------------------------------------
   343 #                         Ladder Diagram Contact
   344 #                         Ladder Diagram Contact
   344 #-------------------------------------------------------------------------------
   345 # -------------------------------------------------------------------------------
   345 
   346 
   346 
   347 
   347 class LD_Contact(Graphic_Element, DebugDataConsumer):
   348 class LD_Contact(Graphic_Element, DebugDataConsumer):
   348     """
   349     """
   349     Class that implements the graphic representation of a contact
   350     Class that implements the graphic representation of a contact
   512     # Returns the contact connector that starts with the point given if it exists
   513     # Returns the contact connector that starts with the point given if it exists
   513     def GetConnector(self, position, name=None):
   514     def GetConnector(self, position, name=None):
   514         # if a name is given
   515         # if a name is given
   515         if name is not None:
   516         if name is not None:
   516             # Test input and output connector
   517             # Test input and output connector
   517             #if name == self.Input.GetName():
   518             # if name == self.Input.GetName():
   518             #    return self.Input
   519             #    return self.Input
   519             if name == self.Output.GetName():
   520             if name == self.Output.GetName():
   520                 return self.Output
   521                 return self.Output
   521         return self.FindNearestConnector(position, [self.Input, self.Output])
   522         return self.FindNearestConnector(position, [self.Input, self.Output])
   522 
   523 
   683                 if name == "reference":
   684                 if name == "reference":
   684                     DrawHighlightedText(dc, self.Name, highlights, name_pos[0], name_pos[1])
   685                     DrawHighlightedText(dc, self.Name, highlights, name_pos[0], name_pos[1])
   685                 elif typetext != "":
   686                 elif typetext != "":
   686                     DrawHighlightedText(dc, typetext, highlights, type_pos[0], type_pos[1])
   687                     DrawHighlightedText(dc, typetext, highlights, type_pos[0], type_pos[1])
   687 
   688 
   688 #-------------------------------------------------------------------------------
   689 
       
   690 # -------------------------------------------------------------------------------
   689 #                         Ladder Diagram Coil
   691 #                         Ladder Diagram Coil
   690 #-------------------------------------------------------------------------------
   692 # -------------------------------------------------------------------------------
   691 
   693 
   692 
   694 
   693 class LD_Coil(Graphic_Element):
   695 class LD_Coil(Graphic_Element):
   694     """
   696     """
   695     Class that implements the graphic representation of a coil
   697     Class that implements the graphic representation of a coil
   831     # Returns the coil connector that starts with the point given if it exists
   833     # Returns the coil connector that starts with the point given if it exists
   832     def GetConnector(self, position, name=None):
   834     def GetConnector(self, position, name=None):
   833         # if a name is given
   835         # if a name is given
   834         if name is not None:
   836         if name is not None:
   835             # Test input and output connector
   837             # Test input and output connector
   836             #if self.Input and name == self.Input.GetName():
   838             # if self.Input and name == self.Input.GetName():
   837             #    return self.Input
   839             #    return self.Input
   838             if self.Output and name == self.Output.GetName():
   840             if self.Output and name == self.Output.GetName():
   839                 return self.Output
   841                 return self.Output
   840         return self.FindNearestConnector(position, [self.Input, self.Output])
   842         return self.FindNearestConnector(position, [self.Input, self.Output])
   841 
   843