graphics/FBD_Objects.py
changeset 269 34eff05909b0
parent 249 d8425712acef
child 283 c4199b88cf60
--- a/graphics/FBD_Objects.py	Thu Sep 11 14:55:49 2008 +0200
+++ b/graphics/FBD_Objects.py	Fri Sep 12 16:23:40 2008 +0200
@@ -38,10 +38,11 @@
 class FBD_Block(Graphic_Element):
     
     # Create a new block
-    def __init__(self, parent, type, name, id = None, extension = 0, inputs = None, connectors = {}, executionOrder = 0):
+    def __init__(self, parent, type, name, id = None, extension = 0, inputs = None, connectors = {}, executionControl = False, executionOrder = 0):
         Graphic_Element.__init__(self, parent)
         self.Type = None
         self.Extension = None
+        self.ExecutionControl = False
         self.Id = id
         self.SetName(name)
         self.SetExecutionOrder(executionOrder)
@@ -49,7 +50,7 @@
         self.Outputs = []
         self.Colour = wx.BLACK
         self.Pen = wx.BLACK_PEN
-        self.SetType(type, extension, inputs, connectors)
+        self.SetType(type, extension, inputs, connectors, executionControl)
         self.Errors = {}
     
     # Make a clone of this FBD_Block
@@ -174,7 +175,7 @@
         return None
     
     def GetInputTypes(self):
-        return tuple([input.GetType(True) for input in self.Inputs])
+        return tuple([input.GetType(True) for input in self.Inputs if input.GetName() != "EN"])
     
     def SetOutputValues(self, values):
         for output in self.Outputs:
@@ -213,12 +214,13 @@
         return None
     
     # Changes the block type
-    def SetType(self, type, extension, inputs = None, connectors = {}):
-        if type != self.Type or self.Extension != extension: 
+    def SetType(self, type, extension, inputs = None, connectors = {}, executionControl = False):
+        if type != self.Type or self.Extension != extension or executionControl != self.ExecutionControl: 
             if type != self.Type:
                 self.Type = type
                 self.TypeSize = self.Parent.GetTextExtent(self.Type)
             self.Extension = extension
+            self.ExecutionControl = executionControl
             # Find the block definition from type given and create the corresponding
             # inputs and outputs
             blocktype = self.Parent.GetBlockType(type, inputs)
@@ -241,6 +243,9 @@
                     outputs = connectors["outputs"]
                 else:
                     outputs = []
+            if self.ExecutionControl:
+                inputs.insert(0, ("EN","BOOL","none"))
+                outputs.insert(0, ("ENO","BOOL","none"))
             self.Pen = wx.Pen(self.Colour)
             self.Clean()
             # Extract the inputs properties and create the corresponding connector
@@ -295,6 +300,10 @@
     def GetExecutionOrder(self):
         return self.ExecutionOrder
     
+    # Returs the execution order
+    def GetExecutionControl(self):
+        return self.ExecutionControl
+    
     # Refresh the block minimum size
     def RefreshMinSize(self):
         # Calculate the inputs maximum width