379 if result: |
379 if result: |
380 return result |
380 return result |
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 |
384 self.UpdateButtons() |
385 if os.path.exists(self._getBuildPath()): |
|
386 self.EnableMethod("_Clean", True) |
|
387 |
|
388 if os.path.isfile(self._getIECcodepath()): |
|
389 self.ShowMethod("_showIECcode", True) |
|
390 |
|
391 self.UpdateMethodsFromPLCStatus() |
|
392 |
|
393 return None |
385 return None |
394 |
386 |
395 def RecursiveConfNodeInfos(self, confnode): |
387 def RecursiveConfNodeInfos(self, confnode): |
396 values = [] |
388 values = [] |
397 for CTNChild in confnode.IECSortedChildren(): |
389 for CTNChild in confnode.IECSortedChildren(): |
969 buildpath = self._getBuildPath() |
961 buildpath = self._getBuildPath() |
970 |
962 |
971 # Eventually create build dir |
963 # Eventually create build dir |
972 if not os.path.exists(buildpath): |
964 if not os.path.exists(buildpath): |
973 os.mkdir(buildpath) |
965 os.mkdir(buildpath) |
974 # There is something to clean |
|
975 self.EnableMethod("_Clean", True) |
|
976 |
966 |
977 self.logger.flush() |
967 self.logger.flush() |
978 self.logger.write(_("Start build in %s\n") % buildpath) |
968 self.logger.write(_("Start build in %s\n") % buildpath) |
979 |
969 |
980 # Generate SoftPLC IEC code |
970 # Generate SoftPLC IEC code |
981 IECGenRes = self._Generate_SoftPLC() |
971 IECGenRes = self._Generate_SoftPLC() |
982 self.ShowMethod("_showIECcode", True) |
972 self.UpdateButtons() |
983 |
973 |
984 # If IEC code gen fail, bail out. |
974 # If IEC code gen fail, bail out. |
985 if not IECGenRes: |
975 if not IECGenRes: |
986 self.logger.write_error(_("PLC code generation failed !\n")) |
976 self.logger.write_error(_("PLC code generation failed !\n")) |
987 self.ResetBuildMD5() |
977 self.ResetBuildMD5() |
1219 if os.path.isdir(os.path.join(self._getBuildPath())): |
1209 if os.path.isdir(os.path.join(self._getBuildPath())): |
1220 self.logger.write(_("Cleaning the build directory\n")) |
1210 self.logger.write(_("Cleaning the build directory\n")) |
1221 shutil.rmtree(os.path.join(self._getBuildPath())) |
1211 shutil.rmtree(os.path.join(self._getBuildPath())) |
1222 else: |
1212 else: |
1223 self.logger.write_error(_("Build directory already clean\n")) |
1213 self.logger.write_error(_("Build directory already clean\n")) |
1224 self.ShowMethod("_showIECcode", False) |
|
1225 self.EnableMethod("_Clean", False) |
|
1226 # kill the builder |
1214 # kill the builder |
1227 self._builder = None |
1215 self._builder = None |
1228 self.CompareLocalAndRemotePLC() |
1216 self.CompareLocalAndRemotePLC() |
1229 |
1217 self.UpdateButtons() |
|
1218 |
|
1219 def _UpdateButtons(self): |
|
1220 self.EnableMethod("_Clean", os.path.exists(self._getBuildPath())) |
|
1221 self.ShowMethod("_showIECcode", os.path.isfile(self._getIECcodepath())) |
|
1222 if not self.UpdateMethodsFromPLCStatus(): |
|
1223 self.AppFrame.RefreshStatusToolBar() |
|
1224 |
|
1225 def UpdateButtons(self): |
|
1226 wx.CallAfter(self._UpdateButtons) |
|
1227 |
|
1228 |
1230 def UpdatePLCLog(self, log_count): |
1229 def UpdatePLCLog(self, log_count): |
1231 if log_count: |
1230 if log_count: |
1232 if self.AppFrame is not None: |
1231 if self.AppFrame is not None: |
1233 self.AppFrame.LogViewer.SetLogCounters(log_count) |
1232 self.AppFrame.LogViewer.SetLogCounters(log_count) |
1234 |
1233 |
1235 def UpdateMethodsFromPLCStatus(self): |
1234 def UpdateMethodsFromPLCStatus(self): |
|
1235 updated = False |
1236 status = None |
1236 status = None |
1237 if self._connector is not None: |
1237 if self._connector is not None: |
1238 PLCstatus = self._connector.GetPLCstatus() |
1238 PLCstatus = self._connector.GetPLCstatus() |
1239 if PLCstatus is not None: |
1239 if PLCstatus is not None: |
1240 status, log_count = PLCstatus |
1240 status, log_count = PLCstatus |
1258 ("_Disconnect", False)], |
1258 ("_Disconnect", False)], |
1259 }.get(status,[]): |
1259 }.get(status,[]): |
1260 self.ShowMethod(*args) |
1260 self.ShowMethod(*args) |
1261 self.previous_plcstate = status |
1261 self.previous_plcstate = status |
1262 if self.AppFrame is not None: |
1262 if self.AppFrame is not None: |
|
1263 updated = True |
1263 self.AppFrame.RefreshStatusToolBar() |
1264 self.AppFrame.RefreshStatusToolBar() |
1264 if status == "Disconnected": |
1265 if status == "Disconnected": |
1265 self.AppFrame.ConnectionStatusBar.SetStatusText(_(status), 1) |
1266 self.AppFrame.ConnectionStatusBar.SetStatusText(_(status), 1) |
1266 self.AppFrame.ConnectionStatusBar.SetStatusText('', 2) |
1267 self.AppFrame.ConnectionStatusBar.SetStatusText('', 2) |
1267 else: |
1268 else: |
1268 self.AppFrame.ConnectionStatusBar.SetStatusText( |
1269 self.AppFrame.ConnectionStatusBar.SetStatusText( |
1269 _("Connected to URI: %s") % self.BeremizRoot.getURI_location().strip(), 1) |
1270 _("Connected to URI: %s") % self.BeremizRoot.getURI_location().strip(), 1) |
1270 self.AppFrame.ConnectionStatusBar.SetStatusText(_(status), 2) |
1271 self.AppFrame.ConnectionStatusBar.SetStatusText(_(status), 2) |
|
1272 return updated |
1271 |
1273 |
1272 def PullPLCStatusProc(self, event): |
1274 def PullPLCStatusProc(self, event): |
1273 self.UpdateMethodsFromPLCStatus() |
1275 self.UpdateMethodsFromPLCStatus() |
1274 |
1276 |
1275 def SnapshotAndResetDebugValuesBuffers(self): |
1277 def SnapshotAndResetDebugValuesBuffers(self): |