From 5af78b67e779f0a67f6cfb2a4d37719a7f359ea9 Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Fri, 2 Feb 2018 09:17:04 -0800 Subject: [PATCH 1/2] Fixing CompletingPrintTurnsoffHeat --- PrinterCommunication/PrinterConnection.cs | 11 ++++++----- Tests/MatterControl.AutomationTests/PrintingTests.cs | 7 +++++-- 2 files changed, 11 insertions(+), 7 deletions(-) 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..81e13f22d 100644 --- a/Tests/MatterControl.AutomationTests/PrintingTests.cs +++ b/Tests/MatterControl.AutomationTests/PrintingTests.cs @@ -48,6 +48,9 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.WaitFor(() => ApplicationController.Instance.ActivePrinter.Connection.ActualBedTemperature <= 10); Assert.Less(ApplicationController.Instance.ActivePrinter.Connection.ActualBedTemperature, 10); + // Sorten the delay so the test runs in a reasonable time + ApplicationController.Instance.ActivePrinter.Connection.TurnOffHeatDelay = 5; + // Make sure we can run this whole thing again testRunner.StartPrint(); @@ -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")] From c904b4bf802075f0a2ff96c0d6a84ee625b2134e Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Fri, 2 Feb 2018 09:27:06 -0800 Subject: [PATCH 2/2] Fixed test --- Tests/MatterControl.AutomationTests/PrintingTests.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/MatterControl.AutomationTests/PrintingTests.cs b/Tests/MatterControl.AutomationTests/PrintingTests.cs index 81e13f22d..4c1477e6e 100644 --- a/Tests/MatterControl.AutomationTests/PrintingTests.cs +++ b/Tests/MatterControl.AutomationTests/PrintingTests.cs @@ -35,22 +35,22 @@ 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 testRunner.WaitFor(() => ApplicationController.Instance.ActivePrinter.Connection.ActualBedTemperature <= 10); Assert.Less(ApplicationController.Instance.ActivePrinter.Connection.ActualBedTemperature, 10); - // Sorten the delay so the test runs in a reasonable time - ApplicationController.Instance.ActivePrinter.Connection.TurnOffHeatDelay = 5; - // Make sure we can run this whole thing again testRunner.StartPrint();