summaryrefslogtreecommitdiff
path: root/ADSBDecoder
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 /ADSBDecoder
parent9070c9e6b7c7ce5671f4fad85e4aefa8c27aad28 (diff)
downloadADSBDecoder-2b599499dc26f0f93537d1bea4733eae68333a1c.tar.gz
ADSBDecoder-2b599499dc26f0f93537d1bea4733eae68333a1c.zip
Save old work that I have no clue what I where doing
Diffstat (limited to 'ADSBDecoder')
-rw-r--r--ADSBDecoder/ADSBRegEx.swift54
-rw-r--r--ADSBDecoder/Configs.swift2
-rw-r--r--ADSBDecoder/main.swift16
3 files changed, 67 insertions, 5 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)")