149 try: |
149 try: |
150 # Invoke compiler. Output files are listed to stdout, errors to stderr |
150 # Invoke compiler. Output files are listed to stdout, errors to stderr |
151 status, result, err_result = ProcessLogger(None, buildcmd, |
151 status, result, err_result = ProcessLogger(None, buildcmd, |
152 no_stdout=True, |
152 no_stdout=True, |
153 no_stderr=True).spin() |
153 no_stderr=True).spin() |
154 except Exception, e: |
154 except Exception: |
155 return buildopt |
155 return buildopt |
156 |
156 |
157 for opt in options: |
157 for opt in options: |
158 if opt in result: |
158 if opt in result: |
159 buildopt = buildopt + " " + opt |
159 buildopt = buildopt + " " + opt |
964 |
964 |
965 # third section contains ticktime |
965 # third section contains ticktime |
966 if len(ListGroup) > 2: |
966 if len(ListGroup) > 2: |
967 self._Ticktime = int(ListGroup[2][0]) |
967 self._Ticktime = int(ListGroup[2][0]) |
968 |
968 |
969 except Exception, e: |
969 except Exception: |
970 self.logger.write_error(_("Cannot open/parse VARIABLES.csv!\n")) |
970 self.logger.write_error(_("Cannot open/parse VARIABLES.csv!\n")) |
971 self.logger.write_error(traceback.format_exc()) |
971 self.logger.write_error(traceback.format_exc()) |
972 self.ResetIECProgramsAndVariables() |
972 self.ResetIECProgramsAndVariables() |
973 return False |
973 return False |
974 |
974 |
1105 # Build |
1105 # Build |
1106 try: |
1106 try: |
1107 if not builder.build(): |
1107 if not builder.build(): |
1108 self.logger.write_error(_("C Build failed.\n")) |
1108 self.logger.write_error(_("C Build failed.\n")) |
1109 return False |
1109 return False |
1110 except Exception, exc: |
1110 except Exception: |
1111 self.logger.write_error(_("C Build crashed !\n")) |
1111 self.logger.write_error(_("C Build crashed !\n")) |
1112 self.logger.write_error(traceback.format_exc()) |
1112 self.logger.write_error(traceback.format_exc()) |
1113 self.ResetBuildMD5() |
1113 self.ResetBuildMD5() |
1114 return False |
1114 return False |
1115 |
1115 |
1124 # Generate C code and compilation params from confnode hierarchy |
1124 # Generate C code and compilation params from confnode hierarchy |
1125 try: |
1125 try: |
1126 CTNLocationCFilesAndCFLAGS, CTNLDFLAGS, CTNExtraFiles = self._Generate_C( |
1126 CTNLocationCFilesAndCFLAGS, CTNLDFLAGS, CTNExtraFiles = self._Generate_C( |
1127 buildpath, |
1127 buildpath, |
1128 self.PLCGeneratedLocatedVars) |
1128 self.PLCGeneratedLocatedVars) |
1129 except Exception, exc: |
1129 except Exception: |
1130 self.logger.write_error(_("Runtime IO extensions C code generation failed !\n")) |
1130 self.logger.write_error(_("Runtime IO extensions C code generation failed !\n")) |
1131 self.logger.write_error(traceback.format_exc()) |
1131 self.logger.write_error(traceback.format_exc()) |
1132 self.ResetBuildMD5() |
1132 self.ResetBuildMD5() |
1133 return False |
1133 return False |
1134 |
1134 |
1135 # Generate C code and compilation params from liraries |
1135 # Generate C code and compilation params from liraries |
1136 try: |
1136 try: |
1137 LibCFilesAndCFLAGS, LibLDFLAGS, LibExtraFiles = self.GetLibrariesCCode(buildpath) |
1137 LibCFilesAndCFLAGS, LibLDFLAGS, LibExtraFiles = self.GetLibrariesCCode(buildpath) |
1138 except Exception, exc: |
1138 except Exception: |
1139 self.logger.write_error(_("Runtime library extensions C code generation failed !\n")) |
1139 self.logger.write_error(_("Runtime library extensions C code generation failed !\n")) |
1140 self.logger.write_error(traceback.format_exc()) |
1140 self.logger.write_error(traceback.format_exc()) |
1141 self.ResetBuildMD5() |
1141 self.ResetBuildMD5() |
1142 return False |
1142 return False |
1143 |
1143 |
1176 raise |
1176 raise |
1177 code_path = os.path.join(buildpath, filename) |
1177 code_path = os.path.join(buildpath, filename) |
1178 open(code_path, "w").write(code) |
1178 open(code_path, "w").write(code) |
1179 # Insert this file as first file to be compiled at root confnode |
1179 # Insert this file as first file to be compiled at root confnode |
1180 self.LocationCFilesAndCFLAGS[0][1].insert(0, (code_path, self.plcCFLAGS)) |
1180 self.LocationCFilesAndCFLAGS[0][1].insert(0, (code_path, self.plcCFLAGS)) |
1181 except Exception, exc: |
1181 except Exception: |
1182 self.logger.write_error(name+_(" generation failed !\n")) |
1182 self.logger.write_error(name+_(" generation failed !\n")) |
1183 self.logger.write_error(traceback.format_exc()) |
1183 self.logger.write_error(traceback.format_exc()) |
1184 self.ResetBuildMD5() |
1184 self.ResetBuildMD5() |
1185 return False |
1185 return False |
1186 self.logger.write(_("C code generated successfully.\n")) |
1186 self.logger.write(_("C code generated successfully.\n")) |
1598 plc_status, Traces = self._connector.GetTraceVariables() |
1598 plc_status, Traces = self._connector.GetTraceVariables() |
1599 debug_getvar_retry += 1 |
1599 debug_getvar_retry += 1 |
1600 # print [dict.keys() for IECPath, (dict, log, status, fvalue) in self.IECdebug_datas.items()] |
1600 # print [dict.keys() for IECPath, (dict, log, status, fvalue) in self.IECdebug_datas.items()] |
1601 if plc_status == "Started": |
1601 if plc_status == "Started": |
1602 if len(Traces) > 0: |
1602 if len(Traces) > 0: |
1603 Failed = False |
|
1604 self.IECdebug_lock.acquire() |
1603 self.IECdebug_lock.acquire() |
1605 for debug_tick, debug_buff in Traces: |
1604 for debug_tick, debug_buff in Traces: |
1606 debug_vars = UnpackDebugBuffer(debug_buff, self.TracedIECTypes) |
1605 debug_vars = UnpackDebugBuffer(debug_buff, self.TracedIECTypes) |
1607 if debug_vars is not None and len(debug_vars) == len(self.TracedIECPath): |
1606 if debug_vars is not None and len(debug_vars) == len(self.TracedIECPath): |
1608 for IECPath, values_buffer, value in izip( |
1607 for IECPath, values_buffer, value in izip( |
1753 self.AppFrame.RefreshPageTitles() |
1752 self.AppFrame.RefreshPageTitles() |
1754 |
1753 |
1755 # Get connector from uri |
1754 # Get connector from uri |
1756 try: |
1755 try: |
1757 self._SetConnector(connectors.ConnectorFactory(uri, self)) |
1756 self._SetConnector(connectors.ConnectorFactory(uri, self)) |
1758 except Exception, msg: |
1757 except Exception: |
1759 self.logger.write_error(_("Exception while connecting %s!\n") % uri) |
1758 self.logger.write_error(_("Exception while connecting %s!\n") % uri) |
1760 self.logger.write_error(traceback.format_exc()) |
1759 self.logger.write_error(traceback.format_exc()) |
1761 |
1760 |
1762 # Did connection success ? |
1761 # Did connection success ? |
1763 if self._connector is None: |
1762 if self._connector is None: |
1770 |
1769 |
1771 self.CompareLocalAndRemotePLC() |
1770 self.CompareLocalAndRemotePLC() |
1772 |
1771 |
1773 # Init with actual PLC status and print it |
1772 # Init with actual PLC status and print it |
1774 self.UpdateMethodsFromPLCStatus() |
1773 self.UpdateMethodsFromPLCStatus() |
1775 if self.previous_plcstate is not None: |
|
1776 status = _(self.previous_plcstate) |
|
1777 else: |
|
1778 status = "" |
|
1779 |
|
1780 # self.logger.write(_("PLC is %s\n")%status) |
|
1781 |
|
1782 if self.previous_plcstate in ["Started", "Stopped"]: |
1774 if self.previous_plcstate in ["Started", "Stopped"]: |
1783 if self.DebugAvailable() and self.GetIECProgramsAndVariables(): |
1775 if self.DebugAvailable() and self.GetIECProgramsAndVariables(): |
1784 self.logger.write(_("Debugger ready\n")) |
1776 self.logger.write(_("Debugger ready\n")) |
1785 self._connect_debug() |
1777 self._connect_debug() |
1786 else: |
1778 else: |