From 688a5083d223b84067d9c4b6a7ccc301b6618db1 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Wed, 8 Aug 2018 15:53:26 +0200 Subject: [PATCH] Add canUpdateFirmware property to printer output devices --- cura/PrinterOutput/GenericOutputController.py | 2 ++ cura/PrinterOutput/PrinterOutputController.py | 1 + cura/PrinterOutput/PrinterOutputModel.py | 7 +++++++ plugins/USBPrinting/AvrFirmwareUpdater.py | 1 - .../UpgradeFirmwareMachineAction.qml | 1 + 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cura/PrinterOutput/GenericOutputController.py b/cura/PrinterOutput/GenericOutputController.py index e6310e5bff..32ad9d8022 100644 --- a/cura/PrinterOutput/GenericOutputController.py +++ b/cura/PrinterOutput/GenericOutputController.py @@ -29,6 +29,8 @@ class GenericOutputController(PrinterOutputController): self._output_device.printersChanged.connect(self._onPrintersChanged) self._active_printer = None + self.can_update_firmware = True + def _onPrintersChanged(self): if self._active_printer: self._active_printer.stateChanged.disconnect(self._onPrinterStateChanged) diff --git a/cura/PrinterOutput/PrinterOutputController.py b/cura/PrinterOutput/PrinterOutputController.py index 58c6ef05a7..4fe5c04a65 100644 --- a/cura/PrinterOutput/PrinterOutputController.py +++ b/cura/PrinterOutput/PrinterOutputController.py @@ -18,6 +18,7 @@ class PrinterOutputController: self.can_pre_heat_hotends = True self.can_send_raw_gcode = True self.can_control_manually = True + self.can_update_firmware = False self._output_device = output_device def setTargetHotendTemperature(self, printer: "PrinterOutputModel", extruder: "ExtruderOutputModel", temperature: int): diff --git a/cura/PrinterOutput/PrinterOutputModel.py b/cura/PrinterOutput/PrinterOutputModel.py index 6fafa368bb..f43dbf570e 100644 --- a/cura/PrinterOutput/PrinterOutputModel.py +++ b/cura/PrinterOutput/PrinterOutputModel.py @@ -277,6 +277,13 @@ class PrinterOutputModel(QObject): return self._controller.can_control_manually return False + # Does the printer support upgrading firmware + @pyqtProperty(bool, notify = canUpdateFirmwareChanged) + def canUpdateFirmware(self): + if self._controller: + return self._controller.can_update_firmware + return False + # Returns the configuration (material, variant and buildplate) of the current printer @pyqtProperty(QObject, notify = configurationChanged) def printerConfiguration(self): diff --git a/plugins/USBPrinting/AvrFirmwareUpdater.py b/plugins/USBPrinting/AvrFirmwareUpdater.py index 5c2b8dc19e..681601e3a5 100644 --- a/plugins/USBPrinting/AvrFirmwareUpdater.py +++ b/plugins/USBPrinting/AvrFirmwareUpdater.py @@ -9,7 +9,6 @@ from .avr_isp import stk500v2, intelHex from enum import IntEnum -@signalemitter class AvrFirmwareUpdater(QObject): firmwareProgressChanged = pyqtSignal() firmwareUpdateStateChanged = pyqtSignal() diff --git a/plugins/UltimakerMachineActions/UpgradeFirmwareMachineAction.qml b/plugins/UltimakerMachineActions/UpgradeFirmwareMachineAction.qml index ed771d2a04..03c17cd811 100644 --- a/plugins/UltimakerMachineActions/UpgradeFirmwareMachineAction.qml +++ b/plugins/UltimakerMachineActions/UpgradeFirmwareMachineAction.qml @@ -16,6 +16,7 @@ Cura.MachineAction anchors.fill: parent; property bool printerConnected: Cura.MachineManager.printerConnected property var activeOutputDevice: printerConnected ? Cura.MachineManager.printerOutputDevices[0] : null + property var canUpdateFirmware: activeOutputDevice ? activeOutputDevice.canUpdateFirmware : False Item {