Пример #1
0
 public override int GetHashCode()
 {
     return(base.GetHashCode() ^
            IsSuccess.GetHashCode() ^
            State.GetHashCode() ^
            Manufacturer.GetHashCode() ^
            ModelName.GetHashCode() ^
            SerialNumber.GetHashCode() ^
            SignalQuality.GetHashCode() ^
            Imsi.GetHashCode() ^
            Imei.GetHashCode() ^
            OperatorName.GetHashCode());
 }
Пример #2
0
        /// <summary>
        ///     проверка качества связи
        /// </summary>
        private SignalQuality GetSignalQuality(SerialPort serial)
        {
            var result = new SignalQuality
            {
                dBmW    = 0,
                IsValid = false,
                Percent = string.Empty
            };
            var response = retry.Execute(() => { return(SendATCommand(serial, "AT+CSQ")); });

            if (string.IsNullOrEmpty(response))
            {
                return(result);
            }
            var matches = Regex.Matches(response, @"[\S ]+", RegexOptions.Singleline);

            if (matches.Count >= 2 && "OK".Equals(matches[matches.Count - 1].Value, StringComparison.OrdinalIgnoreCase))
            {
                matches = Regex.Matches(matches[matches.Count - 2].Value, @"\d+", RegexOptions.None);
                if (matches.Count > 0)
                {
                    var r = int.Parse(matches[0].Value);
                    if (r > 32)
                    {
                        result.dBmW    = 0;
                        result.Percent = "0.0";
                        result.IsValid = false;
                    }

                    else if (r == 99)
                    {
                        return(result);
                    }

                    else
                    {
                        result.dBmW    = -113 + (r << 1);
                        result.Percent = (r * 100.0 / 31.0).ToString("F2");
                        result.IsValid = true;
                    }
                }
            }

            return(result);
        }