mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-16 11:17:49 -06:00
PrinterOutput device now uses connection state
This is instead of the multiple booleans that were used in USB printer CURA-1339
This commit is contained in:
parent
5830690107
commit
2b9aa1dbb5
1 changed files with 17 additions and 13 deletions
|
@ -1,6 +1,6 @@
|
||||||
from UM.OutputDevice.OutputDevice import OutputDevice
|
from UM.OutputDevice.OutputDevice import OutputDevice
|
||||||
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject
|
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.
|
## 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._bed_temperature = 0
|
||||||
self._hotend_temperatures = {}
|
self._hotend_temperatures = {}
|
||||||
self._target_hotend_temperatures = {}
|
self._target_hotend_temperatures = {}
|
||||||
self._progress = -1
|
self._progress = 0
|
||||||
self._head_x = 0
|
self._head_x = 0
|
||||||
self._head_y = 0
|
self._head_y = 0
|
||||||
self._head_z = 0
|
self._head_z = 0
|
||||||
self._connected = False
|
self._connection_state = ConnectionState.CLOSED
|
||||||
self._connecting = False
|
|
||||||
|
|
||||||
def requestWrite(self, node, file_name = None, filter_by_machine = False):
|
def requestWrite(self, node, file_name = None, filter_by_machine = False):
|
||||||
raise NotImplementedError("requestWrite needs to be implemented")
|
raise NotImplementedError("requestWrite needs to be implemented")
|
||||||
|
@ -41,8 +40,7 @@ class PrinterOutputDevice(OutputDevice, QObject):
|
||||||
|
|
||||||
headPositionChanged = pyqtSignal()
|
headPositionChanged = pyqtSignal()
|
||||||
|
|
||||||
conectedChanged = pyqtSignal()
|
connectionStateChanged = pyqtSignal(str)
|
||||||
connectingChanged = pyqtSignal()
|
|
||||||
|
|
||||||
## Get the bed temperature of the bed (if any)
|
## Get the bed temperature of the bed (if any)
|
||||||
# This function is "final" (do not re-implement)
|
# This function is "final" (do not re-implement)
|
||||||
|
@ -112,13 +110,13 @@ class PrinterOutputDevice(OutputDevice, QObject):
|
||||||
def close(self):
|
def close(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@pyqtProperty(bool, notify = conectedChanged)
|
@pyqtProperty(bool, notify = connectionStateChanged)
|
||||||
def connected(self):
|
def connectionState(self):
|
||||||
return self._connected
|
return self._connection_state
|
||||||
|
|
||||||
@pyqtProperty(bool, notify = connectingChanged)
|
def setConnectionState(self, connection_state):
|
||||||
def isConnecting(self):
|
self._connection_state = connection_state
|
||||||
return self._connecting
|
self.connectionStateChanged.emit(self._id)
|
||||||
|
|
||||||
## Ensure that close gets called when object is destroyed
|
## Ensure that close gets called when object is destroyed
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
|
@ -203,4 +201,10 @@ class PrinterOutputDevice(OutputDevice, QObject):
|
||||||
## Set the progress of any currently active process
|
## Set the progress of any currently active process
|
||||||
def setProgress(self, progress):
|
def setProgress(self, progress):
|
||||||
self._progress = progress
|
self._progress = progress
|
||||||
self.progressChanged.emit()
|
self.progressChanged.emit()
|
||||||
|
|
||||||
|
## The current processing state of the backend.
|
||||||
|
class ConnectionState(IntEnum):
|
||||||
|
CLOSED = 0
|
||||||
|
CONNECTING = 1
|
||||||
|
CONNECTED = 2
|
Loading…
Add table
Add a link
Reference in a new issue