Example #1
0
        public CommandList Convert(ConvertOptions options)
        {
            var list  = new CommandList();
            var state = new CommandState();

            foreach (Command r in this)
            {
                r.SetCommandState(state);
                list.AddCommands(r.ConvertCommand(state, options));
            }

            return(list);
        }
Example #2
0
        public override Command[] ConvertCommand(CommandState state, ConvertOptions options)
        {
            if (!options.SubstG82)
            {
                return(base.ConvertCommand(state, options));
            }

            // from
            // G82 X-8.8900 Y3.8100  Z-0.2794 F400 R0.5000  P0.000000
            // next command with R and P G82 X-11.4300 Y3.8100
            // to
            // G00 X-8.8900 Y3.8100
            // G01 Z-0.2794 F400
            // (G04 P0)
            // G00 Z0.5000

            Variable r = GetVariable('R');

            if (r == null)
            {
                r = state.G82R;
            }
            else
            {
                state.G82R = r.ShallowCopy();
            }

            Variable p = GetVariable('P');

            if (p == null)
            {
                p = state.G82P;
            }
            else
            {
                state.G82P = p.ShallowCopy();
            }

            Variable z = GetVariable('Z');

            if (z == null)
            {
                z = state.G82Z;
            }
            else
            {
                state.G82Z = z.ShallowCopy();
            }

            var list = new List <Command>();

            var move1 = new G00Command();

            CopyVariable('X', move1);
            CopyVariable('Y', move1);
            list.Add(move1);

            var move2 = new G01Command();

            move2.AddVariable('Z', z);
            CopyVariable('F', move2);
            list.Add(move2);

            if (p != null && Math.Abs(p.Value ?? 0.0) > double.Epsilon)
            {
                var move3 = new G04Command();
                move3.AddVariable('P', p);
                list.Add(move3);
            }

            var move4 = new G00Command();

            move4.AddVariable('Z', r);
            list.Add(move4);

            return(list.ToArray());
        }
Example #3
0
 public virtual Command[] ConvertCommand(CommandState state, ConvertOptions options)
 {
     return(new[] { this });
 }