111 # otherwise use iec2c from PATH |
111 # otherwise use iec2c from PATH |
112 if path is not None: |
112 if path is not None: |
113 cmd=os.path.join(path, cmd) |
113 cmd=os.path.join(path, cmd) |
114 |
114 |
115 return cmd |
115 return cmd |
116 |
116 |
117 def findLibPath(self): |
117 def findLibPath(self): |
118 paths=[ |
118 paths=[ |
119 os.path.join(base_folder, "matiec", "lib"), |
119 os.path.join(base_folder, "matiec", "lib"), |
120 "/usr/lib/matiec" |
120 "/usr/lib/matiec" |
121 ] |
121 ] |
122 path = self.findObject(paths, lambda p:os.path.isfile(os.path.join(p, "ieclib.txt"))) |
122 path = self.findObject(paths, lambda p:os.path.isfile(os.path.join(p, "ieclib.txt"))) |
123 return path |
123 return path |
124 |
124 |
125 def findLibCPath(self): |
125 def findLibCPath(self): |
126 path=None |
126 path=None |
127 paths=[ |
127 paths=[ |
128 os.path.join(self.ieclib_path, "C"), |
128 os.path.join(self.ieclib_path, "C"), |
129 self.ieclib_path] |
129 self.ieclib_path] |
1156 return True |
1156 return True |
1157 |
1157 |
1158 def ShowError(self, logger, from_location, to_location): |
1158 def ShowError(self, logger, from_location, to_location): |
1159 chunk_infos = self.GetChunkInfos(from_location, to_location) |
1159 chunk_infos = self.GetChunkInfos(from_location, to_location) |
1160 for infos, (start_row, start_col) in chunk_infos: |
1160 for infos, (start_row, start_col) in chunk_infos: |
1161 row = 1 if from_location[0] < start_row else (from_location[0] - start_row) |
1161 row = 1 if from_location[0] < start_row else (from_location[0] - start_row) |
1162 col = 1 if (start_row != from_location[0]) else (from_location[1] - start_col) |
1162 col = 1 if (start_row != from_location[0]) else (from_location[1] - start_col) |
1163 start = (row, col) |
1163 start = (row, col) |
1164 |
1164 |
1165 row = 1 if to_location[0] < start_row else (to_location[0] - start_row) |
1165 row = 1 if to_location[0] < start_row else (to_location[0] - start_row) |
1166 col = 1 if (start_row != to_location[0]) else (to_location[1] - start_col) |
1166 col = 1 if (start_row != to_location[0]) else (to_location[1] - start_col) |
1167 end = (row, col) |
1167 end = (row, col) |
1168 |
1168 |
1169 if self.AppFrame is not None: |
1169 if self.AppFrame is not None: |
1170 self.AppFrame.ShowError(infos, start, end) |
1170 self.AppFrame.ShowError(infos, start, end) |
1171 |
1171 |
1172 _IECCodeView = None |
1172 _IECCodeView = None |
1173 def _showIECcode(self): |
1173 def _showIECcode(self): |
1196 try: |
1196 try: |
1197 text = file(plc_file).read() |
1197 text = file(plc_file).read() |
1198 except: |
1198 except: |
1199 text = '(* No IEC code have been generated at that time ! *)' |
1199 text = '(* No IEC code have been generated at that time ! *)' |
1200 self._IECCodeView.SetText(text = text) |
1200 self._IECCodeView.SetText(text = text) |
1201 self._IECCodeView.Editor.SetReadOnly(True) |
1201 self._IECCodeView.Editor.SetReadOnly(True) |
1202 self._IECCodeView.SetIcon(GetBitmap("ST")) |
1202 self._IECCodeView.SetIcon(GetBitmap("ST")) |
1203 setattr(self._IECCodeView, "_OnClose", self.OnCloseEditor) |
1203 setattr(self._IECCodeView, "_OnClose", self.OnCloseEditor) |
1204 |
1204 |
1205 if self._IECCodeView is not None: |
1205 if self._IECCodeView is not None: |
1206 self.AppFrame.EditProjectElement(self._IECCodeView, name) |
1206 self.AppFrame.EditProjectElement(self._IECCodeView, name) |
1303 def _UpdateButtons(self): |
1303 def _UpdateButtons(self): |
1304 self.EnableMethod("_Clean", os.path.exists(self._getBuildPath())) |
1304 self.EnableMethod("_Clean", os.path.exists(self._getBuildPath())) |
1305 self.ShowMethod("_showIECcode", os.path.isfile(self._getIECcodepath())) |
1305 self.ShowMethod("_showIECcode", os.path.isfile(self._getIECcodepath())) |
1306 if self.AppFrame is not None and not self.UpdateMethodsFromPLCStatus(): |
1306 if self.AppFrame is not None and not self.UpdateMethodsFromPLCStatus(): |
1307 self.AppFrame.RefreshStatusToolBar() |
1307 self.AppFrame.RefreshStatusToolBar() |
1308 |
1308 |
1309 def UpdateButtons(self): |
1309 def UpdateButtons(self): |
1310 wx.CallAfter(self._UpdateButtons) |
1310 wx.CallAfter(self._UpdateButtons) |
1311 |
1311 |
1312 |
1312 |
1313 def UpdatePLCLog(self, log_count): |
1313 def UpdatePLCLog(self, log_count): |
1314 if log_count: |
1314 if log_count: |
1315 if self.AppFrame is not None: |
1315 if self.AppFrame is not None: |
1316 self.AppFrame.LogViewer.SetLogCounters(log_count) |
1316 self.AppFrame.LogViewer.SetLogCounters(log_count) |
1317 |
1317 |
1362 "Empty": _("Empty"), |
1362 "Empty": _("Empty"), |
1363 "Broken": _("Broken"), |
1363 "Broken": _("Broken"), |
1364 "Disconnected": _("Disconnected") |
1364 "Disconnected": _("Disconnected") |
1365 } |
1365 } |
1366 return msgs.get(status, status) |
1366 return msgs.get(status, status) |
1367 |
1367 |
1368 def ShowPLCProgress(self, status = "", progress = 0): |
1368 def ShowPLCProgress(self, status = "", progress = 0): |
1369 self.AppFrame.ProgressStatusBar.Show() |
1369 self.AppFrame.ProgressStatusBar.Show() |
1370 self.AppFrame.ConnectionStatusBar.SetStatusText(self.GetTextStatus(status), 1) |
1370 self.AppFrame.ConnectionStatusBar.SetStatusText(self.GetTextStatus(status), 1) |
1371 self.AppFrame.ProgressStatusBar.SetValue(progress) |
1371 self.AppFrame.ProgressStatusBar.SetValue(progress) |
1372 |
1372 |
1374 # clear previous_plcstate to restore status |
1374 # clear previous_plcstate to restore status |
1375 # in UpdateMethodsFromPLCStatus() |
1375 # in UpdateMethodsFromPLCStatus() |
1376 self.previous_plcstate = "" |
1376 self.previous_plcstate = "" |
1377 self.AppFrame.ProgressStatusBar.Hide() |
1377 self.AppFrame.ProgressStatusBar.Hide() |
1378 self.UpdateMethodsFromPLCStatus() |
1378 self.UpdateMethodsFromPLCStatus() |
1379 |
1379 |
1380 def PullPLCStatusProc(self, event): |
1380 def PullPLCStatusProc(self, event): |
1381 self.UpdateMethodsFromPLCStatus() |
1381 self.UpdateMethodsFromPLCStatus() |
1382 |
1382 |
1383 def SnapshotAndResetDebugValuesBuffers(self): |
1383 def SnapshotAndResetDebugValuesBuffers(self): |
1384 buffers, self.DebugValuesBuffers = (self.DebugValuesBuffers, |
1384 buffers, self.DebugValuesBuffers = (self.DebugValuesBuffers, |
1819 self.AppFrame.RefreshPouInstanceVariablesPanel() |
1819 self.AppFrame.RefreshPouInstanceVariablesPanel() |
1820 self.logger.write(_("Transfer completed successfully.\n")) |
1820 self.logger.write(_("Transfer completed successfully.\n")) |
1821 self.AppFrame.LogViewer.ResetLogCounters(); |
1821 self.AppFrame.LogViewer.ResetLogCounters(); |
1822 else: |
1822 else: |
1823 self.logger.write_error(_("Transfer failed\n")) |
1823 self.logger.write_error(_("Transfer failed\n")) |
1824 self.HidePLCProgress() |
1824 self.HidePLCProgress() |
1825 else: |
1825 else: |
1826 self.logger.write_error(_("No PLC to transfer (did build succeed ?)\n")) |
1826 self.logger.write_error(_("No PLC to transfer (did build succeed ?)\n")) |
1827 |
1827 |
1828 wx.CallAfter(self.UpdateMethodsFromPLCStatus) |
1828 wx.CallAfter(self.UpdateMethodsFromPLCStatus) |
1829 |
1829 |