示例#1
0
        public async Task SimpleCodesNL()
        {
            DuetControlServer.Commands.SimpleCode simpleCode = new DuetControlServer.Commands.SimpleCode {
                Code = "G91\nG1 X5 Y2"
            };
            List <DuetControlServer.Commands.Code> codes = new List <DuetControlServer.Commands.Code>();

            await foreach (DuetControlServer.Commands.Code code in simpleCode.ParseAsync())
            {
                codes.Add(code);
            }

            Assert.AreEqual(2, codes.Count);

            Assert.AreEqual(CodeType.GCode, codes[0].Type);
            Assert.AreEqual(91, codes[0].MajorNumber);

            Assert.AreEqual(CodeType.GCode, codes[1].Type);
            Assert.AreEqual(1, codes[1].MajorNumber);
            Assert.AreEqual(2, codes[1].Parameters.Count);
            Assert.AreEqual('X', codes[1].Parameters[0].Letter);
            Assert.AreEqual(5, (int)codes[1].Parameters[0]);
            Assert.AreEqual('Y', codes[1].Parameters[1].Letter);
            Assert.AreEqual(2, (int)codes[1].Parameters[1]);
        }
示例#2
0
        public void ParseG53Line()
        {
            DuetControlServer.Commands.SimpleCode simpleCode = new DuetControlServer.Commands.SimpleCode {
                Code = "G53 G1 X100 G0 Y200\nG1 Z50"
            };
            IList <DuetControlServer.Commands.Code> codes = simpleCode.Parse().ToList();

            Assert.AreEqual(3, codes.Count);

            Assert.AreEqual(1, codes[0].MajorNumber);
            Assert.AreEqual(1, codes[0].Parameters.Count);
            Assert.AreEqual('X', codes[0].Parameters[0].Letter);
            Assert.AreEqual(100, (int)codes[0].Parameters[0]);
            Assert.IsTrue(codes[0].Flags.HasFlag(CodeFlags.EnforceAbsolutePosition));

            Assert.AreEqual(0, codes[1].MajorNumber);
            Assert.AreEqual(1, codes[1].Parameters.Count);
            Assert.AreEqual('Y', codes[1].Parameters[0].Letter);
            Assert.AreEqual(200, (int)codes[1].Parameters[0]);
            Assert.IsTrue(codes[1].Flags.HasFlag(CodeFlags.EnforceAbsolutePosition));

            Assert.AreEqual(1, codes[2].MajorNumber);
            Assert.AreEqual(1, codes[2].Parameters.Count);
            Assert.AreEqual('Z', codes[2].Parameters[0].Letter);
            Assert.AreEqual(50, (int)codes[2].Parameters[0]);
            Assert.IsFalse(codes[2].Flags.HasFlag(CodeFlags.EnforceAbsolutePosition));
        }
示例#3
0
        public async Task SimpleCodesG53Line()
        {
            DuetControlServer.Commands.SimpleCode simpleCode = new DuetControlServer.Commands.SimpleCode {
                Code = "G53 G1 X100 G0 Y200\nG1 Z50"
            };
            List <DuetControlServer.Commands.Code> codes = new List <DuetControlServer.Commands.Code>();

            await foreach (DuetControlServer.Commands.Code code in simpleCode.ParseAsync())
            {
                codes.Add(code);
            }
            Assert.AreEqual(3, codes.Count);

            Assert.AreEqual(1, codes[0].MajorNumber);
            Assert.AreEqual(1, codes[0].Parameters.Count);
            Assert.AreEqual('X', codes[0].Parameters[0].Letter);
            Assert.AreEqual(100, (int)codes[0].Parameters[0]);
            Assert.IsTrue(codes[0].Flags.HasFlag(CodeFlags.EnforceAbsolutePosition));

            Assert.AreEqual(0, codes[1].MajorNumber);
            Assert.AreEqual(1, codes[1].Parameters.Count);
            Assert.AreEqual('Y', codes[1].Parameters[0].Letter);
            Assert.AreEqual(200, (int)codes[1].Parameters[0]);
            Assert.IsTrue(codes[1].Flags.HasFlag(CodeFlags.EnforceAbsolutePosition));

            Assert.AreEqual(1, codes[2].MajorNumber);
            Assert.AreEqual(1, codes[2].Parameters.Count);
            Assert.AreEqual('Z', codes[2].Parameters[0].Letter);
            Assert.AreEqual(50, (int)codes[2].Parameters[0]);
            Assert.IsFalse(codes[2].Flags.HasFlag(CodeFlags.EnforceAbsolutePosition));
        }
示例#4
0
        public void ParseMultipleCodesNL()
        {
            DuetControlServer.Commands.SimpleCode simpleCode = new DuetControlServer.Commands.SimpleCode {
                Code = "G91\nG1 X5 Y2"
            };
            IList <DuetControlServer.Commands.Code> codes = simpleCode.Parse().ToList();

            Assert.AreEqual(2, codes.Count);

            Assert.AreEqual(CodeType.GCode, codes[0].Type);
            Assert.AreEqual(91, codes[0].MajorNumber);

            Assert.AreEqual(CodeType.GCode, codes[1].Type);
            Assert.AreEqual(1, codes[1].MajorNumber);
            Assert.AreEqual(2, codes[1].Parameters.Count);
            Assert.AreEqual('X', codes[1].Parameters[0].Letter);
            Assert.AreEqual(5, (int)codes[1].Parameters[0]);
            Assert.AreEqual('Y', codes[1].Parameters[1].Letter);
            Assert.AreEqual(2, (int)codes[1].Parameters[1]);
        }
示例#5
0
        public async Task SimpleCodesIndented()
        {
            DuetControlServer.Commands.SimpleCode simpleCode = new DuetControlServer.Commands.SimpleCode {
                Code = "    G1 X5 Y5 G1 X10 Y10\nG1 X15 Y15"
            };
            List <DuetControlServer.Commands.Code> codes = new List <DuetControlServer.Commands.Code>();

            await foreach (DuetControlServer.Commands.Code code in simpleCode.ParseAsync())
            {
                codes.Add(code);
            }

            Assert.AreEqual(3, codes.Count);

            Assert.AreEqual(CodeType.GCode, codes[0].Type);
            Assert.AreEqual(4, codes[0].Indent);
            Assert.AreEqual(1, codes[0].MajorNumber);
            Assert.AreEqual(2, codes[0].Parameters.Count);
            Assert.AreEqual('X', codes[0].Parameters[0].Letter);
            Assert.AreEqual(5, (int)codes[0].Parameters[0]);
            Assert.AreEqual('Y', codes[0].Parameters[1].Letter);
            Assert.AreEqual(5, (int)codes[0].Parameters[1]);

            Assert.AreEqual(CodeType.GCode, codes[1].Type);
            Assert.AreEqual(4, codes[1].Indent);
            Assert.AreEqual(1, codes[1].MajorNumber);
            Assert.AreEqual(2, codes[1].Parameters.Count);
            Assert.AreEqual('X', codes[1].Parameters[0].Letter);
            Assert.AreEqual(10, (int)codes[1].Parameters[0]);
            Assert.AreEqual('Y', codes[1].Parameters[1].Letter);
            Assert.AreEqual(10, (int)codes[1].Parameters[1]);

            Assert.AreEqual(CodeType.GCode, codes[2].Type);
            Assert.AreEqual(0, codes[2].Indent);
            Assert.AreEqual(1, codes[2].MajorNumber);
            Assert.AreEqual(2, codes[2].Parameters.Count);
            Assert.AreEqual('X', codes[2].Parameters[0].Letter);
            Assert.AreEqual(15, (int)codes[2].Parameters[0]);
            Assert.AreEqual('Y', codes[2].Parameters[1].Letter);
            Assert.AreEqual(15, (int)codes[2].Parameters[1]);
        }