public static SNRValue StrToSNRValue(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;
                }
            }

            SNRUnits units = SNRUnits.dB;
            var      u     = unit.ToLower();

            if (u == "d" || u == "db" || u == "dB")
            {
                units = SNRUnits.dB;
            }

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

            return(null);
        }
Exemplo n.º 2
0
 public SNRValue(double value, SNRUnits units = SNRUnits.dB)
 {
     _value = value;
     _units = SNRUnits.dB;
 }