Adding support for creating default configuration to newly created project and project without one defined
authorLaurent Bessard
Tue, 25 Sep 2012 13:06:59 +0200
changeset 19 1ef6f6fddaa8
parent 18 17e6293e9191
child 20 6bfbf83d6c2d
Adding support for creating default configuration to newly created project and project without one defined
LPCManager.py
--- a/LPCManager.py	Fri Sep 07 20:11:05 2012 +0200
+++ b/LPCManager.py	Tue Sep 25 13:06:59 2012 +0200
@@ -826,6 +826,17 @@
         self.Project.removeVariableByFilter(leading)
         self.BufferProject()
 
+    def AddProjectDefaultConfiguration(self, config_name="config", res_name="resource1"):
+        ProjectController.AddProjectDefaultConfiguration(self, config_name, res_name)
+        
+        self.SetEditedResourceInfos(
+            self.ComputeConfigurationResourceName(config_name, res_name),
+            [{"Name": "main_task",
+              "Triggering": "Cyclic",
+              "Interval": "T#50ms",
+              "Priority": 0}],
+            [])
+    
     def LoadProject(self, ProjectPath, BuildPath=None):
         """
         Load a project contained in a folder
@@ -848,6 +859,8 @@
                                    "projectName": "",
                                    "pageSize": (0, 0),
                                    "scaling": {}})
+        if len(self.GetProjectConfigNames()) == 0:
+            self.AddProjectDefaultConfiguration()
         
         # Change XSD into class members
         self._AddParamsMembers()
@@ -1877,7 +1890,7 @@
         def Refresh(self):
             global frame
             if frame is not None:
-                frame._Refresh(TITLE, POUINSTANCEVARIABLESPANEL, FILEMENU, EDITMENU)
+                frame._Refresh(TITLE, PROJECTTREE, POUINSTANCEVARIABLESPANEL, FILEMENU, EDITMENU)
                 frame.RefreshEditor()
                 frame.RefreshAll()