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:
parent
99f5cae65f
commit
2063583714
11
Program.cs
11
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}");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -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
24
Tracking/SimPosition.cs
Normal 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]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user