-
Does anyone know how to add one of the sentences DBK, DBS, or DBT? |
Beta Was this translation helpful? Give feedback.
Answered by
dotMorten
Jan 20, 2021
Replies: 1 comment
-
See the section on adding custom messages: It'll probably be something along the lines of: public abstract class DepthBelowBaseMessage : NmeaMessage
{
protected DepthBelowBaseMessage(string type, string[] parameters) : base(type, parameters)
{
WaterDepthFeet = parameters.Length > 0 ? ReadDouble(parameters[0]) : double.NaN;
WaterDepthMeters= parameters.Length > 1 ? ReadDouble(parameters[1]) : double.NaN;
WaterDepthFathoms = parameters.Length > 2 ? ReadDouble(parameters[2]) : double.NaN;
}
public double WaterDepthFeet { get; }
public double WaterDepthMeters { get; }
public double WaterDepthFathoms { get; }
private static double ReadDouble(string value)
{
if(value != null && double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out double result))
{
return result;
}
return double.NaN;
}
}
[NmeaMessageType("--DBK")]
public abstract class DepthBelowKeelMessage : DepthBelowBaseMessage
{
public DepthBelowKeelMessage(string type, string[] parameters) : base(type, parameters)
{ }
}
[NmeaMessageType("--DBS")]
public abstract class DepthBelowSurfaceMessage : DepthBelowBaseMessage
{
public DepthBelowSurfaceMessage(string type, string[] parameters) : base(type, parameters)
{ }
}
[NmeaMessageType("--DBT")]
public abstract class DepthBelowTransducerMessage : DepthBelowBaseMessage
{
public DepthBelowTransducerMessage (string type, string[] parameters) : base(type, parameters)
{ }
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
dotMorten
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See the section on adding custom messages:
https://dotmorten.github.io/NmeaParser/concepts/CustomMessages.html
It'll probably be something along the lines of: