mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-12-02 15:21:15 -07: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
|
|
@ -288,23 +288,16 @@ Column
|
|||
property var endTime: new Date() //Set initial endTime to be the current date, so that the endTime has initially already passed and the timer text becomes invisible if you were to update.
|
||||
function update()
|
||||
{
|
||||
var now = new Date();
|
||||
if (now.getTime() < endTime.getTime())
|
||||
preheatCountdown.text = ""
|
||||
if (connectedPrinter != null)
|
||||
{
|
||||
var remaining = endTime - now; //This is in milliseconds.
|
||||
var minutes = Math.floor(remaining / 60 / 1000);
|
||||
var seconds = Math.floor((remaining / 1000) % 60);
|
||||
preheatCountdown.text = minutes + ":" + (seconds < 10 ? "0" + seconds : seconds);
|
||||
preheatCountdown.visible = true;
|
||||
preheatCountdown.text = connectedPrinter.preheatBedRemainingTime;
|
||||
}
|
||||
else
|
||||
if (preheatCountdown.text == "") //Either time elapsed or not connected.
|
||||
{
|
||||
preheatCountdown.visible = false;
|
||||
running = false;
|
||||
if (connectedPrinter != null)
|
||||
{
|
||||
connectedPrinter.cancelPreheatBed()
|
||||
}
|
||||
stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -440,17 +433,12 @@ Column
|
|||
if (!preheatCountdownTimer.running)
|
||||
{
|
||||
connectedPrinter.preheatBed(preheatTemperatureInput.text, connectedPrinter.preheatBedTimeout);
|
||||
var now = new Date();
|
||||
var end_time = new Date();
|
||||
end_time.setTime(now.getTime() + connectedPrinter.preheatBedTimeout * 1000); //*1000 because time is in milliseconds here.
|
||||
preheatCountdownTimer.endTime = end_time;
|
||||
preheatCountdownTimer.start();
|
||||
preheatCountdownTimer.update(); //Update once before the first timer is triggered.
|
||||
}
|
||||
else
|
||||
{
|
||||
connectedPrinter.cancelPreheatBed();
|
||||
preheatCountdownTimer.endTime = new Date();
|
||||
preheatCountdownTimer.update();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue