private static void ValidateStreamResponse(string[] expected, GCodeStream testStream, List <GCodeStream> streamList = null) { int lineIndex = 0; // Advance string actualLine = testStream.ReadLine(); string expectedLine = expected[lineIndex++]; while (actualLine != null) { if (actualLine == "G92 E0") { testStream.SetPrinterPosition(new PrinterMove(new Vector3(), 0, 300)); } if (actualLine == "G92 Z0") { testStream.SetPrinterPosition(new PrinterMove(new Vector3(), 0, 0)); } if (actualLine == "; do_resume") { PauseHandlingStream pauseStream = null; foreach (var stream in streamList) { if (stream as PauseHandlingStream != null) { pauseStream = (PauseHandlingStream)stream; pauseStream.Resume(); } } } if (expectedLine != actualLine) { int a = 0; } Debug.WriteLine(actualLine); Assert.AreEqual(expectedLine, actualLine, "Unexpected response from testStream"); // Advance actualLine = testStream.ReadLine(); if (lineIndex < expected.Length) { expectedLine = expected[lineIndex++]; } } }
public void CorrectZOutputPositions() { string[] inputLines = new string[] { "G1 Z-2 F300", "G92 Z0", "G1 Z5 F300", "G28", null, }; // We should go back to the above code when possible. It requires making pause part and move while paused part of the stream. // All communication should go through stream to minimize the difference between printing and controlling while not printing (all printing in essence). string[] expected = new string[] { "G1 Z-1 F300", "G1 Z-2", "G92 Z0", "G1 Z1 F300", "G1 Z2", "G1 Z3", "G1 Z4", "G1 Z5", "G28", null, }; AggContext.StaticData = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData")); MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4)); List <GCodeStream> streamList; GCodeStream testStream = CreateTestGCodeStream(inputLines, out streamList); int expectedIndex = 0; string actualLine = testStream.ReadLine(); string expectedLine = expected[expectedIndex++]; Assert.AreEqual(expectedLine, actualLine, "Unexpected response from testStream"); while (actualLine != null) { actualLine = testStream.ReadLine(); if (actualLine == "G92 Z0") { testStream.SetPrinterPosition(new PrinterMove(new Vector3(), 0, 0)); } expectedLine = expected[expectedIndex++]; Assert.AreEqual(expectedLine, actualLine, "Unexpected response from testStream"); } }
public void CorrectZOutputPositions() { string[] inputLines = new string[] { "G1 Z-2 F300", "G92 Z0", "G1 Z5 F300", "G28", null, }; // We should go back to the above code when possible. It requires making pause part and move while paused part of the stream. // All communication should go through stream to minimize the difference between printing and controlling while not printing (all printing in essence). string[] expected = new string[] { "G1 Z-1 F300", "G1 Z-2", "G92 Z0", "G1 Z1 F300", "G1 Z2", "G1 Z3", "G1 Z4", "G1 Z5", "G28", null, }; GCodeStream testStream = CreateTestGCodeStream(inputLines); int expectedIndex = 0; string actualLine = testStream.ReadLine(); string expectedLine = expected[expectedIndex++]; Assert.AreEqual(expectedLine, actualLine, "Unexpected response from testStream"); while (actualLine != null) { actualLine = testStream.ReadLine(); if (actualLine == "G92 Z0") { testStream.SetPrinterPosition(new PrinterMove(new Vector3(), 0, 0)); } expectedLine = expected[expectedIndex++]; Assert.AreEqual(expectedLine, actualLine, "Unexpected response from testStream"); } }
public void CorrectEOutputPositions() { string[] inputLines = new string[] { "G1 E11 F300", // BCN tool change test // Before: "G92 E0", "G91", "G1 E - 5 F302", "G90", // After: "G91", "G1 E8 F150", "G90", "G4 P0", "G92 E0", "G4 P0", "G91", "G1 E-2 F301", "G90", null, }; // We should go back to the above code when possible. It requires making pause part and move while paused part of the stream. // All communication should go through stream to minimize the difference between printing and controlling while not printing (all printing in essence). string[] expected = new string[] { "G1 E11 F300", // before "G92 E0", "", "G1 E-5 F302", "G90", // after "", // G91 is removed "G1 E3 F150", // altered to be absolute "G90", "G4 P0", "G92 E0", "G4 P0", "", // G91 is removed "G1 E-2 F301", "G90", null, }; GCodeStream testStream = CreateTestGCodeStream(inputLines); int expectedIndex = 0; string actualLine = testStream.ReadLine(); string expectedLine = expected[expectedIndex++]; Assert.AreEqual(expectedLine, actualLine, "Unexpected response from testStream"); while (actualLine != null) { actualLine = testStream.ReadLine(); if (actualLine == "G92 E0") { testStream.SetPrinterPosition(new PrinterMove(new Vector3(), 0, 300)); } expectedLine = expected[expectedIndex++]; Assert.AreEqual(expectedLine, actualLine, "Unexpected response from testStream"); } }
public void CorrectEOutputPositions() { string[] inputLines = new string[] { "G1 E11 F300", // BCN tool change test // Before: "G92 E0", "G91", "G1 E - 5 F302", "G90", // After: "G91", "G1 E8 F150", "G90", "G4 P0", "G92 E0", "G4 P0", "G91", "G1 E-2 F301", "G90", null, }; // We should go back to the above code when possible. It requires making pause part and move while paused part of the stream. // All communication should go through stream to minimize the difference between printing and controlling while not printing (all printing in essence). string[] expected = new string[] { "G1 E1 F300", "G1 E2", "G1 E3", "G1 E4", "G1 E5", "G1 E6", "G1 E7", "G1 E8", "G1 E9", "G1 E10", "G1 E11", "G92 E0", "", "G1 E-1 F302", "G1 E-2", "G1 E-3", "G1 E-4", "G1 E-5", "G90", "", "G1 E-4 F150", "G1 E-3", "G1 E-2", "G1 E-1", "G1 E0", "G1 E1", "G1 E2", "G1 E3", "G90", "G4 P0", "G92 E0", "G4 P0", "", "G1 E-1 F301", "G1 E-2", "G90", null, }; AggContext.StaticData = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData")); MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4)); List <GCodeStream> streamList; GCodeStream testStream = CreateTestGCodeStream(inputLines, out streamList); int expectedIndex = 0; string actualLine = testStream.ReadLine(); string expectedLine = expected[expectedIndex++]; Assert.AreEqual(expectedLine, actualLine, "Unexpected response from testStream"); Debug.WriteLine(actualLine); while (actualLine != null) { actualLine = testStream.ReadLine(); if (actualLine == "G92 E0") { testStream.SetPrinterPosition(new PrinterMove(new Vector3(), 0, 300)); } expectedLine = expected[expectedIndex++]; Debug.WriteLine(actualLine); Assert.AreEqual(expectedLine, actualLine, "Unexpected response from testStream"); } }
public override void SetPrinterPosition(PrinterMove position) { internalStream.SetPrinterPosition(position); }