2014-07-25 21:21:07 +02:00
|
|
|
|
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
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Interaction logic for MainWindow.xaml
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public partial class MainWindow : Window
|
|
|
|
|
|
{
|
|
|
|
|
|
public MainWindow()
|
|
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
var device = new NmeaParser.NmeaFileDevice("NmeaSampleData.txt");
|
|
|
|
|
|
device.MessageReceived += device_MessageReceived;
|
2014-07-29 01:38:45 +02:00
|
|
|
|
var _ = device.OpenAsync();
|
2014-07-25 21:21:07 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2014-07-29 01:38:45 +02:00
|
|
|
|
Dictionary<int, NmeaParser.Nmea.Gps.Gpgsv> gpgsvList = new Dictionary<int,NmeaParser.Nmea.Gps.Gpgsv>();
|
2014-07-31 09:37:30 +02:00
|
|
|
|
private void device_MessageReceived(object sender, NmeaParser.NmeaMessageReceivedEventArgs args)
|
2014-07-25 21:21:07 +02:00
|
|
|
|
{
|
|
|
|
|
|
Dispatcher.BeginInvoke((Action) delegate()
|
|
|
|
|
|
{
|
2014-07-31 09:37:30 +02:00
|
|
|
|
output.Text += args.Message.MessageType + ": " + args.ToString() + '\n';
|
2014-07-29 01:38:45 +02:00
|
|
|
|
output.Select(output.Text.Length - 1, 0); //scroll to bottom
|
|
|
|
|
|
|
|
|
|
|
|
//Merge all gpgsv satellite messages
|
2014-07-31 09:37:30 +02:00
|
|
|
|
if(args.Message is NmeaParser.Nmea.Gps.Gpgsv)
|
2014-07-29 01:38:45 +02:00
|
|
|
|
{
|
2014-07-31 09:37:30 +02:00
|
|
|
|
var gpgsv = (NmeaParser.Nmea.Gps.Gpgsv)args.Message;
|
2014-07-29 01:38:45 +02:00
|
|
|
|
if(gpgsv.MessageNumber == 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
gpgsvList = new Dictionary<int,NmeaParser.Nmea.Gps.Gpgsv>(); //first one. Replace list
|
|
|
|
|
|
}
|
|
|
|
|
|
gpgsvList[gpgsv.MessageNumber] = gpgsv;
|
|
|
|
|
|
if(gpgsv.MessageNumber == gpgsv.TotalMessages)
|
|
|
|
|
|
satView.GpgsvMessages = gpgsvList.Values;
|
|
|
|
|
|
}
|
2014-07-25 21:21:07 +02:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|