Allow printer output devices to set their ability to update firmware

This commit is contained in:
fieldOfView 2018-08-22 14:37:48 +02:00
parent c1d7ca7bff
commit 4bea1410b8
5 changed files with 40 additions and 17 deletions

View file

@ -29,8 +29,6 @@ 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)

View file

@ -2,6 +2,7 @@
# Cura is released under the terms of the LGPLv3 or higher.
from UM.Logger import Logger
from UM.Signal import Signal
MYPY = False
if MYPY:
@ -56,3 +57,9 @@ class PrinterOutputController:
def sendRawCommand(self, printer: "PrinterOutputModel", command: str):
Logger.log("w", "Custom command not implemented in controller")
canUpdateFirmwareChanged = Signal()
def setCanUpdateFirmware(self, can_update_firmware: bool):
if can_update_firmware != self.can_update_firmware:
self.can_update_firmware = can_update_firmware
self.canUpdateFirmwareChanged.emit()

View file

@ -26,6 +26,7 @@ class PrinterOutputModel(QObject):
buildplateChanged = pyqtSignal()
cameraChanged = pyqtSignal()
configurationChanged = pyqtSignal()
canUpdateFirmwareChanged = pyqtSignal()
def __init__(self, output_controller: "PrinterOutputController", number_of_extruders: int = 1, parent=None, firmware_version = "") -> None:
super().__init__(parent)
@ -34,6 +35,7 @@ class PrinterOutputModel(QObject):
self._name = ""
self._key = "" # Unique identifier
self._controller = output_controller
self._controller.canUpdateFirmwareChanged.connect(self._onControllerCanUpdateFirmwareChanged)
self._extruders = [ExtruderOutputModel(printer = self, position = i) for i in range(number_of_extruders)]
self._printer_configuration = ConfigurationModel() # Indicates the current configuration setup in this printer
self._head_position = Vector(0, 0, 0)
@ -284,6 +286,10 @@ class PrinterOutputModel(QObject):
return self._controller.can_update_firmware
return False
# Stub to connect UM.Signal to pyqtSignal
def _onControllerCanUpdateFirmwareChanged(self):
self.canUpdateFirmwareChanged.emit()
# Returns the configuration (material, variant and buildplate) of the current printer
@pyqtProperty(QObject, notify = configurationChanged)
def printerConfiguration(self):