コード例 #1
0
ファイル: NmeaTests.cs プロジェクト: vahidarr/DotSpatial
        public void GpsaSentenceFromObjects()
        {
            List <Satellite> sateliteList = new List <Satellite>
            {
                new Satellite(19, new Azimuth(30.3), new Elevation(10.5), new SignalToNoiseRatio(50), true),
                new Satellite(28, new Azimuth(40.3), new Elevation(70.4), new SignalToNoiseRatio(50), true),
                new Satellite(14, new Azimuth(50.3), new Elevation(40.2), new SignalToNoiseRatio(50), true),
                new Satellite(18, new Azimuth(60.3), new Elevation(30.6), new SignalToNoiseRatio(50), true),
                new Satellite(27, new Azimuth(160.3), new Elevation(70.0), new SignalToNoiseRatio(50), true),
                new Satellite(22, new Azimuth(260.3), new Elevation(70.0), new SignalToNoiseRatio(50), true),
                new Satellite(31, new Azimuth(200.3), new Elevation(90.3), new SignalToNoiseRatio(50), true),
                new Satellite(39, new Azimuth(10.3), new Elevation(20.3), new SignalToNoiseRatio(50), true),
                new Satellite(24, new Azimuth(5.3), new Elevation(40.7), new SignalToNoiseRatio(50), true),
            };

            GpgsaSentence sentence = new GpgsaSentence(FixMode.Manual, FixMethod.Fix3D, sateliteList,
                                                       new DilutionOfPrecision((float)1.2), new DilutionOfPrecision((float)1.2),
                                                       new DilutionOfPrecision((float)1.2));

            Assert.AreEqual("$GPGSA,M,3,19,28,14,18,27,22,31,39,24,,,,1.2,1.2,1.2*38", sentence.Sentence);
            Assert.AreEqual(FixMode.Manual, sentence.FixMode);
            Assert.AreEqual(FixMethod.Fix3D, sentence.FixMethod);

            DilutionOfPrecision dil = new DilutionOfPrecision((float)1.2);

            Assert.AreEqual(dil, sentence.HorizontalDilutionOfPrecision);
            Assert.AreEqual(dil, sentence.PositionDilutionOfPrecision);
            Assert.AreEqual(dil, sentence.VerticalDilutionOfPrecision);
            Assert.AreEqual(sateliteList.Count, sentence.FixedSatellites.Count);

            for (int i = 0; i < Math.Min(sentence.FixedSatellites.Count, sateliteList.Count); i++)
            {
                Assert.AreEqual(sateliteList[i].PseudorandomNumber, sentence.FixedSatellites[i].PseudorandomNumber);
            }
        }
コード例 #2
0
ファイル: NmeaDataSet.cs プロジェクト: rowetechinc/RTI
            /// <summary>
            /// Set any possible values for the given NMEA data.
            /// It will continue to replace
            /// the values so the last value is used as the final value.
            /// </summary>
            /// <param name="sentence">NMEA sentence containing data.</param>
            private void SetValues(NmeaSentence sentence)
            {
                /*
                 * NMEA specification states that the first two letters of
                 * a sentence may change.  For example, for "$GPGSV" there may be variations such as
                 * "$__GSV" where the first two letters change.  As a result, we need only test the last three
                 * characters.
                 */

                try
                {
                    if (sentence.CommandWord.EndsWith("GGA", StringComparison.Ordinal))
                    {
                        // Yes.  Convert it using the fast pre-parseed constructor
                        GPGGA = new GpggaSentence(sentence.Sentence);

                        // Set the Lat and Lon and time
                    }
                    if (sentence.CommandWord.EndsWith("VTG", StringComparison.Ordinal))
                    {
                        // Yes.  Convert it using the fast pre-parseed constructor
                        GPVTG = new GpvtgSentence(sentence.Sentence);
                    }
                    if (sentence.CommandWord.EndsWith("RMC", StringComparison.Ordinal))
                    {
                        // Yes.  Convert it using the fast pre-parseed constructor
                        GPRMC = new GprmcSentence(sentence.Sentence);
                    }
                    if (sentence.CommandWord.EndsWith("RMF", StringComparison.Ordinal))
                    {
                        // Yes.  Convert it using the fast pre-parseed constructor
                        PGRMF = new PgrmfSentence(sentence.Sentence);
                    }
                    if (sentence.CommandWord.EndsWith("GLL", StringComparison.Ordinal))
                    {
                        // Yes.  Convert it using the fast pre-parseed constructor
                        GPGLL = new GpgllSentence(sentence.Sentence);
                    }
                    if (sentence.CommandWord.EndsWith("GSV", StringComparison.Ordinal))
                    {
                        // Yes.  Convert it using the fast pre-parseed constructor
                        GPGSV = new GpgsvSentence(sentence.Sentence);
                    }
                    if (sentence.CommandWord.EndsWith("GSA", StringComparison.Ordinal))
                    {
                        // Yes.  Convert it using the fast pre-parseed constructor
                        GPGSA = new GpgsaSentence(sentence.Sentence);
                    }
                    if (sentence.CommandWord.EndsWith("HDT", StringComparison.Ordinal))
                    {
                        // Yes.  Convert it using the fast pre-parseed constructor
                        GPHDT = new GphdtSentence(sentence.Sentence);
                    }
                }
                catch (Exception e)
                {
                    log.Error("Error decoding a NMEA sentance.", e);
                }
            }
コード例 #3
0
ファイル: NmeaTests.cs プロジェクト: vahidarr/DotSpatial
        public void GpsaSentenceFromString()
        {
            GpgsaSentence sentence = new GpgsaSentence("$GPGSA,A,3,04,05,,09,12,,,24,,,,,2.5,1.3,2.1*39");

            Assert.AreEqual("$GPGSA,A,3,04,05,,09,12,,,24,,,,,2.5,1.3,2.1*39", sentence.Sentence);
            Assert.AreEqual(FixMode.Automatic, sentence.FixMode);
            Assert.AreEqual(FixMethod.Fix3D, sentence.FixMethod);
            Assert.AreEqual(new DilutionOfPrecision((float)2.5), sentence.PositionDilutionOfPrecision);
            Assert.AreEqual(new DilutionOfPrecision((float)1.3), sentence.HorizontalDilutionOfPrecision);
            Assert.AreEqual(new DilutionOfPrecision((float)2.1), sentence.VerticalDilutionOfPrecision);
            Assert.AreEqual(5, sentence.FixedSatellites.Count);
            Assert.AreEqual(4, sentence.FixedSatellites[0].PseudorandomNumber);
            Assert.AreEqual(5, sentence.FixedSatellites[1].PseudorandomNumber);
            Assert.AreEqual(9, sentence.FixedSatellites[2].PseudorandomNumber);
            Assert.AreEqual(12, sentence.FixedSatellites[3].PseudorandomNumber);
            Assert.AreEqual(24, sentence.FixedSatellites[4].PseudorandomNumber);
        }
コード例 #4
0
ファイル: NmeaDataSet.cs プロジェクト: Bobfrat/RTI
            /// <summary>
            /// Set any possible values for the given NMEA data.
            /// It will continue to replace
            /// the values so the last value is used as the final value.
            /// </summary>
            /// <param name="sentence">NMEA sentence containing data.</param>
            private void SetValues(NmeaSentence sentence)
            {
                /*
                 * NMEA specification states that the first two letters of
                 * a sentence may change.  For example, for "$GPGSV" there may be variations such as
                 * "$__GSV" where the first two letters change.  As a result, we need only test the last three
                 * characters.
                 */

                if (sentence.CommandWord.EndsWith("GGA", StringComparison.Ordinal))
                {
                    // Yes.  Convert it using the fast pre-parseed constructor
                    GPGGA = new GpggaSentence(sentence.Sentence);

                    // Set the Lat and Lon and time
                }
                if (sentence.CommandWord.EndsWith("VTG", StringComparison.Ordinal))
                {
                    // Yes.  Convert it using the fast pre-parseed constructor
                    GPVTG = new GpvtgSentence(sentence.Sentence);
                }
                if (sentence.CommandWord.EndsWith("RMC", StringComparison.Ordinal))
                {
                    // Yes.  Convert it using the fast pre-parseed constructor
                    GPRMC = new GprmcSentence(sentence.Sentence);
                }
                if (sentence.CommandWord.EndsWith("RMF", StringComparison.Ordinal))
                {
                    // Yes.  Convert it using the fast pre-parseed constructor
                    PGRMF = new PgrmfSentence(sentence.Sentence);
                }
                if (sentence.CommandWord.EndsWith("GLL", StringComparison.Ordinal))
                {
                    // Yes.  Convert it using the fast pre-parseed constructor
                    GPGLL = new GpgllSentence(sentence.Sentence);
                }
                if (sentence.CommandWord.EndsWith("GSV", StringComparison.Ordinal))
                {
                    // Yes.  Convert it using the fast pre-parseed constructor
                    GPGSV = new GpgsvSentence(sentence.Sentence);
                }
                if (sentence.CommandWord.EndsWith("GSA", StringComparison.Ordinal))
                {
                    // Yes.  Convert it using the fast pre-parseed constructor
                    GPGSA = new GpgsaSentence(sentence.Sentence);
                }
                if (sentence.CommandWord.EndsWith("HDT", StringComparison.Ordinal))
                {
                    // Yes.  Convert it using the fast pre-parseed constructor
                    GPHDT = new GphdtSentence(sentence.Sentence);
                }
            }