diff --git a/Gui/QtGUIutils/QtApplication.py b/Gui/QtGUIutils/QtApplication.py index 588a1d5b..0e4c6d94 100644 --- a/Gui/QtGUIutils/QtApplication.py +++ b/Gui/QtGUIutils/QtApplication.py @@ -1329,10 +1329,19 @@ def goExpert(self): def GlobalStop(self): print("Critical status detected: Emitting Global Stop signal") self.globalStop.emit() - self.instruments.off() - if self.expertMode: - self.releaseHVPowerPanel() - self.releaseLVPowerPanel() + try: + self.instruments.off() + if self.expertMode: + self.releaseHVPowerPanel() + self.releaseLVPowerPanel() + except Exception: + QMessageBox.critical( + None, + "Cold Box Connection Error", + "Warning: connection lost with the cold box.\n\n" + "The instruments could not be switched off. Please check the " + "connection to the cold box.", + ) ############################################################### ## Main page and related functions (END) @@ -1373,7 +1382,16 @@ def closeEvent(self, event): logger.debug("Failed to stop Tessie monitoring cleanly during application shutdown") print("Application terminated") if self.instruments is not None: - self.instruments.off() + try: + self.instruments.off() + except Exception: + QMessageBox.critical( + None, + "Cold Box Connection Error", + "Warning: connection lost with the cold box.\n\n" + "The instruments could not be switched off during shutdown. " + "Please check the connection to the cold box.", + ) # If you didn't start the Peltier controller, tempPower won't be defined if site_settings.cooler == "Peltier":