mirror of
https://github.com/dotMorten/NmeaParser.git
synced 2026-04-06 06:53:51 +00:00
Various sample tweaks + added BT sample to Android.
This commit is contained in:
parent
102805a100
commit
2e4e6aa939
11 changed files with 264 additions and 107 deletions
|
|
@ -39,7 +39,7 @@
|
|||
<local:SatelliteView MaxWidth="{Binding ActualHeight, ElementName=satView}"
|
||||
Grid.Column="1" x:Name="satView" />
|
||||
<local:SatelliteSnr Grid.Row="1"
|
||||
GpgsvMessages="{Binding GpgsvMessages, ElementName=satView}" />
|
||||
GsvMessages="{Binding GsvMessages, ElementName=satView}" />
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="Messages">
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ using System.Windows.Media;
|
|||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
using NmeaParser;
|
||||
|
||||
namespace SampleApp.WinDesktop
|
||||
{
|
||||
/// <summary>
|
||||
|
|
@ -66,7 +67,7 @@ namespace SampleApp.WinDesktop
|
|||
gpgsaView.Message = null;
|
||||
gpgllView.Message = null;
|
||||
pgrmeView.Message = null;
|
||||
satView.GpgsvMessages = null;
|
||||
satView.GsvMessages = null;
|
||||
//Start new device
|
||||
currentDevice = device;
|
||||
currentDevice.MessageReceived += device_MessageReceived;
|
||||
|
|
@ -78,9 +79,10 @@ namespace SampleApp.WinDesktop
|
|||
currentDeviceInfo.Text = string.Format("SerialPortDevice( port={0}, baud={1} )",
|
||||
((NmeaParser.SerialPortDevice)device).Port.PortName,
|
||||
((NmeaParser.SerialPortDevice)device).Port.BaudRate);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Dictionary<string, List<NmeaParser.Nmea.Gsv>> gsvMessages = new Dictionary<string, List<NmeaParser.Nmea.Gsv>>();
|
||||
|
||||
private void device_MessageReceived(object sender, NmeaParser.NmeaMessageReceivedEventArgs args)
|
||||
{
|
||||
Dispatcher.BeginInvoke((Action) delegate()
|
||||
|
|
@ -90,11 +92,13 @@ namespace SampleApp.WinDesktop
|
|||
output.Text = string.Join("\n", messages.ToArray());
|
||||
output.Select(output.Text.Length - 1, 0); //scroll to bottom
|
||||
|
||||
if(args.Message is NmeaParser.Nmea.Gps.Gpgsv)
|
||||
{
|
||||
var gpgsv = (NmeaParser.Nmea.Gps.Gpgsv)args.Message;
|
||||
if(args.IsMultipart && args.MessageParts != null)
|
||||
satView.GpgsvMessages = args.MessageParts.OfType<NmeaParser.Nmea.Gps.Gpgsv>();
|
||||
if(args.Message is NmeaParser.Nmea.Gsv gpgsv)
|
||||
{
|
||||
if (args.IsMultipart && args.MessageParts != null)
|
||||
{
|
||||
gsvMessages[args.Message.MessageType] = args.MessageParts.OfType<NmeaParser.Nmea.Gsv>().ToList();
|
||||
satView.GsvMessages = gsvMessages.SelectMany(m=>m.Value);
|
||||
}
|
||||
}
|
||||
if (args.Message is NmeaParser.Nmea.Gps.Gprmc)
|
||||
gprmcView.Message = args.Message as NmeaParser.Nmea.Gps.Gprmc;
|
||||
|
|
|
|||
|
|
@ -25,19 +25,19 @@ namespace SampleApp.WinDesktop
|
|||
InitializeComponent();
|
||||
}
|
||||
|
||||
public IEnumerable<NmeaParser.Nmea.Gps.Gpgsv> GpgsvMessages
|
||||
public IEnumerable<NmeaParser.Nmea.Gsv> GsvMessages
|
||||
{
|
||||
get { return (IEnumerable<NmeaParser.Nmea.Gps.Gpgsv>)GetValue(GpgsvMessagesProperty); }
|
||||
set { SetValue(GpgsvMessagesProperty, value); }
|
||||
get { return (IEnumerable<NmeaParser.Nmea.Gsv>)GetValue(GsvMessagesProperty); }
|
||||
set { SetValue(GsvMessagesProperty, value); }
|
||||
}
|
||||
|
||||
// Using a DependencyProperty as the backing store for GpgsvMessages. This enables animation, styling, binding, etc...
|
||||
public static readonly DependencyProperty GpgsvMessagesProperty =
|
||||
DependencyProperty.Register("GpgsvMessages", typeof(IEnumerable<NmeaParser.Nmea.Gps.Gpgsv>), typeof(SatelliteSnr), new PropertyMetadata(null, OnGpgsvMessagesChanged));
|
||||
public static readonly DependencyProperty GsvMessagesProperty =
|
||||
DependencyProperty.Register("GsvMessages", typeof(IEnumerable<NmeaParser.Nmea.Gsv>), typeof(SatelliteSnr), new PropertyMetadata(null, OnGpgsvMessagesChanged));
|
||||
|
||||
private static void OnGpgsvMessagesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var sats = e.NewValue as IEnumerable<NmeaParser.Nmea.Gps.Gpgsv>;
|
||||
var sats = e.NewValue as IEnumerable<NmeaParser.Nmea.Gsv>;
|
||||
if (sats == null)
|
||||
(d as SatelliteSnr).satellites.ItemsSource = null;
|
||||
else
|
||||
|
|
|
|||
|
|
@ -27,19 +27,18 @@ namespace SampleApp.WinDesktop
|
|||
|
||||
|
||||
|
||||
public IEnumerable<NmeaParser.Nmea.Gps.Gpgsv> GpgsvMessages
|
||||
public IEnumerable<NmeaParser.Nmea.Gsv> GsvMessages
|
||||
{
|
||||
get { return (IEnumerable<NmeaParser.Nmea.Gps.Gpgsv>)GetValue(GpgsvMessagesProperty); }
|
||||
set { SetValue(GpgsvMessagesProperty, value); }
|
||||
get { return (IEnumerable<NmeaParser.Nmea.Gsv>)GetValue(GsvMessagesProperty); }
|
||||
set { SetValue(GsvMessagesProperty, value); }
|
||||
}
|
||||
|
||||
// Using a DependencyProperty as the backing store for GpgsvMessages. This enables animation, styling, binding, etc...
|
||||
public static readonly DependencyProperty GpgsvMessagesProperty =
|
||||
DependencyProperty.Register("GpgsvMessages", typeof(IEnumerable<NmeaParser.Nmea.Gps.Gpgsv>), typeof(SatelliteView), new PropertyMetadata(null, OnGpgsvMessagesChanged));
|
||||
public static readonly DependencyProperty GsvMessagesProperty =
|
||||
DependencyProperty.Register("GsvMessages", typeof(IEnumerable<NmeaParser.Nmea.Gsv>), typeof(SatelliteView), new PropertyMetadata(null, OnGsvMessagesChanged));
|
||||
|
||||
private static void OnGpgsvMessagesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
private static void OnGsvMessagesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var sats = e.NewValue as IEnumerable<NmeaParser.Nmea.Gps.Gpgsv>;
|
||||
var sats = e.NewValue as IEnumerable<NmeaParser.Nmea.Gsv>;
|
||||
if (sats == null)
|
||||
(d as SatelliteView).satellites.ItemsSource = null;
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue