示例#1
0
        public GsvStandardGpsMessage(GpsMessage message)
            : base(StandardGpsMessageKind.Gsv)
        {
            // Example of data fields:
            // "3", "1", "12", "01", "05", "060", "18", "02", "17", "259", "43", "04", "56", "287", "28", "09", "08", "277", "28"
            // "3", "2", "12", "10", "34", "195", "46", "13", "08", "125", "45", "17", "67", "014", "", "20", "32", "048", "24"
            // "3", "3", "12", "23", "13", "094", "48", "24", "04", "292", "24", "28", "49", "178", "46", "32", "06", "037", "22"
            // or
            // "1", "1", "00"

            NumberOfMessages      = GpsValueParser.ParseNullableInt(message.DataFields[0]) ?? 1;
            SequenceNumber        = GpsValueParser.ParseNullableInt(message.DataFields[1]) ?? 1;
            TotalSatellitesInView = GpsValueParser.ParseNullableInt(message.DataFields[2]) ?? 0;

            var satellites = new List <SatelliteInView>();

            int satelliteDataFieldStartIndex = 3;

            while (satelliteDataFieldStartIndex < message.DataFields.Length)
            {
                int satelliteId = GpsValueParser.ParseNullableInt(message.DataFields[satelliteDataFieldStartIndex++]) ?? 0;
                int elevation   = GpsValueParser.ParseNullableInt(message.DataFields[satelliteDataFieldStartIndex++]) ?? 0;
                int azimuth     = GpsValueParser.ParseNullableInt(message.DataFields[satelliteDataFieldStartIndex++]) ?? 0;
                int snr         = GpsValueParser.ParseNullableInt(message.DataFields[satelliteDataFieldStartIndex++]) ?? 0;

                satellites.Add(new SatelliteInView(satelliteId, elevation, azimuth, snr));
            }

            Satellites = satellites.ToArray();
        }
示例#2
0
        public GllStandardGpsMessage(GpsMessage message)
            : base(StandardGpsMessageKind.Gll)
        {
            // Example of data fields:
            // "3110.2908", "N", "12123.2348", "E", "041139.000", "A", "A"

            Latitude        = GpsValueParser.ParseLatitude(message.DataFields[0], message.DataFields[1]);
            Longitude       = GpsValueParser.ParseLongitude(message.DataFields[2], message.DataFields[3]);
            UtcTimeOfDay    = GpsValueParser.ParseUtcTime(message.DataFields[4]);
            DataValid       = message.DataFields[5] == "A";
            PositioningMode = GpsValueParser.ParsePositioningMode(message.DataFields[6]);
        }
        public RmcStandardGpsMessage(GpsMessage message)
            : base(StandardGpsMessageKind.Rmc)
        {
            // Example of data fields:
            // "013732.000", "A", "3150.7238", "N", "11711.7278", "E", "0.00", "0.00", "220413", "", "", "A"

            UtcDateTime      = GpsValueParser.ParseUtcDateTime(message.DataFields[8] + message.DataFields[0]);
            DataValid        = message.DataFields[1] == "A";
            Latitude         = GpsValueParser.ParseLatitude(message.DataFields[2], message.DataFields[3]);
            Longitude        = GpsValueParser.ParseLongitude(message.DataFields[4], message.DataFields[5]);
            Speed            = GpsValueParser.ParseNullableDouble(message.DataFields[6]);
            CourseOverGround = GpsValueParser.ParseNullableDouble(message.DataFields[7]);
            PositioningMode  = GpsValueParser.ParsePositioningMode(message.DataFields[11]);
        }
        public GgaStandardGpsMessage(GpsMessage message)
            : base(StandardGpsMessageKind.Gga)
        {
            // Example of data fields:
            // "015540.000", "3150.68378", "N", "11711.93139", "E", "1", "17", "0.6", "0051.6", "M", "0.0", "M", "", ""

            UtcTimeOfDay                 = GpsValueParser.ParseUtcTime(message.DataFields[0]);
            Latitude                     = GpsValueParser.ParseLatitude(message.DataFields[1], message.DataFields[2]);
            Longitude                    = GpsValueParser.ParseLongitude(message.DataFields[3], message.DataFields[4]);
            FixStatus                    = GpsValueParser.ParseGgaFixStatus(message.DataFields[5]);
            NumberOfSatellites           = GpsValueParser.ParseNullableInt(message.DataFields[6]);
            HorizontalDilutioOfPrecision = GpsValueParser.ParseNullableDouble(message.DataFields[7]);
            Altitude                     = GpsValueParser.ParseNullableDouble(message.DataFields[8]);
            GeoIdSeparation              = GpsValueParser.ParseNullableDouble(message.DataFields[10]);
            DgpsAge     = GpsValueParser.ParseNullableDouble(message.DataFields[12]);
            DgpsStateId = GpsValueParser.ParseNullableDouble(message.DataFields[13]);
        }
        public GsaStandardGpsMessage(GpsMessage message)
            : base(StandardGpsMessageKind.Gsa)
        {
            // Example of data fields:
            // "A", "3", "14", "06", "16", "31", "23", "", "", "", "", "", "", "", "1.66", "1.42", "0.84"

            Mode      = GpsValueParser.ParseGsaMode(message.DataFields[0]);
            FixStatus = GpsValueParser.ParseGsaFixStatus(message.DataFields[1]);

            SatelliteUsedPerChannelArray = new int?[12];
            for (int i = 0; i < SatelliteUsedPerChannelArray.Length; i++)
            {
                SatelliteUsedPerChannelArray[i] = GpsValueParser.ParseNullableInt(message.DataFields[2 + i]);
            }

            PositionDilutionOfPrecision   = GpsValueParser.ParseNullableDouble(message.DataFields[14]);
            HorizontalDilutionOfPrecision = GpsValueParser.ParseNullableDouble(message.DataFields[15]);
            VerticalDilutionOfPrecision   = GpsValueParser.ParseNullableDouble(message.DataFields[16]);
        }