From 2b9aa1dbb5d5a6afb00b3c0a719283e015bbfeee Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 13 Apr 2016 15:09:25 +0200 Subject: [PATCH] PrinterOutput device now uses connection state This is instead of the multiple booleans that were used in USB printer CURA-1339 --- cura/PrinterOutputDevice.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/cura/PrinterOutputDevice.py b/cura/PrinterOutputDevice.py index 6d86cd8a91..54550e1aee 100644 --- a/cura/PrinterOutputDevice.py +++ b/cura/PrinterOutputDevice.py @@ -1,6 +1,6 @@ from UM.OutputDevice.OutputDevice import OutputDevice from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject - +from enum import IntEnum # For the connection state tracking. ## Printer output device adds extra interface options on top of output device. # @@ -20,12 +20,11 @@ class PrinterOutputDevice(OutputDevice, QObject): self._bed_temperature = 0 self._hotend_temperatures = {} self._target_hotend_temperatures = {} - self._progress = -1 + self._progress = 0 self._head_x = 0 self._head_y = 0 self._head_z = 0 - self._connected = False - self._connecting = False + self._connection_state = ConnectionState.CLOSED def requestWrite(self, node, file_name = None, filter_by_machine = False): raise NotImplementedError("requestWrite needs to be implemented") @@ -41,8 +40,7 @@ class PrinterOutputDevice(OutputDevice, QObject): headPositionChanged = pyqtSignal() - conectedChanged = pyqtSignal() - connectingChanged = pyqtSignal() + connectionStateChanged = pyqtSignal(str) ## Get the bed temperature of the bed (if any) # This function is "final" (do not re-implement) @@ -112,13 +110,13 @@ class PrinterOutputDevice(OutputDevice, QObject): def close(self): pass - @pyqtProperty(bool, notify = conectedChanged) - def connected(self): - return self._connected + @pyqtProperty(bool, notify = connectionStateChanged) + def connectionState(self): + return self._connection_state - @pyqtProperty(bool, notify = connectingChanged) - def isConnecting(self): - return self._connecting + def setConnectionState(self, connection_state): + self._connection_state = connection_state + self.connectionStateChanged.emit(self._id) ## Ensure that close gets called when object is destroyed def __del__(self): @@ -203,4 +201,10 @@ class PrinterOutputDevice(OutputDevice, QObject): ## Set the progress of any currently active process def setProgress(self, progress): self._progress = progress - self.progressChanged.emit() \ No newline at end of file + self.progressChanged.emit() + +## The current processing state of the backend. +class ConnectionState(IntEnum): + CLOSED = 0 + CONNECTING = 1 + CONNECTED = 2 \ No newline at end of file