equal
deleted
inserted
replaced
840 """ |
840 """ |
841 Create a new project in an empty folder |
841 Create a new project in an empty folder |
842 @param ProjectPath: path of the folder where project have to be created |
842 @param ProjectPath: path of the folder where project have to be created |
843 @param PLCParams: properties of the PLCOpen program created |
843 @param PLCParams: properties of the PLCOpen program created |
844 """ |
844 """ |
845 # Verify that choosen folder is empty |
845 # Verify that chosen folder is empty |
846 if not os.path.isdir(ProjectPath) or len(os.listdir(ProjectPath)) > 0: |
846 if not os.path.isdir(ProjectPath) or len(os.listdir(ProjectPath)) > 0: |
847 return _("Folder choosen isn't empty. You can't use it for a new project!") |
847 return _("Chosen folder isn't empty. You can't use it for a new project!") |
848 |
848 |
849 dialog = ProjectDialog(self.AppFrame) |
849 dialog = ProjectDialog(self.AppFrame) |
850 if dialog.ShowModal() == wx.ID_OK: |
850 if dialog.ShowModal() == wx.ID_OK: |
851 values = dialog.GetValues() |
851 values = dialog.GetValues() |
852 values["creationDateTime"] = datetime(*localtime()[:6]) |
852 values["creationDateTime"] = datetime(*localtime()[:6]) |
877 if os.path.basename(ProjectPath) == "": |
877 if os.path.basename(ProjectPath) == "": |
878 ProjectPath = os.path.dirname(ProjectPath) |
878 ProjectPath = os.path.dirname(ProjectPath) |
879 # Verify that project contains a PLCOpen program |
879 # Verify that project contains a PLCOpen program |
880 plc_file = os.path.join(ProjectPath, "plc.xml") |
880 plc_file = os.path.join(ProjectPath, "plc.xml") |
881 if not os.path.isfile(plc_file): |
881 if not os.path.isfile(plc_file): |
882 return _("Folder choosen doesn't contain a program. It's not a valid project!") |
882 return _("Chosen folder doesn't contain a program. It's not a valid project!") |
883 # Load PLCOpen file |
883 # Load PLCOpen file |
884 result = self.OpenXMLFile(plc_file) |
884 result = self.OpenXMLFile(plc_file) |
885 if result: |
885 if result: |
886 return result |
886 return result |
887 # Change XSD into class members |
887 # Change XSD into class members |
1033 self.ProgramOffset += 1 |
1033 self.ProgramOffset += 1 |
1034 plc_file.close() |
1034 plc_file.close() |
1035 plc_file = open(self._getIECcodepath(), "a") |
1035 plc_file = open(self._getIECcodepath(), "a") |
1036 plc_file.write(open(self._getIECgeneratedcodepath(), "r").read()) |
1036 plc_file.write(open(self._getIECgeneratedcodepath(), "r").read()) |
1037 plc_file.close() |
1037 plc_file.close() |
1038 self.logger.write(_("Compiling IEC Program in to C code...\n")) |
1038 |
|
1039 self.logger.write(_("Compiling IEC Program into C code...\n")) |
|
1040 |
1039 # Now compile IEC code into many C files |
1041 # Now compile IEC code into many C files |
1040 # files are listed to stdout, and errors to stderr. |
1042 # files are listed to stdout, and errors to stderr. |
1041 status, result, err_result = ProcessLogger( |
1043 status, result, err_result = ProcessLogger( |
1042 self.logger, |
1044 self.logger, |
1043 "\"%s\" -f -I \"%s\" -T \"%s\" \"%s\""%( |
1045 "\"%s\" -f -I \"%s\" -T \"%s\" \"%s\""%( |
1080 # Now extract C files of stdout |
1082 # Now extract C files of stdout |
1081 C_files = [ fname for fname in result.splitlines() if fname[-2:]==".c" or fname[-2:]==".C" ] |
1083 C_files = [ fname for fname in result.splitlines() if fname[-2:]==".c" or fname[-2:]==".C" ] |
1082 # remove those that are not to be compiled because included by others |
1084 # remove those that are not to be compiled because included by others |
1083 C_files.remove("POUS.c") |
1085 C_files.remove("POUS.c") |
1084 if not C_files: |
1086 if not C_files: |
1085 self.logger.write_error(_("Error : At least one configuration and one ressource must be declared in PLC !\n")) |
1087 self.logger.write_error(_("Error : At least one configuration and one resource must be declared in PLC !\n")) |
1086 return False |
1088 return False |
1087 # transform those base names to full names with path |
1089 # transform those base names to full names with path |
1088 C_files = map(lambda filename:os.path.join(buildpath, filename), C_files) |
1090 C_files = map(lambda filename:os.path.join(buildpath, filename), C_files) |
1089 self.logger.write(_("Extracting Located Variables...\n")) |
1091 self.logger.write(_("Extracting Located Variables...\n")) |
1090 # Keep track of generated located variables for later use by self._Generate_C |
1092 # Keep track of generated located variables for later use by self._Generate_C |
1740 MD5 = self.GetLastBuildMD5() |
1742 MD5 = self.GetLastBuildMD5() |
1741 # Check remote target PLC correspondance to that md5 |
1743 # Check remote target PLC correspondance to that md5 |
1742 if MD5 is not None: |
1744 if MD5 is not None: |
1743 if not self._connector.MatchMD5(MD5): |
1745 if not self._connector.MatchMD5(MD5): |
1744 self.logger.write_warning( |
1746 self.logger.write_warning( |
1745 _("Latest build do not match with target, please transfer.\n")) |
1747 _("Latest build does not match with target, please transfer.\n")) |
1746 self.EnableMethod("_Transfer", True) |
1748 self.EnableMethod("_Transfer", True) |
1747 else: |
1749 else: |
1748 self.logger.write( |
1750 self.logger.write( |
1749 _("Latest build match target, no transfer needed.\n")) |
1751 _("Latest build matches target, no transfer needed.\n")) |
1750 self.EnableMethod("_Transfer", True) |
1752 self.EnableMethod("_Transfer", True) |
1751 #self.EnableMethod("_Transfer", False) |
1753 #self.EnableMethod("_Transfer", False) |
1752 else: |
1754 else: |
1753 self.logger.write_warning( |
1755 self.logger.write_warning( |
1754 _("Cannot compare latest build to target. Please build.\n")) |
1756 _("Cannot compare latest build to target. Please build.\n")) |
1770 return False |
1772 return False |
1771 |
1773 |
1772 # Compare PLC project with PLC on target |
1774 # Compare PLC project with PLC on target |
1773 if self._connector.MatchMD5(MD5): |
1775 if self._connector.MatchMD5(MD5): |
1774 self.logger.write( |
1776 self.logger.write( |
1775 _("Latest build already match current target. Transfering anyway...\n")) |
1777 _("Latest build already matches current target. Transfering anyway...\n")) |
1776 |
1778 |
1777 # Get temprary directory path |
1779 # Get temprary directory path |
1778 extrafilespath = self._getExtraFilesPath() |
1780 extrafilespath = self._getExtraFilesPath() |
1779 extrafiles = [(name, open(os.path.join(extrafilespath, name), |
1781 extrafiles = [(name, open(os.path.join(extrafilespath, name), |
1780 'rb').read()) \ |
1782 'rb').read()) \ |
1794 self.ProgramTransferred() |
1796 self.ProgramTransferred() |
1795 self.logger.write(_("Transfer completed successfully.\n")) |
1797 self.logger.write(_("Transfer completed successfully.\n")) |
1796 else: |
1798 else: |
1797 self.logger.write_error(_("Transfer failed\n")) |
1799 self.logger.write_error(_("Transfer failed\n")) |
1798 else: |
1800 else: |
1799 self.logger.write_error(_("No PLC to transfer (did build success ?)\n")) |
1801 self.logger.write_error(_("No PLC to transfer (did build succeed ?)\n")) |
|
1802 |
1800 self.UpdateMethodsFromPLCStatus() |
1803 self.UpdateMethodsFromPLCStatus() |
1801 |
1804 |
1802 PluginMethods = [ |
1805 PluginMethods = [ |
1803 {"bitmap" : opjimg("Build"), |
1806 {"bitmap" : opjimg("Build"), |
1804 "name" : _("Build"), |
1807 "name" : _("Build"), |