From ba42ff1207a07cbcc5c2b5254c1471ba76ba647d Mon Sep 17 00:00:00 2001 From: Madeline Date: Mon, 20 Mar 2023 20:03:18 -0400 Subject: [PATCH] Reorganize project, remove some dead code --- Soyuz.xcodeproj/project.pbxproj | 28 ++++++++---- Soyuz/PrinterStats.swift | 44 ------------------- .../PrinterObjectsQuery.swift | 13 ------ .../PrinterRequestManager.swift | 7 --- Soyuz/{ => Views}/PrinterConfigView.swift | 0 Soyuz/{ => Views}/SoyuzMenuBarExtraView.swift | 0 6 files changed, 20 insertions(+), 72 deletions(-) delete mode 100644 Soyuz/PrinterStats.swift rename Soyuz/{ => ViewModels}/PrinterObjectsQuery.swift (77%) rename Soyuz/{ => ViewModels}/PrinterRequestManager.swift (98%) rename Soyuz/{ => Views}/PrinterConfigView.swift (100%) rename Soyuz/{ => Views}/SoyuzMenuBarExtraView.swift (100%) diff --git a/Soyuz.xcodeproj/project.pbxproj b/Soyuz.xcodeproj/project.pbxproj index a94af93..26ccf92 100644 --- a/Soyuz.xcodeproj/project.pbxproj +++ b/Soyuz.xcodeproj/project.pbxproj @@ -22,7 +22,6 @@ E180B61F2992DBB000425DB0 /* SoyuzMenuBarExtraView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E180B61E2992DBB000425DB0 /* SoyuzMenuBarExtraView.swift */; }; E180B6222993256E00425DB0 /* PrinterRequestManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = E180B6212993256E00425DB0 /* PrinterRequestManager.swift */; }; E1E8B07729949E2700BABE4B /* Starscream in Frameworks */ = {isa = PBXBuildFile; productRef = E1E8B07629949E2700BABE4B /* Starscream */; }; - E1E8B07929955ABE00BABE4B /* PrinterStats.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1E8B07829955ABE00BABE4B /* PrinterStats.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -62,7 +61,6 @@ E180B61C2992D53700425DB0 /* PrinterObjectsQuery.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrinterObjectsQuery.swift; sourceTree = ""; }; E180B61E2992DBB000425DB0 /* SoyuzMenuBarExtraView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SoyuzMenuBarExtraView.swift; sourceTree = ""; }; E180B6212993256E00425DB0 /* PrinterRequestManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrinterRequestManager.swift; sourceTree = ""; }; - E1E8B07829955ABE00BABE4B /* PrinterStats.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrinterStats.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -114,6 +112,8 @@ E180B5E72992CD9100425DB0 /* Soyuz */ = { isa = PBXGroup; children = ( + E1A93C6529C92B3500BAE750 /* ViewModels */, + E1A93C6429C92AEE00BAE750 /* Views */, E124B9D72993FE5500C0D2D2 /* Info.plist */, E180B5E82992CD9100425DB0 /* SoyuzApp.swift */, E180B5EC2992CD9200425DB0 /* Assets.xcassets */, @@ -121,11 +121,6 @@ E180B5F62992CD9200425DB0 /* Soyuz.entitlements */, E180B5F32992CD9200425DB0 /* KlipperMon.xcdatamodeld */, E180B5EE2992CD9200425DB0 /* Preview Content */, - E180B61C2992D53700425DB0 /* PrinterObjectsQuery.swift */, - E180B61E2992DBB000425DB0 /* SoyuzMenuBarExtraView.swift */, - E180B6212993256E00425DB0 /* PrinterRequestManager.swift */, - E124B9D829941A4D00C0D2D2 /* PrinterConfigView.swift */, - E1E8B07829955ABE00BABE4B /* PrinterStats.swift */, ); path = Soyuz; sourceTree = ""; @@ -157,6 +152,24 @@ path = SoyuzUITests; sourceTree = ""; }; + E1A93C6429C92AEE00BAE750 /* Views */ = { + isa = PBXGroup; + children = ( + E180B61E2992DBB000425DB0 /* SoyuzMenuBarExtraView.swift */, + E124B9D829941A4D00C0D2D2 /* PrinterConfigView.swift */, + ); + path = Views; + sourceTree = ""; + }; + E1A93C6529C92B3500BAE750 /* ViewModels */ = { + isa = PBXGroup; + children = ( + E180B61C2992D53700425DB0 /* PrinterObjectsQuery.swift */, + E180B6212993256E00425DB0 /* PrinterRequestManager.swift */, + ); + path = ViewModels; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -293,7 +306,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - E1E8B07929955ABE00BABE4B /* PrinterStats.swift in Sources */, E180B61D2992D53700425DB0 /* PrinterObjectsQuery.swift in Sources */, E180B5F52992CD9200425DB0 /* KlipperMon.xcdatamodeld in Sources */, E124B9D929941A4D00C0D2D2 /* PrinterConfigView.swift in Sources */, diff --git a/Soyuz/PrinterStats.swift b/Soyuz/PrinterStats.swift deleted file mode 100644 index 3318e3a..0000000 --- a/Soyuz/PrinterStats.swift +++ /dev/null @@ -1,44 +0,0 @@ -// -// PrinterStats.swift -// KlipperMon -// -// Created by maddiefuzz on 2/9/23. -// - -import Foundation - -class PrinterStats: ObservableObject { - @Published var state: String - @Published var progress: Double - @Published var extruderTemperature: Double - @Published var bedTemperature: Double - - init(response: jsonRpcResponse) { - state = response.result.status.print_stats?.state ?? "" - progress = response.result.status.virtual_sdcard?.progress ?? 0.0 - extruderTemperature = response.result.status.extruder?.temperature ?? 0.0 - bedTemperature = response.result.status.heater_bed?.temperature ?? 0.0 - - print(response) - } - - func update(update: jsonRpcUpdate) { -// print(update) - if let newState = update.params.status?.print_stats?.state { - //state = update.params[0].print_stats?.state - state = newState - } - if let newProgress = update.params.status?.virtual_sdcard?.progress { - print("Update progress") - progress = newProgress - } - if let newExtruderTemp = update.params.status?.extruder?.temperature { - print("Update extruder temp \(newExtruderTemp)") - extruderTemperature = newExtruderTemp - } - if let newBedTemp = update.params.status?.heater_bed?.temperature { - print("Update heated bed \(newBedTemp)") - bedTemperature = newBedTemp - } - } -} diff --git a/Soyuz/PrinterObjectsQuery.swift b/Soyuz/ViewModels/PrinterObjectsQuery.swift similarity index 77% rename from Soyuz/PrinterObjectsQuery.swift rename to Soyuz/ViewModels/PrinterObjectsQuery.swift index 2298476..c3f3fa8 100644 --- a/Soyuz/PrinterObjectsQuery.swift +++ b/Soyuz/ViewModels/PrinterObjectsQuery.swift @@ -33,19 +33,6 @@ struct jsonRpcParams: Decodable { self.timestamp = try container.decode(Double.self) } } -// -// public init(from decoder: Decoder) throws { -// let container = try decoder.container(keyedBy: CodingKeys.self) -// -// do { -// self = .statusData(try container.decode(StatusData.self, forKey: .statusData)) -// } catch DecodingError.keyNotFound { -// print("Error") -// self = .double(try container.decode(Double.self)) -// //self = .timestamp(try container.decode(Double.self, forKey: .timestamp)) -// } -// -// } // Root structs to decode for JSON-RPC response struct jsonRpcResponse: Decodable { diff --git a/Soyuz/PrinterRequestManager.swift b/Soyuz/ViewModels/PrinterRequestManager.swift similarity index 98% rename from Soyuz/PrinterRequestManager.swift rename to Soyuz/ViewModels/PrinterRequestManager.swift index fb01a0a..22547f4 100644 --- a/Soyuz/PrinterRequestManager.swift +++ b/Soyuz/ViewModels/PrinterRequestManager.swift @@ -18,14 +18,7 @@ protocol NetworkDiscoveryEngine { func setStateUpdateHandler(_ handler: @escaping ((NWBrowser.State) -> Void)) } -//protocol NDEResult { -// var endpoint: NWEndpoint { get } -// var interface: [NWInterface] { get } -// var metadata: NWBrowser.Result.Metadata { get } -//} - extension NWBrowser: NetworkDiscoveryEngine { -//class NDEngine: NetworkDiscoveryEngine, func startScan(queue: DispatchQueue) { start(queue: queue) } diff --git a/Soyuz/PrinterConfigView.swift b/Soyuz/Views/PrinterConfigView.swift similarity index 100% rename from Soyuz/PrinterConfigView.swift rename to Soyuz/Views/PrinterConfigView.swift diff --git a/Soyuz/SoyuzMenuBarExtraView.swift b/Soyuz/Views/SoyuzMenuBarExtraView.swift similarity index 100% rename from Soyuz/SoyuzMenuBarExtraView.swift rename to Soyuz/Views/SoyuzMenuBarExtraView.swift