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

This commit is contained in:
Luke Else 2022-02-17 20:07:53 +00:00
parent 99f5cae65f
commit 2063583714
3 changed files with 34 additions and 5 deletions

View File

@ -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}");
}

View File

@ -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;

24
Tracking/SimPosition.cs Normal file
View File

@ -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]);
}
}
}
}