Пример #1
0
        public void LineCuttingOffWhenNoLevelingTest()
        {
            string[] inputLines = new string[]
            {
                "G1 X0Y0Z0E0 F1000",
                "G1 X10 Y0 Z0 F1000",
                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 X0 Y0 Z0 E0 F1000",
                "G1 X10",
                null,
            };

            AggContext.StaticData = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData"));
            MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4));

            var printer = new PrinterConfig(new PrinterSettings());

            printer.Settings.SetValue(SettingsKey.has_hardware_leveling, "1");

            var testStream = GCodeExport.GetExportStream(printer, new TestGCodeStream(printer, inputLines), true);

            ValidateStreamResponse(expected, testStream);
        }
Пример #2
0
        public void SmoothieRewriteTest()
        {
            string[] inputLines = new string[]
            {
                "G28",
                "M119",
            };

            // 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[]
            {
                "G28",
                "M280 P0 S10.6",
                "G4 P400",
                "M280 P0 S7",
                "G4 P400",
                "M117 Ready ",
                "M119",
                "switch filament; WRITE_RAW",
            };

            var printer = new PrinterConfig(new PrinterSettings());

            var write_filter = "\"^(G28)\", \"G28,M280 P0 S10.6,G4 P400,M280 P0 S7,G4 P400,M117 Ready \"";

            write_filter += "\\n\"^(M119)\", \"M119,switch filament; WRITE_RAW\"";
            printer.Settings.SetValue(SettingsKey.write_regex, write_filter);

            var testStream = GCodeExport.GetExportStream(printer, new TestGCodeStream(printer, inputLines), true);

            ValidateStreamResponse(expected, testStream);
        }
Пример #3
0
        public void ToolChangeHeatNoExtrusion()
        {
            string[] inputLines = new string[]
            {
                // tell the printer to heat up
                "M104 T1 S240",                 // start with T0 to test smoothie temp change code
                "M104 T0 S230",
                // send some movement comands with tool switching
                "; the printer is moving normally",
                "G1 X10 Y10 Z10 E0 F2500",
                "T1",
                "G1 X10 Y10 Z10 E0",
                "T0",
                "G1 X10 Y10 Z10 E0",
                // now do the same thing with a long enough print to cause
                // cooling and heating
                null,
            };

            string[] expected = new string[]
            {
                "M104 T1 S240",
                "T0 ; NO_PROCESSING",
                "M104 T0 S230",
                "; the printer is moving normally",
                "G1 X10 Y10 Z10 E0 F2500",
                // the code to switch to t1
                "; waiting for move on T1",
                "",
                "; simulated before toolchange 1 gcode",
                "T1",
                "; COMPLEATED_BEFORE_GCODE",
                "; simulated after toolchange 1 gcode",
                "G1 X9 Y8 Z7.1 F3000",                // the F comes from the x movement speed
                "G1 X9 Y8 Z7.1 F315",                 // the F comes from the z movement speed
                "G1 X9 Y8 Z7.1 F2500",                // restore the feedrate
                "G1 X9 Y8 Z7.1",
                // the code to switch back to t0
                "; waiting for move on T0",
                "",
                "; simulated before toolchange gcode",
                "T0",
                "; COMPLEATED_BEFORE_GCODE",
                "; simulated after toolchange gcode",
                "G1 F3000",                // the F comes from the x movement speed
                "G1 F315",                 // the F comes from the z movement speed
                "G1 F2500",                // restore the feedrate
                "G1",
                null,
            };

            PrinterConfig printer = SetupToolChangeSettings();

            var testStream = GCodeExport.GetExportStream(printer, new TestGCodeStream(printer, inputLines), true);

            ValidateStreamResponse(expected, testStream);
        }
Пример #4
0
        public void LineCuttingOnWhenLevelingOnTest()
        {
            string[] inputLines = new string[]
            {
                "G1 X0Y0Z0E0F1000",
                "G1 X0Y0Z0E1F1000",
                "G1 X10 Y0 Z0 F1000",
                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[]
            {
                "; Software Leveling Applied",
                "G1 X0 Y0 Z-0.1 E0 F1000",
                "G1 E1",
                "G1 X1 Y0 Z-0.1",
                "G1 X2 Y0 Z-0.1",
                "G1 X3 Y0 Z-0.1",
                "G1 X4 Y0 Z-0.1",
                "G1 X5 Y0 Z-0.1",
                "G1 X6 Y0 Z-0.1",
                "G1 X7 Y0 Z-0.1",
                "G1 X8 Y0 Z-0.1",
                "G1 X9 Y0 Z-0.1",
                "G1 X10 Y0 Z-0.1",
                null,
            };

            AggContext.StaticData = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData"));
            MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4));

            var printer = new PrinterConfig(new PrinterSettings());

            printer.Settings.SetValue(SettingsKey.print_leveling_enabled, "1");

            var testStream = GCodeExport.GetExportStream(printer, new TestGCodeStream(printer, inputLines), true);

            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();
                expectedLine = expected[expectedIndex++];

                Debug.WriteLine(actualLine);
                Assert.AreEqual(expectedLine, actualLine, "Unexpected response from testStream");
            }
        }
Пример #5
0
        public void SmoothieRewriteTest()
        {
            string[] inputLines = new string[]
            {
                "G28",
                "M119",
                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[]
            {
                "G28",
                "M280 P0 S10.6",
                "G4 P400",
                "M280 P0 S7",
                "G4 P400",
                "M117 Ready ",
                "M119",
                "switch filament; WRITE_RAW",
                null,
            };

            AggContext.StaticData = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData"));
            MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4));

            var printer = new PrinterConfig(new PrinterSettings());

            var write_filter = "\"^(G28)\", \"G28,M280 P0 S10.6,G4 P400,M280 P0 S7,G4 P400,M117 Ready \"";

            write_filter += "\\n\"^(M119)\", \"M119,switch filament; WRITE_RAW\"";
            printer.Settings.SetValue(SettingsKey.write_regex, write_filter);

            var testStream = GCodeExport.GetExportStream(printer, new TestGCodeStream(printer, inputLines), true);

            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();
                expectedLine = expected[expectedIndex++];

                Debug.WriteLine(actualLine);
                Assert.AreEqual(expectedLine, actualLine, "Unexpected response from testStream");
            }
        }
Пример #6
0
        public void ExportStreamG30Tests()
        {
            string[] inputLines = new string[]
            {
                "M117 Starting Print",
                "M104 S0",
                "; comment line",
                "G28 ; home all axes",
                "G0 Z10 F1800",
                "G0 Z11 F1800",
                "G0 X1Y0Z9 F1800",
                "G0 Z10 F1801",
                "G30 Z0",
                "M114",
                "G0 Z10 F1800",
                "M114",
                "M109 S[temperature]",
                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[]
            {
                "M117 Starting Print",
                "M104 S0",
                "; comment line",
                "G28 ; home all axes",
                "G1 Z10 F1800",
                "G1 Z11",
                "G1 X1 Y0 Z9",
                "G1 Z10 F1801",
                "G30 Z0",
                "M114",
                "G1 Z10 F1800",
                "M114",
                "M109 S[temperature]",
                null,
            };

            AggContext.StaticData = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData"));
            MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4));

            var printer = new PrinterConfig(new PrinterSettings());

            var testStream = GCodeExport.GetExportStream(printer, new TestGCodeStream(printer, inputLines), true);

            ValidateStreamResponse(expected, testStream);
        }
Пример #7
0
        public void RegexReplacementStreamIsLast()
        {
            var printer = new PrinterConfig(new PrinterSettings());
            var context = GCodeExport.GetExportStream(printer, new TestGCodeStream(printer, new [] { "" }), true);

            var streamProcessors = new List <GCodeStream>();

            while (context is GCodeStream gCodeStream)
            {
                streamProcessors.Add(context);
                context = gCodeStream.InternalStream;
            }

            Assert.IsTrue(streamProcessors.First() is ProcessWriteRegexStream, "ProcessWriteRegexStream should be the last stream in the stack");
        }
Пример #8
0
        public void LineCuttingOnWhenLevelingOnWithProbeTest()
        {
            string[] inputLines = new string[]
            {
                "G1 X0Y0Z0E0F1000",
                "G1 X0Y0Z0E1F1000",
                "G1 X10 Y0 Z0 F1000",
            };

            string[] expected = new string[]
            {
                "; Software Leveling Applied",
                "G1 X0 Y0 Z-0.1 E0 F1000",
                "G1 E1",
                "G1 X1 Y0 Z-0.1",
                "G1 X2 Y0 Z-0.1",
                "G1 X3 Y0 Z-0.1",
                "G1 X4 Y0 Z-0.1",
                "G1 X5 Y0 Z-0.1",
                "G1 X6 Y0 Z-0.1",
                "G1 X7 Y0 Z-0.1",
                "G1 X8 Y0 Z-0.1",
                "G1 X9 Y0 Z-0.1",
                "G1 X10 Y0 Z-0.1",
            };

            var printer = new PrinterConfig(new PrinterSettings());

            var levelingData = new PrintLevelingData()
            {
                SampledPositions = new List <Vector3>()
                {
                    new Vector3(0, 0, 0),
                    new Vector3(10, 0, 0),
                    new Vector3(5, 10, 0)
                }
            };

            printer.Settings.SetValue(SettingsKey.print_leveling_data, JsonConvert.SerializeObject(levelingData));
            printer.Settings.SetValue(SettingsKey.has_z_probe, "1");
            printer.Settings.SetValue(SettingsKey.use_z_probe, "1");
            printer.Settings.SetValue(SettingsKey.probe_offset, "0,0,-.1");
            printer.Settings.SetValue(SettingsKey.print_leveling_enabled, "1");

            var testStream = GCodeExport.GetExportStream(printer, new TestGCodeStream(printer, inputLines), true);

            ValidateStreamResponse(expected, testStream);
        }
        public void ExportStreamG30Tests()
        {
            string[] inputLines = new string[]
            {
                "M117 Starting Print",
                "M104 S0",
                "; comment line",
                "G28 ; home all axes",
                "G0 Z10 F1800",
                "G0 Z11 F1800",
                "G0 X1Y0Z9 F1800",
                "G0 Z10 F1801",
                "G30 Z0",
                "M114",
                "G0 Z10 F1800",
                "M114",
                "M109 S[temperature]",
            };

            // 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[]
            {
                "M117 Starting Print",
                "M104 S0",
                "; comment line",
                "G28 ; home all axes",
                "G1 Z10 F1800",
                "G1 Z11",
                "G1 X1 Y0 Z9",
                "G1 Z10 F1801",
                "G30 Z0",
                "M114",
                "G1 Z10 F1800",
                "M114",
                "M109 S[temperature]",
            };

            var printer = new PrinterConfig(new PrinterSettings());

            var testStream = GCodeExport.GetExportStream(printer, new TestGCodeStream(printer.Shim(), inputLines), true);

            ValidateStreamResponse(expected, testStream);
        }
Пример #10
0
        public void LineCuttingOnWhenLevelingOnTest()
        {
            string[] inputLines = new string[]
            {
                "G1 X0Y0Z0E0F1000",
                "G1 X0Y0Z0E1F1000",
                "G1 X10 Y0 Z0 F1000",
            };

            // 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[]
            {
                "; Software Leveling Applied",
                "G1 X0 Y0 Z-0.1 E0 F1000",
                "G1 E1",
                "G1 X1 Y0 Z-0.1",
                "G1 X2 Y0 Z-0.1",
                "G1 X3 Y0 Z-0.1",
                "G1 X4 Y0 Z-0.1",
                "G1 X5 Y0 Z-0.1",
                "G1 X6 Y0 Z-0.1",
                "G1 X7 Y0 Z-0.1",
                "G1 X8 Y0 Z-0.1",
                "G1 X9 Y0 Z-0.1",
                "G1 X10 Y0 Z-0.1",
            };

            var printer = new PrinterConfig(new PrinterSettings());

            printer.Settings.SetValue(SettingsKey.probe_offset, "0,0,-.1");
            printer.Settings.SetValue(SettingsKey.print_leveling_enabled, "1");

            var testStream = GCodeExport.GetExportStream(printer, new TestGCodeStream(printer, inputLines), true);

            ValidateStreamResponse(expected, testStream);
        }
Пример #11
0
        public void LineCuttingOffWhenNoLevelingTest()
        {
            string[] inputLines = new string[]
            {
                "G1 X0Y0Z0E0 F1000",
                "G1 X10 Y0 Z0 F1000",
            };

            // 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 X0 Y0 Z0 E0 F1000",
                "G1 X10",
            };

            var printer = new PrinterConfig(new PrinterSettings());

            printer.Settings.SetValue(SettingsKey.has_hardware_leveling, "1");

            var testStream = GCodeExport.GetExportStream(printer, new TestGCodeStream(printer, inputLines), true);

            ValidateStreamResponse(expected, testStream);
        }
Пример #12
0
        public void ExportStreamG30Tests()
        {
            string[] inputLines = new string[]
            {
                "M117 Starting Print",
                "M104 S0",
                "; comment line",
                "G28 ; home all axes",
                "G0 Z10 F1800",
                "G0 Z11 F1800",
                "G0 X1Y0Z9 F1800",
                "G0 Z10 F1801",
                "G30 Z0",
                "M114",
                "G0 Z10 F1800",
                "M114",
                "M109 S[temperature]",
                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[]
            {
                "M117 Starting Print",
                "M104 S0",
                "; comment line",
                "G28 ; home all axes",
                "G1 Z10 F1800",
                "G1 Z11",
                "G1 X1 Y0 Z9",
                "G1 Z10 F1801",
                "G30 Z0",
                "M114",
                "G1 Z10 F1800",
                "M114",
                "M109 S[temperature]",
                null,
            };

            AggContext.StaticData = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData"));
            MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4));

            var printer = new PrinterConfig(new PrinterSettings());

            var testStream = GCodeExport.GetExportStream(printer, new TestGCodeStream(printer, inputLines), true);

            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");
            }
        }