From 58d9d561df35f88884b2959d2cf322f1ee69e3cd Mon Sep 17 00:00:00 2001 From: Arturs Artamonovs Date: Wed, 26 Jun 2024 08:29:38 +0100 Subject: Decoding lat/lon seems to work --- ADSBDecoder/Query.swift | 65 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) (limited to 'ADSBDecoder/Query.swift') diff --git a/ADSBDecoder/Query.swift b/ADSBDecoder/Query.swift index 99d9075..a92d919 100644 --- a/ADSBDecoder/Query.swift +++ b/ADSBDecoder/Query.swift @@ -52,7 +52,7 @@ class QueryDF17TC: CustomStringConvertible { } var description: String { - var description = "TypeCode Count\n" + var description = "DF17 TypeCode Count\n" for i in 0...(TClist.count-1) { if TClist[i] != 0 { description += String(format: " %02d: %04d\n", i, TClist[i]) @@ -61,3 +61,66 @@ class QueryDF17TC: CustomStringConvertible { return description } } + +class QueryDecodedMessages: CustomStringConvertible { + + var decoded:Int = 0 + var total:Int = 0 + + init() { + + } + + func addDecoded() { + decoded += 1 + total += 1 + } + + func addUndecoded() { + total = total + 1 + } + + var description: String { + var description = "Total messages:\n" + description += "Decoded:\(decoded)\n" + description += "Total :\(total) \(String(format:"%02.01f",Float(Float(decoded)/Float(total)*100.0)))%\n" + return description + } + +} + + +class QueryDF17TC_decoded: CustomStringConvertible { + var TClist_decoded:[Int] = Array(repeating: 0, count: 32) + var TClist_total:[Int] = Array(repeating: 0, count: 32) + + init() { + + } + + func addDecoded(_ typecode: Int) { + TClist_decoded[typecode] += 1 + TClist_total[typecode] += 1 + } + + func addUndecode(_ typecode: Int) { + TClist_total[typecode] += 1 + } + + var description: String { + var description = "" + var decoded:Int = 0 + var total:Int = 0 + for i in 0...(TClist_decoded.count-1) { + total += TClist_total[i] + decoded += TClist_decoded[i] + if TClist_total[i] != 0 { + description += String(format: " %02d: %04d\n", i, TClist_decoded[i]) + } + } + description += String(format:"Total %d/%d %.1f",decoded,total,Double(Double(decoded)/Double(total))*100) + description += "%\n" + return description + } +} + -- cgit v1.2.3