mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
CURA-2079: Using errorCode (WIP)
Sadly I don't see any reason why errorCode doesn't get updated in QML. self._errorCode is accessible, but changes to it don't take any effect.
This commit is contained in:
parent
b42ef49a4e
commit
e72a10c97a
3 changed files with 80 additions and 55 deletions
|
@ -14,7 +14,7 @@ from UM.Logger import Logger
|
|||
from cura.PrinterOutputDevice import PrinterOutputDevice, ConnectionState
|
||||
from UM.Message import Message
|
||||
|
||||
from PyQt5.QtCore import QUrl, pyqtSlot, pyqtSignal
|
||||
from PyQt5.QtCore import QUrl, pyqtSlot, pyqtSignal, pyqtProperty
|
||||
|
||||
from UM.i18n import i18nCatalog
|
||||
catalog = i18nCatalog("cura")
|
||||
|
@ -173,6 +173,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
|||
|
||||
## Private function (threaded) that actually uploads the firmware.
|
||||
def _updateFirmware(self):
|
||||
self._errorCode = 0
|
||||
self.setProgress(0, 100)
|
||||
self._firmware_update_finished = False
|
||||
|
||||
|
@ -198,7 +199,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
|||
|
||||
if not programmer.isConnected():
|
||||
Logger.log("e", "Unable to connect with serial. Could not update firmware")
|
||||
self._updateFirmware_completed_communication_error()
|
||||
self._updateFirmware_failed_communication_error()
|
||||
return
|
||||
|
||||
self._updating_firmware = True
|
||||
|
@ -208,11 +209,11 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
|||
self._updating_firmware = False
|
||||
except serial.SerialException as e:
|
||||
Logger.log("e", "SerialException while trying to update firmware: <%s>" %(repr(e)))
|
||||
self._updateFirmware_completed_io_error()
|
||||
self._updateFirmware_failed_io_error()
|
||||
return
|
||||
except Exception as e:
|
||||
Logger.log("e", "Exception while trying to update firmware: <%s>" %(repr(e)))
|
||||
self._updateFirmware_completed_unknown()
|
||||
self._updateFirmware_failed_unknown()
|
||||
return
|
||||
programmer.close()
|
||||
|
||||
|
@ -220,35 +221,42 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
|||
return
|
||||
|
||||
## Private function which makes sure that firmware update process has failed by missing firmware
|
||||
def _updateFirmware_completed_missing_firmware(self):
|
||||
return self._updateFirmware_completed_common(progress = -4)
|
||||
def _updateFirmware_failed_missing_firmware(self):
|
||||
return self._updateFirmware_failed_common(4)
|
||||
|
||||
## Private function which makes sure that firmware update process has failed by an IO error
|
||||
def _updateFirmware_completed_io_error(self):
|
||||
return self._updateFirmware_completed_common(progress = -3)
|
||||
def _updateFirmware_failed_io_error(self):
|
||||
return self._updateFirmware_failed_common(3)
|
||||
|
||||
## Private function which makes sure that firmware update process has failed by a communication problem
|
||||
def _updateFirmware_completed_communication_error(self):
|
||||
return self._updateFirmware_completed_common(progress = -2)
|
||||
def _updateFirmware_failed_communication_error(self):
|
||||
return self._updateFirmware_failed_common(2)
|
||||
|
||||
## Private function which makes sure that firmware update process has failed by an unknown error
|
||||
def _updateFirmware_completed_unknown(self):
|
||||
return self._updateFirmware_completed_common(progress = -1)
|
||||
def _updateFirmware_failed_unknown(self):
|
||||
return self._updateFirmware_failed_common(1)
|
||||
|
||||
## Private function which makes sure that firmware update process has sucessfully completed/ended
|
||||
## Private function which makes sure that firmware update process has successfully completed
|
||||
def _updateFirmware_completed_sucessfully(self):
|
||||
return self._updateFirmware_completed_common(progress = 100)
|
||||
|
||||
## Private common function which makes sure that firmware update process has completed/ended with a set progress state
|
||||
def _updateFirmware_completed_common(self, progress, max_progress = 100):
|
||||
if not progress:
|
||||
raise Exception("Progress not set!")
|
||||
|
||||
self.setProgress(progress, max_progress = max_progress)
|
||||
self.setProgress(100, 100)
|
||||
self._firmware_update_finished = True
|
||||
self.resetFirmwareUpdate(update_has_finished=True)
|
||||
self.resetFirmwareUpdate(update_has_finished = True)
|
||||
self.firmwareUpdateComplete.emit()
|
||||
|
||||
|
||||
return
|
||||
|
||||
## Private common function which makes sure that firmware update process has completed/ended with a set progress state
|
||||
def _updateFirmware_failed_common(self, code):
|
||||
if not code:
|
||||
raise Exception("Error code not set!")
|
||||
|
||||
self._errorCode = code
|
||||
|
||||
self._firmware_update_finished = True
|
||||
self.resetFirmwareUpdate(update_has_finished = True)
|
||||
self.progressChanged.emit()
|
||||
self.firmwareUpdateComplete.emit()
|
||||
|
||||
return
|
||||
|
||||
## Upload new firmware to machine
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue