// // ADSBTypeCodeAirbonePositon.swift // ADSBDecoder // // Created by Jacky Jack on 27/09/2026. // //DF17 message types codes 8 to 18 public class ADSBTypeCodeAirbonePositon:CustomStringConvertible { var TypeCode:Int = 11 var SurveillanceStatus: Int = 0 var SingleAntennaFlag: Int = 0 public var Altitude: Int = 0 var Time: Int = 0 public var CPRFormat: Int = 0 public var Latitude: Int = 0 public var Longitude: Int = 0 public init(_ bindata:ArraySlice) { let ss = (bindata[4]>>1)&(0x3) SurveillanceStatus = Int(ss) let saf = bindata[5]&0x1 SingleAntennaFlag = Int(saf) let altitude = UInt16(bindata[5])<<4 + (UInt16(bindata[6])>>4)&0xf //print(altitude) Altitude = BarometricAltitudeFeat(altitude) let time = (bindata[6]>>3)&0x1 Time = Int(time) let cpr = (bindata[6]>>2)&0x1 CPRFormat = Int(cpr) let lat:UInt32 = UInt32(bindata[6]&0x3)<<15 + UInt32(bindata[7])<<7 + UInt32(bindata[8]>>1) Latitude = Int(lat) let lon:UInt32 = UInt32(bindata[8]&0x1)<<16 + UInt32(bindata[9])<<8 + UInt32(bindata[10]) Longitude = Int(lon) } public var description: String { var description = "SS \(SurveillanceStatus) SAF \(SingleAntennaFlag) Altitude \(Altitude)ft \n" description += "Time \(Time) CPR \(CPRFormat)" if (CPRFormat == 0) { description += "even" } else { description += "odd" } description += "\n" description += "Lat \(Latitude) Long \(Longitude)" return description } }