Ad dpacket it tracing and use Linq to select appropriate packets
This commit is contained in:
parent
2063583714
commit
d67d4a8a04
@ -9,10 +9,12 @@ namespace EFBTracker.Tracking
|
||||
public class Packet
|
||||
{
|
||||
public string Type { get; set; }
|
||||
public float[]? Data { get; set; }
|
||||
public int Id { get; set; }
|
||||
public float[] Data { get; set; } = new float[4];
|
||||
|
||||
public Packet(string type, float[] data){
|
||||
public Packet(string type, int id, float[] data){
|
||||
Type = type;
|
||||
Id = id;
|
||||
Data = data;
|
||||
}
|
||||
|
||||
@ -44,7 +46,7 @@ namespace EFBTracker.Tracking
|
||||
}
|
||||
|
||||
//Generate new packet object and add to list
|
||||
packets.Add(new Packet(header, values));
|
||||
packets.Add(new Packet(header, id, values));
|
||||
}
|
||||
return packets.ToArray();
|
||||
}
|
||||
|
@ -14,9 +14,11 @@ namespace EFBTracker.Tracking
|
||||
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]);
|
||||
//Use Linq to search through the packets for a given id and use that data
|
||||
Latitude = (data.Where(x => x.Id == 22).Select(x => x.Data[0]).ToArray())[0];
|
||||
Longitude = (data.Where(x => x.Id == 23).Select(x => x.Data[0]).ToArray())[0];
|
||||
Altitude = Convert.ToInt32((data.Where(x => x.Id == 24).Select(x => x.Data[0]).ToArray())[0]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user