public static SweepCycleValue StrToSweepCycleValue(string value)
        {
            var ss = _doubleRege.Split(value).Where(t =>
            {
                var s = t.Trim();
                return(!(s == "," || s == "" || s == ","));
            });
            string num  = "";
            string unit = "";

            foreach (var s in ss)
            {
                if (_doubleRege.IsMatch(s))
                {
                    num = s;
                    continue;
                }
                if (_unitRegex.IsMatch(s))
                {
                    unit = s;
                    continue;
                }
            }

            SweepCycleUnit units = SweepCycleUnit.rpm;
            var            u     = unit.ToLower();

            if (u == "r" || u == "rp" || u == "rpm")
            {
                units = SweepCycleUnit.rpm;
            }

            if (double.TryParse(num, out double dd))
            {
                return(new SweepCycleValue(dd, units));
            }

            return(null);
        }
Ejemplo n.º 2
0
 public SweepCycleValue(double value, SweepCycleUnit units)
 {
     _value = value;
     _units = units;
 }