mirror of
https://github.com/dotMorten/NmeaParser.git
synced 2026-04-21 06:13:58 +00:00
Improve timestamp display
This commit is contained in:
parent
9183781a5e
commit
41ddca8d0b
3 changed files with 12 additions and 3 deletions
|
|
@ -301,7 +301,7 @@ namespace NmeaParser.Messages
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// This value is deduced from <c>System.Diagnostics.Stopwatch.GetTimestamp() * 1000d / System.Diagnostics.Stopwatch.Frequency</c>.
|
/// 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>
|
/// </remarks>
|
||||||
public double Timestamp { get; }
|
public double Timestamp { get; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
|
@ -48,7 +49,7 @@ namespace SampleApp.WinDesktop
|
||||||
List<string> values = new List<string>();
|
List<string> values = new List<string>();
|
||||||
foreach (var prop in props.OrderBy(t => t.Name))
|
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;
|
continue;
|
||||||
var value = prop.GetValue(e.NewValue);
|
var value = prop.GetValue(e.NewValue);
|
||||||
if (!(value is string) && value is System.Collections.IEnumerable arr)
|
if (!(value is string) && value is System.Collections.IEnumerable arr)
|
||||||
|
|
@ -60,6 +61,13 @@ namespace SampleApp.WinDesktop
|
||||||
}
|
}
|
||||||
values.Add($"{prop.Name}: {value}");
|
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;
|
ctrl.Values.ItemsSource = values;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net451;netcoreapp3.1</TargetFrameworks>
|
<TargetFrameworks>net451;netcoreapp3.1</TargetFrameworks>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
|
<LangVersion>8.0</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue