--- a/PLCControler.py Thu Sep 18 08:05:55 2008 +0200
+++ b/PLCControler.py Mon Sep 22 08:01:10 2008 +0200
@@ -560,6 +560,13 @@
self.SetPouInterfaceReturnType(pou_name, "BOOL")
self.BufferProject()
+ def ProjectChangePouType(self, name, pou_type):
+ if self.Project is not None:
+ pou = self.Project.getpou(name)
+ if pou is not None:
+ pou.setpouType(pou_type)
+ self.BufferProject()
+
def ProjectCreatePouFrom(self, name, from_name):
if self.Project is not None:
pou = self.Project.getpou(from_name)
--- a/PLCOpenEditor.py Thu Sep 18 08:05:55 2008 +0200
+++ b/PLCOpenEditor.py Mon Sep 22 08:01:10 2008 +0200
@@ -1611,8 +1611,19 @@
self.Bind(wx.EVT_MENU, self.GenerateAddActionFunction(name), id=new_id)
menu.AppendSeparator()
new_id = wx.NewId()
- AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Create a new POU from")
+ AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Create A New POU From")
self.Bind(wx.EVT_MENU, self.OnCreatePouFromMenu, id=new_id)
+ pou_type = self.Controler.GetPouType(name, self.Debug)
+ if pou_type in ["function", "functionBlock"]:
+ change_menu = wx.Menu(title='')
+ if pou_type == "function":
+ new_id = wx.NewId()
+ AppendMenu(change_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Function Block")
+ self.Bind(wx.EVT_MENU, self.GenerateChangePouTypeFunction(name, "functionBlock"), id=new_id)
+ new_id = wx.NewId()
+ AppendMenu(change_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Program")
+ self.Bind(wx.EVT_MENU, self.GenerateChangePouTypeFunction(name, "program"), id=new_id)
+ menu.AppendMenu(wx.NewId(), "Change POU Type To", change_menu)
new_id = wx.NewId()
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Delete")
self.Bind(wx.EVT_MENU, self.OnRemovePouMenu, id=new_id)
@@ -2185,10 +2196,18 @@
event.Skip()
return OnAddResourceMenu
-
-#-------------------------------------------------------------------------------
-# Remove Project Elements Functions
-#-------------------------------------------------------------------------------
+ def GenerateChangePouTypeFunction(self, name, new_type):
+ def OnChangePouTypeMenu(event):
+ selected = self.TypesTree.GetSelection()
+ if self.TypesTree.GetPyData(selected) == ITEM_POU:
+ self.Controler.ProjectChangePouType(name, new_type)
+ self.RefreshTitle()
+ self.RefreshEditMenu()
+ self.RefreshTypesTree()
+ self.RefreshLibraryTree()
+ self.RefreshToolBar()
+ event.Skip()
+ return OnChangePouTypeMenu
def OnCreatePouFromMenu(self, event):
selected = self.TypesTree.GetSelection()
@@ -2204,6 +2223,10 @@
self.RefreshToolBar()
event.Skip()
+#-------------------------------------------------------------------------------
+# Remove Project Elements Functions
+#-------------------------------------------------------------------------------
+
def OnRemoveDataTypeMenu(self, event):
selected = self.TypesTree.GetSelection()
if self.TypesTree.GetPyData(selected) == ITEM_DATATYPE:
--- a/Viewer.py Thu Sep 18 08:05:55 2008 +0200
+++ b/Viewer.py Mon Sep 22 08:01:10 2008 +0200
@@ -1883,7 +1883,6 @@
"inputs" : block.GetInputTypes(),
"executionControl" : block.GetExecutionControl(),
"executionOrder" : block.GetExecutionOrder()}
- print old_values
dialog.SetValues(old_values)
if dialog.ShowModal() == wx.ID_OK:
new_values = dialog.GetValues()