mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-24 07:03:56 -06:00
Move pre-heat timer into PrinterOutputDevice
If it's held inside the device that has two advantages: It's being held per-device, so switching connection doesn't stop the timer. And also, the logic is no longer in the GUI. Contributes to issue CURA-3161.
This commit is contained in:
parent
2f89a1cff4
commit
75a50b73c2
3 changed files with 28 additions and 22 deletions
|
@ -3,12 +3,11 @@
|
|||
|
||||
from UM.i18n import i18nCatalog
|
||||
from UM.OutputDevice.OutputDevice import OutputDevice
|
||||
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject
|
||||
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject, QTimer
|
||||
from PyQt5.QtWidgets import QMessageBox
|
||||
from enum import IntEnum # For the connection state tracking.
|
||||
|
||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||
|
||||
from enum import IntEnum # For the connection state tracking.
|
||||
from UM.Logger import Logger
|
||||
from UM.Signal import signalemitter
|
||||
|
||||
|
@ -49,6 +48,9 @@ class PrinterOutputDevice(QObject, OutputDevice):
|
|||
self._error_text = ""
|
||||
self._accepts_commands = True
|
||||
self._preheat_bed_timeout = 900 #Default time-out for pre-heating the bed, in seconds.
|
||||
self._preheat_bed_timer = QTimer() #Timer that tracks how long to preheat still.
|
||||
self._preheat_bed_timer.setSingleShot(True)
|
||||
self._preheat_bed_timer.timeout.connect(self.cancelPreheatBed)
|
||||
|
||||
self._printer_state = ""
|
||||
self._printer_type = "unknown"
|
||||
|
@ -214,13 +216,26 @@ class PrinterOutputDevice(QObject, OutputDevice):
|
|||
self._target_bed_temperature = temperature
|
||||
self.targetBedTemperatureChanged.emit()
|
||||
|
||||
## The duration of the time-out to pre-heat the bed, in seconds.
|
||||
## The total duration of the time-out to pre-heat the bed, in seconds.
|
||||
#
|
||||
# \return The duration of the time-out to pre-heat the bed, in seconds.
|
||||
@pyqtProperty(int)
|
||||
@pyqtProperty(int, constant = True)
|
||||
def preheatBedTimeout(self):
|
||||
return self._preheat_bed_timeout
|
||||
|
||||
## The remaining duration of the pre-heating of the bed.
|
||||
#
|
||||
# This is formatted in M:SS format.
|
||||
# \return The duration of the time-out to pre-heat the bed, formatted.
|
||||
@pyqtProperty(str)
|
||||
def preheatBedRemainingTime(self):
|
||||
period = self._preheat_bed_timer.remainingTime()
|
||||
if period <= 0:
|
||||
return ""
|
||||
minutes, period = divmod(period, 60000) #60000 milliseconds in a minute.
|
||||
seconds, _ = divmod(period, 1000) #1000 milliseconds in a second.
|
||||
return "%d:%02d" % (minutes, seconds)
|
||||
|
||||
## Time the print has been printing.
|
||||
# Note that timeTotal - timeElapsed should give time remaining.
|
||||
@pyqtProperty(float, notify = timeElapsedChanged)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue