diff --git a/PrinterCommunication/PrinterConnection.cs b/PrinterCommunication/PrinterConnection.cs index 20debfcb8..c7978ca91 100644 --- a/PrinterCommunication/PrinterConnection.cs +++ b/PrinterCommunication/PrinterConnection.cs @@ -2449,6 +2449,8 @@ namespace MatterHackers.MatterControl.PrinterCommunication } } + public int TurnOffHeatDelay { get; set; } = 60; + public void TurnOffBedAndExtruders(bool now) { if (now) @@ -2461,9 +2463,8 @@ namespace MatterHackers.MatterControl.PrinterCommunication } else { - int secondsToWait = 60; - bool currentlyWaiting = ContinuWaitingToTurnOffHeaters && TimeHaveBeenWaitingToTurnOffHeaters.IsRunning && TimeHaveBeenWaitingToTurnOffHeaters.Elapsed.TotalSeconds < secondsToWait; - SecondsUntilTurnOffHeaters = secondsToWait; + bool currentlyWaiting = ContinuWaitingToTurnOffHeaters && TimeHaveBeenWaitingToTurnOffHeaters.IsRunning && TimeHaveBeenWaitingToTurnOffHeaters.Elapsed.TotalSeconds < TurnOffHeatDelay; + SecondsUntilTurnOffHeaters = TurnOffHeatDelay; ContinuWaitingToTurnOffHeaters = true; TimeHaveBeenWaitingToTurnOffHeaters = Stopwatch.StartNew(); if (!currentlyWaiting) @@ -2472,10 +2473,10 @@ namespace MatterHackers.MatterControl.PrinterCommunication // wait secondsToWait and turn off the heaters Task.Run(() => { - while (TimeHaveBeenWaitingToTurnOffHeaters.Elapsed.TotalSeconds < secondsToWait + while (TimeHaveBeenWaitingToTurnOffHeaters.Elapsed.TotalSeconds < TurnOffHeatDelay && ContinuWaitingToTurnOffHeaters) { - SecondsUntilTurnOffHeaters = ContinuWaitingToTurnOffHeaters ? Math.Max(0, secondsToWait - TimeHaveBeenWaitingToTurnOffHeaters.Elapsed.TotalSeconds) : 0; + SecondsUntilTurnOffHeaters = ContinuWaitingToTurnOffHeaters ? Math.Max(0, TurnOffHeatDelay - TimeHaveBeenWaitingToTurnOffHeaters.Elapsed.TotalSeconds) : 0; Thread.Sleep(100); } diff --git a/Tests/MatterControl.AutomationTests/PrintingTests.cs b/Tests/MatterControl.AutomationTests/PrintingTests.cs index a10058e23..4c1477e6e 100644 --- a/Tests/MatterControl.AutomationTests/PrintingTests.cs +++ b/Tests/MatterControl.AutomationTests/PrintingTests.cs @@ -35,13 +35,16 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.AddItemToBedplate(); + // Sorten the delay so the test runs in a reasonable time + ApplicationController.Instance.ActivePrinter.Connection.TurnOffHeatDelay = 5; + testRunner.StartPrint(); // Wait for print to finish testRunner.WaitForPrintFinished(); // Wait for expected temp - testRunner.WaitFor(() => ApplicationController.Instance.ActivePrinter.Connection.GetActualHotendTemperature(0) <= 0); + testRunner.WaitFor(() => ApplicationController.Instance.ActivePrinter.Connection.GetActualHotendTemperature(0) <= 0, 10); Assert.Less(ApplicationController.Instance.ActivePrinter.Connection.GetActualHotendTemperature(0), 30); // Wait for expected temp @@ -55,7 +58,7 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.WaitForPrintFinished(); // Wait for expected temp - testRunner.WaitFor(() => ApplicationController.Instance.ActivePrinter.Connection.GetActualHotendTemperature(0) <= 0); + testRunner.WaitFor(() => ApplicationController.Instance.ActivePrinter.Connection.GetActualHotendTemperature(0) <= 0, 10); Assert.Less(ApplicationController.Instance.ActivePrinter.Connection.GetActualHotendTemperature(0), 30); // Wait for expected temp @@ -64,7 +67,7 @@ namespace MatterHackers.MatterControl.Tests.Automation } return Task.CompletedTask; - }, maxTimeToRun: 70); + }, maxTimeToRun: 95); } [Test, Category("Emulator")]