353 if os.path.basename(ProjectPath) == "": |
353 if os.path.basename(ProjectPath) == "": |
354 ProjectPath = os.path.dirname(ProjectPath) |
354 ProjectPath = os.path.dirname(ProjectPath) |
355 # Verify that project contains a PLCOpen program |
355 # Verify that project contains a PLCOpen program |
356 plc_file = os.path.join(ProjectPath, "plc.xml") |
356 plc_file = os.path.join(ProjectPath, "plc.xml") |
357 if not os.path.isfile(plc_file): |
357 if not os.path.isfile(plc_file): |
358 return _("Chosen folder doesn't contain a program. It's not a valid project!") |
358 return _("Chosen folder doesn't contain a program. It's not a valid project!"), True |
359 # Load PLCOpen file |
359 # Load PLCOpen file |
360 error = self.OpenXMLFile(plc_file) |
360 error = self.OpenXMLFile(plc_file) |
361 if error is not None: |
361 if error is not None: |
362 if self.Project is not None: |
362 if self.Project is not None: |
363 (fname_err, lnum, src) = (("PLC",) + error) |
363 (fname_err, lnum, src) = (("PLC",) + error) |
364 self.logger.write_warning(XSDSchemaErrorMessage.format(a1 = fname_err, a2 = lnum, a3 = src)) |
364 self.logger.write_warning(XSDSchemaErrorMessage.format(a1 = fname_err, a2 = lnum, a3 = src)) |
365 else: |
365 else: |
366 return error |
366 return error, False |
367 if len(self.GetProjectConfigNames()) == 0: |
367 if len(self.GetProjectConfigNames()) == 0: |
368 self.AddProjectDefaultConfiguration() |
368 self.AddProjectDefaultConfiguration() |
369 # Change XSD into class members |
369 # Change XSD into class members |
370 self._AddParamsMembers() |
370 self._AddParamsMembers() |
371 self.Children = {} |
371 self.Children = {} |
375 # If dir have already be made, and file exist |
375 # If dir have already be made, and file exist |
376 if os.path.isdir(self.CTNPath()) and os.path.isfile(self.ConfNodeXmlFilePath()): |
376 if os.path.isdir(self.CTNPath()) and os.path.isfile(self.ConfNodeXmlFilePath()): |
377 #Load the confnode.xml file into parameters members |
377 #Load the confnode.xml file into parameters members |
378 result = self.LoadXMLParams() |
378 result = self.LoadXMLParams() |
379 if result: |
379 if result: |
380 return result |
380 return result, False |
381 #Load and init all the children |
381 #Load and init all the children |
382 self.LoadChildren() |
382 self.LoadChildren() |
383 self.RefreshConfNodesBlockLists() |
383 self.RefreshConfNodesBlockLists() |
384 self.UpdateButtons() |
384 self.UpdateButtons() |
385 return None |
385 return None, False |
386 |
386 |
387 def RecursiveConfNodeInfos(self, confnode): |
387 def RecursiveConfNodeInfos(self, confnode): |
388 values = [] |
388 values = [] |
389 for CTNChild in confnode.IECSortedChildren(): |
389 for CTNChild in confnode.IECSortedChildren(): |
390 values.append( |
390 values.append( |