diff options
author | Arturs Artamonovs <arturs.artamonovs@protonmail.com> | 2024-06-26 08:29:38 +0100 |
---|---|---|
committer | Arturs Artamonovs <arturs.artamonovs@protonmail.com> | 2024-06-26 08:29:38 +0100 |
commit | 58d9d561df35f88884b2959d2cf322f1ee69e3cd (patch) | |
tree | d90eb046a4e508bc64adcce558079048e364dd96 /ADSBDecoder/Query.swift | |
parent | de4f742388002e5b8307903369727300dd3e6049 (diff) | |
download | ADSBDecoder-58d9d561df35f88884b2959d2cf322f1ee69e3cd.tar.gz ADSBDecoder-58d9d561df35f88884b2959d2cf322f1ee69e3cd.zip |
Decoding lat/lon seems to work
Diffstat (limited to 'ADSBDecoder/Query.swift')
-rw-r--r-- | ADSBDecoder/Query.swift | 65 |
1 files changed, 64 insertions, 1 deletions
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 + } +} + |