Example #1
0
        public void ActionLineTestIncUnit()
        {
            var test = new ValueXYZEF();

            test.X = 0.1;
            test.Y = 0.2;
            test.Z = 0.3;
            test.E = 0.4;
            test.F = 0.5;

            string line   = "G20";
            var    parser = new LineCommand();

            parser.Parse(line);
            test.ActionLine(parser);
            line = "G91";
            parser.Parse(line);
            test.ActionLine(parser);

            line = "G1 X1 Y2 Z3 E4 F5";
            parser.Parse(line);
            test.ActionLine(parser);

            Assert.AreEqual(test.X, 2.54 * 1 + 0.1);
            Assert.AreEqual(test.Y, 2.54 * 2 + 0.2);
            Assert.AreEqual(test.Z, 2.54 * 3 + 0.3);
            Assert.AreEqual(test.E, 2.54 * 4 + 0.4);
            Assert.AreEqual(test.F, 2.54 * 5 + 0.5);
        }
Example #2
0
        public void ActionLineTestInc1()
        {
            var test = new ValueXYZEF();

            test.PreAction();

            string line   = "G91";
            var    parser = new LineCommand();

            test.X = 0.1;
            test.Y = 0.2;
            test.Z = 0.3;
            test.E = 0.4;
            test.F = 0.5;
            parser.Parse(line);
            test.ActionLine(parser);

            line = "G1 X1 Y2 Z3 E4 F5";
            parser.Parse(line);
            test.ActionLine(parser);

            Assert.AreEqual(test.X, 1.1);
            Assert.AreEqual(test.Y, 2.2);
            Assert.AreEqual(test.Z, 3.3);
            Assert.AreEqual(test.E, 4.4);
            Assert.AreEqual(test.F, 5.5);
        }
Example #3
0
        public void ActionLineTestToAbs()
        {
            var test = new ValueXYZEF();

            test.PreAction();

            string line   = "G91";
            var    parser = new LineCommand();

            test.X = 0.1;
            test.Y = 0.2;
            test.Z = 0.3;
            test.E = 0.4;
            test.F = 0.5;
            parser.Parse(line);
            test.ActionLine(parser);
            Assert.AreEqual(test.IsAbsolute, false);

            line = "G90";
            parser.Parse(line);
            test.ActionLine(parser);
            Assert.AreEqual(test.IsAbsolute, true);

            line = "G1 X1 Y2 Z3 E4 F5";
            parser.Parse(line);
            test.ActionLine(parser);

            Assert.AreEqual(test.X, 1);
            Assert.AreEqual(test.Y, 2);
            Assert.AreEqual(test.Z, 3);
            Assert.AreEqual(test.E, 4);
            Assert.AreEqual(test.F, 5);
        }
Example #4
0
        public void ActionLineTestInc2()
        {
            var test = new ValueXYZEF();

            test.PreAction();

            string line   = "G91";
            var    parser = new LineCommand();

            test.X = 0.1;
            test.Y = 0.2;
            test.Z = 0.3;
            test.E = 0.4;
            test.F = 0.5;
            parser.Parse(line);
            test.ActionLine(parser);

            line = "G1 X-1 Y-2 Z-3 E-4 F-5";
            parser.Parse(line);
            test.ActionLine(parser);

            Assert.AreEqual(test.X, -1 + 0.1);
            Assert.AreEqual(test.Y, -2 + 0.2);
            Assert.AreEqual(test.Z, -3 + 0.3);
            Assert.AreEqual(test.E, -4 + 0.4);
            Assert.AreEqual(test.F, -5 + 0.5);
        }
Example #5
0
        public void Error1()
        {
            string line = "Z11 Z12";
            var    test = new LineCommand();

            Assert.AreEqual(test.Parse(line), false);
        }
Example #6
0
        public void Value2()
        {
            string line = "G1.0";
            var    test = new LineCommand();

            Assert.AreEqual(test.Parse(line), true);
            Assert.AreEqual(test.Comment, null);
            Assert.AreEqual(test.Original, line);
            Assert.AreEqual(test.Count, 1);
            {
                Double value;
                int    pos;
                Assert.AreEqual(test.TryGetValue('G', out value, out pos), true);
                Assert.AreEqual(value, 1.0);
                Assert.AreEqual(pos, 0);
                Assert.AreEqual(test.GetFP('G'), 1);
                Assert.AreEqual(test.Has('G'), true);
            }
            {
                Double value;
                int    pos;
                Assert.AreEqual(test.TryGetValue('A', out value, out pos), false);
                Assert.AreEqual(test.GetFP('A'), 0);
                Assert.AreEqual(test.Has('A'), false);
            }
        }
Example #7
0
        public void Complex1()
        {
            string line = "Z11 G22 ; hoge";
            var    test = new LineCommand();

            Assert.AreEqual(test.Parse(line), true);
            Assert.AreEqual(test.Comment, "; hoge");
            Assert.AreEqual(test.Original, line);
            Assert.AreEqual(test.Count, 2);
            {
                Double value;
                int    pos;
                Assert.AreEqual(test.TryGetValue('G', out value, out pos), true);
                Assert.AreEqual(value, 22);
                Assert.AreEqual(pos, 1);
                Assert.AreEqual(test.GetFP('G'), 0);
            }
            {
                Double value;
                int    pos;
                Assert.AreEqual(test.TryGetValue('Z', out value, out pos), true);
                Assert.AreEqual(value, 11);
                Assert.AreEqual(pos, 0);
                Assert.AreEqual(test.GetFP('Z'), 0);
            }
            {
                Double value;
                int    pos;
                Assert.AreEqual(test.TryGetValue('A', out value, out pos), false);
                Assert.AreEqual(test.GetFP('A'), 0);
            }
        }
Example #8
0
        public void Comment1()
        {
            string line = ";hoge";
            var    test = new LineCommand();

            Assert.AreEqual(test.Parse(line), true);
            Assert.AreEqual(test.Comment, line);
            Assert.AreEqual(test.Original, line);
            Assert.AreEqual(test.Count == 0, true);
        }
Example #9
0
        public void NullLine()
        {
            string line = "";
            var    test = new LineCommand();

            Assert.AreEqual(test.Parse(line), true);
            Assert.AreEqual(test.Comment, null);
            Assert.AreEqual(test.Original, line);
            Assert.AreEqual(test.Count == 0, true);
        }
Example #10
0
        public void ToString10()
        {
            var    source = new LineCommand();
            string line   = "G1.1 A2.22 Z-3;comment";

            source.Parse(line);

            var result = OutputGCode.ToString(source, false);

            Assert.AreEqual(result, "G1.1 A2.22 Z-3");
        }
Example #11
0
        public void CloneValues1()
        {
            string line = "G11.1 Z22.22";
            var    test = new LineCommand();

            Assert.AreEqual(test.Parse(line), true);
            Assert.AreEqual(test.Comment, null);
            Assert.AreEqual(test.Original, line);
            Assert.AreEqual(test.Count, 2);

            var val = test.CloneValues();

            Assert.AreEqual(val.Count, 2);
            Assert.AreEqual(val[0].Key, 'G');
            Assert.AreEqual(val[0].Value, 11.1);
            Assert.AreEqual(val[0].FP, 1);
            Assert.AreEqual(val[0].Position, 0);
            Assert.AreEqual(val[1].Key, 'Z');
            Assert.AreEqual(val[1].Value, 22.22);
            Assert.AreEqual(val[1].FP, 2);
            Assert.AreEqual(val[1].Position, 1);

            // CloneValuesでもらったデータを変更したら、オリジナル側が変わっていないことも確認
            val[0].Value    = 22.3;
            val[0].FP       = 0;
            val[0].Position = 1;
            val[1].Value    = 33.3;
            val[1].FP       = 0;
            val[1].Position = 0;

            {
                Double value;
                int    pos;
                Assert.AreEqual(test.TryGetValue('G', out value, out pos), true);
                Assert.AreEqual(value, 11.1);
                Assert.AreEqual(pos, 0);
                Assert.AreEqual(test.GetFP('G'), 1);
            }
            {
                Double value;
                int    pos;
                Assert.AreEqual(test.TryGetValue('Z', out value, out pos), true);
                Assert.AreEqual(value, 22.22);
                Assert.AreEqual(pos, 1);
                Assert.AreEqual(test.GetFP('Z'), 2);
            }
            {
                Double value;
                int    pos;
                Assert.AreEqual(test.TryGetValue('A', out value, out pos), false);
                Assert.AreEqual(test.GetFP('A'), 0);
            }
        }
Example #12
0
        public void ActionLineTestAbsUnit()
        {
            var test = new ValueXYZEF();

            test.PreAction();

            string line   = "G20";
            var    parser = new LineCommand();

            parser.Parse(line);
            test.ActionLine(parser);
            Assert.AreEqual(test.IsMM, false);

            line = "G1 X1 Y2 Z3 E4 F5";
            parser.Parse(line);
            test.ActionLine(parser);

            Assert.AreEqual(test.X, 2.54 * 1);
            Assert.AreEqual(test.Y, 2.54 * 2);
            Assert.AreEqual(test.Z, 2.54 * 3);
            Assert.AreEqual(test.E, 2.54 * 4);
            Assert.AreEqual(test.F, 2.54 * 5);
            line = "G21";
            parser.Parse(line);
            test.ActionLine(parser);
            Assert.AreEqual(test.IsMM, true);

            line = "G1 X1 Y2 Z3 E4 F5";
            parser.Parse(line);
            test.ActionLine(parser);
            Assert.AreEqual(test.X, 1);
            Assert.AreEqual(test.Y, 2);
            Assert.AreEqual(test.Z, 3);
            Assert.AreEqual(test.E, 4);
            Assert.AreEqual(test.F, 5);
        }
Example #13
0
        public void Values5()
        {
            string line = "ABCDE";
            var    test = new LineCommand();

            Assert.AreEqual(test.Parse(line), true);
            Assert.AreEqual(test.Count, 5);
            Assert.AreEqual(test.GetKey(-1), ' ');
            Assert.AreEqual(test.GetKey(5), ' ');
            Assert.AreEqual(test.GetKey(0), 'A');
            Assert.AreEqual(test.GetKey(1), 'B');
            Assert.AreEqual(test.GetKey(2), 'C');
            Assert.AreEqual(test.GetKey(3), 'D');
            Assert.AreEqual(test.GetKey(4), 'E');
        }
Example #14
0
        public void ActionLineTest4()
        {
            string line   = "X1 Y2 Z3 E4 F5";
            var    parser = new LineCommand();

            parser.Parse(line);
            var test = new ValueXYZEF();

            test.PreAction();
            test.ActionLine(parser);
            Assert.AreEqual(test.X, 0);
            Assert.AreEqual(test.Y, 0);
            Assert.AreEqual(test.Z, 0);
            Assert.AreEqual(test.E, 0);
            Assert.AreEqual(test.F, 0);
        }
Example #15
0
        public void Add3()
        {
            var line = "G10.00";
            var test = new LineCommand();

            test.Parse(line);
            Assert.AreEqual(test.Add('G', 10.1, 1), false);
            {
                Double value;
                int    pos;
                Assert.AreEqual(test.TryGetValue('G', out value, out pos), true);
                Assert.AreEqual(value, 10.0);
                Assert.AreEqual(pos, 0);
                Assert.AreEqual(test.GetFP('G'), 2);
            }
        }
Example #16
0
        public void ActionLineTestAbs()
        {
            string line   = "G1 X1 Y2 Z3 E4 F5";
            var    parser = new LineCommand();

            parser.Parse(line);
            var test = new ValueXYZEF();

            test.X = 0.1;
            test.Y = 0.2;
            test.Z = 0.3;
            test.E = 0.4;
            test.F = 0.5;
            test.ActionLine(parser);
            Assert.AreEqual(test.X, 1);
            Assert.AreEqual(test.Y, 2);
            Assert.AreEqual(test.Z, 3);
            Assert.AreEqual(test.E, 4);
            Assert.AreEqual(test.F, 5);
        }
Example #17
0
        public void Values6()
        {
            string line = "G1 Z5.5";
            var    test = new LineCommand();

            Assert.AreEqual(test.Parse(line), true);
            Assert.AreEqual(test.Modify('A', (x) => {
                x.Value = 5;
            }), false);
            Assert.AreEqual(test.Modify('G', (x) => {
                x.Value    = 5;
                x.FP       = 1;
                x.Position = 2;
            }), true);
            {
                Double value;
                int    pos;
                Assert.AreEqual(test.TryGetValue('G', out value, out pos), true);
                Assert.AreEqual(value, 5);
                Assert.AreEqual(pos, 2);
                Assert.AreEqual(test.GetFP('G'), 1);
            }
        }