mirror of
https://github.com/dotMorten/NmeaParser.git
synced 2026-01-04 23:59:57 +01:00
Better handle display multiple systems for GSV
This commit is contained in:
parent
fe75ff21f1
commit
daa6cedd05
|
|
@ -39,8 +39,7 @@
|
|||
</Grid.RowDefinitions>
|
||||
<local:SatelliteView MaxWidth="{Binding ActualHeight, ElementName=satView}"
|
||||
Grid.Column="1" x:Name="satView" />
|
||||
<local:SatelliteSnr Grid.Row="1"
|
||||
GsvMessage="{Binding GsvMessage, ElementName=satView}" />
|
||||
<local:SatelliteSnr Grid.Row="1" x:Name="satSnr" />
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="Map">
|
||||
|
|
|
|||
|
|
@ -61,7 +61,8 @@ namespace SampleApp.WinDesktop
|
|||
gpgsaView.Message = null;
|
||||
gpgllView.Message = null;
|
||||
pgrmeView.Message = null;
|
||||
satView.GsvMessage = null;
|
||||
satView.ClearGsv();
|
||||
satSnr.ClearGsv();
|
||||
//Start new device
|
||||
currentDevice = device;
|
||||
currentDevice.MessageReceived += device_MessageReceived;
|
||||
|
|
@ -89,7 +90,8 @@ namespace SampleApp.WinDesktop
|
|||
|
||||
if (args.Message is NmeaParser.Messages.Gsv gpgsv)
|
||||
{
|
||||
satView.GsvMessage = gpgsv;
|
||||
satView.SetGsv(gpgsv);
|
||||
satSnr.SetGsv(gpgsv);
|
||||
}
|
||||
else if (args.Message is NmeaParser.Messages.Rmc)
|
||||
gprmcView.Message = args.Message as NmeaParser.Messages.Rmc;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
<SolidColorBrush Color="{Binding Converter={StaticResource conv}}" />
|
||||
</TextBlock.Foreground>
|
||||
</TextBlock>
|
||||
<Border Height="{Binding SignalToNoiseRatio, FallbackValue=10}"
|
||||
<Border Height="{Binding SignalToNoiseRatio, FallbackValue=10, NotifyOnValidationError=False}"
|
||||
BorderBrush="Black"
|
||||
Margin="5,0" Width="20"
|
||||
BorderThickness="1"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
using System;
|
||||
using NmeaParser;
|
||||
using NmeaParser.Messages;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
|
@ -24,23 +26,21 @@ namespace SampleApp.WinDesktop
|
|||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public NmeaParser.Messages.Gsv GsvMessage
|
||||
Dictionary<Talker, Gsv> messages = new Dictionary<Talker, Gsv>();
|
||||
public void SetGsv(Gsv message)
|
||||
{
|
||||
get { return (NmeaParser.Messages.Gsv)GetValue(GsvMessageProperty); }
|
||||
set { SetValue(GsvMessageProperty, value); }
|
||||
messages[message.TalkerId] = message;
|
||||
UpdateSatellites();
|
||||
}
|
||||
public void ClearGsv()
|
||||
{
|
||||
messages.Clear();
|
||||
UpdateSatellites();
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty GsvMessageProperty =
|
||||
DependencyProperty.Register(nameof(GsvMessage), typeof(NmeaParser.Messages.Gsv), typeof(SatelliteSnr), new PropertyMetadata(null, OnGpgsvMessagePropertyChanged));
|
||||
|
||||
private static void OnGpgsvMessagePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
private void UpdateSatellites()
|
||||
{
|
||||
var gsv = e.NewValue as NmeaParser.Messages.Gsv;
|
||||
if (gsv == null)
|
||||
(d as SatelliteSnr).satellites.ItemsSource = null;
|
||||
else
|
||||
(d as SatelliteSnr).satellites.ItemsSource = gsv.SVs;
|
||||
satellites.ItemsSource = messages.Values.SelectMany(g => g.SVs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,23 +27,21 @@ namespace SampleApp.WinDesktop
|
|||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public Gsv GsvMessage
|
||||
Dictionary<Talker, Gsv> messages = new Dictionary<Talker, Gsv>();
|
||||
public void SetGsv(Gsv message)
|
||||
{
|
||||
get { return (Gsv)GetValue(GsvMessageProperty); }
|
||||
set { SetValue(GsvMessageProperty, value); }
|
||||
messages[message.TalkerId] = message;
|
||||
UpdateSatellites();
|
||||
}
|
||||
public void ClearGsv()
|
||||
{
|
||||
messages.Clear();
|
||||
UpdateSatellites();
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty GsvMessageProperty =
|
||||
DependencyProperty.Register(nameof(GsvMessage), typeof(Gsv), typeof(SatelliteView), new PropertyMetadata(null, OnGsvMessagePropertyChanged));
|
||||
|
||||
private static void OnGsvMessagePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
private void UpdateSatellites()
|
||||
{
|
||||
var gsv = e.NewValue as Gsv;
|
||||
if (gsv == null)
|
||||
(d as SatelliteView).satellites.ItemsSource = null;
|
||||
else
|
||||
(d as SatelliteView).satellites.ItemsSource = gsv.SVs;
|
||||
satellites.ItemsSource = messages.Values.SelectMany(g => g.SVs);
|
||||
}
|
||||
}
|
||||
public class PolarPlacementItem : ContentControl
|
||||
|
|
@ -107,7 +105,8 @@ namespace SampleApp.WinDesktop
|
|||
{
|
||||
case Talker.GlobalPositioningSystem: return Color.FromArgb(alpha, 255, 0, 0);
|
||||
case Talker.GalileoPositioningSystem: return Color.FromArgb(alpha, 0, 255, 0);
|
||||
case Talker.GlonassReceiver: return Color.FromArgb(255, 0, 0, alpha);
|
||||
case Talker.GlonassReceiver: return Color.FromArgb(alpha, 0, 0, 255);
|
||||
case Talker.BeiDouNavigationSatelliteSystem : return Color.FromArgb(alpha, 0, 255, 255);
|
||||
case Talker.GlobalNavigationSatelliteSystem: return Color.FromArgb(alpha, 0, 0, 0);
|
||||
default: return Colors.CornflowerBlue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue