when using
NmeaInterpreter nmeaInterpreter = new NmeaInterpreter();
NmeaSentence sentence = null;
string sentenceStr = "$GPGGA,023709.00,2734.90302,S,15306.18218,E,1,12,0.82,38.0,M,38.3,M,,*7D"
sentence = nmeaReader.ReadTypedSentence();
to read from a stream and parse using
nmeaInterpreter.Parse(sentence);
the properties of nmeaInterpreter get updated correctly.
But if I use
sentence = new GpggaSentence(sentenceStr);
nmeaInterpreter.Parse(sentence);
the properties of nmeaInterpreter does not reflect the change.
Looking at the source code it seems that
public NmeaSentence(string sentence)
calls DoSentenceChanged();
which does not update the NmeaSentence properties
protected NmeaSentence(string sentence, string commandWord, string[] words, string validChecksum)
calls OnSentenceChanged(); which does update the NmeaSentence properties.
By adding the line OnSentenceChanged(); to the constructor public NmeaSentence(string sentence) as below fixes the issue.
/// <summary>
/// Creates a new instance from the specified string.
/// </summary>
/// <param name="sentence"></param>
public NmeaSentence(string sentence)
{
// Set this sentence's value
_sentence = sentence;
// Notify of the change
DoSentenceChanged();
OnSentenceChanged();
}
Regards
Marco
NmeaInterpreter nmeaInterpreter = new NmeaInterpreter();
NmeaSentence sentence = null;
string sentenceStr = "$GPGGA,023709.00,2734.90302,S,15306.18218,E,1,12,0.82,38.0,M,38.3,M,,*7D"
sentence = nmeaReader.ReadTypedSentence();
to read from a stream and parse using
nmeaInterpreter.Parse(sentence);
the properties of nmeaInterpreter get updated correctly.
But if I use
sentence = new GpggaSentence(sentenceStr);
nmeaInterpreter.Parse(sentence);
the properties of nmeaInterpreter does not reflect the change.
Looking at the source code it seems that
public NmeaSentence(string sentence)
calls DoSentenceChanged();
which does not update the NmeaSentence properties
protected NmeaSentence(string sentence, string commandWord, string[] words, string validChecksum)
calls OnSentenceChanged(); which does update the NmeaSentence properties.
By adding the line OnSentenceChanged(); to the constructor public NmeaSentence(string sentence) as below fixes the issue.
/// <summary>
/// Creates a new instance from the specified string.
/// </summary>
/// <param name="sentence"></param>
public NmeaSentence(string sentence)
{
// Set this sentence's value
_sentence = sentence;
// Notify of the change
DoSentenceChanged();
OnSentenceChanged();
}
Regards
Marco