lpcmanager

334fec6af85a
Parents d0169d647798
Children 5748975e2d44
LPCProjectController's variant of LoadProject now cares about code re-use.
--- a/LPCProjectController.py Mon Feb 12 14:03:47 2018 +0100
+++ b/LPCProjectController.py Mon Feb 12 14:44:43 2018 +0100
@@ -108,51 +108,24 @@
"Priority": 0}],
[])
- # TODO : use the original function
def LoadProject(self, ProjectPath, BuildPath=None):
"""
- Load a project contained in a folder
- @param ProjectPath: path of the project folder
+ Create plcopen project if plc.xml not found,
+ so that original LoadProject doesn't make errors.
+ After regular load, add CanOpen nodes if not already there,
+ and eventualy save project again.
+ TargetType is forced to MC9.
"""
- if os.path.basename(ProjectPath) == "":
- ProjectPath = os.path.dirname(ProjectPath)
-
- # Verify that project contains a PLCOpen program
plc_file = os.path.join(ProjectPath, "plc.xml")
- if os.path.isfile(plc_file):
- # Load PLCOpen file
- result = self.OpenXMLFile(plc_file)
- if result:
- return result
- else:
+ if not os.path.isfile(plc_file):
self.CreateNewProject({"companyName": "",
"productName": "",
"productVersion": "",
"projectName": "",
"pageSize": (0, 0),
"scaling": {}})
- if len(self.GetProjectConfigNames()) == 0:
- self.AddProjectDefaultConfiguration()
- # Change XSD into class members
- self._AddParamsMembers()
- self.Children = {}
-
- # Keep track of the root confnode (i.e. project path)
- self.ProjectPath = ProjectPath
-
- self.BuildPath = self._getBuildPath()
- if self.OrigBuildPath is not None:
- mycopytree(self.OrigBuildPath, self.BuildPath)
-
- # If dir have already be made, and file exist
- if os.path.isdir(self.CTNPath()) and os.path.isfile(self.ConfNodeXmlFilePath()):
- # Load the confnode.xml file into parameters members
- result = self.LoadXMLParams()
- if result:
- return result
- # Load and init all the children
- self.LoadChildren()
+ ProjectController.LoadProject(self, ProjectPath, BuildPath=None):
canopen_child = self.GetChildByName("CanOpen")
if canopen_child is None:
@@ -163,11 +136,9 @@
if self.CTNTestModified():
self.SaveProject()
- if wx.GetApp() is None:
- self.RefreshConfNodesBlockLists()
- else:
- wx.CallAfter(self.RefreshConfNodesBlockLists)
+ self.RefreshConfNodesBlockLists()
+ # FIXME XXX
if self.arch in PLC_module:
self.SetParamsAttribute('BeremizRoot.TargetType', 'MC9')