示例#1
0
        virtual protected bool parse_value_param(string token, int split, int skip, ref GCodeParam param)
        {
            param.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.type        = GCodeParam.PType.DoubleValue;
                    param.doubleValue = double.Parse(value);
                    return(true);
                }
                else if (numType == GCodeUtil.NumberType.Integer)
                {
                    param.type     = GCodeParam.PType.IntegerValue;
                    param.intValue = int.Parse(value);
                    return(true);
                }
            } catch {
                // just continue on and do generic string param
            }

            param.type      = GCodeParam.PType.TextValue;
            param.textValue = value;
            return(true);
        }
示例#2
0
        virtual protected int is_num_parameter(string token)
        {
            int N = token.Length;

            bool contains_number = false;

            for (int i = 0; i < N && contains_number == false; ++i)
            {
                if (Char.IsDigit(token[i]))
                {
                    contains_number = true;
                }
            }
            if (!contains_number)
            {
                return(-1);
            }

            for (int i = 1; i < N; ++i)
            {
                string sub = token.Substring(i);
                GCodeUtil.NumberType numtype = GCodeUtil.GetNumberType(sub);
                if (numtype != GCodeUtil.NumberType.NotANumber)
                {
                    return(i);
                }
            }
            return(-1);
        }
示例#3
0
        virtual protected bool parse_code_parameter(string token, ref GCodeParam param)
        {
            param.type       = GCodeParam.PType.Code;
            param.identifier = token.Substring(0, 1);

            string value = token.Substring(1);

            GCodeUtil.NumberType numType = GCodeUtil.GetNumberType(value);
            if (numType == GCodeUtil.NumberType.Integer)
            {
                param.intValue = int.Parse(value);
            }

            return(true);
        }
示例#4
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);
        }