summaryrefslogtreecommitdiff
path: root/ADSBDecoder/Query.swift
blob: 99d9075e68c6f1cded740486260fbe64dd66046d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
//  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 = "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
    }
}