예제 #1
0
        public void Parse_CCW_ArcTest()
        {
            var parser = new GCodeParser(new FakeLogger());

            parser.State.Position.X = 45;
            parser.State.Position.Y = 3;

            var words = new List <Word>();

            words.Add(new Word()
            {
                Command = 'R', Parameter = 5
            });
            Debug.WriteLine("Bottom Right Corner");
            Debug.WriteLine("================");

            var arc = parser.ParseArc(words, 3, new Core.Models.Drawing.Vector3(50, 8, 0), 1);

            Debug.WriteLine(arc.U);
            Debug.WriteLine(arc.V);

            Debug.WriteLine(arc.Start);
            Debug.WriteLine(arc.End);

            Assert.AreEqual(45, arc.U);
            Assert.AreEqual(8, arc.V);
            Debug.WriteLine("  ");

            /*-----*/
            Debug.WriteLine("Top Right Corner");
            Debug.WriteLine("================");

            parser.State.Position.X = 50;
            parser.State.Position.Y = 45;
            words.Add(new Word()
            {
                Command = 'R', Parameter = 5
            });

            var arc2 = parser.ParseArc(words, 3, new Core.Models.Drawing.Vector3(45, 50, 0), 1);

            Debug.WriteLine(arc2.U);
            Debug.WriteLine(arc2.V);

            Debug.WriteLine(arc2.Start);
            Debug.WriteLine(arc2.End);

            Assert.AreEqual(45, arc2.U);
            Assert.AreEqual(45, arc2.V);
            Debug.WriteLine("  ");

            /*-----*/
            Debug.WriteLine("Top Left Corner");
            Debug.WriteLine("================");

            parser.State.Position.X = 5;
            parser.State.Position.Y = 50;
            words.Add(new Word()
            {
                Command = 'R', Parameter = 5
            });

            var arc3 = parser.ParseArc(words, 3, new Core.Models.Drawing.Vector3(0, 45, 0), 1);

            Debug.WriteLine(arc3.U);
            Debug.WriteLine(arc3.V);

            Debug.WriteLine(arc3.Start);
            Debug.WriteLine(arc3.End);

            Assert.AreEqual(5, arc3.U);
            Assert.AreEqual(45, arc3.V);
            Debug.WriteLine("  ");

            /*-----*/
            Debug.WriteLine("Bottom Left Corner");
            Debug.WriteLine("================");

            parser.State.Position.X = 0;
            parser.State.Position.Y = 5;
            words.Add(new Word()
            {
                Command = 'R', Parameter = 5
            });

            var arc4 = parser.ParseArc(words, 3, new Core.Models.Drawing.Vector3(5, 0, 0), 1);

            Debug.WriteLine(arc4.U);
            Debug.WriteLine(arc4.V);

            Debug.WriteLine(arc4.Start);
            Debug.WriteLine(arc4.End);

            Assert.AreEqual(5, arc4.U);
            Assert.AreEqual(5, arc4.V);
            Debug.WriteLine("  ");
        }