Beispiel #1
0
        virtual protected bool parse_value_param(string token, int split, int skip, ref GCodeParam param)
        {
            var identifier = token.Substring(0, split);

            string value = token.Substring(split + skip, token.Length - (split + skip));

            try
            {
                GCodeUtil.NumberType numType = GCodeUtil.GetNumberType(value);
                if (numType == GCodeUtil.NumberType.Decimal)
                {
                    param = GCodeParam.Double(double.Parse(value), identifier);
                    return(true);
                }
                else if (numType == GCodeUtil.NumberType.Integer)
                {
                    param = GCodeParam.Integer(int.Parse(value), identifier);
                    return(true);
                }
            }
            catch
            {
                // just continue on and do generic string param
            }

            param = GCodeParam.Text(value);
            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Add a float-value parameter to the current line
        /// </summary>
        public virtual GCodeBuilder AppendF(string identifier, double value)
        {
            GCodeParam p = GCodeParam.Double(value, identifier);

            next_params.Add(p);
            return(this);
        }
Beispiel #3
0
        virtual protected bool parse_code_parameter(string token, ref GCodeParam param)
        {
            string identifier = token.Substring(0, 1);
            string value      = token.Substring(1);

            switch (GCodeUtil.GetNumberType(value))
            {
            case GCodeUtil.NumberType.Integer:
                param = GCodeParam.Integer(int.Parse(value), identifier);
                break;

            case GCodeUtil.NumberType.Decimal:
                param = GCodeParam.Double(double.Parse(value), identifier);
                break;

            default:
            case GCodeUtil.NumberType.NotANumber:
                param = GCodeParam.Text(value, identifier);
                break;
            }

            return(true);
        }