Improve multi-band handling of SNRs

This commit is contained in:
Morten Nielsen 2020-09-24 21:46:08 -07:00
parent 830b5c25f3
commit 1c96176a56
3 changed files with 40 additions and 27 deletions

View file

@ -57,24 +57,7 @@
VerticalAlignment="Bottom">
<Border.ToolTip>
<StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="System: " />
<TextBlock Text="{Binding Converter={StaticResource heightconv}, ConverterParameter=Name}" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Azimuth: " />
<TextBlock Text="{Binding Azimuth}" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Elevation: " />
<TextBlock Text="{Binding Elevation}" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="SNR: " />
<TextBlock Text="{Binding SignalToNoiseRatio}" />
<TextBlock Text="dB" />
</StackPanel>
<TextBlock Text="{Binding Converter={StaticResource heightconv}, ConverterParameter=Name}" />
</StackPanel>
</Border.ToolTip>

View file

@ -41,8 +41,24 @@ namespace SampleApp.WinDesktop
private void UpdateSatellites()
{
satellites.ItemsSource = messages.Values.SelectMany(g => g.SVs).OrderBy(s=>s.GnssSignalId).OrderBy(s => s.Id).OrderByDescending(s => s.TalkerId);
}
//satellites.ItemsSource = messages.Values.SelectMany(g => g.SVs).OrderBy(s=>s.GnssSignalId).OrderBy(s => s.Id).OrderByDescending(s => s.TalkerId);
var sats = messages.Values.SelectMany(g => g.SVs).GroupBy(s => s.TalkerId.ToString() + s.Id);
var infos = sats.Select(s => new SatelliteInfo()
{
Id = s.First().Id,
TalkerId = s.First().TalkerId,
SNRs = new Dictionary<char, int>(s.Select(s => new KeyValuePair<char, int>(s.GnssSignalId, s.SignalToNoiseRatio)), null)
});
satellites.ItemsSource = infos;
}
public struct SatelliteInfo
{
public int Id;
public Talker TalkerId;
public Dictionary<char, int> SNRs;
public int SignalToNoiseRatio => SNRs.Max(s=>s.Value);
}
internal static string SignalIdToName(char signalId, Talker talkerId)
{
@ -139,7 +155,7 @@ namespace SampleApp.WinDesktop
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if(value is SatelliteVehicle sv)
if(value is SatelliteSnr.SatelliteInfo sv)
{
if (parameter as string == "Name")
{
@ -156,10 +172,11 @@ namespace SampleApp.WinDesktop
name = "NavIC IRNSS";
else
name = sv.TalkerId.ToString();
var signalName = SatelliteSnr.SignalIdToName(sv.GnssSignalId, sv.TalkerId);
if (!string.IsNullOrEmpty(signalName))
name += " (" + signalName + ")";
return name;
var snrs = string.Join("\n", sv.SNRs.Select(snr => SatelliteSnr.SignalIdToName(snr.Key, sv.TalkerId) + ": " + snr.Value + "dB"));
if (!string.IsNullOrEmpty(snrs))
name += $"\n{snrs}";
return name;
}
else
return Math.Max(10, sv.SignalToNoiseRatio * 2);

View file

@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
@ -98,10 +99,22 @@ namespace SampleApp.WinDesktop
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
Talker? talker = null;
int snr = 0;
if (value is SatelliteVehicle sv)
{
byte alpha = (byte)(sv.SignalToNoiseRatio <= 0 ? 80 : 255);
switch (sv.TalkerId)
talker = sv.TalkerId;
snr = sv.SignalToNoiseRatio;
}
else if (value is SatelliteSnr.SatelliteInfo info)
{
talker = info.TalkerId;
snr = info.SignalToNoiseRatio;
}
if(talker != null)
{
byte alpha = (byte)(snr <= 0 ? 80 : 255);
switch (talker)
{
case Talker.GlobalPositioningSystem: return Color.FromArgb(alpha, 255, 0, 0);
case Talker.GalileoPositioningSystem: return Color.FromArgb(alpha, 0, 255, 0);