--- a/Beremiz.py Thu May 03 19:02:34 2012 +0200
+++ b/Beremiz.py Mon May 07 18:47:29 2012 +0200
@@ -146,13 +146,13 @@
import TextCtrlAutoComplete, cPickle
from BrowseValuesLibraryDialog import BrowseValuesLibraryDialog
import types, time, re, platform, time, traceback, commands
-from plugger import PluginsRoot, MiniTextControler, MATIEC_ERROR_MODEL
+from ConfigTree import ConfigTreeRoot, MiniTextControler, MATIEC_ERROR_MODEL from wxPopen import ProcessLogger
from PLCOpenEditor import IDEFrame, AppendMenu, TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, TYPESTREE, INSTANCESTREE, LIBRARYTREE, SCALING, PAGETITLES, USE_AUI
from PLCOpenEditor import EditorPanel, Viewer, TextViewer, GraphicViewer, ResourceEditor, ConfigurationEditor, DataTypeEditor
-from PLCControler import LOCATION_PLUGIN, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY
+from PLCControler import LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY WINDOW_COLOUR = wx.Colour(240,240,240)
@@ -378,18 +378,18 @@
[ID_FILEMENURECENTPROJECTS,
] = [wx.NewId() for _init_ctrls in range(1)]
+CONFNODEMENU_POSITION = 3 def _init_coll_MenuBar_Menus(self, parent):
IDEFrame._init_coll_MenuBar_Menus(self, parent)
- parent.Insert(pos=PLUGINMENU_POSITION,
- menu=self.PluginMenu, title=_(u'&Plugin'))
+ parent.Insert(pos=CONFNODEMENU_POSITION, + menu=self.ConfNodeMenu, title=_(u'&ConfNode')) - self.PluginMenu = wx.Menu(title='')
+ self.ConfNodeMenu = wx.Menu(title='') self.RecentProjectsMenu = wx.Menu(title='')
IDEFrame._init_utils(self)
@@ -451,25 +451,25 @@
def _init_coll_PLCConfigMainSizer_Items(self, parent):
parent.AddSizer(self.PLCParamsSizer, 0, border=10, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
- parent.AddSizer(self.PluginTreeSizer, 0, border=10, flag=wx.BOTTOM|wx.LEFT|wx.RIGHT)
+ parent.AddSizer(self.ConfNodeTreeSizer, 0, border=10, flag=wx.BOTTOM|wx.LEFT|wx.RIGHT) def _init_coll_PLCConfigMainSizer_Growables(self, parent):
- def _init_coll_PluginTreeSizer_Growables(self, parent):
+ def _init_coll_ConfNodeTreeSizer_Growables(self, parent): def _init_beremiz_sizers(self):
self.PLCConfigMainSizer = wx.FlexGridSizer(cols=1, hgap=2, rows=2, vgap=2)
self.PLCParamsSizer = wx.BoxSizer(wx.VERTICAL)
- #self.PluginTreeSizer = wx.FlexGridSizer(cols=3, hgap=0, rows=0, vgap=2)
- self.PluginTreeSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=0, vgap=2)
+ #self.ConfNodeTreeSizer = wx.FlexGridSizer(cols=3, hgap=0, rows=0, vgap=2) + self.ConfNodeTreeSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=0, vgap=2) self._init_coll_PLCConfigMainSizer_Items(self.PLCConfigMainSizer)
self._init_coll_PLCConfigMainSizer_Growables(self.PLCConfigMainSizer)
- self._init_coll_PluginTreeSizer_Growables(self.PluginTreeSizer)
+ self._init_coll_ConfNodeTreeSizer_Growables(self.ConfNodeTreeSizer) self.PLCConfig.SetSizer(self.PLCConfigMainSizer)
@@ -485,8 +485,8 @@
def OnMethodGen(obj,meth):
- if obj.PluginRoot is not None:
- obj.PluginRoot.CallMethod('_'+meth)
+ if obj.CTR is not None: + obj.CTR.CallMethod('_'+meth) wx.CallAfter(self.RefreshAll)
@@ -516,7 +516,7 @@
self._init_beremiz_sizers()
- def __init__(self, parent, projectOpen=None, buildpath=None, plugin_root=None, debug=True):
+ def __init__(self, parent, projectOpen=None, buildpath=None, ctr=None, debug=True): IDEFrame.__init__(self, parent, debug)
self.Log = LogPseudoFile(self.LogConsole,self.RiseLogConsole)
@@ -530,7 +530,7 @@
self.LastPanelSelected = None
+ self.ConfNodeInfos = {} # Define Tree item icon list
self.LocationImageList = wx.ImageList(16, 16)
@@ -538,7 +538,7 @@
# Icons for location items
for imgname, itemtype in [
- ("CONFIGURATION", LOCATION_PLUGIN),
+ ("CONFIGURATION", LOCATION_CONFNODE), ("RESOURCE", LOCATION_MODULE),
("PROGRAM", LOCATION_GROUP),
("VAR_INPUT", LOCATION_VAR_INPUT),
@@ -555,9 +555,9 @@
if projectOpen is not None and os.path.isdir(projectOpen):
- self.PluginRoot = PluginsRoot(self, self.Log)
- self.Controler = self.PluginRoot
- result = self.PluginRoot.LoadProject(projectOpen, buildpath)
+ self.CTR = ConfigTreeRoot(self, self.Log) + self.Controler = self.CTR + result = self.CTR.LoadProject(projectOpen, buildpath) self.LibraryPanel.SetControler(self.Controler)
self.RefreshConfigRecentProjects(os.path.abspath(projectOpen))
@@ -567,19 +567,19 @@
self.ShowErrorMessage(result)
- self.PluginRoot = plugin_root
- self.Controler = plugin_root
- if plugin_root is not None:
self.LibraryPanel.SetControler(self.Controler)
self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE)
- self.DebugVariablePanel.SetDataProducer(self.PluginRoot)
+ self.DebugVariablePanel.SetDataProducer(self.CTR) self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU)
- self.RefreshPluginMenu()
+ self.RefreshConfNodeMenu() self.LogConsole.SetFocus()
def RiseLogConsole(self):
@@ -587,9 +587,9 @@
- if self.PluginRoot is not None:
- projectname = self.PluginRoot.GetProjectName()
- if self.PluginRoot.ProjectTestModified():
+ if self.CTR is not None: + projectname = self.CTR.GetProjectName() + if self.CTR.ProjectTestModified(): projectname = "~%s~" % projectname
self.SetTitle("%s - %s" % (name, projectname))
@@ -640,20 +640,20 @@
def SearchLineForError(self):
- if self.PluginRoot is not None:
+ if self.CTR is not None: text = self.LogConsole.GetRange(0, self.LogConsole.GetInsertionPoint())
line = self.LogConsole.GetLineText(len(text.splitlines()) - 1)
result = MATIEC_ERROR_MODEL.match(line)
first_line, first_column, last_line, last_column, error = result.groups()
- infos = self.PluginRoot.ShowError(self.Log,
+ infos = self.CTR.ShowError(self.Log, (int(first_line), int(first_column)),
(int(last_line), int(last_column)))
## Function displaying an Error dialog in PLCOpenEditor.
# @return False if closing cancelled.
def CheckSaveBeforeClosing(self, title=_("Close Project")):
- if self.PluginRoot.ProjectTestModified():
+ if self.CTR.ProjectTestModified(): dialog = wx.MessageDialog(self,
_("There are changes, do you want to save?"),
@@ -661,7 +661,7 @@
answer = dialog.ShowModal()
- self.PluginRoot.SaveProject()
elif answer == wx.ID_CANCEL:
@@ -674,33 +674,33 @@
- return ("plugin", tab.Controler.PlugFullName())
+ return ("confnode", tab.Controler.PlugFullName()) elif (isinstance(tab, TextViewer) and
(tab.Controler is None or isinstance(tab.Controler, MiniTextControler))):
- return ("plugin", None, tab.GetInstancePath())
+ return ("confnode", None, tab.GetInstancePath()) return IDEFrame.GetTabInfos(self, tab)
def LoadTab(self, notebook, page_infos):
- if page_infos[0] == "plugin":
+ if page_infos[0] == "confnode": if page_infos[1] is None:
- plugin = self.PluginRoot
- plugin = self.PluginRoot.GetChildByName(page_infos[1])
- return notebook.GetPageIndex(plugin._OpenView(*page_infos[2:]))
+ confnode = self.CTR.GetChildByName(page_infos[1]) + return notebook.GetPageIndex(confnode._OpenView(*page_infos[2:])) return IDEFrame.LoadTab(self, notebook, page_infos)
def OnCloseFrame(self, event):
- if self.PluginRoot is None or self.CheckSaveBeforeClosing(_("Close Application")):
- if self.PluginRoot is not None:
- self.PluginRoot.KillDebugThread()
+ if self.CTR is None or self.CheckSaveBeforeClosing(_("Close Application")): + if self.CTR is not None: + self.CTR.KillDebugThread() - if self.PluginRoot is not None:
- project_path = os.path.realpath(self.PluginRoot.GetProjectPath())
+ if self.CTR is not None: + project_path = os.path.realpath(self.CTR.GetProjectPath()) self.Config.Write("currenteditedproject", project_path)
@@ -732,7 +732,7 @@
self.RefreshRecentProjectsMenu()
MenuToolBar = self.Panes["MenuToolBar"]
- if self.PluginRoot is not None:
+ if self.CTR is not None: selected = self.TabsOpened.GetSelection()
graphic_viewer = isinstance(self.TabsOpened.GetPage(selected), Viewer)
@@ -754,7 +754,7 @@
self.FileMenu.Enable(wx.ID_PRINT, False)
MenuToolBar.EnableTool(wx.ID_PRINT, False)
self.FileMenu.Enable(wx.ID_PAGE_SETUP, True)
- project_modified = self.PluginRoot.ProjectTestModified()
+ project_modified = self.CTR.ProjectTestModified() self.FileMenu.Enable(wx.ID_SAVE, project_modified)
MenuToolBar.EnableTool(wx.ID_SAVE, project_modified)
self.FileMenu.Enable(wx.ID_SAVEAS, True)
@@ -789,7 +789,7 @@
def GenerateOpenRecentProjectFunction(self, projectpath):
def OpenRecentProject(event):
- if self.PluginRoot is not None and not self.CheckSaveBeforeClosing():
+ if self.CTR is not None and not self.CheckSaveBeforeClosing(): self.OpenProject(projectpath)
@@ -810,28 +810,28 @@
self.Bind(wx.EVT_MENU, callback, id=id)
- def RefreshPluginMenu(self):
- if self.PluginRoot is not None:
+ def RefreshConfNodeMenu(self): + if self.CTR is not None: selected = self.TabsOpened.GetSelection()
panel = self.TabsOpened.GetPage(selected)
if panel != self.LastPanelSelected:
- for i in xrange(self.PluginMenu.GetMenuItemCount()):
- item = self.PluginMenu.FindItemByPosition(0)
- self.PluginMenu.Delete(item.GetId())
+ for i in xrange(self.ConfNodeMenu.GetMenuItemCount()): + item = self.ConfNodeMenu.FindItemByPosition(0) + self.ConfNodeMenu.Delete(item.GetId()) self.LastPanelSelected = panel
- items = panel.GetPluginMenuItems()
+ items = panel.GetConfNodeMenuItems() - self.MenuBar.EnableTop(PLUGINMENU_POSITION, len(items) > 0)
- self.GenerateMenuRecursive(items, self.PluginMenu)
+ self.MenuBar.EnableTop(CONFNODEMENU_POSITION, len(items) > 0) + self.GenerateMenuRecursive(items, self.ConfNodeMenu) - panel.RefreshPluginMenu(self.PluginMenu)
+ panel.RefreshConfNodeMenu(self.ConfNodeMenu) - self.MenuBar.EnableTop(PLUGINMENU_POSITION, False)
+ self.MenuBar.EnableTop(CONFNODEMENU_POSITION, False) self.MenuBar.UpdateMenus()
def RefreshScrollBars(self):
@@ -850,15 +850,15 @@
self.ClearSizer(self.PLCParamsSizer)
- if self.PluginRoot is not None:
+ if self.CTR is not None: plcwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1))
- if self.PluginRoot.PlugTestModified():
+ if self.CTR.PlugTestModified(): bkgdclr = CHANGED_TITLE_COLOUR
- if self.PluginRoot not in self.PluginInfos:
- self.PluginInfos[self.PluginRoot] = {"right_visible" : False}
+ if self.CTR not in self.ConfNodeInfos: + self.ConfNodeInfos[self.CTR] = {"right_visible" : False} plcwindow.SetBackgroundColour(TITLE_COLOUR)
plcwindow.Bind(wx.EVT_LEFT_DOWN, self.OnPanelLeftDown)
@@ -869,15 +869,15 @@
st = wx.StaticText(plcwindow, -1)
st.SetFont(wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"]))
- st.SetLabel(self.PluginRoot.GetProjectName())
+ st.SetLabel(self.CTR.GetProjectName()) plcwindowsizer.AddWindow(st, 0, border=5, flag=wx.ALL|wx.ALIGN_CENTER)
addbutton_id = wx.NewId()
addbutton = wx.lib.buttons.GenBitmapButton(id=addbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'Add.png')),
- name='AddPluginButton', parent=plcwindow, pos=wx.Point(0, 0),
+ name='AddConfNodeButton', parent=plcwindow, pos=wx.Point(0, 0), size=wx.Size(16, 16), style=wx.NO_BORDER)
- addbutton.SetToolTipString(_("Add a sub plugin"))
- addbutton.Bind(wx.EVT_BUTTON, self.Gen_AddPluginMenu(self.PluginRoot), id=addbutton_id)
+ addbutton.SetToolTipString(_("Add a sub confnode")) + addbutton.Bind(wx.EVT_BUTTON, self.Gen_AddConfNodeMenu(self.CTR), id=addbutton_id) plcwindowsizer.AddWindow(addbutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER)
plcwindowmainsizer = wx.BoxSizer(wx.VERTICAL)
@@ -886,7 +886,7 @@
plcwindowbuttonsizer = wx.BoxSizer(wx.HORIZONTAL)
plcwindowmainsizer.AddSizer(plcwindowbuttonsizer, 0, border=0, flag=wx.ALIGN_CENTER)
- msizer = self.GenerateMethodButtonSizer(self.PluginRoot, plcwindow, not self.PluginInfos[self.PluginRoot]["right_visible"])
+ msizer = self.GenerateMethodButtonSizer(self.CTR, plcwindow, not self.ConfNodeInfos[self.CTR]["right_visible"]) plcwindowbuttonsizer.AddSizer(msizer, 0, border=0, flag=wx.GROW)
paramswindow = wx.Panel(plcwindow, -1, size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL)
@@ -897,10 +897,10 @@
psizer = wx.BoxSizer(wx.HORIZONTAL)
paramswindow.SetSizer(psizer)
- plugin_infos = self.PluginRoot.GetParamsAttributes()
- self.RefreshSizerElement(paramswindow, psizer, self.PluginRoot, plugin_infos, None, False)
+ confnode_infos = self.CTR.GetParamsAttributes() + self.RefreshSizerElement(paramswindow, psizer, self.CTR, confnode_infos, None, False) - if not self.PluginInfos[self.PluginRoot]["right_visible"]:
+ if not self.ConfNodeInfos[self.CTR]["right_visible"]: minimizebutton_id = wx.NewId()
@@ -909,7 +909,7 @@
size=wx.Size(24, 24), style=wx.NO_BORDER)
make_genbitmaptogglebutton_flat(minimizebutton)
minimizebutton.SetBitmapSelected(wx.Bitmap(Bpath( 'images', 'Minimize.png')))
- minimizebutton.SetToggle(self.PluginInfos[self.PluginRoot]["right_visible"])
+ minimizebutton.SetToggle(self.ConfNodeInfos[self.CTR]["right_visible"]) plcwindowbuttonsizer.AddWindow(minimizebutton, 0, border=5, flag=wx.ALL)
@@ -918,32 +918,32 @@
- msizer.SetCols(len(self.PluginRoot.PluginMethods))
- self.PluginInfos[self.PluginRoot]["right_visible"] = minimizebutton.GetToggle()
+ msizer.SetCols(len(self.CTR.ConfNodeMethods)) + self.ConfNodeInfos[self.CTR]["right_visible"] = minimizebutton.GetToggle() self.PLCConfigMainSizer.Layout()
minimizebutton.Bind(wx.EVT_BUTTON, togglewindow, id=minimizebutton_id)
- self.PluginInfos[self.PluginRoot]["main"] = plcwindow
- self.PluginInfos[self.PluginRoot]["params"] = paramswindow
+ self.ConfNodeInfos[self.CTR]["main"] = plcwindow + self.ConfNodeInfos[self.CTR]["params"] = paramswindow self.PLCConfigMainSizer.Layout()
- def GenerateEnableButton(self, parent, sizer, plugin):
- enabled = plugin.PlugEnabled()
+ def GenerateEnableButton(self, parent, sizer, confnode): + enabled = confnode.PlugEnabled() enablebutton_id = wx.NewId()
enablebutton = wx.lib.buttons.GenBitmapToggleButton(id=enablebutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'Disabled.png')),
name='EnableButton', parent=parent, size=wx.Size(16, 16), pos=wx.Point(0, 0), style=0)#wx.NO_BORDER)
- enablebutton.SetToolTipString(_("Enable/Disable this plugin"))
+ enablebutton.SetToolTipString(_("Enable/Disable this confnode")) make_genbitmaptogglebutton_flat(enablebutton)
enablebutton.SetBitmapSelected(wx.Bitmap(Bpath( 'images', 'Enabled.png')))
enablebutton.SetToggle(enabled)
def toggleenablebutton(event):
- res = self.SetPluginParamsAttribute(plugin, "BaseParams.Enabled", enablebutton.GetToggle())
+ res = self.SetConfNodeParamsAttribute(confnode, "BaseParams.Enabled", enablebutton.GetToggle()) enablebutton.SetToggle(res)
enablebutton.Bind(wx.EVT_BUTTON, toggleenablebutton, id=enablebutton_id)
@@ -951,23 +951,23 @@
sizer.AddSpacer(wx.Size(16, 16))
- def GenerateMethodButtonSizer(self, plugin, parent, horizontal = True):
+ def GenerateMethodButtonSizer(self, confnode, parent, horizontal = True): normal_bt_font=wx.Font(faces["size"] / 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName = faces["helv"])
mouseover_bt_font=wx.Font(faces["size"] / 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, underline=True, faceName = faces["helv"])
- msizer = wx.FlexGridSizer(cols=len(plugin.PluginMethods))
+ msizer = wx.FlexGridSizer(cols=len(confnode.ConfNodeMethods)) msizer = wx.FlexGridSizer(cols=1)
- for plugin_method in plugin.PluginMethods:
- if "method" in plugin_method and plugin_method.get("shown",True):
+ for confnode_method in confnode.ConfNodeMethods: + if "method" in confnode_method and confnode_method.get("shown",True): - label = plugin_method["name"]
+ label = confnode_method["name"] button = GenBitmapTextButton(id=id, parent=parent,
- bitmap=wx.Bitmap(Bpath( "%s.png"%plugin_method.get("bitmap", os.path.join("images", "Unknown")))), label=label,
+ bitmap=wx.Bitmap(Bpath( "%s.png"%confnode_method.get("bitmap", os.path.join("images", "Unknown")))), label=label, name=label, pos=wx.DefaultPosition, style=wx.NO_BORDER)
button.SetFont(normal_bt_font)
- button.SetToolTipString(plugin_method["tooltip"])
- button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(plugin, plugin_method["method"]), id=id)
+ button.SetToolTipString(confnode_method["tooltip"]) + button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(confnode, confnode_method["method"]), id=id) # a fancy underline on mouseover
@@ -978,12 +978,12 @@
button.Bind(wx.EVT_ENTER_WINDOW, setFontStyle(button, mouseover_bt_font))
button.Bind(wx.EVT_LEAVE_WINDOW, setFontStyle(button, normal_bt_font))
#hack to force size to mini
- if not plugin_method.get("enabled",True):
+ if not confnode_method.get("enabled",True): msizer.AddWindow(button, 0, border=0, flag=wx.ALIGN_CENTER)
- def GenerateParamsPanel(self, plugin, bkgdclr, top_offset=0):
+ def GenerateParamsPanel(self, confnode, bkgdclr, top_offset=0): rightwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1))
rightwindow.SetBackgroundColour(bkgdclr)
@@ -995,7 +995,7 @@
rightwindowsizer.AddGrowableRow(0)
rightwindowmainsizer.AddSizer(rightwindowsizer, 0, border=0, flag=wx.GROW)
- msizer = self.GenerateMethodButtonSizer(plugin, rightwindow, not self.PluginInfos[plugin]["right_visible"])
+ msizer = self.GenerateMethodButtonSizer(confnode, rightwindow, not self.ConfNodeInfos[confnode]["right_visible"]) rightwindowsizer.AddSizer(msizer, 0, border=top_offset, flag=wx.TOP|wx.GROW)
rightparamssizer = wx.BoxSizer(wx.HORIZONTAL)
@@ -1006,15 +1006,15 @@
psizer = wx.BoxSizer(wx.VERTICAL)
paramswindow.SetSizer(psizer)
- self.PluginInfos[plugin]["params"] = paramswindow
+ self.ConfNodeInfos[confnode]["params"] = paramswindow rightparamssizer.AddWindow(paramswindow, 0, border=5, flag=wx.ALL)
- plugin_infos = plugin.GetParamsAttributes()
- if len(plugin_infos) > 0:
- self.RefreshSizerElement(paramswindow, psizer, plugin, plugin_infos, None, False)
+ confnode_infos = confnode.GetParamsAttributes() + if len(confnode_infos) > 0: + self.RefreshSizerElement(paramswindow, psizer, confnode, confnode_infos, None, False) - if not self.PluginInfos[plugin]["right_visible"]:
+ if not self.ConfNodeInfos[confnode]["right_visible"]: rightminimizebutton_id = wx.NewId()
@@ -1023,7 +1023,7 @@
size=wx.Size(24, 24), style=wx.NO_BORDER)
make_genbitmaptogglebutton_flat(rightminimizebutton)
rightminimizebutton.SetBitmapSelected(wx.Bitmap(Bpath( 'images', 'Minimize.png')))
- rightminimizebutton.SetToggle(self.PluginInfos[plugin]["right_visible"])
+ rightminimizebutton.SetToggle(self.ConfNodeInfos[confnode]["right_visible"]) rightparamssizer.AddWindow(rightminimizebutton, 0, border=5, flag=wx.ALL)
def togglerightwindow(event):
@@ -1032,8 +1032,8 @@
- msizer.SetCols(len(plugin.PluginMethods))
- self.PluginInfos[plugin]["right_visible"] = rightminimizebutton.GetToggle()
+ msizer.SetCols(len(confnode.ConfNodeMethods)) + self.ConfNodeInfos[confnode]["right_visible"] = rightminimizebutton.GetToggle() self.PLCConfigMainSizer.Layout()
@@ -1042,58 +1042,58 @@
- def RefreshPluginTree(self):
+ def RefreshConfNodeTree(self): - self.ClearSizer(self.PluginTreeSizer)
- if self.PluginRoot is not None:
- for child in self.PluginRoot.IECSortedChilds():
+ self.ClearSizer(self.ConfNodeTreeSizer) + if self.CTR is not None: + for child in self.CTR.IECSortedChilds(): self.GenerateTreeBranch(child)
- if not self.PluginInfos[child]["expanded"]:
- self.CollapsePlugin(child)
+ if not self.ConfNodeInfos[child]["expanded"]: + self.CollapseConfNode(child) self.PLCConfigMainSizer.Layout()
- def SetPluginParamsAttribute(self, plugin, *args, **kwargs):
- res, StructChanged = plugin.SetParamsAttribute(*args, **kwargs)
+ def SetConfNodeParamsAttribute(self, confnode, *args, **kwargs): + res, StructChanged = confnode.SetParamsAttribute(*args, **kwargs) - wx.CallAfter(self.RefreshPluginTree)
+ wx.CallAfter(self.RefreshConfNodeTree) - if plugin == self.PluginRoot:
+ if confnode == self.CTR: bkgdclr = CHANGED_TITLE_COLOUR
items = ["main", "params"]
bkgdclr = CHANGED_WINDOW_COLOUR
items = ["left", "right", "params"]
- self.PluginInfos[plugin][i].SetBackgroundColour(bkgdclr)
- self.PluginInfos[plugin][i].Refresh()
+ self.ConfNodeInfos[confnode][i].SetBackgroundColour(bkgdclr) + self.ConfNodeInfos[confnode][i].Refresh() self._Refresh(TITLE, FILEMENU)
- def ExpandPlugin(self, plugin, force = False):
- for child in self.PluginInfos[plugin]["children"]:
- self.PluginInfos[child]["left"].Show()
- self.PluginInfos[child]["right"].Show()
- if force or self.PluginInfos[child]["expanded"]:
- self.ExpandPlugin(child, force)
+ def ExpandConfNode(self, confnode, force = False): + for child in self.ConfNodeInfos[confnode]["children"]: + self.ConfNodeInfos[child]["left"].Show() + self.ConfNodeInfos[child]["right"].Show() + if force or self.ConfNodeInfos[child]["expanded"]: + self.ExpandConfNode(child, force) - self.PluginInfos[child]["expanded"] = True
- locations_infos = self.PluginInfos[plugin].get("locations_infos", None)
+ self.ConfNodeInfos[child]["expanded"] = True + locations_infos = self.ConfNodeInfos[confnode].get("locations_infos", None) if locations_infos is not None:
if force or locations_infos["root"]["expanded"]:
self.ExpandLocation(locations_infos, "root", force)
locations_infos["root"]["expanded"] = True
- def CollapsePlugin(self, plugin, force = False):
- for child in self.PluginInfos[plugin]["children"]:
- self.PluginInfos[child]["left"].Hide()
- self.PluginInfos[child]["right"].Hide()
- self.CollapsePlugin(child, force)
+ def CollapseConfNode(self, confnode, force = False): + for child in self.ConfNodeInfos[confnode]["children"]: + self.ConfNodeInfos[child]["left"].Hide() + self.ConfNodeInfos[child]["right"].Hide() + self.CollapseConfNode(child, force) - self.PluginInfos[child]["expanded"] = False
- locations_infos = self.PluginInfos[plugin].get("locations_infos", None)
+ self.ConfNodeInfos[child]["expanded"] = False + locations_infos = self.ConfNodeInfos[confnode].get("locations_infos", None) if locations_infos is not None:
self.CollapseLocation(locations_infos, "root", force)
@@ -1129,30 +1129,30 @@
if locations_infos["root"]["left"] is not None and refresh_size:
self.RefreshTreeCtrlSize(locations_infos["root"]["left"])
- def GenerateTreeBranch(self, plugin):
+ def GenerateTreeBranch(self, confnode): leftwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1))
- if plugin.PlugTestModified():
+ if confnode.PlugTestModified(): bkgdclr=CHANGED_WINDOW_COLOUR
leftwindow.SetBackgroundColour(bkgdclr)
- if not self.PluginInfos.has_key(plugin):
- self.PluginInfos[plugin] = {"expanded" : False, "right_visible" : False}
+ if not self.ConfNodeInfos.has_key(confnode): + self.ConfNodeInfos[confnode] = {"expanded" : False, "right_visible" : False} - self.PluginInfos[plugin]["children"] = plugin.IECSortedChilds()
- if len(self.PluginInfos[plugin]["children"]) == 0:
- plugin_locations = plugin.GetVariableLocationTree()["children"]
- if not self.PluginInfos[plugin].has_key("locations_infos"):
- self.PluginInfos[plugin]["locations_infos"] = {"root": {"expanded" : False}}
+ self.ConfNodeInfos[confnode]["children"] = confnode.IECSortedChilds() + confnode_locations = [] + if len(self.ConfNodeInfos[confnode]["children"]) == 0: + confnode_locations = confnode.GetVariableLocationTree()["children"] + if not self.ConfNodeInfos[confnode].has_key("locations_infos"): + self.ConfNodeInfos[confnode]["locations_infos"] = {"root": {"expanded" : False}} - self.PluginInfos[plugin]["locations_infos"]["root"]["left"] = None
- self.PluginInfos[plugin]["locations_infos"]["root"]["right"] = None
- self.PluginInfos[plugin]["locations_infos"]["root"]["children"] = []
+ self.ConfNodeInfos[confnode]["locations_infos"]["root"]["left"] = None + self.ConfNodeInfos[confnode]["locations_infos"]["root"]["right"] = None + self.ConfNodeInfos[confnode]["locations_infos"]["root"]["children"] = [] - self.PluginTreeSizer.AddWindow(leftwindow, 0, border=0, flag=wx.GROW)
+ self.ConfNodeTreeSizer.AddWindow(leftwindow, 0, border=0, flag=wx.GROW) leftwindowsizer = wx.FlexGridSizer(cols=1, rows=2)
leftwindowsizer.AddGrowableCol(0)
@@ -1171,38 +1171,38 @@
rolesizer = wx.BoxSizer(wx.HORIZONTAL)
leftsizer.AddSizer(rolesizer, 0, border=0, flag=wx.GROW|wx.RIGHT)
- #self.GenerateEnableButton(leftwindow, rolesizer, plugin)
+ #self.GenerateEnableButton(leftwindow, rolesizer, confnode) roletext = wx.StaticText(leftwindow, -1)
- roletext.SetLabel(plugin.PlugHelp)
+ roletext.SetLabel(confnode.PlugHelp) rolesizer.AddWindow(roletext, 0, border=5, flag=wx.RIGHT|wx.ALIGN_LEFT)
- plugin_IECChannel = plugin.BaseParams.getIEC_Channel()
+ confnode_IECChannel = confnode.BaseParams.getIEC_Channel() iecsizer = wx.BoxSizer(wx.HORIZONTAL)
leftsizer.AddSizer(iecsizer, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
st = wx.StaticText(leftwindow, -1)
st.SetFont(wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"]))
- st.SetLabel(plugin.GetFullIEC_Channel())
+ st.SetLabel(confnode.GetFullIEC_Channel()) iecsizer.AddWindow(st, 0, border=0, flag=0)
updownsizer = wx.BoxSizer(wx.VERTICAL)
iecsizer.AddSizer(updownsizer, 0, border=5, flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL)
- if plugin_IECChannel > 0:
+ if confnode_IECChannel > 0: ieccdownbutton_id = wx.NewId()
ieccdownbutton = wx.lib.buttons.GenBitmapButton(id=ieccdownbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'IECCDown.png')),
name='IECCDownButton', parent=leftwindow, pos=wx.Point(0, 0),
size=wx.Size(16, 16), style=wx.NO_BORDER)
- ieccdownbutton.Bind(wx.EVT_BUTTON, self.GetItemChannelChangedFunction(plugin, plugin_IECChannel - 1), id=ieccdownbutton_id)
+ ieccdownbutton.Bind(wx.EVT_BUTTON, self.GetItemChannelChangedFunction(confnode, confnode_IECChannel - 1), id=ieccdownbutton_id) updownsizer.AddWindow(ieccdownbutton, 0, border=0, flag=wx.ALIGN_LEFT)
ieccupbutton_id = wx.NewId()
ieccupbutton = wx.lib.buttons.GenBitmapTextButton(id=ieccupbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'IECCUp.png')),
name='IECCUpButton', parent=leftwindow, pos=wx.Point(0, 0),
size=wx.Size(16, 16), style=wx.NO_BORDER)
- ieccupbutton.Bind(wx.EVT_BUTTON, self.GetItemChannelChangedFunction(plugin, plugin_IECChannel + 1), id=ieccupbutton_id)
+ ieccupbutton.Bind(wx.EVT_BUTTON, self.GetItemChannelChangedFunction(confnode, confnode_IECChannel + 1), id=ieccupbutton_id) updownsizer.AddWindow(ieccupbutton, 0, border=0, flag=wx.ALIGN_LEFT)
adddeletesizer = wx.BoxSizer(wx.VERTICAL)
@@ -1210,19 +1210,19 @@
deletebutton_id = wx.NewId()
deletebutton = wx.lib.buttons.GenBitmapButton(id=deletebutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'Delete.png')),
- name='DeletePluginButton', parent=leftwindow, pos=wx.Point(0, 0),
+ name='DeleteConfNodeButton', parent=leftwindow, pos=wx.Point(0, 0), size=wx.Size(16, 16), style=wx.NO_BORDER)
- deletebutton.SetToolTipString(_("Delete this plugin"))
- deletebutton.Bind(wx.EVT_BUTTON, self.GetDeleteButtonFunction(plugin), id=deletebutton_id)
+ deletebutton.SetToolTipString(_("Delete this confnode")) + deletebutton.Bind(wx.EVT_BUTTON, self.GetDeleteButtonFunction(confnode), id=deletebutton_id) adddeletesizer.AddWindow(deletebutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER)
- if len(plugin.PlugChildsTypes) > 0:
+ if len(confnode.PlugChildsTypes) > 0: addbutton_id = wx.NewId()
addbutton = wx.lib.buttons.GenBitmapButton(id=addbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'Add.png')),
- name='AddPluginButton', parent=leftwindow, pos=wx.Point(0, 0),
+ name='AddConfNodeButton', parent=leftwindow, pos=wx.Point(0, 0), size=wx.Size(16, 16), style=wx.NO_BORDER)
- addbutton.SetToolTipString(_("Add a sub plugin"))
- addbutton.Bind(wx.EVT_BUTTON, self.Gen_AddPluginMenu(plugin), id=addbutton_id)
+ addbutton.SetToolTipString(_("Add a sub confnode")) + addbutton.Bind(wx.EVT_BUTTON, self.Gen_AddConfNodeMenu(confnode), id=addbutton_id) adddeletesizer.AddWindow(addbutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER)
expandbutton_id = wx.NewId()
@@ -1234,27 +1234,27 @@
expandbutton.SetUseFocusIndicator(False)
expandbutton.SetBitmapSelected(wx.Bitmap(Bpath( 'images', 'minus.png')))
- if len(self.PluginInfos[plugin]["children"]) > 0:
- expandbutton.SetToggle(self.PluginInfos[plugin]["expanded"])
+ if len(self.ConfNodeInfos[confnode]["children"]) > 0: + expandbutton.SetToggle(self.ConfNodeInfos[confnode]["expanded"]) if expandbutton.GetToggle():
- self.ExpandPlugin(plugin)
+ self.ExpandConfNode(confnode) - self.CollapsePlugin(plugin)
- self.PluginInfos[plugin]["expanded"] = expandbutton.GetToggle()
+ self.CollapseConfNode(confnode) + self.ConfNodeInfos[confnode]["expanded"] = expandbutton.GetToggle() self.PLCConfigMainSizer.Layout()
expandbutton.Bind(wx.EVT_BUTTON, togglebutton, id=expandbutton_id)
- elif len(plugin_locations) > 0:
- locations_infos = self.PluginInfos[plugin]["locations_infos"]
+ elif len(confnode_locations) > 0: + locations_infos = self.ConfNodeInfos[confnode]["locations_infos"] expandbutton.SetToggle(locations_infos["root"]["expanded"])
if expandbutton.GetToggle():
self.ExpandLocation(locations_infos, "root")
self.CollapseLocation(locations_infos, "root")
- self.PluginInfos[plugin]["expanded"] = expandbutton.GetToggle()
+ self.ConfNodeInfos[confnode]["expanded"] = expandbutton.GetToggle() locations_infos["root"]["expanded"] = expandbutton.GetToggle()
self.PLCConfigMainSizer.Layout()
@@ -1267,22 +1267,22 @@
tc = wx.TextCtrl(leftwindow, tc_id, size=wx.Size(150, 25), style=wx.NO_BORDER)
tc.SetFont(wx.Font(faces["size"] * 0.75, wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"]))
- tc.ChangeValue(plugin.MandatoryParams[1].getName())
- tc.Bind(wx.EVT_TEXT, self.GetTextCtrlCallBackFunction(tc, plugin, "BaseParams.Name"), id=tc_id)
+ tc.ChangeValue(confnode.MandatoryParams[1].getName()) + tc.Bind(wx.EVT_TEXT, self.GetTextCtrlCallBackFunction(tc, confnode, "BaseParams.Name"), id=tc_id) iecsizer.AddWindow(tc, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
- rightwindow = self.GenerateParamsPanel(plugin, bkgdclr, 8)
- self.PluginTreeSizer.AddWindow(rightwindow, 0, border=0, flag=wx.GROW)
+ rightwindow = self.GenerateParamsPanel(confnode, bkgdclr, 8) + self.ConfNodeTreeSizer.AddWindow(rightwindow, 0, border=0, flag=wx.GROW) - self.PluginInfos[plugin]["left"] = leftwindow
- self.PluginInfos[plugin]["right"] = rightwindow
- for child in self.PluginInfos[plugin]["children"]:
+ self.ConfNodeInfos[confnode]["left"] = leftwindow + self.ConfNodeInfos[confnode]["right"] = rightwindow + for child in self.ConfNodeInfos[confnode]["children"]: self.GenerateTreeBranch(child)
- if not self.PluginInfos[child]["expanded"]:
- self.CollapsePlugin(child)
+ if not self.ConfNodeInfos[child]["expanded"]: + self.CollapseConfNode(child) - if len(plugin_locations) > 0:
- locations_infos = self.PluginInfos[plugin]["locations_infos"]
+ if len(confnode_locations) > 0: + locations_infos = self.ConfNodeInfos[confnode]["locations_infos"] treectrl = wx.TreeCtrl(self.PLCConfig, -1, size=wx.DefaultSize,
style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.NO_BORDER|wx.TR_HIDE_ROOT|wx.TR_NO_LINES|wx.TR_LINES_AT_ROOT)
treectrl.SetImageList(self.LocationImageList)
@@ -1292,19 +1292,19 @@
treectrl.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheelTreeCtrl)
- self.PluginTreeSizer.AddWindow(treectrl, 0, border=0, flag=0)
+ self.ConfNodeTreeSizer.AddWindow(treectrl, 0, border=0, flag=0) rightwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1))
rightwindow.SetBackgroundColour(wx.WHITE)
- self.PluginTreeSizer.AddWindow(rightwindow, 0, border=0, flag=wx.GROW)
+ self.ConfNodeTreeSizer.AddWindow(rightwindow, 0, border=0, flag=wx.GROW) locations_infos["root"]["left"] = treectrl
locations_infos["root"]["right"] = rightwindow
- for location in plugin_locations:
+ for location in confnode_locations: locations_infos["root"]["children"].append("root.%s" % location["name"])
self.GenerateLocationTreeBranch(treectrl, treectrl.GetRootItem(), locations_infos, "root", location)
if locations_infos["root"]["expanded"]:
- self.PluginTreeSizer.Layout()
+ self.ConfNodeTreeSizer.Layout() self.ExpandLocation(locations_infos, "root")
self.RefreshTreeCtrlSize(treectrl)
@@ -1399,38 +1399,38 @@
- self.RefreshPluginTree()
+ self.RefreshConfNodeTree() - def GetItemChannelChangedFunction(self, plugin, value):
- def OnPluginTreeItemChannelChanged(event):
- res = self.SetPluginParamsAttribute(plugin, "BaseParams.IEC_Channel", value)
+ def GetItemChannelChangedFunction(self, confnode, value): + def OnConfNodeTreeItemChannelChanged(event): + res = self.SetConfNodeParamsAttribute(confnode, "BaseParams.IEC_Channel", value) - return OnPluginTreeItemChannelChanged
+ return OnConfNodeTreeItemChannelChanged - def _GetAddPluginFunction(self, name, plugin):
- def OnPluginMenu(event):
- wx.CallAfter(self.AddPlugin, name, plugin)
+ def _GetAddConfNodeFunction(self, name, confnode): + def OnConfNodeMenu(event): + wx.CallAfter(self.AddConfNode, name, confnode) - def Gen_AddPluginMenu(self, plugin):
- def AddPluginMenu(event):
+ def Gen_AddConfNodeMenu(self, confnode): + def AddConfNodeMenu(event): main_menu = wx.Menu(title='')
- if len(plugin.PlugChildsTypes) > 0:
- for name, XSDClass, help in plugin.PlugChildsTypes:
+ if len(confnode.PlugChildsTypes) > 0: + for name, XSDClass, help in confnode.PlugChildsTypes: main_menu.Append(help=help, id=new_id, kind=wx.ITEM_NORMAL, text=_("Append ")+help)
- self.Bind(wx.EVT_MENU, self._GetAddPluginFunction(name, plugin), id=new_id)
+ self.Bind(wx.EVT_MENU, self._GetAddConfNodeFunction(name, confnode), id=new_id) self.PopupMenuXY(main_menu)
- def GetButtonCallBackFunction(self, plugin, method):
- """ Generate the callbackfunc for a given plugin method"""
+ def GetButtonCallBackFunction(self, confnode, method): + """ Generate the callbackfunc for a given confnode method""" def OnButtonClick(event):
# Disable button to prevent re-entrant call
event.GetEventObject().Disable()
- getattr(plugin,method)()
+ getattr(confnode,method)() event.GetEventObject().Enable()
# Trigger refresh on Idle
@@ -1438,20 +1438,20 @@
- def GetChoiceCallBackFunction(self, choicectrl, plugin, path):
+ def GetChoiceCallBackFunction(self, choicectrl, confnode, path): def OnChoiceChanged(event):
- res = self.SetPluginParamsAttribute(plugin, path, choicectrl.GetStringSelection())
+ res = self.SetConfNodeParamsAttribute(confnode, path, choicectrl.GetStringSelection()) choicectrl.SetStringSelection(res)
- def GetChoiceContentCallBackFunction(self, choicectrl, staticboxsizer, plugin, path):
+ def GetChoiceContentCallBackFunction(self, choicectrl, staticboxsizer, confnode, path): def OnChoiceContentChanged(event):
- res = self.SetPluginParamsAttribute(plugin, path, choicectrl.GetStringSelection())
+ res = self.SetConfNodeParamsAttribute(confnode, path, choicectrl.GetStringSelection()) if wx.VERSION < (2, 8, 0):
self.ParamsPanel.Freeze()
choicectrl.SetStringSelection(res)
- infos = self.PluginRoot.GetParamsAttributes(path)
+ infos = self.CTR.GetParamsAttributes(path) staticbox = staticboxsizer.GetStaticBox()
staticbox.SetLabel("%(name)s - %(value)s"%infos)
self.RefreshSizerElement(self.ParamsPanel, staticboxsizer, infos["children"], "%s.%s"%(path, infos["name"]), selected=selected)
@@ -1463,27 +1463,27 @@
return OnChoiceContentChanged
- def GetTextCtrlCallBackFunction(self, textctrl, plugin, path):
+ def GetTextCtrlCallBackFunction(self, textctrl, confnode, path): def OnTextCtrlChanged(event):
- res = self.SetPluginParamsAttribute(plugin, path, textctrl.GetValue())
+ res = self.SetConfNodeParamsAttribute(confnode, path, textctrl.GetValue()) if res != textctrl.GetValue():
textctrl.ChangeValue(res)
- def GetCheckBoxCallBackFunction(self, chkbx, plugin, path):
+ def GetCheckBoxCallBackFunction(self, chkbx, confnode, path): def OnCheckBoxChanged(event):
- res = self.SetPluginParamsAttribute(plugin, path, chkbx.IsChecked())
+ res = self.SetConfNodeParamsAttribute(confnode, path, chkbx.IsChecked()) - def GetBrowseCallBackFunction(self, name, textctrl, library, value_infos, plugin, path):
+ def GetBrowseCallBackFunction(self, name, textctrl, library, value_infos, confnode, path): def OnBrowseButton(event):
dialog = BrowseValuesLibraryDialog(self, name, library, infos[0])
if dialog.ShowModal() == wx.ID_OK:
- value, value_infos = self.SetPluginParamsAttribute(plugin, path, dialog.GetValueInfos())
+ value, value_infos = self.SetConfNodeParamsAttribute(confnode, path, dialog.GetValueInfos()) textctrl.ChangeValue(value)
@@ -1502,7 +1502,7 @@
for staticbox in staticboxes:
- def RefreshSizerElement(self, parent, sizer, plugin, elements, path, clean = True):
+ def RefreshSizerElement(self, parent, sizer, confnode, elements, path, clean = True): if wx.VERSION < (2, 8, 0):
@@ -1524,7 +1524,7 @@
sizer.AddSizer(staticboxsizer, 0, border=0, flag=wx.GROW|wx.TOP)
sizer.AddSizer(staticboxsizer, 0, border=0, flag=wx.GROW)
- self.RefreshSizerElement(parent, staticboxsizer, plugin, element_infos["children"], element_path)
+ self.RefreshSizerElement(parent, staticboxsizer, confnode, element_infos["children"], element_path) boxsizer = wx.FlexGridSizer(cols=3, rows=1)
boxsizer.AddGrowableCol(1)
@@ -1561,7 +1561,7 @@
browse_boxsizer.AddWindow(button, 0, border=0, flag=0)
button.Bind(wx.EVT_BUTTON,
self.GetBrowseCallBackFunction(element_infos["name"], textctrl, element_infos["type"],
- value_infos, plugin, element_path),
+ value_infos, confnode, element_path), combobox = wx.ComboBox(id=id, name=element_infos["name"], parent=parent,
@@ -1579,12 +1579,12 @@
pos=wx.Point(0, 0), size=wx.Size(10, 0), style=0)
staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL)
sizer.AddSizer(staticboxsizer, 0, border=5, flag=wx.GROW|wx.BOTTOM)
- self.RefreshSizerElement(parent, staticboxsizer, plugin, element_infos["children"], element_path)
- callback = self.GetChoiceContentCallBackFunction(combobox, staticboxsizer, plugin, element_path)
+ self.RefreshSizerElement(parent, staticboxsizer, confnode, element_infos["children"], element_path) + callback = self.GetChoiceContentCallBackFunction(combobox, staticboxsizer, confnode, element_path) for choice in element_infos["type"]:
- callback = self.GetChoiceCallBackFunction(combobox, plugin, element_path)
+ callback = self.GetChoiceCallBackFunction(combobox, confnode, element_path) if element_infos["value"] is None:
combobox.SetStringSelection("")
@@ -1603,7 +1603,7 @@
boxsizer.AddWindow(spinctrl, 0, border=0, flag=0)
if element_infos["value"] is not None:
spinctrl.SetValue(element_infos["value"])
- spinctrl.Bind(wx.EVT_SPINCTRL, self.GetTextCtrlCallBackFunction(spinctrl, plugin, element_path), id=id)
+ spinctrl.Bind(wx.EVT_SPINCTRL, self.GetTextCtrlCallBackFunction(spinctrl, confnode, element_path), id=id) if element_infos["type"] == "boolean":
checkbox = wx.CheckBox(id=id, name=element_infos["name"], parent=parent,
@@ -1611,7 +1611,7 @@
boxsizer.AddWindow(checkbox, 0, border=0, flag=0)
if element_infos["value"] is not None:
checkbox.SetValue(element_infos["value"])
- checkbox.Bind(wx.EVT_CHECKBOX, self.GetCheckBoxCallBackFunction(checkbox, plugin, element_path), id=id)
+ checkbox.Bind(wx.EVT_CHECKBOX, self.GetCheckBoxCallBackFunction(checkbox, confnode, element_path), id=id) elif element_infos["type"] in ["unsignedLong", "long","integer"]:
if element_infos["type"].startswith("unsigned"):
@@ -1624,7 +1624,7 @@
boxsizer.AddWindow(spinctrl, 0, border=0, flag=0)
if element_infos["value"] is not None:
spinctrl.SetValue(element_infos["value"])
- spinctrl.Bind(wx.EVT_SPINCTRL, self.GetTextCtrlCallBackFunction(spinctrl, plugin, element_path), id=id)
+ spinctrl.Bind(wx.EVT_SPINCTRL, self.GetTextCtrlCallBackFunction(spinctrl, confnode, element_path), id=id) choices = cPickle.loads(str(self.Config.Read(element_path, cPickle.dumps([""]))))
textctrl = TextCtrlAutoComplete.TextCtrlAutoComplete(id=id,
@@ -1640,15 +1640,15 @@
boxsizer.AddWindow(textctrl, 0, border=0, flag=0)
if element_infos["value"] is not None:
textctrl.ChangeValue(str(element_infos["value"]))
- textctrl.Bind(wx.EVT_TEXT, self.GetTextCtrlCallBackFunction(textctrl, plugin, element_path))
+ textctrl.Bind(wx.EVT_TEXT, self.GetTextCtrlCallBackFunction(textctrl, confnode, element_path))
- if self.PluginRoot is not None:
- self.PluginRoot.CloseProject()
+ self.ConfNodeInfos = {} + if self.CTR is not None: + self.CTR.CloseProject() self.DebugVariablePanel.SetDataProducer(None)
@@ -1662,7 +1662,7 @@
def OnNewProjectMenu(self, event):
- if self.PluginRoot is not None and not self.CheckSaveBeforeClosing():
+ if self.CTR is not None and not self.CheckSaveBeforeClosing(): if not self.Config.HasEntry("lastopenedfolder"):
@@ -1676,15 +1676,15 @@
self.Config.Write("lastopenedfolder", os.path.dirname(projectpath))
- plugin_root = PluginsRoot(self, self.Log)
- result = plugin_root.NewProject(projectpath)
+ ctr = ConfigTreeRoot(self, self.Log) + result = ctr.NewProject(projectpath) - self.PluginRoot = plugin_root
- self.Controler = self.PluginRoot
+ self.Controler = self.CTR self.LibraryPanel.SetControler(self.Controler)
self.RefreshConfigRecentProjects(projectpath)
- self.DebugVariablePanel.SetDataProducer(self.PluginRoot)
+ self.DebugVariablePanel.SetDataProducer(self.CTR) self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE)
@@ -1694,7 +1694,7 @@
def OnOpenProjectMenu(self, event):
- if self.PluginRoot is not None and not self.CheckSaveBeforeClosing():
+ if self.CTR is not None and not self.CheckSaveBeforeClosing(): if not self.Config.HasEntry("lastopenedfolder"):
@@ -1712,14 +1712,14 @@
self.Config.Write("lastopenedfolder", os.path.dirname(projectpath))
- self.PluginRoot = PluginsRoot(self, self.Log)
- self.Controler = self.PluginRoot
- result = self.PluginRoot.LoadProject(projectpath)
+ self.CTR = ConfigTreeRoot(self, self.Log) + self.Controler = self.CTR + result = self.CTR.LoadProject(projectpath) self.LibraryPanel.SetControler(self.Controler)
self.RefreshConfigRecentProjects(projectpath)
- self.DebugVariablePanel.SetDataProducer(self.PluginRoot)
+ self.DebugVariablePanel.SetDataProducer(self.CTR) self.LoadProjectOrganization()
self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE)
@@ -1731,7 +1731,7 @@
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU)
def OnCloseProjectMenu(self, event):
- if self.PluginRoot is not None and not self.CheckSaveBeforeClosing():
+ if self.CTR is not None and not self.CheckSaveBeforeClosing(): self.SaveProjectOrganization()
@@ -1740,14 +1740,14 @@
def OnSaveProjectMenu(self, event):
- if self.PluginRoot is not None:
- self.PluginRoot.SaveProject()
+ if self.CTR is not None: self._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES)
def OnSaveProjectAsMenu(self, event):
- if self.PluginRoot is not None:
- self.PluginRoot.SaveProjectAs()
+ if self.CTR is not None: + self.CTR.SaveProjectAs() self._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES)
@@ -1765,53 +1765,53 @@
OpenHtmlFrame(self,_("About Beremiz"), Bpath("doc","about.html"), wx.Size(550, 500))
def OnPouSelectedChanged(self, event):
- wx.CallAfter(self.RefreshPluginMenu)
+ wx.CallAfter(self.RefreshConfNodeMenu) IDEFrame.OnPouSelectedChanged(self, event)
def OnPageClose(self, event):
- wx.CallAfter(self.RefreshPluginMenu)
+ wx.CallAfter(self.RefreshConfNodeMenu) IDEFrame.OnPageClose(self, event)
- def GetAddButtonFunction(self, plugin, window):
+ def GetAddButtonFunction(self, confnode, window): def AddButtonFunction(event):
- if plugin and len(plugin.PlugChildsTypes) > 0:
- plugin_menu = wx.Menu(title='')
- for name, XSDClass, help in plugin.PlugChildsTypes:
+ if confnode and len(confnode.PlugChildsTypes) > 0: + confnode_menu = wx.Menu(title='') + for name, XSDClass, help in confnode.PlugChildsTypes: - plugin_menu.Append(help=help, id=new_id, kind=wx.ITEM_NORMAL, text=name)
- self.Bind(wx.EVT_MENU, self._GetAddPluginFunction(name, plugin), id=new_id)
+ confnode_menu.Append(help=help, id=new_id, kind=wx.ITEM_NORMAL, text=name) + self.Bind(wx.EVT_MENU, self._GetAddConfNodeFunction(name, confnode), id=new_id) window_pos = window.GetPosition()
- wx.CallAfter(self.PLCConfig.PopupMenu, plugin_menu)
+ wx.CallAfter(self.PLCConfig.PopupMenu, confnode_menu) - def GetDeleteButtonFunction(self, plugin):
+ def GetDeleteButtonFunction(self, confnode): def DeleteButtonFunction(event):
- wx.CallAfter(self.DeletePlugin, plugin)
+ wx.CallAfter(self.DeleteConfNode, confnode) return DeleteButtonFunction
- def AddPlugin(self, PluginType, plugin):
- if self.PluginRoot.CheckProjectPathPerm():
- dialog = wx.TextEntryDialog(self, _("Please enter a name for plugin:"), _("Add Plugin"), "", wx.OK|wx.CANCEL)
+ def AddConfNode(self, ConfNodeType, confnode): + if self.CTR.CheckProjectPathPerm(): + dialog = wx.TextEntryDialog(self, _("Please enter a name for confnode:"), _("Add ConfNode"), "", wx.OK|wx.CANCEL) if dialog.ShowModal() == wx.ID_OK:
- PluginName = dialog.GetValue()
- plugin.PlugAddChild(PluginName, PluginType)
- self.PluginRoot.RefreshPluginsBlockLists()
+ ConfNodeName = dialog.GetValue() + confnode.PlugAddChild(ConfNodeName, ConfNodeType) + self.CTR.RefreshConfNodesBlockLists() self._Refresh(TITLE, FILEMENU)
- self.RefreshPluginTree()
+ self.RefreshConfNodeTree() - def DeletePlugin(self, plugin):
- if self.PluginRoot.CheckProjectPathPerm():
- dialog = wx.MessageDialog(self, _("Really delete plugin ?"), _("Remove plugin"), wx.YES_NO|wx.NO_DEFAULT)
+ def DeleteConfNode(self, confnode): + if self.CTR.CheckProjectPathPerm(): + dialog = wx.MessageDialog(self, _("Really delete confnode ?"), _("Remove confnode"), wx.YES_NO|wx.NO_DEFAULT) if dialog.ShowModal() == wx.ID_YES:
- self.PluginInfos.pop(plugin)
- self.PluginRoot.RefreshPluginsBlockLists()
+ self.ConfNodeInfos.pop(confnode) + self.CTR.RefreshConfNodesBlockLists() self._Refresh(TITLE, FILEMENU)
- self.RefreshPluginTree()
+ self.RefreshConfNodeTree() #-------------------------------------------------------------------------------
--- a/LPCBeremiz.py Thu May 03 19:02:34 2012 +0200
+++ b/LPCBeremiz.py Mon May 07 18:47:29 2012 +0200
@@ -59,25 +59,25 @@
__builtin__.__dict__['_'] = wx.GetTranslation#unicode_translation
-from plugger import PluginsRoot, PlugTemplate, opjimg, connectors
+from ConfigTree import ConfigTreeRoot, ConfigTreeNode, opjimg, connectors from plcopen.structures import LOCATIONDATATYPES
-from PLCControler import LOCATION_PLUGIN, LOCATION_MODULE, LOCATION_GROUP,\
+from PLCControler import LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP,\ LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY
from PLCOpenEditor import IDEFrame, ProjectDialog
- from plugins.canfestival import RootClass as CanOpenRootClass
- from plugins.canfestival.canfestival import _SlavePlug, _NodeListPlug, NodeManager
+ from confnodes.canfestival import RootClass as CanOpenRootClass + from confnodes.canfestival.canfestival import _SlavePlug, _NodeListPlug, NodeManager #-------------------------------------------------------------------------------
-# CANFESTIVAL PLUGIN HACK
+# CANFESTIVAL CONFNODE HACK #-------------------------------------------------------------------------------
-# from plugins.canfestival import canfestival
+# from confnodes.canfestival import canfestival # class LPC_canfestival_config:
# def getCFLAGS(self, *args):
@@ -148,9 +148,9 @@
if group["type"] == LOCATION_GROUP and child in group["children"]:
group["children"].remove(child)
-BUS_TEXT = """/* Code generated by LPCBus plugin */
+BUS_TEXT = """/* Code generated by LPCBus confnode */ -/* LPCBus plugin includes */
+/* LPCBus confnode includes */ @@ -160,10 +160,10 @@
-/* LPCBus plugin user variables definition */
+/* LPCBus confnode user variables definition */ -/* LPCBus plugin functions */
+/* LPCBus confnode functions */ int __init_%(location_str)s(int argc,char **argv)
@@ -240,7 +240,7 @@
def GetVariableLocationTree(self):
return {"name": self.BaseParams.getName(),
- "type": LOCATION_PLUGIN,
+ "type": LOCATION_CONFNODE, "location": self.GetFullIEC_Channel(),
"children": [self._GetVariableLocationTree(self.GetCurrentLocation(), child)
@@ -291,7 +291,7 @@
def PlugGenerate_C(self, buildpath, locations):
- @param current_location: Tupple containing plugin IEC location : %I0.0.4.5 => (0,0,4,5)
+ @param current_location: Tupple containing confnode IEC location : %I0.0.4.5 => (0,0,4,5) @param locations: List of complete variables locations \
[{"IEC_TYPE" : the IEC type (i.e. "INT", "STRING", ...)
"NAME" : name of the variable (generally "__IW0_1_2" style)
@@ -367,7 +367,7 @@
return [(Gen_Module_path, matiec_flags)],"",True
#-------------------------------------------------------------------------------
-# LPC CanFestival Plugin Class
+# LPC CanFestival ConfNode Class #-------------------------------------------------------------------------------
@@ -444,7 +444,7 @@
- PlugTemplate.LoadChilds(self)
+ ConfigTreeNode.LoadChilds(self) if self.GetChildByName("Master") is None:
master = self.PlugAddChild("Master", "CanOpenNode", 0)
@@ -456,7 +456,7 @@
#-------------------------------------------------------------------------------
+# LPCConfigTreeRoot Class #-------------------------------------------------------------------------------
def mycopytree(src, dst):
@@ -479,9 +479,9 @@
[SIMULATION_MODE, TRANSFER_MODE] = range(2)
-class LPCPluginsRoot(PluginsRoot):
+class LPCConfigTreeRoot(ConfigTreeRoot):
{"bitmap" : opjimg("Debug"),
"tooltip" : _("Simulate PLC"),
@@ -510,7 +510,7 @@
def __init__(self, frame, logger, buildpath):
self.OrigBuildPath = buildpath
- PluginsRoot.__init__(self, frame, logger)
+ ConfigTreeRoot.__init__(self, frame, logger) self.PlugChildsTypes += [("LPCBus", LPCBus, "LPC bus"), ("CanOpen", LPCCanOpen, "CanOpen bus")]
@@ -528,23 +528,23 @@
self.AbortTransferTimer = None
- def PluginLibraryFilePath(self):
+ def ConfNodeLibraryFilePath(self): if self.OrigBuildPath is not None:
return os.path.join(self.OrigBuildPath, "pous.xml")
- return PluginsRoot.PluginLibraryFilePath(self)
+ return ConfigTreeRoot.ConfNodeLibraryFilePath(self) def GetProjectName(self):
return self.Project.getname()
def GetDefaultTargetName(self):
if self.CurrentMode == SIMULATION_MODE:
- return PluginsRoot.GetDefaultTargetName(self)
+ return ConfigTreeRoot.GetDefaultTargetName(self) - target = PluginsRoot.GetTarget(self)
+ target = ConfigTreeRoot.GetTarget(self) if self.CurrentMode != SIMULATION_MODE:
target.getcontent()["value"].setBuildPath(self.BuildPath)
@@ -555,7 +555,7 @@
self.SimulationBuildPath = os.path.join(tempfile.mkdtemp(), os.path.basename(self.ProjectPath), "build")
return self.SimulationBuildPath
- return PluginsRoot._getBuildPath(self)
+ return ConfigTreeRoot._getBuildPath(self) save = self.ProjectTestModified()
@@ -564,7 +564,7 @@
self.AppFrame._Refresh(TITLE, FILEMENU)
if self.BuildPath is not None:
mycopytree(self.OrigBuildPath, self.BuildPath)
- PluginsRoot._Build(self)
+ ConfigTreeRoot._Build(self) wx.CallAfter(self.AppFrame.RefreshAll)
@@ -678,7 +678,7 @@
- # Keep track of the root plugin (i.e. project path)
+ # Keep track of the root confnode (i.e. project path) self.ProjectPath = ProjectPath
self.BuildPath = self._getBuildPath()
@@ -686,8 +686,8 @@
mycopytree(self.OrigBuildPath, self.BuildPath)
# If dir have already be made, and file exist
- if os.path.isdir(self.PlugPath()) and os.path.isfile(self.PluginXmlFilePath()):
- #Load the plugin.xml file into parameters members
+ if os.path.isdir(self.PlugPath()) and os.path.isfile(self.ConfNodeXmlFilePath()): + #Load the confnode.xml file into parameters members result = self.LoadXMLParams()
@@ -703,9 +703,9 @@
- self.RefreshPluginsBlockLists()
+ self.RefreshConfNodesBlockLists() - wx.CallAfter(self.RefreshPluginsBlockLists)
+ wx.CallAfter(self.RefreshConfNodesBlockLists) @@ -889,7 +889,7 @@
self.LocationCFilesAndCFLAGS = []
- # plugin asks for some LDFLAGS
+ # confnode asks for some LDFLAGS # LDFLAGS can be either string
if type(PlugLDFLAGS)==type(str()):
@@ -901,7 +901,7 @@
# Template based part of C code generation
- # files are stacked at the beginning, as files of plugin tree root
+ # files are stacked at the beginning, as files of confnode tree root for generator, filename, name in [
(self.Generate_plc_debugger, "plc_debugger.c", "Debugger"),
@@ -918,7 +918,7 @@
code_path = os.path.join(buildpath,filename)
open(code_path, "w").write(code)
- # Insert this file as first file to be compiled at root plugin
+ # Insert this file as first file to be compiled at root confnode self.LocationCFilesAndCFLAGS[0][1].insert(0,(code_path, self.plcCFLAGS))
self.logger.write_error(name+_(" generation failed !\n"))
@@ -970,7 +970,7 @@
- PluginsRoot._Stop(self)
+ ConfigTreeRoot._Stop(self) if self.CurrentMode == SIMULATION_MODE:
@@ -1001,7 +1001,7 @@
if self.CurrentMode is None and self.OnlineMode != "OFF":
self.CurrentMode = TRANSFER_MODE
- if PluginsRoot._Build(self):
+ if ConfigTreeRoot._Build(self): ID_ABORTTRANSFERTIMER = wx.NewId()
self.AbortTransferTimer = wx.Timer(self.AppFrame, ID_ABORTTRANSFERTIMER)
@@ -1023,7 +1023,7 @@
self.logger.write(_("Start PLC transfer\n"))
self.AbortTransferTimer.Stop()
- PluginsRoot._Transfer(self)
+ ConfigTreeRoot._Transfer(self) self.AbortTransferTimer.Start(milliseconds=5000, oneShot=True)
def AbortTransfer(self, event):
@@ -1113,11 +1113,11 @@
- self.PluginRoot.ResetAppFrame(lpcberemiz_cmd.Log)
- if self.PluginRoot.OnlineMode == 0:
- self.PluginRoot._connector = None
+ self.CTR.ResetAppFrame(lpcberemiz_cmd.Log) + if self.CTR.OnlineMode == 0: + self.CTR._connector = None - self.PluginRoot.KillDebugThread()
+ self.CTR.KillDebugThread() @@ -1141,7 +1141,7 @@
def RefreshFileMenu(self):
MenuToolBar = self.Panes["MenuToolBar"]
- if self.PluginRoot is not None:
+ if self.CTR is not None: selected = self.TabsOpened.GetSelection()
graphic_viewer = isinstance(self.TabsOpened.GetPage(selected), Viewer)
@@ -1163,7 +1163,7 @@
self.FileMenu.Enable(wx.ID_PRINT, False)
MenuToolBar.EnableTool(wx.ID_PRINT, False)
self.FileMenu.Enable(wx.ID_PAGE_SETUP, True)
- project_modified = self.PluginRoot.ProjectTestModified()
+ project_modified = self.CTR.ProjectTestModified() self.FileMenu.Enable(wx.ID_SAVE, project_modified)
MenuToolBar.EnableTool(wx.ID_SAVE, project_modified)
self.FileMenu.Enable(wx.ID_PROPERTIES, True)
@@ -1181,15 +1181,15 @@
self.ClearSizer(self.PLCParamsSizer)
- if self.PluginRoot is not None:
+ if self.CTR is not None: plcwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1))
- if self.PluginRoot.PlugTestModified():
+ if self.CTR.PlugTestModified(): bkgdclr = CHANGED_TITLE_COLOUR
- if self.PluginRoot not in self.PluginInfos:
- self.PluginInfos[self.PluginRoot] = {"right_visible" : False}
+ if self.CTR not in self.ConfNodeInfos: + self.ConfNodeInfos[self.CTR] = {"right_visible" : False} plcwindow.SetBackgroundColour(TITLE_COLOUR)
plcwindow.Bind(wx.EVT_LEFT_DOWN, self.OnPanelLeftDown)
@@ -1200,7 +1200,7 @@
st = wx.StaticText(plcwindow, -1)
st.SetFont(wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"]))
- st.SetLabel(self.PluginRoot.GetProjectName())
+ st.SetLabel(self.CTR.GetProjectName()) plcwindowsizer.AddWindow(st, 0, border=5, flag=wx.ALL|wx.ALIGN_CENTER)
plcwindowmainsizer = wx.BoxSizer(wx.VERTICAL)
@@ -1209,38 +1209,38 @@
plcwindowbuttonsizer = wx.BoxSizer(wx.HORIZONTAL)
plcwindowmainsizer.AddSizer(plcwindowbuttonsizer, 0, border=0, flag=wx.ALIGN_CENTER)
- msizer = self.GenerateMethodButtonSizer(self.PluginRoot, plcwindow, not self.PluginInfos[self.PluginRoot]["right_visible"])
+ msizer = self.GenerateMethodButtonSizer(self.CTR, plcwindow, not self.ConfNodeInfos[self.CTR]["right_visible"]) plcwindowbuttonsizer.AddSizer(msizer, 0, border=0, flag=wx.GROW)
self.PLCConfigMainSizer.Layout()
- def GenerateTreeBranch(self, plugin):
+ def GenerateTreeBranch(self, confnode): leftwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1))
- if plugin.PlugTestModified():
+ if confnode.PlugTestModified(): bkgdclr=CHANGED_WINDOW_COLOUR
leftwindow.SetBackgroundColour(bkgdclr)
- if plugin not in self.PluginInfos:
- self.PluginInfos[plugin] = {"expanded" : False, "left_visible" : False, "right_visible" : False}
+ if confnode not in self.ConfNodeInfos: + self.ConfNodeInfos[confnode] = {"expanded" : False, "left_visible" : False, "right_visible" : False} - self.PluginInfos[plugin]["children"] = plugin.IECSortedChilds()
- plugin_infos = plugin.GetVariableLocationTree()
- if len(self.PluginInfos[plugin]["children"]) == 0:
- plugin_locations = plugin_infos["children"]
- if not self.PluginInfos[plugin].has_key("locations_infos"):
- self.PluginInfos[plugin]["locations_infos"] = {"root": {"expanded" : False}}
+ self.ConfNodeInfos[confnode]["children"] = confnode.IECSortedChilds() + confnode_infos = confnode.GetVariableLocationTree() + confnode_locations = [] + if len(self.ConfNodeInfos[confnode]["children"]) == 0: + confnode_locations = confnode_infos["children"] + if not self.ConfNodeInfos[confnode].has_key("locations_infos"): + self.ConfNodeInfos[confnode]["locations_infos"] = {"root": {"expanded" : False}} - self.PluginInfos[plugin]["locations_infos"]["root"]["left"] = None
- self.PluginInfos[plugin]["locations_infos"]["root"]["right"] = None
- self.PluginInfos[plugin]["locations_infos"]["root"]["children"] = []
+ self.ConfNodeInfos[confnode]["locations_infos"]["root"]["left"] = None + self.ConfNodeInfos[confnode]["locations_infos"]["root"]["right"] = None + self.ConfNodeInfos[confnode]["locations_infos"]["root"]["children"] = [] - self.PluginTreeSizer.AddWindow(leftwindow, 0, border=0, flag=wx.GROW)
+ self.ConfNodeTreeSizer.AddWindow(leftwindow, 0, border=0, flag=wx.GROW) leftwindowvsizer = wx.BoxSizer(wx.VERTICAL)
leftwindow.SetSizer(leftwindowvsizer)
@@ -1248,11 +1248,11 @@
leftwindowsizer = wx.BoxSizer(wx.HORIZONTAL)
leftwindowvsizer.AddSizer(leftwindowsizer, 0, border=0, flag=0)
- self.GenerateEnableButton(leftwindow, leftwindowsizer, plugin)
+ self.GenerateEnableButton(leftwindow, leftwindowsizer, confnode) st = wx.StaticText(leftwindow, -1)
st.SetFont(wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"]))
- st.SetLabel(plugin.GetFullIEC_Channel())
+ st.SetLabel(confnode.GetFullIEC_Channel()) leftwindowsizer.AddWindow(st, 0, border=5, flag=wx.RIGHT)
expandbutton_id = wx.NewId()
@@ -1264,27 +1264,27 @@
expandbutton.SetUseFocusIndicator(False)
expandbutton.SetBitmapSelected(wx.Bitmap(Bpath( 'images', 'minus.png')))
- if len(self.PluginInfos[plugin]["children"]) > 0:
- expandbutton.SetToggle(self.PluginInfos[plugin]["expanded"])
+ if len(self.ConfNodeInfos[confnode]["children"]) > 0: + expandbutton.SetToggle(self.ConfNodeInfos[confnode]["expanded"]) if expandbutton.GetToggle():
- self.ExpandPlugin(plugin)
+ self.ExpandConfNode(confnode) - self.CollapsePlugin(plugin)
- self.PluginInfos[plugin]["expanded"] = expandbutton.GetToggle()
+ self.CollapseConfNode(confnode) + self.ConfNodeInfos[confnode]["expanded"] = expandbutton.GetToggle() self.PLCConfigMainSizer.Layout()
expandbutton.Bind(wx.EVT_BUTTON, togglebutton, id=expandbutton_id)
- elif len(plugin_locations) > 0:
- locations_infos = self.PluginInfos[plugin]["locations_infos"]
+ elif len(confnode_locations) > 0: + locations_infos = self.ConfNodeInfos[confnode]["locations_infos"] expandbutton.SetToggle(locations_infos["root"]["expanded"])
if expandbutton.GetToggle():
self.ExpandLocation(locations_infos, "root")
self.CollapseLocation(locations_infos, "root")
- self.PluginInfos[plugin]["expanded"] = expandbutton.GetToggle()
+ self.ConfNodeInfos[confnode]["expanded"] = expandbutton.GetToggle() locations_infos["root"]["expanded"] = expandbutton.GetToggle()
self.PLCConfigMainSizer.Layout()
@@ -1295,9 +1295,9 @@
leftwindowsizer.AddWindow(expandbutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
sb = wx.StaticBitmap(leftwindow, -1)
- icon = plugin_infos.get("icon", None)
+ icon = confnode_infos.get("icon", None) - icon_bitmap = self.LocationImageList.GetBitmap(self.LocationImageDict[plugin_infos["type"]])
+ icon_bitmap = self.LocationImageList.GetBitmap(self.LocationImageDict[confnode_infos["type"]]) icon_bitmap = wx.Bitmap(icon)
sb.SetBitmap(icon_bitmap)
@@ -1306,21 +1306,21 @@
st = wx.StaticText(leftwindow, st_id, size=wx.DefaultSize, style=wx.NO_BORDER)
st.SetFont(wx.Font(faces["size"] * 0.75, wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"]))
- st.SetLabel(plugin.MandatoryParams[1].getName())
+ st.SetLabel(confnode.MandatoryParams[1].getName()) leftwindowsizer.AddWindow(st, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
- rightwindow = self.GenerateParamsPanel(plugin, bkgdclr)
- self.PluginTreeSizer.AddWindow(rightwindow, 0, border=0, flag=wx.GROW)
+ rightwindow = self.GenerateParamsPanel(confnode, bkgdclr) + self.ConfNodeTreeSizer.AddWindow(rightwindow, 0, border=0, flag=wx.GROW) - self.PluginInfos[plugin]["left"] = leftwindow
- self.PluginInfos[plugin]["right"] = rightwindow
- for child in self.PluginInfos[plugin]["children"]:
+ self.ConfNodeInfos[confnode]["left"] = leftwindow + self.ConfNodeInfos[confnode]["right"] = rightwindow + for child in self.ConfNodeInfos[confnode]["children"]: self.GenerateTreeBranch(child)
- if not self.PluginInfos[child]["expanded"]:
- self.CollapsePlugin(child)
+ if not self.ConfNodeInfos[child]["expanded"]: + self.CollapseConfNode(child) - if len(plugin_locations) > 0:
- locations_infos = self.PluginInfos[plugin]["locations_infos"]
+ if len(confnode_locations) > 0: + locations_infos = self.ConfNodeInfos[confnode]["locations_infos"] treectrl = wx.TreeCtrl(self.PLCConfig, -1, size=wx.DefaultSize,
style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.NO_BORDER|wx.TR_HIDE_ROOT|wx.TR_NO_LINES|wx.TR_LINES_AT_ROOT)
treectrl.SetImageList(self.LocationImageList)
@@ -1329,15 +1329,15 @@
treectrl.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.GenerateLocationExpandCollapseFunction(locations_infos, False))
- self.PluginTreeSizer.AddWindow(treectrl, 0, border=0, flag=0)
+ self.ConfNodeTreeSizer.AddWindow(treectrl, 0, border=0, flag=0) rightwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1))
rightwindow.SetBackgroundColour(wx.WHITE)
- self.PluginTreeSizer.AddWindow(rightwindow, 0, border=0, flag=wx.GROW)
+ self.ConfNodeTreeSizer.AddWindow(rightwindow, 0, border=0, flag=wx.GROW) locations_infos["root"]["left"] = treectrl
locations_infos["root"]["right"] = rightwindow
- for location in plugin_locations:
+ for location in confnode_locations: locations_infos["root"]["children"].append("root.%s" % location["name"])
self.GenerateLocationTreeBranch(treectrl, treectrl.GetRootItem(), locations_infos, "root", location)
if locations_infos["root"]["expanded"]:
@@ -1416,11 +1416,11 @@
- def __init__(self, PluginRoot, Log):
+ def __init__(self, CTR, Log): cmd.Cmd.__init__(self, stdin=Log, stdout=Log)
self.use_rawinput = False
- self.PluginRoot = PluginRoot
if self.RefreshTimer is not None:
@@ -1440,7 +1440,7 @@
- self.PluginRoot.SetAppFrame(frame, frame.Log)
+ self.CTR.SetAppFrame(frame, frame.Log) @@ -1454,77 +1454,77 @@
- self.PluginRoot.ResetAppFrame(self.Log)
+ self.CTR.ResetAppFrame(self.Log) - self.PluginRoot._Build()
def SetProjectProperties(self, projectname, productname, productversion, companyname):
- properties = self.PluginRoot.GetProjectProperties()
+ properties = self.CTR.GetProjectProperties() new_properties = properties.copy()
new_properties["projectName"] = projectname
new_properties["productName"] = productname
new_properties["productVersion"] = productversion
new_properties["companyName"] = companyname
if new_properties != properties:
- self.PluginRoot.SetProjectProperties(properties=new_properties, buffer=False)
+ self.CTR.SetProjectProperties(properties=new_properties, buffer=False) def SetOnlineMode(self, mode, path=None):
- self.PluginRoot.SetOnlineMode(mode, path)
+ self.CTR.SetOnlineMode(mode, path) def AddBus(self, iec_channel, name, icon=None):
- for child in self.PluginRoot.IterChilds():
+ for child in self.CTR.IterChilds(): if child.BaseParams.getName() == name:
return "Error: A bus named %s already exists\n" % name
elif child.BaseParams.getIEC_Channel() == iec_channel:
return "Error: A bus with IEC_channel %d already exists\n" % iec_channel
- bus = self.PluginRoot.PlugAddChild(name, "LPCBus", iec_channel)
+ bus = self.CTR.PlugAddChild(name, "LPCBus", iec_channel) return "Error: Unable to create bus\n"
def RenameBus(self, iec_channel, name):
- bus = self.PluginRoot.GetChildByIECLocation((iec_channel,))
+ bus = self.CTR.GetChildByIECLocation((iec_channel,)) return "Error: No bus found\n"
- for child in self.PluginRoot.IterChilds():
+ for child in self.CTR.IterChilds(): if child != bus and child.BaseParams.getName() == name:
return "Error: A bus named %s already exists\n" % name
bus.BaseParams.setName(name)
def ChangeBusIECChannel(self, old_iec_channel, new_iec_channel):
- bus = self.PluginRoot.GetChildByIECLocation((old_iec_channel,))
+ bus = self.CTR.GetChildByIECLocation((old_iec_channel,)) return "Error: No bus found\n"
- for child in self.PluginRoot.IterChilds():
+ for child in self.CTR.IterChilds(): if child != bus and child.BaseParams.getIEC_Channel() == new_iec_channel:
return "Error: A bus with IEC_channel %d already exists\n" % new_iec_channel
- self.PluginRoot.UpdateProjectVariableLocation(str(old_iec_channel),
+ self.CTR.UpdateProjectVariableLocation(str(old_iec_channel), - self.PluginRoot.UpdateProjectVariableLocation(
+ self.CTR.UpdateProjectVariableLocation( bus.BaseParams.setIEC_Channel(new_iec_channel)
def RemoveBus(self, iec_channel):
- bus = self.PluginRoot.GetChildByIECLocation((iec_channel,))
+ bus = self.CTR.GetChildByIECLocation((iec_channel,)) return "Error: No bus found\n"
- self.PluginRoot.RemoveProjectVariableByFilter(str(iec_channel))
- self.PluginRoot.PluggedChilds["LPCBus"].remove(bus)
+ self.CTR.RemoveProjectVariableByFilter(str(iec_channel)) + self.CTR.PluggedChilds["LPCBus"].remove(bus) def AddModule(self, parent, iec_channel, name, icode, icon=None):
- module = self.PluginRoot.GetChildByIECLocation(parent)
+ module = self.CTR.GetChildByIECLocation(parent) return "Error: No parent found\n"
for child in _GetModuleChildren(module):
@@ -1541,11 +1541,11 @@
def RenameModule(self, iec_location, name):
- module = self.PluginRoot.GetChildByIECLocation(iec_location)
+ module = self.CTR.GetChildByIECLocation(iec_location) return "Error: No module found\n"
- parent = self.PluginRoot.GetChildByIECLocation(iec_location[:-1])
- if parent is self.PluginRoot:
+ parent = self.CTR.GetChildByIECLocation(iec_location[:-1]) return "Error: No module found\n"
if module["name"] != name:
for child in _GetModuleChildren(parent):
@@ -1555,39 +1555,39 @@
def ChangeModuleIECChannel(self, old_iec_location, new_iec_channel):
- module = self.PluginRoot.GetChildByIECLocation(old_iec_location)
+ module = self.CTR.GetChildByIECLocation(old_iec_location) return "Error: No module found\n"
- parent = self.PluginRoot.GetChildByIECLocation(old_iec_location[:-1])
- if parent is self.PluginRoot:
+ parent = self.CTR.GetChildByIECLocation(old_iec_location[:-1]) return "Error: No module found\n"
if module["IEC_Channel"] != new_iec_channel:
for child in _GetModuleChildren(parent):
if child["IEC_Channel"] == new_iec_channel:
return "Error: A module with IEC_channel %d already exists\n" % new_iec_channel
- self.PluginRoot.UpdateProjectVariableLocation(".".join(map(str, old_iec_location)), ".".join(map(str, old_iec_location[:1] + (new_iec_channel,))))
+ self.CTR.UpdateProjectVariableLocation(".".join(map(str, old_iec_location)), ".".join(map(str, old_iec_location[:1] + (new_iec_channel,)))) module["IEC_Channel"] = new_iec_channel
def ChangeModuleInitCode(self, iec_location, icode):
- module = self.PluginRoot.GetChildByIECLocation(iec_location)
+ module = self.CTR.GetChildByIECLocation(iec_location) return "Error: No module found\n"
def RemoveModule(self, parent, iec_channel):
- module = self.PluginRoot.GetChildByIECLocation(parent)
+ module = self.CTR.GetChildByIECLocation(parent) return "Error: No parent found\n"
child = _GetModuleBySomething(module, "IEC_Channel", (iec_channel,))
return "Error: No module found\n"
- self.PluginRoot.RemoveProjectVariableByFilter(".".join(map(str, parent + (iec_channel,))))
+ self.CTR.RemoveProjectVariableByFilter(".".join(map(str, parent + (iec_channel,)))) _RemoveModuleChild(module, child)
def StartGroup(self, parent, name, icon=None):
- module = self.PluginRoot.GetChildByIECLocation(parent)
+ module = self.CTR.GetChildByIECLocation(parent) return "Error: No parent found\n"
for child in module["children"]:
@@ -1600,7 +1600,7 @@
def AddVariable(self, parent, location, name, direction, type, rcode, pcode, description=""):
- module = self.PluginRoot.GetChildByIECLocation(parent)
+ module = self.CTR.GetChildByIECLocation(parent) return "Error: No parent found\n"
for child in _GetModuleChildren(module):
@@ -1618,7 +1618,7 @@
def ChangeVariableParams(self, parent, location, new_name, new_direction, new_type, new_rcode, new_pcode, new_description=None):
- module = self.PluginRoot.GetChildByIECLocation(parent)
+ module = self.CTR.GetChildByIECLocation(parent) return "Error: No parent found\n"
@@ -1630,7 +1630,7 @@
return "Error: No variable found\n"
if variable["name"] != new_name:
- self.PluginRoot.UpdateProjectVariableName(variable["name"], new_name)
+ self.CTR.UpdateProjectVariableName(variable["name"], new_name) variable["name"] = new_name
variable["type"] = LOCATION_TYPES[new_direction]
variable["IEC_type"] = new_type
@@ -1641,15 +1641,15 @@
def RemoveVariable(self, parent, location, direction):
- module = self.PluginRoot.GetChildByIECLocation(parent)
+ module = self.CTR.GetChildByIECLocation(parent) return "Error: No parent found\n"
child = _GetModuleVariable(module, location, direction)
return "Error: No variable found\n"
- size = LOCATION_SIZES[self.PluginRoot.GetBaseType(child["IEC_type"])]
+ size = LOCATION_SIZES[self.CTR.GetBaseType(child["IEC_type"])] address = "%" + LOCATION_DIRS[child["type"]] + size + ".".join(map(str, parent + location))
- self.PluginRoot.RemoveProjectVariableByAddress(address)
+ self.CTR.RemoveProjectVariableByAddress(address) _RemoveModuleChild(module, child)
@@ -1714,7 +1714,7 @@
- def CmdThreadProc(PluginRoot, Log):
+ def CmdThreadProc(CTR, Log): for function, (arg_types, opt) in {"Exit": ([], 0),
@@ -1738,26 +1738,26 @@
"RemoveVariable": ([location, location], 0)}.iteritems():
setattr(LPCBeremiz_Cmd, "do_%s" % function, GetCmdFunction(function, arg_types, opt))
- lpcberemiz_cmd = LPCBeremiz_Cmd(PluginRoot, Log)
+ lpcberemiz_cmd = LPCBeremiz_Cmd(CTR, Log) Log = StdoutPseudoFile(port)
- PluginRoot = LPCPluginsRoot(None, Log, buildpath)
+ CTR = LPCConfigTreeRoot(None, Log, buildpath) if projectOpen is not None and os.path.isdir(projectOpen):
- result = PluginRoot.LoadProject(projectOpen)
+ result = CTR.LoadProject(projectOpen) Log.write("Error: Invalid project directory", result)
Log.write("Error: No such file or directory")
- cmd_thread=Thread(target=CmdThreadProc, args=[PluginRoot, Log])
+ cmd_thread=Thread(target=CmdThreadProc, args=[CTR, Log]) # Install a exception handle for bug reports
AddExceptHook(os.getcwd(),__version__)
- frame = LPCBeremiz(None, plugin_root=PluginRoot, debug=True)
+ frame = LPCBeremiz(None, ctr=CTR, debug=True)