public void CreatesValidGgaSentence() { DateTimeOffset time = DateTimeOffset.UtcNow; GlobalPositioningSystemFixData sentence = new GlobalPositioningSystemFixData(time, GpsQuality.DifferentialFix, new GeographicPosition(47.49, 9.48, 720), 680, 2.4, 10); Assert.True(sentence.Valid); Assert.NotEqual(default(TalkerId), sentence.TalkerId); Assert.NotEqual(default(SentenceId), sentence.SentenceId); Assert.False(string.IsNullOrWhiteSpace(sentence.ToReadableContent())); }
public void GgaDecode() { _lastPacketTime = DateTimeOffset.UtcNow; string msg = "$GPGGA,163810,4728.7027,N,00929.9666,E,2,12,0.6,397.4,M,46.8,M,,*4C"; var inSentence = TalkerSentence.FromSentenceString(msg, out var error); Assert.Equal(NmeaError.None, error); Assert.NotNull(inSentence); GlobalPositioningSystemFixData nmeaSentence = (GlobalPositioningSystemFixData)inSentence !.TryGetTypedValue(ref _lastPacketTime) !; var expectedPos = new GeographicPosition(47.478378333333332, 9.4994433333333337, 397.4 + 46.8); Assert.True(expectedPos.EqualPosition(nmeaSentence.Position)); Assert.Equal(GpsQuality.DifferentialFix, nmeaSentence.Status); Assert.Equal(12, nmeaSentence.NumberOfSatellites); Assert.Equal(0.6, nmeaSentence.Hdop); Assert.Equal(_lastPacketTime.Date, nmeaSentence.DateTime.Date); Assert.Equal(new TimeSpan(0, 16, 38, 10), nmeaSentence.DateTime.TimeOfDay); }
private void SendNewData() { try { var data = _activeData; RecommendedMinimumNavigationInformation rmc = new RecommendedMinimumNavigationInformation(DateTimeOffset.UtcNow, NavigationStatus.Valid, data.Position, data.Speed, data.Course, null); SendSentence(rmc); GlobalPositioningSystemFixData gga = new GlobalPositioningSystemFixData( DateTimeOffset.UtcNow, GpsQuality.DifferentialFix, data.Position, data.Position.EllipsoidalHeight - 54, 2.5, 10); SendSentence(gga); TimeDate zda = new TimeDate(DateTimeOffset.UtcNow); SendSentence(zda); } catch (IOException x) { Console.WriteLine($"Error writing to the output stream: {x.Message}. Connection lost."); } }