27 from Viewer import * |
27 from Viewer import * |
28 |
28 |
29 |
29 |
30 class SFC_Viewer(Viewer): |
30 class SFC_Viewer(Viewer): |
31 |
31 |
32 def __init__(self, parent, tagname, window, controler): |
32 def __init__(self, parent, tagname, window, controler, debug = False, instancepath = ""): |
33 Viewer.__init__(self, parent, tagname, window, controler) |
33 Viewer.__init__(self, parent, tagname, window, controler, debug, instancepath) |
34 self.CurrentLanguage = "SFC" |
34 self.CurrentLanguage = "SFC" |
35 |
35 |
36 def ConnectConnectors(self, start, end): |
36 def ConnectConnectors(self, start, end): |
37 startpoint = [start.GetPosition(False), start.GetDirection()] |
37 startpoint = [start.GetPosition(False), start.GetDirection()] |
38 endpoint = [end.GetPosition(False), end.GetDirection()] |
38 endpoint = [end.GetPosition(False), end.GetDirection()] |
354 # Adding element functions |
354 # Adding element functions |
355 #------------------------------------------------------------------------------- |
355 #------------------------------------------------------------------------------- |
356 |
356 |
357 def AddInitialStep(self, pos): |
357 def AddInitialStep(self, pos): |
358 dialog = StepNameDialog(self.ParentWindow, "Add a new initial step", "Please enter step name", "", wx.OK|wx.CANCEL) |
358 dialog = StepNameDialog(self.ParentWindow, "Add a new initial step", "Please enter step name", "", wx.OK|wx.CANCEL) |
359 dialog.SetPouNames(self.Controler.GetProjectPouNames()) |
359 dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug)) |
360 dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName)) |
360 dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName, self.Debug)) |
361 dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)]) |
361 dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)]) |
362 if dialog.ShowModal() == wx.ID_OK: |
362 if dialog.ShowModal() == wx.ID_OK: |
363 id = self.GetNewId() |
363 id = self.GetNewId() |
364 name = dialog.GetValue() |
364 name = dialog.GetValue() |
365 step = SFC_Step(self, name, True, id) |
365 step = SFC_Step(self, name, True, id) |
376 dialog.Destroy() |
376 dialog.Destroy() |
377 |
377 |
378 def AddStep(self): |
378 def AddStep(self): |
379 if self.SelectedElement in self.Wires or isinstance(self.SelectedElement, SFC_Step): |
379 if self.SelectedElement in self.Wires or isinstance(self.SelectedElement, SFC_Step): |
380 dialog = StepNameDialog(self.ParentWindow, "Add a new step", "Please enter step name", "", wx.OK|wx.CANCEL) |
380 dialog = StepNameDialog(self.ParentWindow, "Add a new step", "Please enter step name", "", wx.OK|wx.CANCEL) |
381 dialog.SetPouNames(self.Controler.GetProjectPouNames()) |
381 dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug)) |
382 dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName)) |
382 dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName, self.Debug)) |
383 dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)]) |
383 dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)]) |
384 if dialog.ShowModal() == wx.ID_OK: |
384 if dialog.ShowModal() == wx.ID_OK: |
385 name = dialog.GetValue() |
385 name = dialog.GetValue() |
386 if self.IsWire(self.SelectedElement): |
386 if self.IsWire(self.SelectedElement): |
387 self.SelectedElement.SetSelectedSegment(None) |
387 self.SelectedElement.SetSelectedSegment(None) |
433 if isinstance(self.SelectedElement, SFC_Step): |
433 if isinstance(self.SelectedElement, SFC_Step): |
434 connectors = self.SelectedElement.GetConnectors() |
434 connectors = self.SelectedElement.GetConnectors() |
435 if not connectors["action"]: |
435 if not connectors["action"]: |
436 dialog = ActionBlockDialog(self.ParentWindow) |
436 dialog = ActionBlockDialog(self.ParentWindow) |
437 dialog.SetQualifierList(self.Controler.GetQualifierTypes()) |
437 dialog.SetQualifierList(self.Controler.GetQualifierTypes()) |
438 dialog.SetActionList(self.Controler.GetEditedElementActions(self.TagName)) |
438 dialog.SetActionList(self.Controler.GetEditedElementActions(self.TagName, self.Debug)) |
439 dialog.SetVariableList(self.Controler.GetEditedElementInterfaceVars(self.TagName)) |
439 dialog.SetVariableList(self.Controler.GetEditedElementInterfaceVars(self.TagName, self.Debug)) |
440 if dialog.ShowModal() == wx.ID_OK: |
440 if dialog.ShowModal() == wx.ID_OK: |
441 actions = dialog.GetValues() |
441 actions = dialog.GetValues() |
442 self.SelectedElement.AddAction() |
442 self.SelectedElement.AddAction() |
443 self.RefreshStepModel(self.SelectedElement) |
443 self.RefreshStepModel(self.SelectedElement) |
444 connectors = self.SelectedElement.GetConnectors() |
444 connectors = self.SelectedElement.GetConnectors() |
716 def EditStepContent(self, step): |
716 def EditStepContent(self, step): |
717 if self.GetDrawingMode() == FREEDRAWING_MODE: |
717 if self.GetDrawingMode() == FREEDRAWING_MODE: |
718 Viewer.EditStepContent(self, step) |
718 Viewer.EditStepContent(self, step) |
719 else: |
719 else: |
720 dialog = StepNameDialog(self.ParentWindow, "Edit step name", "Please enter step name", step.GetName(), wx.OK|wx.CANCEL) |
720 dialog = StepNameDialog(self.ParentWindow, "Edit step name", "Please enter step name", step.GetName(), wx.OK|wx.CANCEL) |
721 dialog.SetPouNames(self.Controler.GetProjectPouNames()) |
721 dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug)) |
722 dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName)) |
722 dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName, self.Debug)) |
723 dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step) and block.GetName() != step.GetName()]) |
723 dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step) and block.GetName() != step.GetName()]) |
724 if dialog.ShowModal() == wx.ID_OK: |
724 if dialog.ShowModal() == wx.ID_OK: |
725 value = dialog.GetValue() |
725 value = dialog.GetValue() |
726 step.SetName(value) |
726 step.SetName(value) |
727 min_size = step.GetMinSize() |
727 min_size = step.GetMinSize() |