plugger.py
changeset 256 1da137b99948
parent 253 b1a9d37bb84c
child 273 d15a20eb2b8b
equal deleted inserted replaced
255:1f660bed2ab1 256:1da137b99948
   680         self.PlugParent = None
   680         self.PlugParent = None
   681         # Keep track of the plugin type name
   681         # Keep track of the plugin type name
   682         self.PlugType = "Beremiz"
   682         self.PlugType = "Beremiz"
   683         # After __init__ root plugin is not valid
   683         # After __init__ root plugin is not valid
   684         self.ProjectPath = None
   684         self.ProjectPath = None
       
   685         self.BuildPath = None
   685         self.PLCEditor = None
   686         self.PLCEditor = None
   686         self.PLCDebug = None
   687         self.PLCDebug = None
   687         # copy PluginMethods so that it can be later customized
   688         # copy PluginMethods so that it can be later customized
   688         self.PluginMethods = [dic.copy() for dic in self.PluginMethods]
   689         self.PluginMethods = [dic.copy() for dic in self.PluginMethods]
   689 
   690 
   712         childs = []
   713         childs = []
   713         for child in self.IterChilds():
   714         for child in self.IterChilds():
   714             childs.append(child.GetPlugInfos())
   715             childs.append(child.GetPlugInfos())
   715         return {"name" : "PLC (%s)"%self.GetProjectName(), "type" : None, "values" : childs}
   716         return {"name" : "PLC (%s)"%self.GetProjectName(), "type" : None, "values" : childs}
   716     
   717     
   717     def NewProject(self, ProjectPath):
   718     def NewProject(self, ProjectPath, BuildPath=None):
   718         """
   719         """
   719         Create a new project in an empty folder
   720         Create a new project in an empty folder
   720         @param ProjectPath: path of the folder where project have to be created
   721         @param ProjectPath: path of the folder where project have to be created
   721         @param PLCParams: properties of the PLCOpen program created
   722         @param PLCParams: properties of the PLCOpen program created
   722         """
   723         """
   738         # Change XSD into class members
   739         # Change XSD into class members
   739         self._AddParamsMembers()
   740         self._AddParamsMembers()
   740         self.PluggedChilds = {}
   741         self.PluggedChilds = {}
   741         # Keep track of the root plugin (i.e. project path)
   742         # Keep track of the root plugin (i.e. project path)
   742         self.ProjectPath = ProjectPath
   743         self.ProjectPath = ProjectPath
       
   744         self.BuildPath = BuildPath
   743         # get plugins bloclist (is that usefull at project creation?)
   745         # get plugins bloclist (is that usefull at project creation?)
   744         self.RefreshPluginsBlockLists()
   746         self.RefreshPluginsBlockLists()
   745         # this will create files base XML files
   747         # this will create files base XML files
   746         self.SaveProject()
   748         self.SaveProject()
   747         return None
   749         return None
   748         
   750         
   749     def LoadProject(self, ProjectPath):
   751     def LoadProject(self, ProjectPath, BuildPath=None):
   750         """
   752         """
   751         Load a project contained in a folder
   753         Load a project contained in a folder
   752         @param ProjectPath: path of the project folder
   754         @param ProjectPath: path of the project folder
   753         """
   755         """
   754         if os.path.basename(ProjectPath) == "":
   756         if os.path.basename(ProjectPath) == "":
   764         # Change XSD into class members
   766         # Change XSD into class members
   765         self._AddParamsMembers()
   767         self._AddParamsMembers()
   766         self.PluggedChilds = {}
   768         self.PluggedChilds = {}
   767         # Keep track of the root plugin (i.e. project path)
   769         # Keep track of the root plugin (i.e. project path)
   768         self.ProjectPath = ProjectPath
   770         self.ProjectPath = ProjectPath
       
   771         self.BuildPath = BuildPath
   769         # If dir have already be made, and file exist
   772         # If dir have already be made, and file exist
   770         if os.path.isdir(self.PlugPath()) and os.path.isfile(self.PluginXmlFilePath()):
   773         if os.path.isdir(self.PlugPath()) and os.path.isfile(self.PluginXmlFilePath()):
   771             #Load the plugin.xml file into parameters members
   774             #Load the plugin.xml file into parameters members
   772             result = self.LoadXMLParams()
   775             result = self.LoadXMLParams()
   773             if result:
   776             if result:
   808     
   811     
   809     def PluginXmlFilePath(self, PlugName=None):
   812     def PluginXmlFilePath(self, PlugName=None):
   810         return os.path.join(self.PlugPath(PlugName), "beremiz.xml")
   813         return os.path.join(self.PlugPath(PlugName), "beremiz.xml")
   811 
   814 
   812     def _getBuildPath(self):
   815     def _getBuildPath(self):
   813         return os.path.join(self.ProjectPath, "build")
   816         if self.BuildPath is None:
       
   817             return os.path.join(self.ProjectPath, "build")
       
   818         return self.BuildPath
   814     
   819     
   815     def _getExtraFilesPath(self):
   820     def _getExtraFilesPath(self):
   816         return os.path.join(self._getBuildPath(), "extra_files")
   821         return os.path.join(self._getBuildPath(), "extra_files")
   817 
   822 
   818     def _getIECcodepath(self):
   823     def _getIECcodepath(self):