From a3e63a1111e5c8cfc8d0db22bea8940f7cdf2cc2 Mon Sep 17 00:00:00 2001 From: mort5161 Date: Sat, 15 Nov 2014 00:10:24 -0800 Subject: [PATCH] Improved sample app --- src/NmeaParser.Shared/Nmea/Gps/GPBOD.cs | 4 +- src/NmeaParser.Shared/Nmea/Gps/GPGGA.cs | 4 +- src/SampleApp.WinDesktop/GpggaControl.xaml | 38 ++++++++++++++ src/SampleApp.WinDesktop/GpggaControl.xaml.cs | 38 ++++++++++++++ src/SampleApp.WinDesktop/GpgllControl.xaml | 24 +++++++++ src/SampleApp.WinDesktop/GpgllControl.xaml.cs | 38 ++++++++++++++ src/SampleApp.WinDesktop/GpgsaControl.xaml | 20 ++++++++ src/SampleApp.WinDesktop/GpgsaControl.xaml.cs | 38 ++++++++++++++ src/SampleApp.WinDesktop/GprmcControl.xaml | 26 ++++++++++ src/SampleApp.WinDesktop/GprmcControl.xaml.cs | 38 ++++++++++++++ .../KeyValuePairControl.xaml | 12 +++++ .../KeyValuePairControl.xaml.cs | 50 +++++++++++++++++++ src/SampleApp.WinDesktop/MainWindow.xaml | 40 ++++++++++++--- src/SampleApp.WinDesktop/MainWindow.xaml.cs | 17 +++++++ src/SampleApp.WinDesktop/PgrmeControl.xaml | 38 ++++++++++++++ src/SampleApp.WinDesktop/PgrmeControl.xaml.cs | 39 +++++++++++++++ .../SampleApp.WinDesktop.csproj | 42 ++++++++++++++++ 17 files changed, 494 insertions(+), 12 deletions(-) create mode 100644 src/SampleApp.WinDesktop/GpggaControl.xaml create mode 100644 src/SampleApp.WinDesktop/GpggaControl.xaml.cs create mode 100644 src/SampleApp.WinDesktop/GpgllControl.xaml create mode 100644 src/SampleApp.WinDesktop/GpgllControl.xaml.cs create mode 100644 src/SampleApp.WinDesktop/GpgsaControl.xaml create mode 100644 src/SampleApp.WinDesktop/GpgsaControl.xaml.cs create mode 100644 src/SampleApp.WinDesktop/GprmcControl.xaml create mode 100644 src/SampleApp.WinDesktop/GprmcControl.xaml.cs create mode 100644 src/SampleApp.WinDesktop/KeyValuePairControl.xaml create mode 100644 src/SampleApp.WinDesktop/KeyValuePairControl.xaml.cs create mode 100644 src/SampleApp.WinDesktop/PgrmeControl.xaml create mode 100644 src/SampleApp.WinDesktop/PgrmeControl.xaml.cs diff --git a/src/NmeaParser.Shared/Nmea/Gps/GPBOD.cs b/src/NmeaParser.Shared/Nmea/Gps/GPBOD.cs index 0e9c1b6..95ab6eb 100644 --- a/src/NmeaParser.Shared/Nmea/Gps/GPBOD.cs +++ b/src/NmeaParser.Shared/Nmea/Gps/GPBOD.cs @@ -64,11 +64,11 @@ namespace NmeaParser.Nmea.Gps /// /// Name of origin /// - public string OriginId { get; set; } + public string OriginId { get; private set; } /// /// Name of destination /// - public string DestinationId { get; set; } + public string DestinationId { get; private set; } } } diff --git a/src/NmeaParser.Shared/Nmea/Gps/GPGGA.cs b/src/NmeaParser.Shared/Nmea/Gps/GPGGA.cs index b35f0b9..3c78958 100644 --- a/src/NmeaParser.Shared/Nmea/Gps/GPGGA.cs +++ b/src/NmeaParser.Shared/Nmea/Gps/GPGGA.cs @@ -137,11 +137,11 @@ namespace NmeaParser.Nmea.Gps /// /// Time since last DGPS update /// - public TimeSpan TimeSinceLastDgpsUpdate { get; set; } + public TimeSpan TimeSinceLastDgpsUpdate { get; private set; } /// /// DGPS Station ID Number /// - public int DgpsStationId { get; set; } + public int DgpsStationId { get; private set; } } } diff --git a/src/SampleApp.WinDesktop/GpggaControl.xaml b/src/SampleApp.WinDesktop/GpggaControl.xaml new file mode 100644 index 0000000..9afcf39 --- /dev/null +++ b/src/SampleApp.WinDesktop/GpggaControl.xaml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SampleApp.WinDesktop/GpggaControl.xaml.cs b/src/SampleApp.WinDesktop/GpggaControl.xaml.cs new file mode 100644 index 0000000..61e24fe --- /dev/null +++ b/src/SampleApp.WinDesktop/GpggaControl.xaml.cs @@ -0,0 +1,38 @@ +using NmeaParser.Nmea.Gps; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace SampleApp.WinDesktop +{ + /// + /// Interaction logic for GpggaControl.xaml + /// + public partial class GpggaControl : UserControl + { + public GpggaControl() + { + InitializeComponent(); + } + + public Gpgga Message + { + get { return (Gpgga)GetValue(GpggaProperty); } + set { SetValue(GpggaProperty, value); } + } + + public static readonly DependencyProperty GpggaProperty = + DependencyProperty.Register("Message", typeof(Gpgga), typeof(GpggaControl), new PropertyMetadata(null)); + } +} diff --git a/src/SampleApp.WinDesktop/GpgllControl.xaml b/src/SampleApp.WinDesktop/GpgllControl.xaml new file mode 100644 index 0000000..848d429 --- /dev/null +++ b/src/SampleApp.WinDesktop/GpgllControl.xaml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/src/SampleApp.WinDesktop/GpgllControl.xaml.cs b/src/SampleApp.WinDesktop/GpgllControl.xaml.cs new file mode 100644 index 0000000..e0ed3d5 --- /dev/null +++ b/src/SampleApp.WinDesktop/GpgllControl.xaml.cs @@ -0,0 +1,38 @@ +using NmeaParser.Nmea.Gps; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace SampleApp.WinDesktop +{ + /// + /// Interaction logic for GpgllControl.xaml + /// + public partial class GpgllControl : UserControl + { + public GpgllControl() + { + InitializeComponent(); + } + + public Gpgll Message + { + get { return (Gpgll)GetValue(MessageProperty); } + set { SetValue(MessageProperty, value); } + } + + public static readonly DependencyProperty MessageProperty = + DependencyProperty.Register("Message", typeof(Gpgll), typeof(GpgllControl), new PropertyMetadata(null)); + } +} diff --git a/src/SampleApp.WinDesktop/GpgsaControl.xaml b/src/SampleApp.WinDesktop/GpgsaControl.xaml new file mode 100644 index 0000000..68f8249 --- /dev/null +++ b/src/SampleApp.WinDesktop/GpgsaControl.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + diff --git a/src/SampleApp.WinDesktop/GpgsaControl.xaml.cs b/src/SampleApp.WinDesktop/GpgsaControl.xaml.cs new file mode 100644 index 0000000..2ceb34a --- /dev/null +++ b/src/SampleApp.WinDesktop/GpgsaControl.xaml.cs @@ -0,0 +1,38 @@ +using NmeaParser.Nmea.Gps; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace SampleApp.WinDesktop +{ + /// + /// Interaction logic for GpgsaControl.xaml + /// + public partial class GpgsaControl : UserControl + { + public GpgsaControl() + { + InitializeComponent(); + } + + public Gpgsa Message + { + get { return (Gpgsa)GetValue(GpgsaProperty); } + set { SetValue(GpgsaProperty, value); } + } + + public static readonly DependencyProperty GpgsaProperty = + DependencyProperty.Register("Message", typeof(Gpgsa), typeof(GpgsaControl), new PropertyMetadata(null)); + } +} diff --git a/src/SampleApp.WinDesktop/GprmcControl.xaml b/src/SampleApp.WinDesktop/GprmcControl.xaml new file mode 100644 index 0000000..caccc24 --- /dev/null +++ b/src/SampleApp.WinDesktop/GprmcControl.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/SampleApp.WinDesktop/GprmcControl.xaml.cs b/src/SampleApp.WinDesktop/GprmcControl.xaml.cs new file mode 100644 index 0000000..8fe2035 --- /dev/null +++ b/src/SampleApp.WinDesktop/GprmcControl.xaml.cs @@ -0,0 +1,38 @@ +using NmeaParser.Nmea.Gps; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace SampleApp.WinDesktop +{ + /// + /// Interaction logic for GprmcControl.xaml + /// + public partial class GprmcControl : UserControl + { + public GprmcControl() + { + InitializeComponent(); + } + + public Gprmc Message + { + get { return (Gprmc)GetValue(MessageProperty); } + set { SetValue(MessageProperty, value); } + } + + public static readonly DependencyProperty MessageProperty = + DependencyProperty.Register("Message", typeof(Gprmc), typeof(GprmcControl), new PropertyMetadata(null)); + } +} diff --git a/src/SampleApp.WinDesktop/KeyValuePairControl.xaml b/src/SampleApp.WinDesktop/KeyValuePairControl.xaml new file mode 100644 index 0000000..43e4e06 --- /dev/null +++ b/src/SampleApp.WinDesktop/KeyValuePairControl.xaml @@ -0,0 +1,12 @@ + + + + + + diff --git a/src/SampleApp.WinDesktop/KeyValuePairControl.xaml.cs b/src/SampleApp.WinDesktop/KeyValuePairControl.xaml.cs new file mode 100644 index 0000000..fdbaaf6 --- /dev/null +++ b/src/SampleApp.WinDesktop/KeyValuePairControl.xaml.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace SampleApp.WinDesktop +{ + /// + /// Interaction logic for KeyValuePairControl.xaml + /// + public partial class KeyValuePairControl : UserControl + { + public KeyValuePairControl() + { + InitializeComponent(); + } + + + public string Header + { + get { return (string)GetValue(HeaderProperty); } + set { SetValue(HeaderProperty, value); } + } + + public static readonly DependencyProperty HeaderProperty = + DependencyProperty.Register("Header", typeof(string), typeof(KeyValuePairControl), new PropertyMetadata(null)); + + + + public object Value + { + get { return (object)GetValue(ValueProperty); } + set { SetValue(ValueProperty, value); } + } + + public static readonly DependencyProperty ValueProperty = + DependencyProperty.Register("Value", typeof(object), typeof(KeyValuePairControl), new PropertyMetadata(null)); + + } +} diff --git a/src/SampleApp.WinDesktop/MainWindow.xaml b/src/SampleApp.WinDesktop/MainWindow.xaml index 78f3dd1..c4a1144 100644 --- a/src/SampleApp.WinDesktop/MainWindow.xaml +++ b/src/SampleApp.WinDesktop/MainWindow.xaml @@ -2,16 +2,32 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:SampleApp.WinDesktop" - Title="Sample App" Height="450" Width="525"> + Title="Sample App" Height="500" Width="625"> + + + - - + + + + + + + + + + @@ -25,6 +41,14 @@ GpgsvMessages="{Binding GpgsvMessages, ElementName=satView}" /> + + + diff --git a/src/SampleApp.WinDesktop/MainWindow.xaml.cs b/src/SampleApp.WinDesktop/MainWindow.xaml.cs index 7c3d096..f2979b8 100644 --- a/src/SampleApp.WinDesktop/MainWindow.xaml.cs +++ b/src/SampleApp.WinDesktop/MainWindow.xaml.cs @@ -25,6 +25,13 @@ namespace SampleApp.WinDesktop public MainWindow() { InitializeComponent(); + + // Use serial port: + //var comPort = System.IO.Ports.SerialPort.GetPortNames().First(); + //var port = new System.IO.Ports.SerialPort(comPort, 4800); + //var device = new NmeaParser.SerialPortDevice(port); + + //Use a log file for playing back logged data var device = new NmeaParser.NmeaFileDevice("NmeaSampleData.txt"); device.MessageReceived += device_MessageReceived; var _ = device.OpenAsync(); @@ -45,6 +52,16 @@ namespace SampleApp.WinDesktop if(args.IsMultipart && args.MessageParts != null) satView.GpgsvMessages = args.MessageParts.OfType(); } + if (args.Message is NmeaParser.Nmea.Gps.Gprmc) + gprmcView.Message = args.Message as NmeaParser.Nmea.Gps.Gprmc; + else if (args.Message is NmeaParser.Nmea.Gps.Gpgga) + gpggaView.Message = args.Message as NmeaParser.Nmea.Gps.Gpgga; + else if (args.Message is NmeaParser.Nmea.Gps.Gpgsa) + gpgsaView.Message = args.Message as NmeaParser.Nmea.Gps.Gpgsa; + else if (args.Message is NmeaParser.Nmea.Gps.Gpgll) + gpgllView.Message = args.Message as NmeaParser.Nmea.Gps.Gpgll; + else if (args.Message is NmeaParser.Nmea.Gps.Garmin.Pgrme) + pgrmeView.Message = args.Message as NmeaParser.Nmea.Gps.Garmin.Pgrme; }); } } diff --git a/src/SampleApp.WinDesktop/PgrmeControl.xaml b/src/SampleApp.WinDesktop/PgrmeControl.xaml new file mode 100644 index 0000000..a8ec909 --- /dev/null +++ b/src/SampleApp.WinDesktop/PgrmeControl.xaml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SampleApp.WinDesktop/PgrmeControl.xaml.cs b/src/SampleApp.WinDesktop/PgrmeControl.xaml.cs new file mode 100644 index 0000000..bbb3b4d --- /dev/null +++ b/src/SampleApp.WinDesktop/PgrmeControl.xaml.cs @@ -0,0 +1,39 @@ +using NmeaParser.Nmea.Gps; +using NmeaParser.Nmea.Gps.Garmin; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace SampleApp.WinDesktop +{ + /// + /// Interaction logic for PgrmeControl.xaml + /// + public partial class PgrmeControl : UserControl + { + public PgrmeControl() + { + InitializeComponent(); + } + + public Pgrme Message + { + get { return (Pgrme)GetValue(MessageProperty); } + set { SetValue(MessageProperty, value); } + } + + public static readonly DependencyProperty MessageProperty = + DependencyProperty.Register("Message", typeof(Pgrme), typeof(PgrmeControl), new PropertyMetadata(null)); + } +} diff --git a/src/SampleApp.WinDesktop/SampleApp.WinDesktop.csproj b/src/SampleApp.WinDesktop/SampleApp.WinDesktop.csproj index eca9dce..4422c96 100644 --- a/src/SampleApp.WinDesktop/SampleApp.WinDesktop.csproj +++ b/src/SampleApp.WinDesktop/SampleApp.WinDesktop.csproj @@ -53,12 +53,54 @@ MSBuild:Compile Designer + + GpgsaControl.xaml + + + GpggaControl.xaml + + + GpgllControl.xaml + + + KeyValuePairControl.xaml + + + PgrmeControl.xaml + + + GprmcControl.xaml + SatelliteSnr.xaml SatelliteView.xaml + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + MSBuild:Compile Designer