diff --git a/PrinterCommunication/Io/GCodeFileStream.cs b/PrinterCommunication/Io/GCodeFileStream.cs index 253d383f9..8c2393738 100644 --- a/PrinterCommunication/Io/GCodeFileStream.cs +++ b/PrinterCommunication/Io/GCodeFileStream.cs @@ -33,8 +33,8 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io { public class GCodeFileStream : GCodeStream { - public GCodeFile GCodeFile { get; private set; } private int printerCommandQueueLineIndex = -1; + public GCodeFile GCodeFile { get; } public GCodeFileStream(GCodeFile fileStreaming, int startLine = 0) { @@ -42,11 +42,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io printerCommandQueueLineIndex = startLine; } - public int LineIndex { get { return printerCommandQueueLineIndex; } } - - public override void Dispose() - { - } + public int LineIndex => printerCommandQueueLineIndex; public override string ReadLine() { @@ -61,5 +57,9 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io public override void SetPrinterPosition(PrinterMove position) { } + + public override void Dispose() + { + } } } \ No newline at end of file diff --git a/PrinterCommunication/PrinterConnection.cs b/PrinterCommunication/PrinterConnection.cs index 7be3fe42d..998cc8010 100644 --- a/PrinterCommunication/PrinterConnection.cs +++ b/PrinterCommunication/PrinterConnection.cs @@ -546,10 +546,10 @@ namespace MatterHackers.MatterControl.PrinterCommunication if (gCodeFileStream0 != null) { int instructionIndex = gCodeFileStream0.LineIndex - backupAmount; - return gCodeFileStream0?.GCodeFile?.GetLayerIndex(instructionIndex) ?? 0; + return gCodeFileStream0?.GCodeFile?.GetLayerIndex(instructionIndex) ?? -1; } - return 0; + return -1; } } @@ -2112,6 +2112,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication } else { + gCodeFileStream0 = null; firstStream = new NotPrintingStream(); } diff --git a/Tests/MatterControl.AutomationTests/PrintingTests.cs b/Tests/MatterControl.AutomationTests/PrintingTests.cs index c10581553..79afee8a3 100644 --- a/Tests/MatterControl.AutomationTests/PrintingTests.cs +++ b/Tests/MatterControl.AutomationTests/PrintingTests.cs @@ -287,12 +287,14 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.WaitForName("Connect to printer button", 10); testRunner.ClickByName("Connect to printer button"); + testRunner.WaitFor(() => ApplicationController.Instance.ActivePrinter.Connection.CommunicationState == CommunicationStates.Connected); + // Assert that recovery happens // Recover the print ClickDialogButton(testRunner, "Yes Button", -1); - // The first pause that we get affter recovery should be layer 6. + // The first pause that we get after recovery should be layer 6. // wait for the pause and continue ClickDialogButton(testRunner, "No Button", 6);