diff options
| author | Arturs Artamonovs <arturs.artamonovs@protonmail.com> | 2026-09-24 11:02:35 +0100 |
|---|---|---|
| committer | Arturs Artamonovs <arturs.artamonovs@protonmail.com> | 2026-09-24 11:02:35 +0100 |
| commit | 505b23afc68ecbb63b8f0a7d44c0b0ad063d5cfd (patch) | |
| tree | d38b29a0cf23041571eb08fd79f49fdad8deb85f /ADSBDecoderFramework/Query.swift | |
| parent | 056ee0c3355db995d7ea571e0635ebe8b09bf8ee (diff) | |
| download | ADSBDecoder-505b23afc68ecbb63b8f0a7d44c0b0ad063d5cfd.tar.gz ADSBDecoder-505b23afc68ecbb63b8f0a7d44c0b0ad063d5cfd.zip | |
rearrange source, move common parts to framework
Diffstat (limited to 'ADSBDecoderFramework/Query.swift')
| -rw-r--r-- | ADSBDecoderFramework/Query.swift | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/ADSBDecoderFramework/Query.swift b/ADSBDecoderFramework/Query.swift new file mode 100644 index 0000000..a92d919 --- /dev/null +++ b/ADSBDecoderFramework/Query.swift @@ -0,0 +1,126 @@ +// +// Query.swift +// ADSBDecoder +// +// Created by Jacky Jack on 31/05/2024. +// + +import Foundation + +class QueryDF: CustomStringConvertible { + + //max I see is 24 + var DFlist:[Int] = Array(repeating: 0, count: 30) + + init() { + + } + + func addDF(_ dataformat: UInt32) { + DFlist[Int(dataformat)] += 1 + } + + func showStat() { + print("DataFormat Count") + for i in 0...(DFlist.count)-1 { + if DFlist[i] != 0 { + print(String(format:" %02d: %05d", i, DFlist[i])) + } + } + } + + var description: String { + var description = "DataFormat Count\n" + for i in 0...(DFlist.count)-1 { + if DFlist[i] != 0 { + description += String(format:" %02d: %04d\n", i, DFlist[i]) + } + } + return description + } +} + +class QueryDF17TC: CustomStringConvertible { + var TClist:[Int] = Array(repeating: 0, count: 32) + + init() { + + } + + func addTC(_ typecode: Int) { + TClist[typecode] += 1 + } + + var description: String { + 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]) + } + } + 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 + } +} + |
