diff --git a/MatterControl.Winforms/InspectForm.cs b/MatterControl.Winforms/InspectForm.cs index 921764d43..d7469d804 100644 --- a/MatterControl.Winforms/InspectForm.cs +++ b/MatterControl.Winforms/InspectForm.cs @@ -512,7 +512,7 @@ namespace MatterHackers.MatterControl var sb = new StringBuilder(); - while (context is GCodeStreamProxy gCodeStream) + while (context is GCodeStream gCodeStream) { sb.AppendFormat("{0} {1}\r\n", gCodeStream.GetType().Name, gCodeStream.DebugInfo); context = gCodeStream.InternalStream; diff --git a/MatterControlLib/PrinterCommunication/Io/GCodeFileStream.cs b/MatterControlLib/PrinterCommunication/Io/GCodeFileStream.cs index 3c0f7bcf9..40ed9b374 100644 --- a/MatterControlLib/PrinterCommunication/Io/GCodeFileStream.cs +++ b/MatterControlLib/PrinterCommunication/Io/GCodeFileStream.cs @@ -34,7 +34,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io public class GCodeFileStream : GCodeStream { private int printerCommandQueueLineIndex = -1; - public GCodeFile GCodeFile { get; } + private string lastLine = ""; public GCodeFileStream(GCodeFile fileStreaming, PrinterConfig printer, int startLine = 0) : base(printer) @@ -43,6 +43,8 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io printerCommandQueueLineIndex = startLine; } + public GCodeFile GCodeFile { get; } + public int LineIndex => printerCommandQueueLineIndex; public override string ReadLine() @@ -62,5 +64,9 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io public override void Dispose() { } + + public override GCodeStream InternalStream => null; + + public override string DebugInfo => lastLine; } } \ No newline at end of file diff --git a/MatterControlLib/PrinterCommunication/Io/GCodeStream.cs b/MatterControlLib/PrinterCommunication/Io/GCodeStream.cs index 5a1eee3ed..ed2595a6f 100644 --- a/MatterControlLib/PrinterCommunication/Io/GCodeStream.cs +++ b/MatterControlLib/PrinterCommunication/Io/GCodeStream.cs @@ -60,6 +60,10 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io } } + public abstract GCodeStream InternalStream { get; } + + public abstract string DebugInfo { get; } + public string CreateMovementLine(PrinterMove currentDestination) { return CreateMovementLine(currentDestination, PrinterMove.Unknown); diff --git a/MatterControlLib/PrinterCommunication/Io/GCodeStreamProxy.cs b/MatterControlLib/PrinterCommunication/Io/GCodeStreamProxy.cs index 4b60d8c12..12a99c84e 100644 --- a/MatterControlLib/PrinterCommunication/Io/GCodeStreamProxy.cs +++ b/MatterControlLib/PrinterCommunication/Io/GCodeStreamProxy.cs @@ -27,13 +27,6 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ -using System; -using MatterHackers.Agg; -using MatterHackers.GCodeVisualizer; -using MatterHackers.VectorMath; -using System.Text; -using System.Collections.Generic; -using MatterHackers.MatterControl.ConfigurationPage.PrintLeveling; namespace MatterHackers.MatterControl.PrinterCommunication.Io { @@ -47,9 +40,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io this.internalStream = internalStream; } - public GCodeStream InternalStream => internalStream; - - public abstract string DebugInfo { get; } + public override GCodeStream InternalStream => internalStream; public override void Dispose() { diff --git a/MatterControlLib/PrinterCommunication/Io/GCodeSwitcher.cs b/MatterControlLib/PrinterCommunication/Io/GCodeSwitcher.cs index 1c6e65bc0..e4fd9f7ee 100644 --- a/MatterControlLib/PrinterCommunication/Io/GCodeSwitcher.cs +++ b/MatterControlLib/PrinterCommunication/Io/GCodeSwitcher.cs @@ -27,11 +27,11 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ -using MatterControl.Printing; -using MatterHackers.VectorMath; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; +using MatterControl.Printing; +using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.PrinterCommunication.Io { @@ -41,6 +41,8 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io private object locker = new object(); private List commandQueue = new List(); + private string lastLine = ""; + public GCodeSwitcher(string gcodeFilename, PrinterConfig printer, int startLine = 0) : base(printer) { @@ -70,6 +72,9 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io { var lineToSend = commandQueue[0]; commandQueue.RemoveAt(0); + + lastLine = lineToSend; + return lineToSend; } } @@ -128,7 +133,9 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io } } - return GCodeFile.Instruction(LineIndex++).Line; + lastLine = GCodeFile.Instruction(LineIndex++).Line; + + return lastLine; } return null; @@ -158,5 +165,9 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io }); } } + + public override GCodeStream InternalStream => null; + + public override string DebugInfo => lastLine; } } \ No newline at end of file diff --git a/MatterControlLib/PrinterCommunication/Io/NotPrintingStream.cs b/MatterControlLib/PrinterCommunication/Io/NotPrintingStream.cs index 88214e16f..714cff3a1 100644 --- a/MatterControlLib/PrinterCommunication/Io/NotPrintingStream.cs +++ b/MatterControlLib/PrinterCommunication/Io/NotPrintingStream.cs @@ -27,12 +27,6 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ -using System; -using MatterHackers.Agg; -using MatterHackers.GCodeVisualizer; -using MatterHackers.VectorMath; -using System.Text; -using System.Collections.Generic; using System.Threading; namespace MatterHackers.MatterControl.PrinterCommunication.Io @@ -57,5 +51,9 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io public override void SetPrinterPosition(PrinterMove position) { } + + public override GCodeStream InternalStream => null; + + public override string DebugInfo => ""; } } \ No newline at end of file diff --git a/MatterControlLib/PrinterCommunication/Io/PrintRecoveryStream.cs b/MatterControlLib/PrinterCommunication/Io/PrintRecoveryStream.cs index 335a56e2b..21acfc7f2 100644 --- a/MatterControlLib/PrinterCommunication/Io/PrintRecoveryStream.cs +++ b/MatterControlLib/PrinterCommunication/Io/PrintRecoveryStream.cs @@ -44,6 +44,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io PrinterMove lastDestination; QueuedCommandsStream queuedCommands; RectangleDouble boundsOfSkippedLayers = RectangleDouble.ZeroIntersection; + private string lastLine; public RecoveryState RecoveryState { get; private set; } = RecoveryState.RemoveHeating; @@ -79,6 +80,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io string nextCommand = queuedCommands.ReadLine(); if (nextCommand != null) { + lastLine = nextCommand; return nextCommand; } @@ -112,6 +114,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io } RecoveryState = RecoveryState.Raising; + lastLine = ""; return ""; // remove it from the part @@ -123,6 +126,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io queuedCommands.Add("G1 Z10 F{0}".FormatWith(printer.Settings.ZSpeed())); queuedCommands.Add("G90 ; move absolute"); RecoveryState = RecoveryState.Homing; + lastLine = ""; return ""; // if top homing, home the extruder @@ -200,6 +204,8 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io || line.StartsWith("M107") // fan off || line.StartsWith("G92")) // set position { + lastLine = line; + return line; } } @@ -262,6 +268,8 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io return lineToSend; } + lastLine = lineToSend; + return lineToSend; } } @@ -276,5 +284,9 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io return null; } + + public override GCodeStream InternalStream => internalStream; + + public override string DebugInfo => lastLine + $" {this.lastDestination}"; } } \ No newline at end of file diff --git a/Tests/MatterControl.Tests/MatterControl/GCodeStreamTests.cs b/Tests/MatterControl.Tests/MatterControl/GCodeStreamTests.cs index 63e3ae8a1..ee8e467e4 100644 --- a/Tests/MatterControl.Tests/MatterControl/GCodeStreamTests.cs +++ b/Tests/MatterControl.Tests/MatterControl/GCodeStreamTests.cs @@ -852,5 +852,9 @@ namespace MatterControl.Tests.MatterControl public override void SetPrinterPosition(PrinterMove position) { } + + public override GCodeStream InternalStream => null; + + public override string DebugInfo => ""; } } \ No newline at end of file