mirror of
https://github.com/dotMorten/NmeaParser.git
synced 2026-01-12 11:40:24 +01:00
Improve timestamp display
This commit is contained in:
parent
9183781a5e
commit
41ddca8d0b
|
|
@ -301,7 +301,7 @@ namespace NmeaParser.Messages
|
|||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This value is deduced from <c>System.Diagnostics.Stopwatch.GetTimestamp() * 1000d / System.Diagnostics.Stopwatch.Frequency</c>.
|
||||
/// You can use it to calculate the age of the message in seconds by calculating the difference between the timestamp and the above expression
|
||||
/// You can use it to calculate the age of the message in milliseconds by calculating the difference between the timestamp and the above expression
|
||||
/// </remarks>
|
||||
public double Timestamp { get; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
|
@ -48,7 +49,7 @@ namespace SampleApp.WinDesktop
|
|||
List<string> values = new List<string>();
|
||||
foreach (var prop in props.OrderBy(t => t.Name))
|
||||
{
|
||||
if (prop.Name == nameof(NmeaMessage.MessageType) || prop.Name == nameof(NmeaMessage.Checksum))
|
||||
if (prop.Name == nameof(NmeaMessage.MessageType) || prop.Name == nameof(NmeaMessage.Checksum) || prop.Name == nameof(NmeaMessage.Timestamp))
|
||||
continue;
|
||||
var value = prop.GetValue(e.NewValue);
|
||||
if (!(value is string) && value is System.Collections.IEnumerable arr)
|
||||
|
|
@ -60,6 +61,13 @@ namespace SampleApp.WinDesktop
|
|||
}
|
||||
values.Add($"{prop.Name}: {value}");
|
||||
}
|
||||
if (e.NewValue is NmeaMessage msg)
|
||||
{
|
||||
var age = (System.Diagnostics.Stopwatch.GetTimestamp() * 1000d / System.Diagnostics.Stopwatch.Frequency) - msg.Timestamp;
|
||||
values.Add($"Timestamp: " + DateTime.Now.AddMilliseconds(-age).TimeOfDay.ToString("h\\:mm\\:ss"));
|
||||
}
|
||||
//;
|
||||
|
||||
ctrl.Values.ItemsSource = values;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<TargetFrameworks>net451;netcoreapp3.1</TargetFrameworks>
|
||||
<IsPackable>false</IsPackable>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
Loading…
Reference in a new issue