summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ADSBDecoder.xcodeproj/project.pbxproj4
-rw-r--r--ADSBStats/main.swift14
-rw-r--r--LearnMapKit/ContentView.swift86
-rw-r--r--LearnMapKit/LearnMapKitApp.swift9
-rw-r--r--LearnMapKit/NetConfigView.swift45
-rw-r--r--Net1090/main.swift9
6 files changed, 88 insertions, 79 deletions
diff --git a/ADSBDecoder.xcodeproj/project.pbxproj b/ADSBDecoder.xcodeproj/project.pbxproj
index 010ce91..f8a27db 100644
--- a/ADSBDecoder.xcodeproj/project.pbxproj
+++ b/ADSBDecoder.xcodeproj/project.pbxproj
@@ -30,6 +30,7 @@
8D93B6942C4598E300C91865 /* AirplaneTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DB347C42C242BAC00F3C020 /* AirplaneTracker.swift */; };
8D93B6962C45992F00C91865 /* ArgumentParser in Frameworks */ = {isa = PBXBuildFile; productRef = 8D93B6952C45992F00C91865 /* ArgumentParser */; };
8D93B6982C45993600C91865 /* Collections in Frameworks */ = {isa = PBXBuildFile; productRef = 8D93B6972C45993600C91865 /* Collections */; };
+ 8D93B69A2C4A665B00C91865 /* NetConfigView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D93B6992C4A665B00C91865 /* NetConfigView.swift */; };
8DB347BF2C1C501200F3C020 /* PositionDecoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DB347BE2C1C501200F3C020 /* PositionDecoder.swift */; };
8DB347C32C1C53ED00F3C020 /* Collections in Frameworks */ = {isa = PBXBuildFile; productRef = 8DB347C22C1C53ED00F3C020 /* Collections */; };
8DB347C52C242BAC00F3C020 /* AirplaneTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DB347C42C242BAC00F3C020 /* AirplaneTracker.swift */; };
@@ -115,6 +116,7 @@
8D93B6782C3FE6F400C91865 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
8D93B6872C45986700C91865 /* ADSBStats */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ADSBStats; sourceTree = BUILT_PRODUCTS_DIR; };
8D93B6892C45986700C91865 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
+ 8D93B6992C4A665B00C91865 /* NetConfigView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetConfigView.swift; sourceTree = "<group>"; };
8DB347BE2C1C501200F3C020 /* PositionDecoder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PositionDecoder.swift; sourceTree = "<group>"; };
8DB347C42C242BAC00F3C020 /* AirplaneTracker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AirplaneTracker.swift; sourceTree = "<group>"; };
8DEC6F2D2C2E9C3000AC6209 /* ADSBRunner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ADSBRunner.swift; sourceTree = "<group>"; };
@@ -286,6 +288,7 @@
children = (
8DEC6F2D2C2E9C3000AC6209 /* ADSBRunner.swift */,
8DF756862C10556A008E8DFF /* ContentView.swift */,
+ 8D93B6992C4A665B00C91865 /* NetConfigView.swift */,
8DF756842C10556A008E8DFF /* LearnMapKitApp.swift */,
8DEC6F312C31530C00AC6209 /* FlighState.swift */,
8DF756882C10556C008E8DFF /* Assets.xcassets */,
@@ -612,6 +615,7 @@
8DEC6F322C31530C00AC6209 /* FlighState.swift in Sources */,
8DF756852C10556A008E8DFF /* LearnMapKitApp.swift in Sources */,
8D93B6542C32095800C91865 /* ADSBRegEx.swift in Sources */,
+ 8D93B69A2C4A665B00C91865 /* NetConfigView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/ADSBStats/main.swift b/ADSBStats/main.swift
index 20ea285..d431e1f 100644
--- a/ADSBStats/main.swift
+++ b/ADSBStats/main.swift
@@ -8,7 +8,8 @@
import Foundation
import ArgumentParser
import RegexBuilder
-//import SQLite3
+import SQLite3
+import SwiftData
decoder_debug_mode = false
@@ -16,7 +17,8 @@ struct CommandLineArgs: ParsableCommand {
@Option(name: .shortAndLong) var inputfile: String
@Flag(name: .shortAndLong) var debug:Bool = false
@Flag(name: .shortAndLong) var version:Bool = false
- @Flag(name: .shortAndLong) var show_stats:Bool = false
+ @Flag(name: .shortAndLong) var showstats:Bool = false
+ @Flag(name: .shortAndLong) var dbadd:Bool = false
}
let args = CommandLineArgs.parseOrExit()
@@ -105,7 +107,7 @@ for line in adsb_source.components(separatedBy: .newlines) {
}
-if args.show_stats {
+if args.showstats {
print("----STAT----")
//q_df.showStat()
print(q_df)
@@ -116,3 +118,9 @@ if args.show_stats {
print("Total message:\(count_messages)")
}
+
+//Add new plane names to database
+if args.dbadd {
+ print("Adding to database")
+
+}
diff --git a/LearnMapKit/ContentView.swift b/LearnMapKit/ContentView.swift
index 13ef64f..9f7fd29 100644
--- a/LearnMapKit/ContentView.swift
+++ b/LearnMapKit/ContentView.swift
@@ -9,6 +9,8 @@ import SwiftUI
import MapKit
import Collections
+
+
struct FlightView: View {
var evilClass: FlightState
@@ -41,6 +43,7 @@ struct ContentView: View {
@Binding var pos_queue: Deque<ADSBLocation>
@EnvironmentObject var evilClass: FlightState
+ @Environment(\.openWindow) private var openWindow
let initialPosition: MapCameraPosition = {
@@ -87,73 +90,6 @@ struct ContentView: View {
//.padding()
Map(initialPosition: initialPosition) {
- /*Annotation("plane1", coordinate: position1) {
- 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)
- Annotation("plane2", coordinate: position2) {
- 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)
- Annotation("plane3", coordinate: position3) {
- 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)
- Annotation("plane4", coordinate: position4) {
- 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)*//*
- ForEach(0..<evilClass.flight.count, id:\.self) { _ in
- Annotation("plane\(0)", coordinate: CLLocationCoordinate2D(latitude: evilClass.flight[0]?.lat!, longitude: evilClass.flight[0]?.long!)) {
- 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)
- }*/
- //let c = self.evilClass.flight.count
- /*ForEach(0..<self.evilClass.flight.count, id:\.self) { exp in
- //print("Draw annotation")
- //Annotation("plane\(exp+4)", coordinate: CLLocationCoordinate2D(latitude: 55.80159, longitude:-3.53154+Double(exp)*0.1)) {
- Annotation("plane\(exp+4)", coordinate: CLLocationCoordinate2D(latitude: self.evilClass.flight[exp]!.lat, longitude:self.evilClass.flight[exp]!.long)) {
- Image(systemName:"airplane.circle.fill")
- .resizable()
- .frame(width:20,height: 20)
- }
- }*/
ForEach(self.evilClass.flight.sorted(by: { $0.key < $1.key} ), id:\.key) { k in
Annotation("\(k.key)", coordinate: CLLocationCoordinate2D(latitude: self.evilClass.flight[k.key]!.lat, longitude:self.evilClass.flight[k.key]!.long)) {
VStack {
@@ -183,6 +119,13 @@ struct ContentView: View {
Label("Import file", systemImage: "square.and.arrow.down")
}
}
+ ToolbarItem {
+ Button {
+ openWindow(id: "net-config")
+ } label: {
+ Label("Network config", systemImage: "network")
+ }
+ }
} .fileImporter(isPresented: $isImporting, allowedContentTypes: [.text], allowsMultipleSelection: false) {
result in switch result {
case .success(let files):
@@ -191,7 +134,7 @@ struct ContentView: View {
print(error)
}
}
- drawFlights()
+
}
.padding()
@@ -203,13 +146,6 @@ struct ContentView: View {
print("This is called")
}
- @ViewBuilder
- func drawFlights() -> some View {
- let c = self.evilClass.flight.count
- ForEach(0..<c, id:\.self) { exp in
- //Annotation("plane4", coordinate: position4)
- }
- }
}
//#Preview {
diff --git a/LearnMapKit/LearnMapKitApp.swift b/LearnMapKit/LearnMapKitApp.swift
index 1b64510..6c46f3b 100644
--- a/LearnMapKit/LearnMapKitApp.swift
+++ b/LearnMapKit/LearnMapKitApp.swift
@@ -7,12 +7,17 @@
import SwiftUI
import Collections
+import ArgumentParser
//https://www.hackingwithswift.com/quick-start/swiftui/how-to-run-code-when-your-app-launches
+
+
@main
struct LearnMapKitApp: App {
+
+
@State var queue: Deque<ADSBLocation> = []
@StateObject private var flightState = FlightState()
@@ -27,6 +32,10 @@ struct LearnMapKitApp: App {
WindowGroup {
ContentView(pos_queue: $queue)
}.environmentObject(flightState)
+
+ WindowGroup("Network", id: "net-config") {
+ NetConfigView()
+ }
}
}
diff --git a/LearnMapKit/NetConfigView.swift b/LearnMapKit/NetConfigView.swift
new file mode 100644
index 0000000..06fc5c2
--- /dev/null
+++ b/LearnMapKit/NetConfigView.swift
@@ -0,0 +1,45 @@
+//
+// NetConfigView.swift
+// LearnMapKit
+//
+// Created by Jacky Jack on 19/07/2024.
+//
+
+import SwiftUI
+
+struct NetConfigView: View {
+ @State private var server_name: String = ""
+ @State private var server_port: String = ""
+ @Environment(\.dismissWindow) private var dismissWindow
+
+ var body: some View {
+ VStack {
+ HStack {
+ Text("Server")
+ TextField("Server", text: $server_name)
+ }
+ HStack {
+ Text("Port")
+ TextField("Port", text: $server_port)
+ }
+ HStack {
+ Button(action:{
+ print("Cancel")
+ dismissWindow(id:"net-config")
+ }) {
+ Text("Cancel")
+ }
+ Button(action: {
+ print("Save config")
+ dismissWindow(id:"net-config")
+ }) {
+ Text("Save")
+ }
+ }
+ }
+ }
+}
+
+#Preview {
+ NetConfigView()
+}
diff --git a/Net1090/main.swift b/Net1090/main.swift
index 93ff716..04d0384 100644
--- a/Net1090/main.swift
+++ b/Net1090/main.swift
@@ -9,6 +9,7 @@ import Foundation
import Network
import NIO
+
class ADSBHandlder: ChannelInboundHandler {
typealias InboundIn = ByteBuffer
typealias OutboundOut = ByteBuffer
@@ -58,7 +59,13 @@ class TCPClient {
}
func stop() {
-
+ do {
+ try group.syncShutdownGracefully()
+ } catch let error {
+ print("Error shutting down \(error.localizedDescription)")
+ exit(0)
+ }
+ print("Connection closed")
}
}