59 name = self.Name |
59 name = self.Name |
60 block = FBD_Block(parent, self.Type, name, id, self.Extension) |
60 block = FBD_Block(parent, self.Type, name, id, self.Extension) |
61 block.SetSize(self.Size[0], self.Size[1]) |
61 block.SetSize(self.Size[0], self.Size[1]) |
62 if pos is not None: |
62 if pos is not None: |
63 block.SetPosition(pos.x, pos.y) |
63 block.SetPosition(pos.x, pos.y) |
|
64 else: |
|
65 block.SetPosition(self.Pos.x, self.Pos.y) |
64 block.Inputs = [input.Clone(block) for input in self.Inputs] |
66 block.Inputs = [input.Clone(block) for input in self.Inputs] |
65 block.Outputs = [output.Clone(block) for output in self.Outputs] |
67 block.Outputs = [output.Clone(block) for output in self.Outputs] |
66 return block |
68 return block |
|
69 |
|
70 def GetConnectorTranslation(self, element): |
|
71 return dict(zip(self.Inputs + self.Outputs, element.Inputs + element.Outputs)) |
67 |
72 |
68 def Flush(self): |
73 def Flush(self): |
69 for input in self.Inputs: |
74 for input in self.Inputs: |
70 input.Flush() |
75 input.Flush() |
71 self.Inputs = [] |
76 self.Inputs = [] |
438 def Clone(self, parent, id = None, pos = None): |
443 def Clone(self, parent, id = None, pos = None): |
439 variable = FBD_Variable(parent, self.Type, self.Name, self.ValueType, id) |
444 variable = FBD_Variable(parent, self.Type, self.Name, self.ValueType, id) |
440 variable.SetSize(self.Size[0], self.Size[1]) |
445 variable.SetSize(self.Size[0], self.Size[1]) |
441 if pos is not None: |
446 if pos is not None: |
442 variable.SetPosition(pos.x, pos.y) |
447 variable.SetPosition(pos.x, pos.y) |
|
448 else: |
|
449 variable.SetPosition(self.Pos.x, self.Pos.y) |
443 if self.Input: |
450 if self.Input: |
444 variable.Input = self.Input.Clone(variable) |
451 variable.Input = self.Input.Clone(variable) |
445 if self.Output: |
452 if self.Output: |
446 variable.Output = self.Output.Clone(variable) |
453 variable.Output = self.Output.Clone(variable) |
447 return variable |
454 return variable |
|
455 |
|
456 def GetConnectorTranslation(self, element): |
|
457 connectors = {} |
|
458 if self.Input is not None: |
|
459 connector[self.Input] = element.Input |
|
460 if self.Output is not None: |
|
461 connectors[self.Output] = element.Output |
|
462 return connectors |
448 |
463 |
449 def Flush(self): |
464 def Flush(self): |
450 if self.Input is not None: |
465 if self.Input is not None: |
451 self.Input.Flush() |
466 self.Input.Flush() |
452 self.Input = None |
467 self.Input = None |
704 def Clone(self, parent, id = None, pos = None): |
719 def Clone(self, parent, id = None, pos = None): |
705 connection = FBD_Connector(parent, self.Type, self.Name, id) |
720 connection = FBD_Connector(parent, self.Type, self.Name, id) |
706 connection.SetSize(self.Size[0], self.Size[1]) |
721 connection.SetSize(self.Size[0], self.Size[1]) |
707 if pos is not None: |
722 if pos is not None: |
708 connection.SetPosition(pos.x, pos.y) |
723 connection.SetPosition(pos.x, pos.y) |
|
724 else: |
|
725 connection.SetPosition(self.Pos.x, self.Pos.y) |
709 connection.Connector = self.Connector.Clone(connection) |
726 connection.Connector = self.Connector.Clone(connection) |
710 return connection |
727 return connection |
711 |
728 |
|
729 def GetConnectorTranslation(self, element): |
|
730 return {self.Connector : element.Connector} |
|
731 |
712 # Unconnect connector |
732 # Unconnect connector |
713 def Clean(self): |
733 def Clean(self): |
714 if self.Connector: |
734 if self.Connector: |
715 self.Connector.UnConnect(delete = True) |
735 self.Connector.UnConnect(delete = True) |
716 |
736 |