Ejemplo n.º 1
0
        /// <summary>
        /// Append a label-only parameter to the current line (eg like G162 X Y)
        /// </summary>
        /// <param name="identifier">Identifier.</param>
        public virtual GCodeBuilder AppendL(string identifier)
        {
            GCodeParam p = GCodeParam.NoValue(identifier);

            next_params.Add(p);
            return(this);
        }
Ejemplo n.º 2
0
        virtual protected GCodeParam[] parse_parameters(string[] tokens, int iStart, int iEnd = -1)
        {
            if (iEnd == -1)
            {
                iEnd = tokens.Length;
            }

            int N = iEnd - iStart;

            GCodeParam[] paramList = new GCodeParam[N];

            for (int ti = iStart; ti < iEnd; ++ti)
            {
                int pi = ti - iStart;

                bool bHandled = false;
                if (tokens[ti].Contains('='))
                {
                    parse_equals_parameter(tokens[ti], ref paramList[pi]);
                    bHandled = true;
                }
                else if (tokens[ti][0] == 'G' || tokens[ti][0] == 'M')
                {
                    parse_code_parameter(tokens[ti], ref paramList[pi]);
                    bHandled = true;
                }
                else if (is_num_parameter(tokens[ti]) > 0)
                {
                    parse_noequals_num_parameter(tokens[ti], ref paramList[pi]);
                    bHandled = true;
                }
                else if (tokens[ti].Length == 1)
                {
                    paramList[pi] = GCodeParam.NoValue(tokens[ti]);
                    bHandled      = true;
                }

                if (!bHandled)
                {
                    paramList[pi] = GCodeParam.Text(tokens[ti], default);
                }
            }

            return(paramList);
        }