From 2b599499dc26f0f93537d1bea4733eae68333a1c Mon Sep 17 00:00:00 2001 From: Arturs Artamonovs Date: Mon, 17 Nov 2025 00:32:31 +0000 Subject: Save old work that I have no clue what I where doing --- LearnMapKit/ADSBDataQueue.swift | 20 ++++++++++++++--- LearnMapKit/ADSBFileRunner.swift | 3 ++- LearnMapKit/ADSBNetRunner.swift | 3 ++- LearnMapKit/ContentView.swift | 44 ++------------------------------------ LearnMapKit/FlighState.swift | 4 ++-- LearnMapKit/LearnMapKitApp.swift | 4 ++-- LearnMapKit/NetworkConfigure.swift | 4 ++-- 7 files changed, 29 insertions(+), 53 deletions(-) (limited to 'LearnMapKit') 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 = [] var icaoArray: Array = [] @@ -41,6 +44,8 @@ class ADSBDataQueue { //var tagQueue: Deque<> = [] var tagArray: Array = [] + ///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 -- cgit v1.2.3