public void WriteReplaceStreamTests()
        {
            string[] inputLines = new string[]
            {
                "; the printer is moving normally",
                "G1 X10 Y10 Z10 E0",
                "M114",
                "G29",
                "G28",
                "G28 X0",
                "M107",
                "M107 ; extra stuff",
                null,
            };

            string[] expected = new string[]
            {
                "; the printer is moving normally",
                "G1 X10 Y10 Z10 E0",
                "M114",
                "G29",
                "G28",
                "M115",
                "G28 X0",
                "M115",
                "; none",
                "; none ; extra stuff",
                null,
            };

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

            PrinterSettings printerSettings = ActiveSliceSettings.Instance;

            printerSettings.SetValue(SettingsKey.write_regex, "\"^(G28)\",\"G28,M115\"\\n\"^(M107)\",\"; none\"");

            var inputLinesStream = new TestGCodeStream(inputLines);
            var queueStream      = new QueuedCommandsStream(inputLinesStream);
            ProcessWriteRegexStream writeStream = new ProcessWriteRegexStream(printerSettings, queueStream, queueStream);

            int    expectedIndex = 0;
            string actualLine    = writeStream.ReadLine();
            string expectedLine  = expected[expectedIndex++];

            Assert.AreEqual(expectedLine, actualLine, "Unexpected response from ProcessWriteRegexStream");

            while (actualLine != null)
            {
                expectedLine = expected[expectedIndex++];
                actualLine   = writeStream.ReadLine();
                Assert.AreEqual(expectedLine, actualLine, "Unexpected response from ProcessWriteRegexStream");
            }
        }
示例#2
0
        public static GCodeStream CreateTestGCodeStream(string[] inputLines)
        {
            GCodeStream gCodeFileStream0          = new TestGCodeStream(inputLines);
            GCodeStream pauseHandlingStream1      = new PauseHandlingStream(gCodeFileStream0);
            GCodeStream queuedCommandStream2      = new QueuedCommandsStream(pauseHandlingStream1);
            GCodeStream relativeToAbsoluteStream3 = new RelativeToAbsoluteStream(queuedCommandStream2);
            //GCodeStream printLevelingStream4 = new PrintLevelingStream(relativeToAbsoluteStream3);
            GCodeStream printLevelingStream4       = relativeToAbsoluteStream3;
            GCodeStream waitForTempStream5         = new WaitForTempStream(printLevelingStream4);
            GCodeStream babyStepsStream6           = new BabyStepsStream(waitForTempStream5);
            GCodeStream extrusionMultiplyerStream7 = new ExtrusionMultiplyerStream(babyStepsStream6);
            GCodeStream feedrateMultiplyerStream8  = new FeedRateMultiplyerStream(extrusionMultiplyerStream7);
            GCodeStream totalGCodeStream           = feedrateMultiplyerStream8;

            return(totalGCodeStream);
        }
        public void WriteReplaceStreamTests()
        {
            string[] inputLines = new string[]
            {
                "; the printer is moving normally",
                "G1 X10 Y10 Z10 E0",
                "M114",
                "G29",
                "G28",
                "G28 X0",
                "M107",
                "M107 ; extra stuff",
                null,
            };

            string[] expected = new string[]
            {
                "; the printer is moving normally",
                "G1 X10 Y10 Z10 E0",
                "M114",
                "G29",
                "G28",
                "M115",
                "G28 X0",
                "M115",
                "; none",
                "; none ; extra stuff",
                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.write_regex, "\"^(G28)\",\"G28,M115\"\\n\"^(M107)\",\"; none\"");

            var inputLinesStream = new TestGCodeStream(printer, inputLines);
            var queueStream      = new QueuedCommandsStream(printer, inputLinesStream);
            ProcessWriteRegexStream writeStream = new ProcessWriteRegexStream(printer, queueStream, queueStream);

            ValidateStreamResponse(expected, writeStream);
        }
示例#4
0
        public void WriteReplaceStreamTests()
        {
            string[] inputLines = new string[]
            {
                "; the printer is moving normally",
                "G1 X10 Y10 Z10 E0",
                "M114",
                "G29",
                "G28",
                "G28 X0",
                "M107",
                "M107 ; extra stuff",
            };

            string[] expected = new string[]
            {
                "; the printer is moving normally",
                "G1 X10 Y10 Z10 E0",
                "M114",
                "G29",
                "G28",
                "M115",
                "G28 X0",
                "M115",
                "; none",
                "; none ; extra stuff",
            };

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

            printer.Settings.SetValue(SettingsKey.write_regex, "\"^(G28)\",\"G28,M115\"\\n\"^(M107)\",\"; none\"");

            var inputLinesStream = new TestGCodeStream(printer, inputLines);
            var queueStream      = new QueuedCommandsStream(printer, inputLinesStream);

            var writeStream = new ProcessWriteRegexStream(printer, queueStream, queueStream);

            ValidateStreamResponse(expected, writeStream);
        }