static void test_nmea() { Nmea nmea_message = new Nmea(); nmea_message.Init("!AIVDM,1,1,,B,19NS7Sp02wo?HETKA2K6mUM20<L=,0*27\r\n"); Assert.True(nmea_message.CheckChecksum() == 0, "Checksum is BAD"); }
private void OnMessageReceived(Nmea.NmeaMessage msg) { if (MessageReceived != null) MessageReceived(this, msg); }
internal NmeaMessageReceivedEventArgs(Nmea.NmeaMessage message) { Message = message; }
private void OnMessageReceived(Nmea.NmeaMessage msg) { var args = new NmeaMessageReceivedEventArgs(msg); var multi = msg as IMultiPartMessage; if (multi != null) { args.IsMultipart = true; if (MultiPartMessageCache.ContainsKey(msg.MessageType)) { var dic = MultiPartMessageCache[msg.MessageType]; if (dic.ContainsKey(multi.MessageNumber - 1) && !dic.ContainsKey(multi.MessageNumber)) { dic[multi.MessageNumber] = msg; } else //Something is out of order. Clear cache MultiPartMessageCache.Remove(msg.MessageType); } else if (multi.MessageNumber == 1) { MultiPartMessageCache[msg.MessageType] = new Dictionary<int, Nmea.NmeaMessage>(multi.TotalMessages); MultiPartMessageCache[msg.MessageType][1] = msg; } if (MultiPartMessageCache.ContainsKey(msg.MessageType)) { var dic = MultiPartMessageCache[msg.MessageType]; if (dic.Count == multi.TotalMessages) //We have a full list { MultiPartMessageCache.Remove(msg.MessageType); args.MessageParts = dic.Values.ToArray(); } } } if (MessageReceived != null) { MessageReceived(this, args); } }