From 2063583714c02063551cddb4b87d59ded8a43558 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Thu, 17 Feb 2022 20:07:53 +0000 Subject: [PATCH] Tracking software now fully functional however hanging on by a thread as it is realiant on the sim delivering the exact number of packets in the exact position. Could be worth trying to assign the id to the packet to ensure that we are assigning the correct values to the correct place --- Program.cs | 11 ++++++++--- Tracking/Packet.cs | 4 ++-- Tracking/SimPosition.cs | 24 ++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 Tracking/SimPosition.cs diff --git a/Program.cs b/Program.cs index d0eb6cc..13499c6 100644 --- a/Program.cs +++ b/Program.cs @@ -16,9 +16,14 @@ using(UdpClient listener = new UdpClient(listenPort)) Console.WriteLine("Received broadcast message from client {0}", listenEndPoint.ToString()); Console.WriteLine("Decoded data is:"); - var packets = Packet.ReadPackets(receivedData); - //Console.WriteLine(Encoding.ASCII.GetString(receivedData)); - Console.WriteLine(BitConverter.ToString(receivedData)); + + Packet[]? data = Packet.ReadPackets(receivedData); + + if (data != null) + { + SimPosition position = new SimPosition(data); + Console.WriteLine($"Latitude: {position.Latitude} Longitude: {position.Longitude} Altitude: {position.Altitude}"); + } diff --git a/Tracking/Packet.cs b/Tracking/Packet.cs index 20a0c5a..b4b6a48 100644 --- a/Tracking/Packet.cs +++ b/Tracking/Packet.cs @@ -8,8 +8,8 @@ namespace EFBTracker.Tracking { public class Packet { - private string Type { get; set; } - private float[]? Data { get; set; } + public string Type { get; set; } + public float[]? Data { get; set; } public Packet(string type, float[] data){ Type = type; diff --git a/Tracking/SimPosition.cs b/Tracking/SimPosition.cs new file mode 100644 index 0000000..7b7e714 --- /dev/null +++ b/Tracking/SimPosition.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace EFBTracker.Tracking +{ + public class SimPosition + { + public float Latitude { get; set; } + public float Longitude { get; set; } + public int Altitude { get; set; } + + public SimPosition(Packet[] data){ + if (data[0].Data != null) + { + Latitude = data[0].Data[0]; + Longitude = data[1].Data[0]; + Altitude = Convert.ToInt32(data[2].Data[0]); + } + } + + } +} \ No newline at end of file