mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 07:33:57 -06:00
Merge pull request #926 from thopiekar/master-CURA-2079
[CURA-2079] Adding detailed error messages to firmware updater dialog
This commit is contained in:
commit
0e7893f71b
3 changed files with 94 additions and 21 deletions
|
@ -32,20 +32,49 @@ UM.Dialog
|
||||||
}
|
}
|
||||||
|
|
||||||
text: {
|
text: {
|
||||||
if (manager.firmwareUpdateCompleteStatus)
|
if (manager.errorCode == 0)
|
||||||
{
|
{
|
||||||
//: Firmware update status label
|
if (manager.firmwareUpdateCompleteStatus)
|
||||||
return catalog.i18nc("@label","Firmware update completed.")
|
{
|
||||||
|
//: Firmware update status label
|
||||||
|
return catalog.i18nc("@label","Firmware update completed.")
|
||||||
|
}
|
||||||
|
else if (manager.progress == 0)
|
||||||
|
{
|
||||||
|
//: Firmware update status label
|
||||||
|
return catalog.i18nc("@label","Starting firmware update, this may take a while.")
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//: Firmware update status label
|
||||||
|
return catalog.i18nc("@label","Updating firmware.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (manager.progress == 0)
|
else
|
||||||
{
|
{
|
||||||
//: Firmware update status label
|
switch (manager.errorCode)
|
||||||
return catalog.i18nc("@label","Starting firmware update, this may take a while.")
|
{
|
||||||
}
|
case 1:
|
||||||
else
|
//: Firmware update status label
|
||||||
{
|
return catalog.i18nc("@label","Firmware update failed due to an unknown error.")
|
||||||
//: Firmware update status label
|
|
||||||
return catalog.i18nc("@label","Updating firmware.")
|
case 2:
|
||||||
|
//: Firmware update status label
|
||||||
|
return catalog.i18nc("@label","Firmware update failed due to an communication error.")
|
||||||
|
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
//: Firmware update status label
|
||||||
|
return catalog.i18nc("@label","Firmware update failed due to an input/output error.")
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
//: Firmware update status label
|
||||||
|
return catalog.i18nc("@label","Firmware update failed due to missing firmware.")
|
||||||
|
|
||||||
|
default:
|
||||||
|
//: Firmware update status label
|
||||||
|
return catalog.i18nc("@label", "Unknown error code: %1").arg(manager.errorCode)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ from UM.Logger import Logger
|
||||||
from cura.PrinterOutputDevice import PrinterOutputDevice, ConnectionState
|
from cura.PrinterOutputDevice import PrinterOutputDevice, ConnectionState
|
||||||
from UM.Message import Message
|
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
|
from UM.i18n import i18nCatalog
|
||||||
catalog = i18nCatalog("cura")
|
catalog = i18nCatalog("cura")
|
||||||
|
@ -90,6 +90,8 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
||||||
self._firmware_update_finished = False
|
self._firmware_update_finished = False
|
||||||
|
|
||||||
self._error_message = None
|
self._error_message = None
|
||||||
|
|
||||||
|
self._error_code = 0
|
||||||
|
|
||||||
onError = pyqtSignal()
|
onError = pyqtSignal()
|
||||||
|
|
||||||
|
@ -173,6 +175,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
||||||
|
|
||||||
## Private function (threaded) that actually uploads the firmware.
|
## Private function (threaded) that actually uploads the firmware.
|
||||||
def _updateFirmware(self):
|
def _updateFirmware(self):
|
||||||
|
self._error_code = 0
|
||||||
self.setProgress(0, 100)
|
self.setProgress(0, 100)
|
||||||
self._firmware_update_finished = False
|
self._firmware_update_finished = False
|
||||||
|
|
||||||
|
@ -182,7 +185,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
||||||
|
|
||||||
if len(hex_file) == 0:
|
if len(hex_file) == 0:
|
||||||
Logger.log("e", "Unable to read provided hex file. Could not update firmware")
|
Logger.log("e", "Unable to read provided hex file. Could not update firmware")
|
||||||
self._updateFirmware_completed()
|
self._updateFirmwareFailedMissingFirmware()
|
||||||
return
|
return
|
||||||
|
|
||||||
programmer = stk500v2.Stk500v2()
|
programmer = stk500v2.Stk500v2()
|
||||||
|
@ -198,7 +201,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
||||||
|
|
||||||
if not programmer.isConnected():
|
if not programmer.isConnected():
|
||||||
Logger.log("e", "Unable to connect with serial. Could not update firmware")
|
Logger.log("e", "Unable to connect with serial. Could not update firmware")
|
||||||
self._updateFirmware_completed()
|
self._updateFirmwareFailedCommunicationError()
|
||||||
return
|
return
|
||||||
|
|
||||||
self._updating_firmware = True
|
self._updating_firmware = True
|
||||||
|
@ -206,22 +209,56 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
||||||
try:
|
try:
|
||||||
programmer.programChip(hex_file)
|
programmer.programChip(hex_file)
|
||||||
self._updating_firmware = False
|
self._updating_firmware = False
|
||||||
|
except serial.SerialException as e:
|
||||||
|
Logger.log("e", "SerialException while trying to update firmware: <%s>" %(repr(e)))
|
||||||
|
self._updateFirmwareFailedIOError()
|
||||||
|
return
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Logger.log("e", "Exception while trying to update firmware %s" %e)
|
Logger.log("e", "Exception while trying to update firmware: <%s>" %(repr(e)))
|
||||||
self._updateFirmware_completed()
|
self._updateFirmwareFailedUnknown()
|
||||||
return
|
return
|
||||||
programmer.close()
|
programmer.close()
|
||||||
|
|
||||||
self._updateFirmware_completed()
|
self._updateFirmwareCompletedSucessfully()
|
||||||
return
|
return
|
||||||
|
|
||||||
## Private function which makes sure that firmware update process has completed/ended
|
## Private function which makes sure that firmware update process has failed by missing firmware
|
||||||
def _updateFirmware_completed(self):
|
def _updateFirmwareFailedMissingFirmware(self):
|
||||||
|
return self._updateFirmwareFailedCommon(4)
|
||||||
|
|
||||||
|
## Private function which makes sure that firmware update process has failed by an IO error
|
||||||
|
def _updateFirmwareFailedIOError(self):
|
||||||
|
return self._updateFirmwareFailedCommon(3)
|
||||||
|
|
||||||
|
## Private function which makes sure that firmware update process has failed by a communication problem
|
||||||
|
def _updateFirmwareFailedCommunicationError(self):
|
||||||
|
return self._updateFirmwareFailedCommon(2)
|
||||||
|
|
||||||
|
## Private function which makes sure that firmware update process has failed by an unknown error
|
||||||
|
def _updateFirmwareFailedUnknown(self):
|
||||||
|
return self._updateFirmwareFailedCommon(1)
|
||||||
|
|
||||||
|
## Private common function which makes sure that firmware update process has completed/ended with a set progress state
|
||||||
|
def _updateFirmwareFailedCommon(self, code):
|
||||||
|
if not code:
|
||||||
|
raise Exception("Error code not set!")
|
||||||
|
|
||||||
|
self._error_code = code
|
||||||
|
|
||||||
|
self._firmware_update_finished = True
|
||||||
|
self.resetFirmwareUpdate(update_has_finished = True)
|
||||||
|
self.progressChanged.emit()
|
||||||
|
self.firmwareUpdateComplete.emit()
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
## Private function which makes sure that firmware update process has successfully completed
|
||||||
|
def _updateFirmwareCompletedSucessfully(self):
|
||||||
self.setProgress(100, 100)
|
self.setProgress(100, 100)
|
||||||
self._firmware_update_finished = True
|
self._firmware_update_finished = True
|
||||||
self.resetFirmwareUpdate(update_has_finished=True)
|
self.resetFirmwareUpdate(update_has_finished = True)
|
||||||
self.firmwareUpdateComplete.emit()
|
self.firmwareUpdateComplete.emit()
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
## Upload new firmware to machine
|
## Upload new firmware to machine
|
||||||
|
|
|
@ -57,6 +57,13 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin, Extension):
|
||||||
progress += device.progress
|
progress += device.progress
|
||||||
return progress / len(self._usb_output_devices)
|
return progress / len(self._usb_output_devices)
|
||||||
|
|
||||||
|
@pyqtProperty(int, notify = progressChanged)
|
||||||
|
def errorCode(self):
|
||||||
|
for printer_name, device in self._usb_output_devices.items(): # TODO: @UnusedVariable "printer_name"
|
||||||
|
if device._error_code:
|
||||||
|
return device._error_code
|
||||||
|
return 0
|
||||||
|
|
||||||
## Return True if all printers finished firmware update
|
## Return True if all printers finished firmware update
|
||||||
@pyqtProperty(float, notify = firmwareUpdateChange)
|
@pyqtProperty(float, notify = firmwareUpdateChange)
|
||||||
def firmwareUpdateCompleteStatus(self):
|
def firmwareUpdateCompleteStatus(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue