mirror of
https://github.com/dotMorten/NmeaParser.git
synced 2026-01-29 03:44:25 +01:00
✨ AML,SVM
This commit is contained in:
parent
3678abc2c6
commit
531fe94d0d
|
|
@ -188,8 +188,9 @@ namespace NmeaParser.Messages
|
|||
|
||||
string[] parts = message.Split(new char[] { ',' });
|
||||
string MessageType = parts[0].Substring(1);
|
||||
if (MessageType == "PTNL") {
|
||||
if (MessageType is "PTNL" or "AML") {
|
||||
// PTNL is parent to e.g. AVR, GGK etc.
|
||||
// AML is parent to e.g. SVT, SV, SVP etc
|
||||
MessageType = parts[1];
|
||||
parts = parts.Skip(1).ToArray();
|
||||
}
|
||||
|
|
|
|||
76
src/NmeaParser/Nmea/Svm.cs
Normal file
76
src/NmeaParser/Nmea/Svm.cs
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
// *******************************************************************************
|
||||
// * Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// * you may not use this file except in compliance with the License.
|
||||
// * You may obtain a copy of the License at
|
||||
// *
|
||||
// * http://www.apache.org/licenses/LICENSE-2.0
|
||||
// *
|
||||
// * Unless required by applicable law or agreed to in writing, software
|
||||
// * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// * See the License for the specific language governing permissions and
|
||||
// * limitations under the License.
|
||||
// ******************************************************************************
|
||||
|
||||
using System;
|
||||
|
||||
namespace NmeaParser.Messages
|
||||
{
|
||||
/// <summary>
|
||||
/// AML Sound Velocity (m/s), Temperature (C)
|
||||
/// AML Oceanographic Svm sensor
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// 1.: Sound Velocity m/s
|
||||
/// 2.: Unit of temperature, TC = Celcius
|
||||
/// 3.: Temperature
|
||||
/// 4.: Label, SN: Serial number
|
||||
/// 5.: Device serial number
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[NmeaMessageType("SVM")]
|
||||
public class Svm : NmeaMessage
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Svm"/> class.
|
||||
/// </summary>
|
||||
/// <param name="type">The message type</param>
|
||||
/// <param name="message">The NMEA message values.</param>
|
||||
public Svm(string type, string[] message) : base(type, message)
|
||||
{
|
||||
if (message == null || message.Length < 5)
|
||||
throw new ArgumentException("Invalid Svm", "message");
|
||||
SoundVelocity = StringToDouble(message[0]);
|
||||
TemperatureUnit = message[1];
|
||||
Temperature = StringToDouble(message[2]);
|
||||
IsSerialNumber = message[3] == "SN";
|
||||
SerialNumber = StringToDouble(message[4]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sound Velocity m/s
|
||||
/// </summary>
|
||||
public double SoundVelocity { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Temperature Unit
|
||||
/// </summary>
|
||||
public string TemperatureUnit { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Temperature
|
||||
/// </summary>
|
||||
public double Temperature { get; }
|
||||
|
||||
/// <summary>
|
||||
/// String indicating Serial number
|
||||
/// </summary>
|
||||
public bool IsSerialNumber { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Serial Number
|
||||
/// </summary>
|
||||
public double SerialNumber { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -86,6 +86,7 @@ namespace NmeaParser.Tests
|
|||
var msg = NmeaMessage.Parse(line, previousMessage as IMultiSentenceMessage);
|
||||
Assert.IsNotNull(msg);
|
||||
if (line.IndexOf("PTNL,") > 0) continue; // TODO PTNL
|
||||
if (line.IndexOf("AML,") > 0) continue; // TODO AML
|
||||
var idx = line.IndexOf('*');
|
||||
if (idx >= 0)
|
||||
{
|
||||
|
|
@ -125,6 +126,20 @@ namespace NmeaParser.Tests
|
|||
Assert.ThrowsException<ArgumentException>(() => NmeaMessage.Parse(input, ignoreChecksum: false));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestAmlSvm()
|
||||
{
|
||||
string input = "$AML,SVM,1468.951,TC,15.753,SN,168753*0F";
|
||||
var msg = NmeaMessage.Parse(input);
|
||||
Assert.IsInstanceOfType(msg, typeof(Svm));
|
||||
Svm svm = (Svm)msg;
|
||||
Assert.AreEqual(1468.951, svm.SoundVelocity);
|
||||
Assert.AreEqual("TC", svm.TemperatureUnit);
|
||||
Assert.AreEqual(15.753, svm.Temperature);
|
||||
Assert.IsTrue(svm.IsSerialNumber);
|
||||
Assert.AreEqual(168753, svm.SerialNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestDPT()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue