Example #1
0
        public GpgsvReceivedEventArgs(string[] values)
        {
            if (String.Compare(values[0], "GPGSV", true) != 0 || !(values.Length >= 8 && values.Length <= 20 && (values.Length % 4 == 0)))
            {
                throw new ArgumentException("Invalid GPGSV sentence.", "values");
            }

            this.Satellites = new List<Satellite>();

            this.Identifier = values[0];
            var numberFormat = new NumberFormatInfo { NumberDecimalSeparator = "." };
            if (!String.IsNullOrEmpty(values[1]))
            {
                this.SentenceCount = Int32.Parse(values[1], numberFormat);
            }

            if (!String.IsNullOrEmpty(values[2]))
            {
                this.SentenceId = Int32.Parse(values[2], numberFormat);
            }

            if (!String.IsNullOrEmpty(values[3]))
            {
                this.SatelliteCount = Int32.Parse(values[3], numberFormat);
            }

            for (int i = 4, count = 0; count < (values.Length / 4) - 1; i += 4, count++)
            {
                Satellite satellite = new Satellite();
                satellite.Prn = Int32.Parse(values[i], numberFormat);
                satellite.Elevation = Int32.Parse(values[i + 1], numberFormat);
                satellite.Azimuth = Int32.Parse(values[i + 2], numberFormat);

                if (!String.IsNullOrEmpty(values[i + 3]))
                {
                    satellite.Snr = Int32.Parse(values[i + 3], numberFormat);
                }

                this.Satellites.Add(satellite);
            }
        }
Example #2
0
        public GpgsvReceivedEventArgs(string[] values)
        {
            if (String.Compare(values[0], "GPGSV", true) != 0 || !(values.Length >= 8 && values.Length <= 20 && (values.Length % 4 == 0)))
            {
                throw new ArgumentException("Invalid GPGSV sentence.", "values");
            }

            this.Satellites = new List <Satellite>();

            this.Identifier = values[0];

            if (!String.IsNullOrEmpty(values[1]))
            {
                this.SentenceCount = Int32.Parse(values[1]);
            }

            if (!String.IsNullOrEmpty(values[2]))
            {
                this.SentenceId = Int32.Parse(values[2]);
            }

            if (!String.IsNullOrEmpty(values[3]))
            {
                this.SatelliteCount = Int32.Parse(values[3]);
            }

            for (int i = 4, count = 0; count < (values.Length / 4) - 1; i += 4, count++)
            {
                Satellite satellite = new Satellite();
                satellite.Prn       = Int32.Parse(values[i]);
                satellite.Elevation = Int32.Parse(values[i + 1]);
                satellite.Azimuth   = Int32.Parse(values[i + 2]);

                if (!String.IsNullOrEmpty(values[i + 3]))
                {
                    satellite.Snr = Int32.Parse(values[i + 3]);
                }

                this.Satellites.Add(satellite);
            }
        }