diff -r 5508af39d1f7 -r 34eff05909b0 Viewer.py --- a/Viewer.py Thu Sep 11 14:55:49 2008 +0200 +++ b/Viewer.py Fri Sep 12 16:23:40 2008 +0200 @@ -781,12 +781,20 @@ storage = instance["storage"] else: storage = "none" - if negated and storage == "none": + if instance["edge"]: + edge = instance["edge"] + else: + edge = "none" + if negated and storage == "none" and edge == "none": coil_type = COIL_REVERSE - elif not negated and storage == "set": + elif not negated and edge == "none" and storage == "set": coil_type = COIL_SET - elif not negated and storage == "reset": + elif not negated and edge == "none" and storage == "reset": coil_type = COIL_RESET + elif not negated and storage == "none" and edge == "rising": + coil_type = COIL_RISING + elif not negated and storage == "none" and edge == "falling": + coil_type = COIL_FALLING else: coil_type = COIL_NORMAL coil = LD_Coil(self, coil_type, instance["name"], instance["id"]) @@ -871,6 +879,7 @@ self.CreateWires(connector, instance["connector"]["links"], ids) else: connectors = {"inputs" : [], "outputs" : []} + executionControl = False for input in instance["connectors"]["inputs"]: if input["negated"]: connectors["inputs"].append((input["name"], None, "negated")) @@ -885,10 +894,16 @@ connectors["outputs"].append((output["name"], None, output["edge"])) else: connectors["outputs"].append((output["name"], None, "none")) - if instance["name"] != None: - block = FBD_Block(self, instance["type"], instance["name"], instance["id"], len(instance["connectors"]["inputs"]), connectors=connectors, executionOrder=instance["executionOrder"]) - else: - block = FBD_Block(self, instance["type"], "", instance["id"], len(instance["connectors"]["inputs"]), connectors=connectors, executionOrder=instance["executionOrder"]) + if connectors["inputs"][0][0] == "EN" and connectors["outputs"][0][0] == "ENO": + connectors["inputs"].pop(0) + connectors["outputs"].pop(0) + executionControl = True + if instance["name"] is None: + instance["name"] = "" + block = FBD_Block(self, instance["type"], instance["name"], + instance["id"], len(connectors["inputs"]), + connectors=connectors, executionControl=executionControl, + executionOrder=instance["executionOrder"]) block.SetPosition(instance["x"], instance["y"]) block.SetSize(instance["width"], instance["height"]) self.AddBlock(block) @@ -1563,10 +1578,11 @@ if dialog.ShowModal() == wx.ID_OK: id = self.GetNewId() values = dialog.GetValues() - if "name" in values: - block = FBD_Block(self, values["type"], values["name"], id, values["extension"], values["inputs"]) - else: - block = FBD_Block(self, values["type"], "", id, values["extension"], values["inputs"]) + values.setdefault("name", "") + block = FBD_Block(self, values["type"], values["name"], id, + values["extension"], values["inputs"], + executionControl = values["executionControl"], + executionOrder = values["executionOrder"]) block.SetPosition(bbox.x, bbox.y) block.SetSize(*self.GetScaledSize(values["width"], values["height"])) self.AddBlock(block) @@ -1861,8 +1877,12 @@ variable_names.remove(block.GetName()) dialog.SetPouElementNames(variable_names) dialog.SetMinBlockSize(block.GetSize()) - old_values = {"name" : block.GetName(), "type" : block.GetType(), "inputs" : block.GetInputTypes(), - "executionOrder" : block.GetExecutionOrder(), "extension" : block.GetExtension()} + old_values = {"name" : block.GetName(), + "type" : block.GetType(), + "extension" : block.GetExtension(), + "inputs" : block.GetInputTypes(), + "executionControl" : block.GetExecutionControl(), + "executionOrder" : block.GetExecutionOrder()} dialog.SetValues(old_values) if dialog.ShowModal() == wx.ID_OK: new_values = dialog.GetValues() @@ -1872,18 +1892,19 @@ else: block.SetName("") block.SetSize(*self.GetScaledSize(new_values["width"], new_values["height"])) - block.SetType(new_values["type"], new_values["extension"]) + block.SetType(new_values["type"], new_values["extension"], executionControl = new_values["executionControl"]) block.SetExecutionOrder(new_values["executionOrder"]) rect = rect.Union(block.GetRedrawRect()) self.RefreshBlockModel(block) - if old_values["executionOrder"] != new_values["executionOrder"]: - self.RefreshView() self.RefreshBuffer() self.RefreshScrollBars() self.RefreshVisibleElements() self.ParentWindow.RefreshVariablePanel(self.TagName) self.ParentWindow.RefreshInstancesTree() - block.Refresh(rect) + if old_values["executionOrder"] != new_values["executionOrder"]: + self.RefreshView() + else: + block.Refresh(rect) dialog.Destroy() def EditVariableContent(self, variable):