Пример #1
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",
                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 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);
        }
Пример #3
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);
        }