summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArturs Artamonovs <arturs.artamonovs@protonmail.com>2025-11-17 00:32:31 +0000
committerArturs Artamonovs <arturs.artamonovs@protonmail.com>2025-11-17 00:32:31 +0000
commit2b599499dc26f0f93537d1bea4733eae68333a1c (patch)
treedc3b177aa2c5cfcf88cf4d5012bb0555c9f7fb5e
parent9070c9e6b7c7ce5671f4fad85e4aefa8c27aad28 (diff)
downloadADSBDecoder-2b599499dc26f0f93537d1bea4733eae68333a1c.tar.gz
ADSBDecoder-2b599499dc26f0f93537d1bea4733eae68333a1c.zip
Save old work that I have no clue what I where doing
-rw-r--r--ADSBDecoder/ADSBRegEx.swift54
-rw-r--r--ADSBDecoder/Configs.swift2
-rw-r--r--ADSBDecoder/main.swift16
-rw-r--r--ADSBStats/main.swift8
-rw-r--r--LearnMapKit/ADSBDataQueue.swift20
-rw-r--r--LearnMapKit/ADSBFileRunner.swift3
-rw-r--r--LearnMapKit/ADSBNetRunner.swift3
-rw-r--r--LearnMapKit/ContentView.swift44
-rw-r--r--LearnMapKit/FlighState.swift4
-rw-r--r--LearnMapKit/LearnMapKitApp.swift4
-rw-r--r--LearnMapKit/NetworkConfigure.swift4
-rw-r--r--Net1090/main.swift2
12 files changed, 102 insertions, 62 deletions
diff --git a/ADSBDecoder/ADSBRegEx.swift b/ADSBDecoder/ADSBRegEx.swift
index e9ebe17..2841467 100644
--- a/ADSBDecoder/ADSBRegEx.swift
+++ b/ADSBDecoder/ADSBRegEx.swift
@@ -7,7 +7,7 @@
import Foundation
import RegexBuilder
-
+/*
let matchADSBLong = Regex {
Anchor.startOfLine
"*"
@@ -20,8 +20,35 @@ let matchADSBLong = Regex {
,count:28)
";"
+}*/
+class MatchADSBLong {
+ let matchADSBLong = Regex {
+ Anchor.startOfLine
+ "*"
+
+ Repeat(
+ CharacterClass(
+ ("a"..."f"),
+ ("0"..."9")
+ )
+ ,count:28)
+
+ ";"
+ }
+
+ func prefixMatch(_ line: String) -> Regex<Regex<Substring>.RegexOutput>.Match? {
+ do {
+ if let match = try matchADSBLong.prefixMatch(in: line) {
+ return match
+ }
+ } catch {
+ return nil
+ }
+ return nil
+ }
}
+/*
let matchADSBShort = Regex {
Anchor.startOfLine
"*"
@@ -32,4 +59,29 @@ let matchADSBShort = Regex {
)
,count:14)
";"
+}*/
+
+class MatchADSBShort {
+ let matchADSBShort = Regex {
+ Anchor.startOfLine
+ "*"
+ Repeat(
+ CharacterClass(
+ ("a"..."f"),
+ ("0"..."9")
+ )
+ ,count:14)
+ ";"
+ }
+
+ func prefixMatch(_ line: String) -> Regex<Regex<Substring>.RegexOutput>.Match? {
+ do {
+ if let match = try matchADSBShort.prefixMatch(in: line) {
+ return match
+ }
+ } catch {
+ return nil
+ }
+ return nil
+ }
}
diff --git a/ADSBDecoder/Configs.swift b/ADSBDecoder/Configs.swift
index d0357c9..a42e745 100644
--- a/ADSBDecoder/Configs.swift
+++ b/ADSBDecoder/Configs.swift
@@ -7,4 +7,4 @@
import Foundation
-var decoder_debug_mode = false
+let decoder_debug_mode = false
diff --git a/ADSBDecoder/main.swift b/ADSBDecoder/main.swift
index f75cdfb..91ba97b 100644
--- a/ADSBDecoder/main.swift
+++ b/ADSBDecoder/main.swift
@@ -55,8 +55,10 @@ for line in adsb_source.components(separatedBy: .newlines) {
var found=false
//print("\(cnt) \(line)")
count_messages += 1
- if let tokenMatch = try matchADSBLong.prefixMatch(in: line) {
- //print("\(String(tokenMatch.output))")
+ let matchADSBLong = MatchADSBLong()
+ //if let tokenMatch = try matchADSBLong.prefixMatch(in: line) {
+ if let tokenMatch = matchADSBLong.prefixMatch(line) {
+ print("ADSB Long match \(String(tokenMatch.output))")
found = true
let str = String(tokenMatch.output)
let startIndex = str.index(str.startIndex, offsetBy: 1)
@@ -93,12 +95,20 @@ for line in adsb_source.components(separatedBy: .newlines) {
q_df.addDF(decoder.DataFormat)
};
+ /*
if let tokenMatch = try matchADSBShort.prefixMatch(in: line) {
print("\(tokenMatch.output)")
found = true
q_decoded.addUndecoded()
- };
+ };*/
+ let matchADSBShort = MatchADSBShort()
+ if let tokenMatch = matchADSBShort.prefixMatch(line) {
+ print("ADSBShort Match\(tokenMatch.output)")
+ found = true
+
+ q_decoded.addUndecoded()
+ }
if (found == false) {
print("Unknown adsb data line \(line)")
diff --git a/ADSBStats/main.swift b/ADSBStats/main.swift
index d431e1f..d340e16 100644
--- a/ADSBStats/main.swift
+++ b/ADSBStats/main.swift
@@ -11,7 +11,7 @@ import RegexBuilder
import SQLite3
import SwiftData
-decoder_debug_mode = false
+//decoder_debug_mode = false
struct CommandLineArgs: ParsableCommand {
@Option(name: .shortAndLong) var inputfile: String
@@ -56,7 +56,8 @@ var count_messages=0
for line in adsb_source.components(separatedBy: .newlines) {
var found=false
count_messages += 1
- if let tokenMatch = try matchADSBLong.prefixMatch(in: line) {
+ let matchADSBLong = MatchADSBLong()
+ if let tokenMatch = matchADSBLong.prefixMatch(line) {
found = true
let str = String(tokenMatch.output)
let startIndex = str.index(str.startIndex, offsetBy: 1)
@@ -92,7 +93,8 @@ for line in adsb_source.components(separatedBy: .newlines) {
q_df.addDF(decoder.DataFormat)
};
- if let tokenMatch = try matchADSBShort.prefixMatch(in: line) {
+ let matchADSBShort = MatchADSBShort()
+ if let tokenMatch = matchADSBShort.prefixMatch(line) {
//print("\(tokenMatch.output)")
found = true
diff --git a/LearnMapKit/ADSBDataQueue.swift b/LearnMapKit/ADSBDataQueue.swift
index ada0ab5..d3777ec 100644
--- a/LearnMapKit/ADSBDataQueue.swift
+++ b/LearnMapKit/ADSBDataQueue.swift
@@ -8,23 +8,26 @@
import Foundation
import Collections
+///Tag for location
struct ADSBLocation {
let address: Int
let lat: Double
let long: Double
//let alt: Int
}
-
+/// Tag for Altitude
struct ADSBAltitude {
let address: Int
let altitude: Int
}
+/// Tag for ICAO name
struct ADSBICAOname {
let address: Int
let ICAOname: String
}
-
+/// Tag enum for data stream
+///
enum DataStreamType {
case EMPTY
case ADSB_ICAO
@@ -32,7 +35,7 @@ enum DataStreamType {
case ADSB_ALTITUDE
}
-//get stream of decoded data, to tagged stream so all can be processed in sequence
+/// get stream of decoded data, to tagged stream so all can be processed in sequence
class ADSBDataQueue {
//var icaoQueue: Deque<ADSBICAOname> = []
var icaoArray: Array<ADSBICAOname> = []
@@ -41,6 +44,8 @@ class ADSBDataQueue {
//var tagQueue: Deque<> = []
var tagArray: Array<DataStreamType> = []
+ ///get the last tag from a queue
+ ///user handles what todo with this data
func getNextTag() -> DataStreamType {
if tagArray.count < 0 {
return DataStreamType.EMPTY
@@ -48,6 +53,7 @@ class ADSBDataQueue {
return tagArray[tagArray.count-1]
}
+
func addIcaoName(_ address: Int, _ icaoname: String) {
tagArray.append(DataStreamType.ADSB_ICAO)
icaoArray.append(ADSBICAOname(address: address, ICAOname: icaoname))
@@ -63,6 +69,8 @@ class ADSBDataQueue {
locQueue.append(ADSBLocation(address: address, lat: lat, long: long))
}
+ ///let read next tag in a queue, that is ICAO name
+ ///user handles order in a queue for now
func getIcaoName() -> ADSBICAOname {
if tagArray.count < 1 {
print("ADSB tag Queue is empty")
@@ -81,6 +89,8 @@ class ADSBDataQueue {
return ret_icao_name
}
+ ///let read next tag in a queue, that is Altitude
+ ///user handles order in a queue for now
func getAltitude() -> ADSBAltitude {
if tagArray.count < 1 {
print("ADSB tag Queue is empty")
@@ -95,6 +105,8 @@ class ADSBDataQueue {
return altQueue.popLast()!
}
+ ///let read next tag in a queue, that is the location
+ ///user handles order in a queue for now
func getLocation() -> ADSBLocation {
if tagArray.count < 1 {
print("ADSB tag Queue is empry")
@@ -109,6 +121,7 @@ class ADSBDataQueue {
return locQueue.popLast()!
}
+ //check if there is more then specified number in queue
func haveNum(_ num: Int) -> Bool {
if (tagArray.count > num) {
return true
@@ -116,6 +129,7 @@ class ADSBDataQueue {
return false
}
+ ///get number in the queue
func getCount() -> Int {
return tagArray.count
}
diff --git a/LearnMapKit/ADSBFileRunner.swift b/LearnMapKit/ADSBFileRunner.swift
index d61b91b..796892c 100644
--- a/LearnMapKit/ADSBFileRunner.swift
+++ b/LearnMapKit/ADSBFileRunner.swift
@@ -59,7 +59,8 @@ class ADSBFileRunner {
for line in self.adsb_source.components(separatedBy: .newlines) {
var found=false
do {
- if let tokenMatch = try matchADSBLong.prefixMatch(in: line) {
+ let matchADSBLong = MatchADSBLong()
+ if let tokenMatch = matchADSBLong.prefixMatch(line) {
//print("\(String(tokenMatch.output))")
found = true
let str = String(tokenMatch.output)
diff --git a/LearnMapKit/ADSBNetRunner.swift b/LearnMapKit/ADSBNetRunner.swift
index 3307c84..21b8fd8 100644
--- a/LearnMapKit/ADSBNetRunner.swift
+++ b/LearnMapKit/ADSBNetRunner.swift
@@ -40,7 +40,8 @@ class ADSBNetRunner {
if let msg = adsb_net_decoder.msgarray.message_array.popLast() {
//print("msg:[\(msg)]")
do {
- if let tokenMatch = try matchADSBLong.prefixMatch(in: msg) {
+ let matchADSBLong = MatchADSBLong()
+ if let tokenMatch = matchADSBLong.prefixMatch(msg) {
//print("token output \(String(tokenMatch.output))")
found = true
let str = String(tokenMatch.output)
diff --git a/LearnMapKit/ContentView.swift b/LearnMapKit/ContentView.swift
index cbe178f..4042831 100644
--- a/LearnMapKit/ContentView.swift
+++ b/LearnMapKit/ContentView.swift
@@ -8,31 +8,6 @@
import SwiftUI
import MapKit
import Collections
-/*
-struct FlightView: View {
-
- var evilClass: FlightState
-
- var body: some View {
- //let i = evilClass.flight.count
- let pos = CLLocationCoordinate2D(latitude: 55.80159, longitude:-3.13154)
- Map() {
- ForEach(0..<10, id:\.self) {i in
- Annotation("plane\(i)", coordinate: pos) {
- ZStack {
- RoundedRectangle(cornerRadius: 10)
- .fill(.background)
- RoundedRectangle(cornerRadius: 10)
- .stroke(.secondary,lineWidth: 5)
- Image(systemName:"airplane.circle.fill")
- .resizable()
- .frame(width:20,height: 20)
- }
- }//.annotationTitles(.hidden)
- }
- }
- }
-}*/
struct ContentView: View {
@@ -50,11 +25,6 @@ struct ContentView: View {
return .region(region)
}()
- //let position1 = CLLocationCoordinate2D(latitude: 55.80159, longitude:-3.53154)
- //let position2 = CLLocationCoordinate2D(latitude: 55.99159, longitude:-3.53154)
- //let position3 = CLLocationCoordinate2D(latitude: 55.80159, longitude:-3.43154)
- //let position4 = CLLocationCoordinate2D(latitude: 55.80159, longitude:-3.63154)
-
var body: some View {
VStack {
@@ -65,18 +35,8 @@ struct ContentView: View {
latitude: flight.lat,
longitude:flight.long)
) {
+
VStack {
- /*
- ZStack {
- RoundedRectangle(cornerRadius: 10)
- .fill(.background)
- RoundedRectangle(cornerRadius: 10)
- .stroke(.secondary,lineWidth: 5)
- //Image(systemName:"airplane.circle.fill")
- // .resizable()
- // .frame(width:20,height: 20)
- Text("\(flight.ICAOName)").font(.body)
- }*/
ZStack {
RoundedRectangle(cornerRadius: 10)
.fill(.background)
@@ -84,7 +44,7 @@ struct ContentView: View {
.stroke(.secondary,lineWidth: 5)
Image(systemName:"airplane.circle.fill")
.resizable()
- .frame(width:20,height: 20)
+ .frame(width:20,height: 20)
}
Text("\(flight.ICAOName)").font(.body)
}
diff --git a/LearnMapKit/FlighState.swift b/LearnMapKit/FlighState.swift
index a86a660..9e901c6 100644
--- a/LearnMapKit/FlighState.swift
+++ b/LearnMapKit/FlighState.swift
@@ -55,8 +55,8 @@ class FlightState: ObservableObject {
var process_per_second = 120
var sourceDump1090Server = true
- var dump1090address = "192.168.4.233"
- var dump1090port = 30002
+ var dump1090address = "64.226.23.78"
+ var dump1090port = 30003
init() {
print("Init")
diff --git a/LearnMapKit/LearnMapKitApp.swift b/LearnMapKit/LearnMapKitApp.swift
index b10764d..780a172 100644
--- a/LearnMapKit/LearnMapKitApp.swift
+++ b/LearnMapKit/LearnMapKitApp.swift
@@ -36,8 +36,8 @@ struct LearnMapKitApp: App {
//@StateObject var flightState:FlightState = FlightState()
- var default_hostname = "192.168.4.233"
- var default_port = 30002
+ var default_hostname = "64.226.23.78"
+ var default_port = 30003
var default_input_file = ""
diff --git a/LearnMapKit/NetworkConfigure.swift b/LearnMapKit/NetworkConfigure.swift
index c1c8629..270da38 100644
--- a/LearnMapKit/NetworkConfigure.swift
+++ b/LearnMapKit/NetworkConfigure.swift
@@ -9,8 +9,8 @@ import Foundation
import SwiftUI
class NetworkConfigure {
- var servername: String = "192.168.4.201"
- var serverport: Int = 30002
+ var servername: String = "64.226.23.78"
+ var serverport: Int = 30003
var default_values: Bool = true
diff --git a/Net1090/main.swift b/Net1090/main.swift
index b0deb2f..2620dca 100644
--- a/Net1090/main.swift
+++ b/Net1090/main.swift
@@ -11,7 +11,7 @@ import NIO
var timer: Timer?
-let ADSBClient = NetADSBDecoder(host: "192.168.4.233", port: 30002)
+let ADSBClient = NetADSBDecoder(host: "64.226.23.78", port: 30003)
print("Hello, World!")
print("Start listening client 2")