mirror of
https://github.com/dotMorten/NmeaParser.git
synced 2026-01-23 09:00:22 +01:00
Implemement NmeaMessage : IEquatable<NmeaMessage>
Also avoid processing identical messages in GnssMonitor
This commit is contained in:
parent
02579ab3e8
commit
cb5249db73
|
|
@ -75,7 +75,11 @@ namespace NmeaParser.Gnss
|
|||
double lon = 0;
|
||||
List<string> properties = new List<string>();
|
||||
lock (m_lock)
|
||||
{
|
||||
if(m_allMessages.ContainsKey(message.MessageType) && m_allMessages[message.MessageType].Equals(message))
|
||||
return; // Nothing to update/notify
|
||||
m_allMessages[message.MessageType] = message;
|
||||
}
|
||||
properties.Add(nameof(AllMessages));
|
||||
if (message.TalkerId == NmeaParser.Talker.GlobalNavigationSatelliteSystem)
|
||||
m_supportGNMessages = true; // Support for GN* messages detected
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ namespace NmeaParser.Messages
|
|||
/// <summary>
|
||||
/// NMEA Message base class.
|
||||
/// </summary>
|
||||
public abstract class NmeaMessage
|
||||
public abstract class NmeaMessage : IEquatable<NmeaMessage>
|
||||
{
|
||||
private readonly static Dictionary<string, ConstructorInfo> messageTypes;
|
||||
|
||||
|
|
@ -301,6 +301,21 @@ namespace NmeaParser.Messages
|
|||
return TimeSpan.Zero;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Equals(NmeaMessage other)
|
||||
{
|
||||
if (other.MessageType != MessageType)
|
||||
return false;
|
||||
if (other.MessageParts.Count != MessageParts.Count)
|
||||
return false;
|
||||
for (int i = 0; i < MessageParts.Count; i++)
|
||||
{
|
||||
if (other.MessageParts[i] != MessageParts[i])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a relative timestamp in milliseconds indicating the time the message was created.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Reference in a new issue