--- a/Beremiz.py Mon May 07 18:47:29 2012 +0200
+++ b/Beremiz.py Mon May 07 19:19:08 2012 +0200
@@ -674,7 +674,7 @@
- return ("confnode", tab.Controler.PlugFullName())
+ return ("confnode", tab.Controler.CTNFullName()) elif (isinstance(tab, TextViewer) and
(tab.Controler is None or isinstance(tab.Controler, MiniTextControler))):
return ("confnode", None, tab.GetInstancePath())
@@ -852,7 +852,7 @@
plcwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1))
- if self.CTR.PlugTestModified():
+ if self.CTR.CTNTestModified(): bkgdclr = CHANGED_TITLE_COLOUR
@@ -933,7 +933,7 @@
def GenerateEnableButton(self, parent, sizer, confnode):
- enabled = confnode.PlugEnabled()
+ enabled = confnode.CTNEnabled() enablebutton_id = wx.NewId()
enablebutton = wx.lib.buttons.GenBitmapToggleButton(id=enablebutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'Disabled.png')),
@@ -1046,7 +1046,7 @@
self.ClearSizer(self.ConfNodeTreeSizer)
- for child in self.CTR.IECSortedChilds():
+ for child in self.CTR.IECSortedChildren(): self.GenerateTreeBranch(child)
if not self.ConfNodeInfos[child]["expanded"]:
self.CollapseConfNode(child)
@@ -1131,7 +1131,7 @@
def GenerateTreeBranch(self, confnode):
leftwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1))
- if confnode.PlugTestModified():
+ if confnode.CTNTestModified(): bkgdclr=CHANGED_WINDOW_COLOUR
@@ -1141,7 +1141,7 @@
if not self.ConfNodeInfos.has_key(confnode):
self.ConfNodeInfos[confnode] = {"expanded" : False, "right_visible" : False}
- self.ConfNodeInfos[confnode]["children"] = confnode.IECSortedChilds()
+ self.ConfNodeInfos[confnode]["children"] = confnode.IECSortedChildren() if len(self.ConfNodeInfos[confnode]["children"]) == 0:
confnode_locations = confnode.GetVariableLocationTree()["children"]
@@ -1174,7 +1174,7 @@
#self.GenerateEnableButton(leftwindow, rolesizer, confnode)
roletext = wx.StaticText(leftwindow, -1)
- roletext.SetLabel(confnode.PlugHelp)
+ roletext.SetLabel(confnode.CTNHelp) rolesizer.AddWindow(roletext, 0, border=5, flag=wx.RIGHT|wx.ALIGN_LEFT)
confnode_IECChannel = confnode.BaseParams.getIEC_Channel()
@@ -1216,7 +1216,7 @@
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(confnode.PlugChildsTypes) > 0:
+ if len(confnode.CTNChildrenTypes) > 0: addbutton_id = wx.NewId()
addbutton = wx.lib.buttons.GenBitmapButton(id=addbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'Add.png')),
name='AddConfNodeButton', parent=leftwindow, pos=wx.Point(0, 0),
@@ -1415,8 +1415,8 @@
def Gen_AddConfNodeMenu(self, confnode):
def AddConfNodeMenu(event):
main_menu = wx.Menu(title='')
- if len(confnode.PlugChildsTypes) > 0:
- for name, XSDClass, help in confnode.PlugChildsTypes:
+ if len(confnode.CTNChildrenTypes) > 0: + for name, XSDClass, help in confnode.CTNChildrenTypes: main_menu.Append(help=help, id=new_id, kind=wx.ITEM_NORMAL, text=_("Append ")+help)
self.Bind(wx.EVT_MENU, self._GetAddConfNodeFunction(name, confnode), id=new_id)
@@ -1774,9 +1774,9 @@
def GetAddButtonFunction(self, confnode, window):
def AddButtonFunction(event):
- if confnode and len(confnode.PlugChildsTypes) > 0:
+ if confnode and len(confnode.CTNChildrenTypes) > 0: confnode_menu = wx.Menu(title='')
- for name, XSDClass, help in confnode.PlugChildsTypes:
+ for name, XSDClass, help in confnode.CTNChildrenTypes: 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)
@@ -1796,7 +1796,7 @@
dialog = wx.TextEntryDialog(self, _("Please enter a name for confnode:"), _("Add ConfNode"), "", wx.OK|wx.CANCEL)
if dialog.ShowModal() == wx.ID_OK:
ConfNodeName = dialog.GetValue()
- confnode.PlugAddChild(ConfNodeName, ConfNodeType)
+ confnode.CTNAddChild(ConfNodeName, ConfNodeType) self.CTR.RefreshConfNodesBlockLists()
self._Refresh(TITLE, FILEMENU)
self.RefreshConfNodeTree()
@@ -1807,7 +1807,7 @@
dialog = wx.MessageDialog(self, _("Really delete confnode ?"), _("Remove confnode"), wx.YES_NO|wx.NO_DEFAULT)
if dialog.ShowModal() == wx.ID_YES:
self.ConfNodeInfos.pop(confnode)
self.CTR.RefreshConfNodesBlockLists()
self._Refresh(TITLE, FILEMENU)
--- a/ConfigTree.py Mon May 07 18:47:29 2012 +0200
+++ b/ConfigTree.py Mon May 07 19:19:08 2012 +0200
@@ -36,7 +36,7 @@
def __init__(self, filepath):
- def PlugFullName(self):
def SetEditedElementText(self, tagname, text):
@@ -96,21 +96,21 @@
def _AddParamsMembers(self):
self.Classes = GenerateClassesFromXSDstring(self.XSD)
Classes = [(name, XSDclass) for name, XSDclass in self.Classes.items() if XSDclass.IsBaseClass]
name, XSDclass = Classes[0]
- self.PlugParams = (name, obj)
+ self.CTNParams = (name, obj) @@ -118,65 +118,65 @@
self.BaseParams = _BaseParamsClass()
self.MandatoryParams = ("BaseParams", self.BaseParams)
- self.PluggedChilds = {}
# copy ConfNodeMethods so that it can be later customized
self.ConfNodeMethods = [dic.copy() for dic in self.ConfNodeMethods]
- def ConfNodeBaseXmlFilePath(self, PlugName=None):
- return os.path.join(self.PlugPath(PlugName), "baseconfnode.xml")
+ def ConfNodeBaseXmlFilePath(self, CTNName=None): + return os.path.join(self.CTNPath(CTNName), "baseconfnode.xml") - def ConfNodeXmlFilePath(self, PlugName=None):
- return os.path.join(self.PlugPath(PlugName), "confnode.xml")
+ def ConfNodeXmlFilePath(self, CTNName=None): + return os.path.join(self.CTNPath(CTNName), "confnode.xml") def ConfNodeLibraryFilePath(self):
return os.path.join(self.ConfNodePath(), "pous.xml")
- return os.path.join(self.PlugParent.ConfNodePath(), self.PlugType)
+ return os.path.join(self.CTNParent.ConfNodePath(), self.CTNType) - def PlugPath(self,PlugName=None):
- PlugName = self.PlugName()
- return os.path.join(self.PlugParent.PlugPath(),
- PlugName + NameTypeSeparator + self.PlugType)
+ def CTNPath(self,CTNName=None): + CTNName = self.CTNName() + return os.path.join(self.CTNParent.CTNPath(), + CTNName + NameTypeSeparator + self.CTNType)
return self.BaseParams.getName()
return self.BaseParams.getEnabled()
- def PlugFullName(self):
- parent = self.PlugParent.PlugFullName()
+ parent = self.CTNParent.CTNFullName() - return parent + "." + self.PlugName()
+ return parent + "." + self.CTNName() return self.BaseParams.getName()
def GetIconPath(self, name):
- def PlugTestModified(self):
+ def CTNTestModified(self): return self.ChangesToSave
def ProjectTestModified(self):
recursively check modified status
- if self.PlugTestModified():
+ if self.CTNTestModified(): - for PlugChild in self.IterChilds():
- if PlugChild.ProjectTestModified():
+ for CTNChild in self.IterChildren(): + if CTNChild.ProjectTestModified(): def RemoteExec(self, script, **kwargs):
- return self.PlugParent.RemoteExec(script, **kwargs)
+ return self.CTNParent.RemoteExec(script, **kwargs)
#Default, do nothing and return success
@@ -185,14 +185,14 @@
parts = path.split(".", 1)
if self.MandatoryParams and parts[0] == self.MandatoryParams[0]:
return self.MandatoryParams[1].getElementInfos(parts[0], parts[1])
- elif self.PlugParams and parts[0] == self.PlugParams[0]:
- return self.PlugParams[1].getElementInfos(parts[0], parts[1])
+ elif self.CTNParams and parts[0] == self.CTNParams[0]: + return self.CTNParams[1].getElementInfos(parts[0], parts[1]) if wx.VERSION < (2, 8, 0) and self.MandatoryParams:
params.append(self.MandatoryParams[1].getElementInfos(self.MandatoryParams[0]))
- params.append(self.PlugParams[1].getElementInfos(self.PlugParams[0]))
+ params.append(self.CTNParams[1].getElementInfos(self.CTNParams[0])) def SetParamsAttribute(self, path, value):
@@ -201,31 +201,31 @@
if path == "BaseParams.IEC_Channel":
old_leading = ".".join(map(str, self.GetCurrentLocation()))
new_value = self.FindNewIEC_Channel(value)
- new_leading = ".".join(map(str, self.PlugParent.GetCurrentLocation() + (new_value,)))
- self.GetPlugRoot().UpdateProjectVariableLocation(old_leading, new_leading)
+ new_leading = ".".join(map(str, self.CTNParent.GetCurrentLocation() + (new_value,))) + self.GetCTRoot().UpdateProjectVariableLocation(old_leading, new_leading) elif path == "BaseParams.Name":
res = self.FindNewName(value)
parts = path.split(".", 1)
if self.MandatoryParams and parts[0] == self.MandatoryParams[0]:
self.MandatoryParams[1].setElementValue(parts[1], value)
- elif self.PlugParams and parts[0] == self.PlugParams[0]:
- self.PlugParams[1].setElementValue(parts[1], value)
+ elif self.CTNParams and parts[0] == self.CTNParams[0]: + self.CTNParams[1].setElementValue(parts[1], value)
- os.mkdir(self.PlugPath())
+ os.mkdir(self.CTNPath()) - def PlugRequestSave(self):
- if self.GetPlugRoot().CheckProjectPathPerm(False):
+ def CTNRequestSave(self): + if self.GetCTRoot().CheckProjectPathPerm(False): # If confnode do not have corresponding directory
- plugpath = self.PlugPath()
- if not os.path.isdir(plugpath):
+ ctnpath = self.CTNPath() + if not os.path.isdir(ctnpath):
# generate XML for base XML parameters controller of the confnode
@@ -235,31 +235,31 @@
# generate XML for XML parameters controller of the confnode
XMLFile = open(self.ConfNodeXmlFilePath(),'w')
XMLFile.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
- XMLFile.write(self.PlugParams[1].generateXMLText(self.PlugParams[0], 0).encode("utf-8"))
+ XMLFile.write(self.CTNParams[1].generateXMLText(self.CTNParams[0], 0).encode("utf-8")) - # Call the confnode specific OnPlugSave method
- result = self.OnPlugSave()
+ # Call the confnode specific OnCTNSave method + result = self.OnCTNSave() - return _("Error while saving \"%s\"\n")%self.PlugPath()
+ return _("Error while saving \"%s\"\n")%self.CTNPath() self.ChangesToSave = False
- # go through all childs and do the same
- for PlugChild in self.IterChilds():
- result = PlugChild.PlugRequestSave()
+ # go through all children and do the same + for CTNChild in self.IterChildren(): + result = CTNChild.CTNRequestSave() - def PlugImport(self, src_PlugPath):
- shutil.copytree(src_PlugPath, self.PlugPath)
+ def CTNImport(self, src_CTNPath): + shutil.copytree(src_CTNPath, self.CTNPath) - def PlugGenerate_C(self, buildpath, locations):
+ def CTNGenerate_C(self, buildpath, locations): @param locations: List of complete variables locations \
@@ -271,39 +271,39 @@
@return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND
- self.GetPlugRoot().logger.write_warning(".".join(map(lambda x:str(x), self.GetCurrentLocation())) + " -> Nothing to do\n")
+ self.GetCTRoot().logger.write_warning(".".join(map(lambda x:str(x), self.GetCurrentLocation())) + " -> Nothing to do\n") def _Generate_C(self, buildpath, locations):
# Generate confnodes [(Cfiles, CFLAGS)], LDFLAGS, DoCalls, extra_files
# extra_files = [(fname,fobject), ...]
- gen_result = self.PlugGenerate_C(buildpath, locations)
- PlugCFilesAndCFLAGS, PlugLDFLAGS, DoCalls = gen_result[:3]
+ gen_result = self.CTNGenerate_C(buildpath, locations) + CTNCFilesAndCFLAGS, CTNLDFLAGS, DoCalls = gen_result[:3] extra_files = gen_result[3:]
# if some files have been generated put them in the list with their location
- if PlugCFilesAndCFLAGS:
- LocationCFilesAndCFLAGS = [(self.GetCurrentLocation(), PlugCFilesAndCFLAGS, DoCalls)]
+ LocationCFilesAndCFLAGS = [(self.GetCurrentLocation(), CTNCFilesAndCFLAGS, DoCalls)] LocationCFilesAndCFLAGS = []
# confnode asks for some LDFLAGS
# LDFLAGS can be either string
- if type(PlugLDFLAGS)==type(str()):
+ if type(CTNLDFLAGS)==type(str()): - elif type(PlugLDFLAGS)==type(list()):
+ elif type(CTNLDFLAGS)==type(list()): - # recurse through all childs, and stack their results
- for PlugChild in self.IECSortedChilds():
- new_location = PlugChild.GetCurrentLocation()
+ # recurse through all children, and stack their results + for CTNChild in self.IECSortedChildren(): + new_location = CTNChild.GetCurrentLocation() # How deep are we in the tree ?
_LocationCFilesAndCFLAGS, _LDFLAGS, _extra_files = \
# filter locations that start with current IEC location
@@ -317,16 +317,16 @@
def ConfNodeTypesFactory(self):
if self.LibraryControler is not None:
- return [{"name" : self.PlugType, "types": self.LibraryControler.Project}]
+ return [{"name" : self.CTNType, "types": self.LibraryControler.Project}] def ParentsTypesFactory(self):
- return self.PlugParent.ParentsTypesFactory() + self.ConfNodeTypesFactory()
+ return self.CTNParent.ParentsTypesFactory() + self.ConfNodeTypesFactory() def ConfNodesTypesFactory(self):
list = self.ConfNodeTypesFactory()
- for PlugChild in self.IterChilds():
- list += PlugChild.ConfNodesTypesFactory()
+ for CTNChild in self.IterChildren(): + list += CTNChild.ConfNodesTypesFactory() def STLibraryFactory(self):
@@ -337,18 +337,18 @@
def ConfNodesSTLibraryFactory(self):
program = self.STLibraryFactory()
- for PlugChild in self.IECSortedChilds():
- program += PlugChild.ConfNodesSTLibraryFactory()
+ for CTNChild in self.IECSortedChildren(): + program += CTNChild.ConfNodesSTLibraryFactory()
- for PlugType, PluggedChilds in self.PluggedChilds.items():
- for PlugInstance in PluggedChilds:
+ def IterChildren(self): + for CTNType, Children in self.Children.items(): + for CTNInstance in Children: - def IECSortedChilds(self):
- # reorder childs by IEC_channels
- ordered = [(chld.BaseParams.getIEC_Channel(),chld) for chld in self.IterChilds()]
+ def IECSortedChildren(self): + # reorder children by IEC_channels + ordered = [(chld.BaseParams.getIEC_Channel(),chld) for chld in self.IterChildren()] @@ -356,15 +356,15 @@
def _GetChildBySomething(self, something, toks):
- for PlugInstance in self.IterChilds():
+ for CTNInstance in self.IterChildren(): # if match component of the name
- if getattr(PlugInstance.BaseParams, something) == toks[0]:
+ if getattr(CTNInstance.BaseParams, something) == toks[0]: # if Name have other components
# Recurse in order to find the latest object
- return PlugInstance._GetChildBySomething( something, toks[1:])
+ return CTNInstance._GetChildBySomething( something, toks[1:])
@@ -385,29 +385,29 @@
@return: Tupple containing confnode IEC location of current confnode : %I0.0.4.5 => (0,0,4,5)
- return self.PlugParent.GetCurrentLocation() + (self.BaseParams.getIEC_Channel(),)
+ return self.CTNParent.GetCurrentLocation() + (self.BaseParams.getIEC_Channel(),) def GetCurrentName(self):
@return: String "ParentParentName.ParentName.Name"
- return self.PlugParent._GetCurrentName() + self.BaseParams.getName()
+ return self.CTNParent._GetCurrentName() + self.BaseParams.getName() def _GetCurrentName(self):
@return: String "ParentParentName.ParentName.Name."
- return self.PlugParent._GetCurrentName() + self.BaseParams.getName() + "."
+ return self.CTNParent._GetCurrentName() + self.BaseParams.getName() + "."
- return self.PlugParent.GetPlugRoot()
+ return self.CTNParent.GetCTRoot() def GetFullIEC_Channel(self):
return ".".join([str(i) for i in self.GetCurrentLocation()]) + ".x"
location = self.GetCurrentLocation()
- return [loc for loc in self.PlugParent.GetLocations() if loc["LOC"][0:len(location)] == location]
+ return [loc for loc in self.CTNParent.GetLocations() if loc["LOC"][0:len(location)] == location] def GetVariableLocationTree(self):
@@ -419,7 +419,7 @@
- location is a string of this variable's location, like "%IX0.0.0"
- for child in self.IECSortedChilds():
+ for child in self.IECSortedChildren(): children.append(child.GetVariableLocationTree())
return {"name": self.BaseParams.getName(),
"type": LOCATION_CONFNODE,
@@ -435,11 +435,11 @@
CurrentName = self.BaseParams.getName()
# Do nothing if no change
#if CurrentName == DesiredName: return CurrentName
- # Build a list of used Name out of parent's PluggedChilds
+ # Build a list of used Name out of parent's Children - for PlugInstance in self.PlugParent.IterChilds():
- if PlugInstance != self:
- AllNames.append(PlugInstance.BaseParams.getName())
+ for CTNInstance in self.CTNParent.IterChildren(): + if CTNInstance != self: + AllNames.append(CTNInstance.BaseParams.getName()) # Find a free name, eventually appending digit
@@ -449,24 +449,24 @@
- oldname = self.PlugPath()
+ oldname = self.CTNPath() # Check previous confnode existance
dontexist = self.BaseParams.getName() == "__unnamed__"
self.BaseParams.setName(res)
# Rename confnode dir if exist
- shutil.move(oldname, self.PlugPath())
+ shutil.move(oldname, self.CTNPath()) # warn user he has two left hands
- self.GetPlugRoot().logger.write_warning(_("A child names \"%s\" already exist -> \"%s\"\n")%(DesiredName,res))
+ self.GetCTRoot().logger.write_warning(_("A child names \"%s\" already exist -> \"%s\"\n")%(DesiredName,res)) def GetAllChannels(self):
- for PlugInstance in self.PlugParent.IterChilds():
- if PlugInstance != self:
- AllChannels.append(PlugInstance.BaseParams.getIEC_Channel())
+ for CTNInstance in self.CTNParent.IterChildren(): + if CTNInstance != self: + AllChannels.append(CTNInstance.BaseParams.getIEC_Channel()) @@ -479,7 +479,7 @@
CurrentChannel = self.BaseParams.getIEC_Channel()
# Do nothing if no change
#if CurrentChannel == DesiredChannel: return CurrentChannel
- # Build a list of used Channels out of parent's PluggedChilds
+ # Build a list of used Channels out of parent's Children AllChannels = self.GetAllChannels()
# Now, try to guess the nearest available channel
@@ -488,7 +488,7 @@
if res < CurrentChannel: # Want to go down ?
- self.GetPlugRoot().logger.write_warning(_("Cannot find lower free IEC channel than %d\n")%CurrentChannel)
+ self.GetCTRoot().logger.write_warning(_("Cannot find lower free IEC channel than %d\n")%CurrentChannel) return CurrentChannel # Can't go bellow 0, do nothing
@@ -498,11 +498,11 @@
def _OpenView(self, name=None):
if self.EditorType is not None and self._View is None:
- app_frame = self.GetPlugRoot().AppFrame
+ app_frame = self.GetCTRoot().AppFrame self._View = self.EditorType(app_frame.TabsOpened, self, app_frame)
- app_frame.EditProjectElement(self._View, self.PlugName())
+ app_frame.EditProjectElement(self._View, self.CTNName()) @@ -511,103 +511,103 @@
if self._View is not None:
- app_frame = self.GetPlugRoot().AppFrame
+ app_frame = self.GetCTRoot().AppFrame if app_frame is not None:
app_frame.DeletePage(self._View)
- def _doRemoveChild(self, PlugInstance):
- # Remove all childs of child
- for SubPlugInstance in PlugInstance.IterChilds():
- PlugInstance._doRemoveChild(SubPlugInstance)
+ def _doRemoveChild(self, CTNInstance): + # Remove all children of child + for SubCTNInstance in CTNInstance.IterChildren(): + CTNInstance._doRemoveChild(SubCTNInstance) - PlugInstance.OnPlugClose()
+ CTNInstance.OnCTNClose() - shutil.rmtree(PlugInstance.PlugPath())
- # Remove child of PluggedChilds
- self.PluggedChilds[PlugInstance.PlugType].remove(PlugInstance)
+ shutil.rmtree(CTNInstance.CTNPath()) + # Remove child of Children + self.Children[CTNInstance.CTNType].remove(CTNInstance) # Forget it... (View have to refresh)
- #PlugInstance = self.GetChildByName(PlugName)
+ #CTNInstance = self.GetChildByName(CTNName) # Ask to his parent to remove it
- self.PlugParent._doRemoveChild(self)
+ self.CTNParent._doRemoveChild(self) - def PlugAddChild(self, PlugName, PlugType, IEC_Channel=0):
+ def CTNAddChild(self, CTNName, CTNType, IEC_Channel=0): Create the confnodes that may be added as child to this node self
- @param PlugType: string desining the confnode class name (get name from PlugChildsTypes)
- @param PlugName: string for the name of the confnode instance
+ @param CTNType: string desining the confnode class name (get name from CTNChildrenTypes) + @param CTNName: string for the name of the confnode instance - # reorgabize self.PlugChildsTypes tuples from (name, PlugClass, Help)
- # to ( name, (PlugClass, Help)), an make a dict
- transpose = zip(*self.PlugChildsTypes)
- PlugChildsTypes = dict(zip(transpose[0],zip(transpose[1],transpose[2])))
+ # reorgabize self.CTNChildrenTypes tuples from (name, CTNClass, Help) + # to ( name, (CTNClass, Help)), an make a dict + transpose = zip(*self.CTNChildrenTypes) + CTNChildrenTypes = dict(zip(transpose[0],zip(transpose[1],transpose[2]))) # Check that adding this confnode is allowed
- PlugClass, PlugHelp = PlugChildsTypes[PlugType]
+ CTNClass, CTNHelp = CTNChildrenTypes[CTNType] - raise Exception, _("Cannot create child %s of type %s ")%(PlugName, PlugType)
+ raise Exception, _("Cannot create child %s of type %s ")%(CTNName, CTNType) - # if PlugClass is a class factory, call it. (prevent unneeded imports)
- if type(PlugClass) == types.FunctionType:
- PlugClass = PlugClass()
+ # if CTNClass is a class factory, call it. (prevent unneeded imports) + if type(CTNClass) == types.FunctionType: # Eventualy Initialize child instance list for this class of confnode
- PluggedChildsWithSameClass = self.PluggedChilds.setdefault(PlugType, list())
+ ChildrenWithSameClass = self.Children.setdefault(CTNType, list()) - if getattr(PlugClass, "PlugMaxCount", None) and len(PluggedChildsWithSameClass) >= PlugClass.PlugMaxCount:
- raise Exception, _("Max count (%d) reached for this confnode of type %s ")%(PlugClass.PlugMaxCount, PlugType)
+ if getattr(CTNClass, "CTNMaxCount", None) and len(ChildrenWithSameClass) >= CTNClass.CTNMaxCount: + raise Exception, _("Max count (%d) reached for this confnode of type %s ")%(CTNClass.CTNMaxCount, CTNType) # create the final class, derived of provided confnode and template
- class FinalPlugClass(PlugClass, ConfigTreeNode):
+ class FinalCTNClass(CTNClass, ConfigTreeNode): - ConfNode class is derivated into FinalPlugClass before being instanciated
+ ConfNode class is derivated into FinalCTNClass before being instanciated This way __init__ is overloaded to ensure ConfigTreeNode.__init__ is called
- before PlugClass.__init__, and to do the file related stuff.
+ before CTNClass.__init__, and to do the file related stuff. - _self.PlugParent = self
# Keep track of the confnode type name
- _self.PlugType = PlugType
+ _self.CTNType = CTNType # remind the help string, for more fancy display
- _self.PlugHelp = PlugHelp
+ _self.CTNHelp = CTNHelp # Call the base confnode template init - change XSD into class members
ConfigTreeNode.__init__(_self)
- NewPlugName = _self.FindNewName(PlugName)
+ NewCTNName = _self.FindNewName(CTNName) # If dir have already be made, and file exist
- if os.path.isdir(_self.PlugPath(NewPlugName)): #and os.path.isfile(_self.ConfNodeXmlFilePath(PlugName)):
+ if os.path.isdir(_self.CTNPath(NewCTNName)): #and os.path.isfile(_self.ConfNodeXmlFilePath(CTNName)): #Load the confnode.xml file into parameters members
- _self.LoadXMLParams(NewPlugName)
+ _self.LoadXMLParams(NewCTNName) # Basic check. Better to fail immediately.
- if (_self.BaseParams.getName() != NewPlugName):
- raise Exception, _("Project tree layout do not match confnode.xml %s!=%s ")%(NewPlugName, _self.BaseParams.getName())
+ if (_self.BaseParams.getName() != NewCTNName): + raise Exception, _("Project tree layout do not match confnode.xml %s!=%s ")%(NewCTNName, _self.BaseParams.getName()) - # Now, self.PlugPath() should be OK
+ # Now, self.CTNPath() should be OK # Check that IEC_Channel is not already in use.
_self.FindNewIEC_Channel(_self.BaseParams.getIEC_Channel())
# Call the confnode real __init__
- if getattr(PlugClass, "__init__", None):
- PlugClass.__init__(_self)
- #Load and init all the childs
+ if getattr(CTNClass, "__init__", None): + CTNClass.__init__(_self) + #Load and init all the children #just loaded, nothing to saved
_self.ChangesToSave = False
# If confnode do not have corresponding file/dirs - they will be created on Save
_self.FindNewIEC_Channel(IEC_Channel)
# Call the confnode real __init__
- if getattr(PlugClass, "__init__", None):
- PlugClass.__init__(_self)
- _self.PlugRequestSave()
+ if getattr(CTNClass, "__init__", None): + CTNClass.__init__(_self) #just created, must be saved
_self.ChangesToSave = True
@@ -615,16 +615,16 @@
return self._getBuildPath()
# Create the object out of the resulting class
- newConfNodeOpj = FinalPlugClass()
- # Store it in PluggedChils
- PluggedChildsWithSameClass.append(newConfNodeOpj)
+ newConfNodeOpj = FinalCTNClass() + # Store it in CTNgedChils + ChildrenWithSameClass.append(newConfNodeOpj) - def ClearPluggedChilds(self):
- for child in self.IterChilds():
- child.ClearPluggedChilds()
- self.PluggedChilds = {}
+ def ClearChildren(self): + for child in self.IterChildren(): # Get library blocks if plcopen library exist
@@ -635,44 +635,44 @@
self.LibraryControler.ClearConfNodeTypes()
self.LibraryControler.AddConfNodeTypesList(self.ParentsTypesFactory())
- def LoadXMLParams(self, PlugName = None):
- methode_name = os.path.join(self.PlugPath(PlugName), "methods.py")
+ def LoadXMLParams(self, CTNName = None): + methode_name = os.path.join(self.CTNPath(CTNName), "methods.py") if os.path.isfile(methode_name):
- basexmlfile = open(self.ConfNodeBaseXmlFilePath(PlugName), 'r')
+ basexmlfile = open(self.ConfNodeBaseXmlFilePath(CTNName), 'r') basetree = minidom.parse(basexmlfile)
self.MandatoryParams[1].loadXMLTree(basetree.childNodes[0])
- self.GetPlugRoot().logger.write_error(_("Couldn't load confnode base parameters %s :\n %s") % (PlugName, str(exc)))
- self.GetPlugRoot().logger.write_error(traceback.format_exc())
+ self.GetCTRoot().logger.write_error(_("Couldn't load confnode base parameters %s :\n %s") % (CTNName, str(exc))) + self.GetCTRoot().logger.write_error(traceback.format_exc())
- xmlfile = open(self.ConfNodeXmlFilePath(PlugName), 'r')
+ xmlfile = open(self.ConfNodeXmlFilePath(CTNName), 'r') tree = minidom.parse(xmlfile)
- self.PlugParams[1].loadXMLTree(tree.childNodes[0])
+ self.CTNParams[1].loadXMLTree(tree.childNodes[0]) - self.GetPlugRoot().logger.write_error(_("Couldn't load confnode parameters %s :\n %s") % (PlugName, str(exc)))
- self.GetPlugRoot().logger.write_error(traceback.format_exc())
+ self.GetCTRoot().logger.write_error(_("Couldn't load confnode parameters %s :\n %s") % (CTNName, str(exc))) + self.GetCTRoot().logger.write_error(traceback.format_exc())
- # Iterate over all PlugName@PlugType in confnode directory, and try to open them
- for PlugDir in os.listdir(self.PlugPath()):
- if os.path.isdir(os.path.join(self.PlugPath(), PlugDir)) and \
- PlugDir.count(NameTypeSeparator) == 1:
- pname, ptype = PlugDir.split(NameTypeSeparator)
+ def LoadChildren(self): + # Iterate over all CTNName@CTNType in confnode directory, and try to open them + for CTNDir in os.listdir(self.CTNPath()): + if os.path.isdir(os.path.join(self.CTNPath(), CTNDir)) and \ + CTNDir.count(NameTypeSeparator) == 1: + pname, ptype = CTNDir.split(NameTypeSeparator) - self.PlugAddChild(pname, ptype)
+ self.CTNAddChild(pname, ptype) - self.GetPlugRoot().logger.write_error(_("Could not add child \"%s\", type %s :\n%s\n")%(pname, ptype, str(exc)))
- self.GetPlugRoot().logger.write_error(traceback.format_exc())
+ self.GetCTRoot().logger.write_error(_("Could not add child \"%s\", type %s :\n%s\n")%(pname, ptype, str(exc))) + self.GetCTRoot().logger.write_error(traceback.format_exc()) def EnableMethod(self, method, value):
for d in self.ConfNodeMethods:
@@ -742,13 +742,13 @@
- Managing project directory
- Handling PLCOpenEditor controler and view
- - Loading user confnodes and instanciante them as childs
+ - Loading user confnodes and instanciante them as children - # For root object, available Childs Types are modules of the confnode packages.
- PlugChildsTypes = [(name, _GetClassFunction(name), help) for name, help in zip(confnodes.__all__,confnodes.helps)]
+ # For root object, available Children Types are modules of the confnode packages. + CTNChildrenTypes = [(name, _GetClassFunction(name), help) for name, help in zip(confnodes.__all__,confnodes.helps)] XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
@@ -790,15 +790,15 @@
#This method are not called here... but in NewProject and OpenProject
#self._AddParamsMembers()
- #self.PluggedChilds = {}
# In both new or load scenario, no need to save
self.ChangesToSave = False
# Keep track of the confnode type name
- self.PlugType = "Beremiz"
- self.PluggedChilds = {}
+ self.CTNType = "Beremiz" # After __init__ root confnode is not valid
@@ -838,13 +838,13 @@
def ConfNodeLibraryFilePath(self):
return os.path.join(os.path.split(__file__)[0], "pous.xml")
- def PlugTestModified(self):
+ def CTNTestModified(self): return self.ChangesToSave or not self.ProjectIsSaved()
- def PlugFullName(self):
@@ -936,7 +936,7 @@
self.CreateNewProject(values)
# Change XSD into class members
- self.PluggedChilds = {}
# Keep track of the root confnode (i.e. project path)
self.ProjectPath = ProjectPath
self._setBuildPath(BuildPath)
@@ -963,18 +963,18 @@
# Change XSD into class members
- self.PluggedChilds = {}
# Keep track of the root confnode (i.e. project path)
self.ProjectPath = ProjectPath
self._setBuildPath(BuildPath)
# If dir have already be made, and file exist
- if os.path.isdir(self.PlugPath()) and os.path.isfile(self.ConfNodeXmlFilePath()):
+ if os.path.isdir(self.CTNPath()) and os.path.isfile(self.ConfNodeXmlFilePath()): #Load the confnode.xml file into parameters members
result = self.LoadXMLParams()
- #Load and init all the childs
+ #Load and init all the children self.RefreshConfNodesBlockLists()
if os.path.exists(self._getBuildPath()):
@@ -986,13 +986,13 @@
- self.ClearPluggedChilds()
if self.CheckProjectPathPerm(False):
self.SaveXMLFile(os.path.join(self.ProjectPath, 'plc.xml'))
- result = self.PlugRequestSave()
+ result = self.CTNRequestSave() self.logger.write_error(result)
@@ -1017,7 +1017,7 @@
# Update PLCOpenEditor ConfNode Block types from loaded confnodes
def RefreshConfNodesBlockLists(self):
- if getattr(self, "PluggedChilds", None) is not None:
+ if getattr(self, "Children", None) is not None: self.ClearConfNodeTypes()
self.AddConfNodeTypesList(self.ConfNodesTypesFactory())
if self.AppFrame is not None:
@@ -1045,18 +1045,18 @@
- location is a string of this variable's location, like "%IX0.0.0"
- for child in self.IECSortedChilds():
+ for child in self.IECSortedChildren(): children.append(child.GetVariableLocationTree())
return os.path.join(os.path.split(__file__)[0], "confnodes")
- def PlugPath(self, PlugName=None):
+ def CTNPath(self, CTNName=None): - def ConfNodeXmlFilePath(self, PlugName=None):
- return os.path.join(self.PlugPath(PlugName), "beremiz.xml")
+ def ConfNodeXmlFilePath(self, CTNName=None): + return os.path.join(self.CTNPath(CTNName), "beremiz.xml") def ParentsTypesFactory(self):
return self.ConfNodeTypesFactory()
@@ -1102,7 +1102,7 @@
def _getIECrawcodepath(self):
# define name for IEC raw code file
- return os.path.join(self.PlugPath(), "raw_plc.st")
+ return os.path.join(self.CTNPath(), "raw_plc.st") @@ -1222,7 +1222,7 @@
self.logger.write(_("Extracting Located Variables...\n"))
# Keep track of generated located variables for later use by self._Generate_C
self.PLCGeneratedLocatedVars = self.GetLocations()
- # Keep track of generated C files for later use by self.PlugGenerate_C
+ # Keep track of generated C files for later use by self.CTNGenerate_C self.PLCGeneratedCFiles = C_files
self.plcCFLAGS = "\"-I"+self.ieclib_path+"\""
@@ -1274,7 +1274,7 @@
#######################################################################
- def PlugGenerate_C(self, buildpath, locations):
+ def CTNGenerate_C(self, buildpath, locations): Return C code generated by iec2c compiler
when _generate_softPLC have been called
--- a/LPCBeremiz.py Mon May 07 18:47:29 2012 +0200
+++ b/LPCBeremiz.py Mon May 07 19:19:08 2012 +0200
@@ -68,7 +68,7 @@
from confnodes.canfestival import RootClass as CanOpenRootClass
- from confnodes.canfestival.canfestival import _SlavePlug, _NodeListPlug, NodeManager
+ from confnodes.canfestival.canfestival import _SlaveCTN, _NodeListCTN, NodeManager @@ -197,7 +197,7 @@
return self.VariableLocationTree
raise KeyError, "Only 'children' key is available"
@@ -207,10 +207,10 @@
return _GetModuleBySomething({"children" : self.VariableLocationTree}, something, toks)
- return self.GetPlugRoot().GetBaseTypes()
+ return self.GetCTRoot().GetBaseTypes() def GetSizeOfType(self, type):
- return LOCATION_SIZES[self.GetPlugRoot().GetBaseType(type)]
+ return LOCATION_SIZES[self.GetCTRoot().GetBaseType(type)] def _GetVariableLocationTree(self, current_location, infos):
if infos["type"] == LOCATION_MODULE:
@@ -246,13 +246,13 @@
"children": [self._GetVariableLocationTree(self.GetCurrentLocation(), child)
for child in self.VariableLocationTree]}
- def PlugTestModified(self):
+ def CTNTestModified(self):
- def PlugRequestSave(self):
+ def CTNRequestSave(self): def ResetUsedLocations(self):
@@ -288,7 +288,7 @@
return self._CheckLocationConflicts(self.UsedLocations, list(location))
- def PlugGenerate_C(self, buildpath, locations):
+ def CTNGenerate_C(self, buildpath, locations): @param current_location: Tupple containing confnode IEC location : %I0.0.4.5 => (0,0,4,5)
@@ -346,7 +346,7 @@
"Publish": variable["publish"],
- base_types = self.GetPlugRoot().GetBaseTypes()
+ base_types = self.GetCTRoot().GetBaseTypes() if var["Type"] in base_types:
@@ -363,7 +363,7 @@
module.write(BUS_TEXT % code_str)
- matiec_flags = '"-I%s"'%os.path.abspath(self.GetPlugRoot().GetIECLibPath())
+ matiec_flags = '"-I%s"'%os.path.abspath(self.GetCTRoot().GetIECLibPath()) return [(Gen_Module_path, matiec_flags)],"",True
#-------------------------------------------------------------------------------
@@ -378,7 +378,7 @@
- class LPCCanOpenSlave(_SlavePlug):
+ class LPCCanOpenSlave(_SlaveCTN): XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="CanFestivalSlaveNode">
@@ -414,12 +414,12 @@
return str(self.BaseParams.getIEC_Channel())
- class LPCCanOpenMaster(_NodeListPlug):
+ class LPCCanOpenMaster(_NodeListCTN): XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="CanFestivalNode">
@@ -437,21 +437,21 @@
class LPCCanOpen(CanOpenRootClass):
- PlugChildsTypes = [("CanOpenNode",LPCCanOpenMaster, "CanOpen Master"),
+ CTNChildrenTypes = [("CanOpenNode",LPCCanOpenMaster, "CanOpen Master"), ("CanOpenSlave",LPCCanOpenSlave, "CanOpen Slave")]
- ConfigTreeNode.LoadChilds(self)
+ def LoadChildren(self): + ConfigTreeNode.LoadChildren(self) if self.GetChildByName("Master") is None:
- master = self.PlugAddChild("Master", "CanOpenNode", 0)
+ master = self.CTNAddChild("Master", "CanOpenNode", 0) master.BaseParams.setEnabled(False)
if self.GetChildByName("Slave") is None:
- slave = self.PlugAddChild("Slave", "CanOpenSlave", 1)
+ slave = self.CTNAddChild("Slave", "CanOpenSlave", 1) slave.BaseParams.setEnabled(False)
@@ -513,10 +513,10 @@
ConfigTreeRoot.__init__(self, frame, logger)
- self.PlugChildsTypes += [("LPCBus", LPCBus, "LPC bus"), ("CanOpen", LPCCanOpen, "CanOpen bus")]
+ self.CTNChildrenTypes += [("LPCBus", LPCBus, "LPC bus"), ("CanOpen", LPCCanOpen, "CanOpen bus")] - self.PlugChildsTypes += [("LPCBus", LPCBus, "LPC bus")]
+ self.CTNChildrenTypes += [("LPCBus", LPCBus, "LPC bus")] @@ -676,7 +676,7 @@
# Change XSD into class members
- self.PluggedChilds = {}
# Keep track of the root confnode (i.e. project path)
self.ProjectPath = ProjectPath
@@ -686,20 +686,20 @@
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.ConfNodeXmlFilePath()):
+ if os.path.isdir(self.CTNPath()) and os.path.isfile(self.ConfNodeXmlFilePath()): #Load the confnode.xml file into parameters members
result = self.LoadXMLParams()
- #Load and init all the childs
+ #Load and init all the children if havecanfestival and self.GetChildByName("CanOpen") is None:
- canopen = self.PlugAddChild("CanOpen", "CanOpen", 0)
+ canopen = self.CTNAddChild("CanOpen", "CanOpen", 0) canopen.BaseParams.setEnabled(False)
- if self.PlugTestModified():
+ if self.CTNTestModified(): @@ -881,22 +881,22 @@
# CSV file generated by IEC2C compiler.
self.ResetIECProgramsAndVariables()
- gen_result = self.PlugGenerate_C(buildpath, self.PLCGeneratedLocatedVars)
- PlugCFilesAndCFLAGS, PlugLDFLAGS, DoCalls = gen_result[:3]
+ gen_result = self.CTNGenerate_C(buildpath, self.PLCGeneratedLocatedVars) + CTNCFilesAndCFLAGS, CTNLDFLAGS, DoCalls = gen_result[:3] # if some files have been generated put them in the list with their location
- if PlugCFilesAndCFLAGS:
- self.LocationCFilesAndCFLAGS = [(self.GetCurrentLocation(), PlugCFilesAndCFLAGS, DoCalls)]
+ self.LocationCFilesAndCFLAGS = [(self.GetCurrentLocation(), CTNCFilesAndCFLAGS, DoCalls)] self.LocationCFilesAndCFLAGS = []
# confnode asks for some LDFLAGS
# LDFLAGS can be either string
- if type(PlugLDFLAGS)==type(str()):
- self.LDFLAGS=[PlugLDFLAGS]
+ if type(CTNLDFLAGS)==type(str()): + self.LDFLAGS=[CTNLDFLAGS] - elif type(PlugLDFLAGS)==type(list()):
- self.LDFLAGS=PlugLDFLAGS[:]
+ elif type(CTNLDFLAGS)==type(list()): + self.LDFLAGS=CTNLDFLAGS[:] @@ -1183,7 +1183,7 @@
plcwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1))
- if self.CTR.PlugTestModified():
+ if self.CTR.CTNTestModified(): bkgdclr = CHANGED_TITLE_COLOUR
@@ -1218,7 +1218,7 @@
def GenerateTreeBranch(self, confnode):
leftwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1))
- if confnode.PlugTestModified():
+ if confnode.CTNTestModified(): bkgdclr=CHANGED_WINDOW_COLOUR
@@ -1228,7 +1228,7 @@
if confnode not in self.ConfNodeInfos:
self.ConfNodeInfos[confnode] = {"expanded" : False, "left_visible" : False, "right_visible" : False}
- self.ConfNodeInfos[confnode]["children"] = confnode.IECSortedChilds()
+ self.ConfNodeInfos[confnode]["children"] = confnode.IECSortedChildren() confnode_infos = confnode.GetVariableLocationTree()
if len(self.ConfNodeInfos[confnode]["children"]) == 0:
@@ -1477,12 +1477,12 @@
def AddBus(self, iec_channel, name, icon=None):
- for child in self.CTR.IterChilds():
+ for child in self.CTR.IterChildren(): 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.CTR.PlugAddChild(name, "LPCBus", iec_channel)
+ bus = self.CTR.CTNAddChild(name, "LPCBus", iec_channel) return "Error: Unable to create bus\n"
@@ -1492,7 +1492,7 @@
bus = self.CTR.GetChildByIECLocation((iec_channel,))
return "Error: No bus found\n"
- for child in self.CTR.IterChilds():
+ for child in self.CTR.IterChildren(): if child != bus and child.BaseParams.getName() == name:
return "Error: A bus named %s already exists\n" % name
bus.BaseParams.setName(name)
@@ -1502,7 +1502,7 @@
bus = self.CTR.GetChildByIECLocation((old_iec_channel,))
return "Error: No bus found\n"
- for child in self.CTR.IterChilds():
+ for child in self.CTR.IterChildren(): 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
@@ -1520,7 +1520,7 @@
return "Error: No bus found\n"
self.CTR.RemoveProjectVariableByFilter(str(iec_channel))
- self.CTR.PluggedChilds["LPCBus"].remove(bus)
+ self.CTR.Children["LPCBus"].remove(bus) def AddModule(self, parent, iec_channel, name, icode, icon=None):
--- a/confnodes/canfestival/canfestival.py Mon May 07 18:47:29 2012 +0200
+++ b/confnodes/canfestival/canfestival.py Mon May 07 19:19:08 2012 +0200
@@ -41,7 +41,7 @@
#--------------------------------------------------
-class _SlavePlug(NodeManager):
+class _SlaveCTN(NodeManager): XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="CanFestivalSlaveNode">
@@ -99,10 +99,10 @@
def GetSlaveODPath(self):
- return os.path.join(self.PlugPath(), 'slave.od')
+ return os.path.join(self.CTNPath(), 'slave.od') return self.CanFestivalSlaveNode.getCan_Device()
@@ -119,14 +119,14 @@
- def PlugTestModified(self):
+ def CTNTestModified(self): return self.ChangesToSave or self.OneFileHasChanged()
return self.SaveCurrentInFile(self.GetSlaveODPath())
def SetParamsAttribute(self, path, value):
@@ -138,7 +138,7 @@
- def PlugGenerate_C(self, buildpath, locations):
+ def CTNGenerate_C(self, buildpath, locations): @param current_location: Tupple containing confnode IEC location : %I0.0.4.5 => (0,0,4,5)
@@ -194,13 +194,13 @@
def OnCloseEditor(self, view):
self.Parent.OnCloseEditor(view)
- def PlugFullName(self):
def GetBufferState(self):
return self.GetCurrentBufferState()
-class _NodeListPlug(NodeList):
+class _NodeListCTN(NodeList): XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="CanFestivalNode">
@@ -219,7 +219,7 @@
NodeList.__init__(self, manager)
- self.LoadProject(self.PlugPath())
+ self.LoadProject(self.CTNPath()) self.SetNetworkName(self.BaseParams.getName())
@@ -247,24 +247,24 @@
buildpath = self._getBuildPath()
# Eventually create build dir
if not os.path.exists(buildpath):
- self.GetPlugRoot().logger.write_error(_("Error: No PLC built\n"))
+ self.GetCTRoot().logger.write_error(_("Error: No PLC built\n")) masterpath = os.path.join(buildpath, "MasterGenerated.od")
if not os.path.exists(masterpath):
- self.GetPlugRoot().logger.write_error(_("Error: No Master generated\n"))
+ self.GetCTRoot().logger.write_error(_("Error: No Master generated\n")) - app_frame = self.GetPlugRoot().AppFrame
+ app_frame = self.GetCTRoot().AppFrame - manager = MiniNodeManager(self, masterpath, self.PlugFullName() + ".generated_master")
+ manager = MiniNodeManager(self, masterpath, self.CTNFullName() + ".generated_master") self._GeneratedView = SlaveEditor(app_frame.TabsOpened, manager, app_frame, False)
app_frame.EditProjectElement(self._GeneratedView, "MasterGenerated")
def _CloseGenerateView(self):
if self._GeneratedView is not None:
- app_frame = self.GetPlugRoot().AppFrame
+ app_frame = self.GetCTRoot().AppFrame if app_frame is not None:
app_frame.DeletePage(self._GeneratedView)
@@ -284,19 +284,19 @@
if self._GeneratedView == view:
self._GeneratedView = None
- ConfigTreeNode.OnPlugClose(self)
+ ConfigTreeNode.OnCTNClose(self) self._CloseGenerateView()
- def PlugTestModified(self):
+ def CTNTestModified(self): return self.ChangesToSave or self.HasChanged()
- self.SetRoot(self.PlugPath())
+ self.SetRoot(self.CTNPath()) return self.SaveProject() is None
- def PlugGenerate_C(self, buildpath, locations):
+ def CTNGenerate_C(self, buildpath, locations): @param current_location: Tupple containing confnode IEC location : %I0.0.4.5 => (0,0,4,5)
@@ -351,8 +351,8 @@
- PlugChildsTypes = [("CanOpenNode",_NodeListPlug, "CanOpen Master"),
- ("CanOpenSlave",_SlavePlug, "CanOpen Slave")]
+ CTNChildrenTypes = [("CanOpenNode",_NodeListCTN, "CanOpen Master"), + ("CanOpenSlave",_SlaveCTN, "CanOpen Slave")] def GetParamsAttributes(self, path = None):
infos = ConfigTreeNode.GetParamsAttributes(self, path = None)
@@ -373,7 +373,7 @@
- def PlugGenerate_C(self, buildpath, locations):
+ def CTNGenerate_C(self, buildpath, locations): format_dict = {"locstr" : "_".join(map(str,self.GetCurrentLocation())),
"candriver" : self.GetCanDriver(),
@@ -390,7 +390,7 @@
"post_sync_register" : "",
- for child in self.IECSortedChilds():
+ for child in self.IECSortedChildren(): childlocstr = "_".join(map(str,child.GetCurrentLocation()))
nodename = "OD_%s" % childlocstr