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