equal
deleted
inserted
replaced
722 else: |
722 else: |
723 dialog.Destroy() |
723 dialog.Destroy() |
724 return "Project not created" |
724 return "Project not created" |
725 |
725 |
726 # Create PLCOpen program |
726 # Create PLCOpen program |
727 self.CreateNewProject(values.pop("projectName")) |
727 self.CreateNewProject(values) |
728 self.SetProjectProperties(properties = values) |
|
729 # Change XSD into class members |
728 # Change XSD into class members |
730 self._AddParamsMembers() |
729 self._AddParamsMembers() |
731 self.PluggedChilds = {} |
730 self.PluggedChilds = {} |
732 # Keep track of the root plugin (i.e. project path) |
731 # Keep track of the root plugin (i.e. project path) |
733 self.ProjectPath = ProjectPath |
732 self.ProjectPath = ProjectPath |
848 |
847 |
849 logger.write("Generating SoftPLC IEC-61131 ST/IL/SFC code...\n") |
848 logger.write("Generating SoftPLC IEC-61131 ST/IL/SFC code...\n") |
850 buildpath = self._getBuildPath() |
849 buildpath = self._getBuildPath() |
851 # ask PLCOpenEditor controller to write ST/IL/SFC code file |
850 # ask PLCOpenEditor controller to write ST/IL/SFC code file |
852 result = self.GenerateProgram(self._getIECgeneratedcodepath()) |
851 result = self.GenerateProgram(self._getIECgeneratedcodepath()) |
853 if not result: |
852 if result is not None: |
854 # Failed ! |
853 # Failed ! |
855 logger.write_error("Error : ST/IL/SFC code generator returned %d\n"%result) |
854 logger.write_error("Error in ST/IL/SFC code generator :\n%s\n"%result) |
856 return False |
855 return False |
857 plc_file = open(self._getIECcodepath(), "w") |
856 plc_file = open(self._getIECcodepath(), "w") |
858 if os.path.isfile(self._getIECrawcodepath()): |
857 if os.path.isfile(self._getIECrawcodepath()): |
859 plc_file.write(open(self._getIECrawcodepath(), "r").read()) |
858 plc_file.write(open(self._getIECrawcodepath(), "r").read()) |
860 plc_file.write("\n") |
859 plc_file.write("\n") |
873 if status: |
872 if status: |
874 # Failed ! |
873 # Failed ! |
875 logger.write_error("Error : IEC to C compiler returned %d\n"%status) |
874 logger.write_error("Error : IEC to C compiler returned %d\n"%status) |
876 return False |
875 return False |
877 # Now extract C files of stdout |
876 # Now extract C files of stdout |
878 C_files = result.splitlines() |
877 C_files = [ fname for fname in result.splitlines() if fname[-2:]==".c" or fname[-2:]==".C" ] |
879 # remove those that are not to be compiled because included by others |
878 # remove those that are not to be compiled because included by others |
880 C_files.remove("POUS.c") |
879 C_files.remove("POUS.c") |
881 C_files.remove("LOCATED_VARIABLES.h") |
|
882 # transform those base names to full names with path |
880 # transform those base names to full names with path |
883 C_files = map(lambda filename:os.path.join(buildpath, filename), C_files) |
881 C_files = map(lambda filename:os.path.join(buildpath, filename), C_files) |
884 logger.write("Extracting Located Variables...\n") |
882 logger.write("Extracting Located Variables...\n") |
885 # Keep track of generated located variables for later use by self._Generate_C |
883 # Keep track of generated located variables for later use by self._Generate_C |
886 self.PLCGeneratedLocatedVars = self.GetLocations() |
884 self.PLCGeneratedLocatedVars = self.GetLocations() |
1069 if os.path.isfile(command_start_plc): |
1067 if os.path.isfile(command_start_plc): |
1070 logger.write("Starting PLC\n") |
1068 logger.write("Starting PLC\n") |
1071 def this_plc_finish_callback(*args): |
1069 def this_plc_finish_callback(*args): |
1072 if self.runningPLC is not None: |
1070 if self.runningPLC is not None: |
1073 self.runningPLC = None |
1071 self.runningPLC = None |
1074 self._Stop(logger) |
1072 self.reset_finished() |
1075 self.runningPLC = ProcessLogger( |
1073 self.runningPLC = ProcessLogger( |
1076 logger, |
1074 logger, |
1077 command_start_plc, |
1075 command_start_plc, |
1078 finish_callback = this_plc_finish_callback) |
1076 finish_callback = this_plc_finish_callback) |
1079 self.EnableMethod("_Clean", False) |
1077 self.EnableMethod("_Clean", False) |