Преглед на файлове

Change to take account of the modification of the API / functions protocol with the dev version of Loop framework in march 2024:
- update the cgmManager() function for all CGM sensors
- update the pumpManager protocol for all pumps
- update the managerIdentifier -> pluginIdentifier
- correction when use the simulator pump to allow to delete it after choosing it

Pierre L преди 2 години
родител
ревизия
767e516e16

+ 0 - 4
FreeAPS.xcodeproj/project.pbxproj

@@ -344,8 +344,6 @@
 		CE94598429E9E3E60047C9C6 /* WatchConfigStateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE94598329E9E3E60047C9C6 /* WatchConfigStateModel.swift */; };
 		CE94598729E9E4110047C9C6 /* WatchConfigRootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE94598629E9E4110047C9C6 /* WatchConfigRootView.swift */; };
 		CEA4F62329BE10F70011ADF7 /* SavitzkyGolayFilter.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA4F62229BE10F70011ADF7 /* SavitzkyGolayFilter.swift */; };
-		CEB434DC28B8F5B900B70274 /* MKRingProgressView.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEB434DB28B8F5B900B70274 /* MKRingProgressView.framework */; };
-		CEB434DD28B8F5B900B70274 /* MKRingProgressView.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = CEB434DB28B8F5B900B70274 /* MKRingProgressView.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
 		CEB434DF28B8F5C400B70274 /* OmniBLE.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEB434DE28B8F5C400B70274 /* OmniBLE.framework */; };
 		CEB434E028B8F5C400B70274 /* OmniBLE.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = CEB434DE28B8F5C400B70274 /* OmniBLE.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
 		CEB434E328B8F9DB00B70274 /* BluetoothStateManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEB434E228B8F9DB00B70274 /* BluetoothStateManager.swift */; };
@@ -447,7 +445,6 @@
 				3818AA6F274C26A500843DB3 /* RileyLinkKitUI.framework in Embed Frameworks */,
 				3818AA4B274C267100843DB3 /* CGMBLEKit.framework in Embed Frameworks */,
 				CEB434E028B8F5C400B70274 /* OmniBLE.framework in Embed Frameworks */,
-				CEB434DD28B8F5B900B70274 /* MKRingProgressView.framework in Embed Frameworks */,
 				CEB434FE28B90B8C00B70274 /* SwiftCharts in Embed Frameworks */,
 				3818AA6B274C26A500843DB3 /* RileyLinkBLEKit.framework in Embed Frameworks */,
 				3818AA59274C26A300843DB3 /* LoopKit.framework in Embed Frameworks */,
@@ -919,7 +916,6 @@
 				CE79502E29980E4D00FA576E /* ShareClientUI.framework in Frameworks */,
 				CE79502A29980C9F00FA576E /* G7SensorKitUI.framework in Frameworks */,
 				CE79502829980C9600FA576E /* CGMBLEKitUI.framework in Frameworks */,
-				CEB434DC28B8F5B900B70274 /* MKRingProgressView.framework in Frameworks */,
 				38E87403274F78C000975559 /* libswiftCoreNFC.tbd in Frameworks */,
 				38E87401274F77E400975559 /* CoreNFC.framework in Frameworks */,
 				CEB434DF28B8F5C400B70274 /* OmniBLE.framework in Frameworks */,

+ 3 - 3
FreeAPS.xcworkspace/contents.xcworkspacedata

@@ -5,6 +5,9 @@
       location = "group:FreeAPS.xcodeproj">
    </FileRef>
    <FileRef
+      location = "group:Dependencies/RileyLinkKit/RileyLinkKit.xcodeproj">
+   </FileRef>
+   <FileRef
       location = "group:Dependencies/G7SensorKit/G7SensorKit.xcodeproj">
    </FileRef>
    <FileRef
@@ -17,9 +20,6 @@
       location = "group:Dependencies/LoopKit/LoopKit.xcodeproj">
    </FileRef>
    <FileRef
-      location = "group:Dependencies/RileyLinkKit/RileyLinkKit.xcodeproj">
-   </FileRef>
-   <FileRef
       location = "group:Dependencies/OmniBLE/OmniBLE.xcodeproj">
    </FileRef>
    <FileRef

+ 8 - 1
FreeAPS/Sources/APS/CGM/DexcomSourceG5.swift

@@ -97,7 +97,7 @@ extension DexcomSourceG5: CGMManagerDelegate {
 
     func cgmManagerWantsDeletion(_ manager: CGMManager) {
         dispatchPrecondition(condition: .onQueue(.main))
-        debug(.deviceManager, " CGM Manager with identifier \(manager.managerIdentifier) wants deletion")
+        debug(.deviceManager, " CGM Manager with identifier \(manager.pluginIdentifier) wants deletion")
         glucoseManager?.cgmGlucoseSourceType = nil
     }
 
@@ -108,6 +108,13 @@ extension DexcomSourceG5: CGMManagerDelegate {
         }
     }
 
+    func cgmManager(_: LoopKit.CGMManager, hasNew events: [LoopKit.PersistedCgmEvent]) {
+        dispatchPrecondition(condition: .onQueue(processQueue))
+        // TODO: Events in APS ?
+        // currently only display in log the date of the event
+        events.forEach { debug(.deviceManager, "events from CGM at \($0.date)") }
+    }
+
     func startDateToFilterNewData(for _: CGMManager) -> Date? {
         dispatchPrecondition(condition: .onQueue(.main))
         return glucoseStorage.lastGlucoseDate()

+ 8 - 1
FreeAPS/Sources/APS/CGM/DexcomSourceG6.swift

@@ -98,7 +98,7 @@ extension DexcomSourceG6: CGMManagerDelegate {
 
     func cgmManagerWantsDeletion(_ manager: CGMManager) {
         dispatchPrecondition(condition: .onQueue(processQueue))
-        debug(.deviceManager, " CGM Manager with identifier \(manager.managerIdentifier) wants deletion")
+        debug(.deviceManager, " CGM Manager with identifier \(manager.pluginIdentifier) wants deletion")
         glucoseManager?.cgmGlucoseSourceType = nil
     }
 
@@ -109,6 +109,13 @@ extension DexcomSourceG6: CGMManagerDelegate {
         }
     }
 
+    func cgmManager(_: LoopKit.CGMManager, hasNew events: [LoopKit.PersistedCgmEvent]) {
+        dispatchPrecondition(condition: .onQueue(processQueue))
+        // TODO: Events in APS ?
+        // currently only display in log the date of the event
+        events.forEach { debug(.deviceManager, "events from CGM at \($0.date)") }
+    }
+
     func startDateToFilterNewData(for _: CGMManager) -> Date? {
         dispatchPrecondition(condition: .onQueue(processQueue))
         return glucoseStorage.lastGlucoseDate()

+ 8 - 1
FreeAPS/Sources/APS/CGM/dexcomSourceG7.swift

@@ -92,7 +92,7 @@ extension DexcomSourceG7: CGMManagerDelegate {
 
     func cgmManagerWantsDeletion(_ manager: CGMManager) {
         dispatchPrecondition(condition: .onQueue(processQueue))
-        debug(.deviceManager, " CGM Manager with identifier \(manager.managerIdentifier) wants deletion")
+        debug(.deviceManager, " CGM Manager with identifier \(manager.pluginIdentifier) wants deletion")
         glucoseManager?.cgmGlucoseSourceType = nil
     }
 
@@ -103,6 +103,13 @@ extension DexcomSourceG7: CGMManagerDelegate {
         }
     }
 
+    func cgmManager(_: LoopKit.CGMManager, hasNew events: [LoopKit.PersistedCgmEvent]) {
+        dispatchPrecondition(condition: .onQueue(processQueue))
+        // TODO: Events in APS ?
+        // currently only display in log the date of the event
+        events.forEach { debug(.deviceManager, "events from CGM at \($0.date)") }
+    }
+
     func startDateToFilterNewData(for _: CGMManager) -> Date? {
         dispatchPrecondition(condition: .onQueue(processQueue))
         return glucoseStorage.lastGlucoseDate()

+ 19 - 4
FreeAPS/Sources/APS/DeviceDataManager.swift

@@ -37,10 +37,10 @@ private let staticPumpManagers: [PumpManagerUI.Type] = [
 ]
 
 private let staticPumpManagersByIdentifier: [String: PumpManagerUI.Type] = [
-    MinimedPumpManager.managerIdentifier: MinimedPumpManager.self,
-    OmnipodPumpManager.managerIdentifier: OmnipodPumpManager.self,
-    OmniBLEPumpManager.managerIdentifier: OmniBLEPumpManager.self,
-    MockPumpManager.managerIdentifier: MockPumpManager.self
+    MinimedPumpManager.pluginIdentifier: MinimedPumpManager.self,
+    OmnipodPumpManager.pluginIdentifier: OmnipodPumpManager.self,
+    OmniBLEPumpManager.pluginIdentifier: OmniBLEPumpManager.self,
+    MockPumpManager.pluginIdentifier: MockPumpManager.self
 ]
 
 // private let staticPumpManagersByIdentifier: [String: PumpManagerUI.Type] = staticPumpManagers.reduce(into: [:]) { map, Type in
@@ -293,6 +293,18 @@ final class BaseDeviceDataManager: DeviceDataManager, Injectable {
 // MARK: - PumpManagerDelegate
 
 extension BaseDeviceDataManager: PumpManagerDelegate {
+    var automaticDosingEnabled: Bool {
+        settingsManager.settings.closedLoop // Take if close or open loop
+    }
+
+    func pumpManager(
+        _: LoopKit.PumpManager,
+        didRequestBasalRateScheduleChange _: LoopKit.BasalRateSchedule,
+        completion _: @escaping (Error?) -> Void
+    ) {
+        debug(.deviceManager, "pumpManagerBasalRateChange")
+    }
+
     func pumpManagerPumpWasReplaced(_: PumpManager) {
         debug(.deviceManager, "pumpManagerPumpWasReplaced")
     }
@@ -433,6 +445,7 @@ extension BaseDeviceDataManager: PumpManagerDelegate {
         _: PumpManager,
         hasNewPumpEvents events: [NewPumpEvent],
         lastReconciliation _: Date?,
+        replacePendingEvents _: Bool,
         completion: @escaping (_ error: Error?) -> Void
     ) {
         dispatchPrecondition(condition: .onQueue(processQueue))
@@ -573,6 +586,8 @@ extension BaseDeviceDataManager: CGMManagerDelegate {
 
     func cgmManager(_: CGMManager, hasNew _: CGMReadingResult) {}
 
+    func cgmManager(_: LoopKit.CGMManager, hasNew _: [LoopKit.PersistedCgmEvent]) {}
+
     func cgmManagerWantsDeletion(_: CGMManager) {}
 
     func cgmManagerDidUpdateState(_: CGMManager) {}

+ 2 - 1
FreeAPS/Sources/APS/Extensions/LoopUIColorPalette+Default.swift

@@ -26,7 +26,8 @@ extension ChartColorPalette {
             axisLabel: .axisLabelColor,
             grid: .gridColor,
             glucoseTint: .glucoseTintColor,
-            insulinTint: .insulinTintColor
+            insulinTint: .insulinTintColor,
+            carbTint: .carbTintColor
         )
     }
 }

+ 2 - 2
FreeAPS/Sources/APS/Extensions/PumpManagerExtensions.swift

@@ -4,7 +4,7 @@ import LoopKitUI
 extension PumpManager {
     var rawValue: [String: Any] {
         [
-            "managerIdentifier": managerIdentifier, // "managerIdentifier": type(of: self).managerIdentifier,
+            "managerIdentifier": pluginIdentifier, // "managerIdentifier": type(of: self).managerIdentifier,
             "state": rawState
         ]
     }
@@ -26,7 +26,7 @@ extension PumpManagerUI {
         var vc = settingsViewController(
             bluetoothProvider: bluetoothProvider,
             colorPalette: .default,
-            allowDebugFeatures: false,
+            allowDebugFeatures: true,
             allowedInsulinTypes: [.apidra, .humalog, .novolog, .fiasp, .lyumjev]
         )
         vc.pumpManagerOnboardingDelegate = pumpManagerOnboardingDelegate

+ 4 - 4
FreeAPS/Sources/Modules/CGM/View/CGMSettingsView.swift

@@ -11,17 +11,17 @@ extension CGM {
         weak var completionDelegate: CompletionDelegate?
 
         func makeUIViewController(context _: UIViewControllerRepresentableContext<CGMSettingsView>) -> UIViewController {
-            let displayGlucoseUnitObservable: DisplayGlucoseUnitObservable
+            let displayGlucosePreference: DisplayGlucosePreference
             switch unit {
             case .mgdL:
-                displayGlucoseUnitObservable = DisplayGlucoseUnitObservable(displayGlucoseUnit: .milligramsPerDeciliter)
+                displayGlucosePreference = DisplayGlucosePreference(displayGlucoseUnit: .milligramsPerDeciliter)
             case .mmolL:
-                displayGlucoseUnitObservable = DisplayGlucoseUnitObservable(displayGlucoseUnit: .millimolesPerLiter)
+                displayGlucosePreference = DisplayGlucosePreference(displayGlucoseUnit: .millimolesPerLiter)
             }
 
             var vc = cgmManager.settingsViewController(
                 bluetoothProvider: bluetoothManager,
-                displayGlucoseUnitObservable: displayGlucoseUnitObservable,
+                displayGlucosePreference: displayGlucosePreference,
                 colorPalette: .default,
                 allowDebugFeatures: false
             )

+ 8 - 7
FreeAPS/Sources/Modules/CGM/View/CGMSetupView.swift

@@ -21,26 +21,26 @@ extension CGM {
                 CGMManagerUI
             >?
 
-            let displayGlucoseUnitObservable: DisplayGlucoseUnitObservable
+            let displayGlucosePreference: DisplayGlucosePreference
             switch unit {
             case .mgdL:
-                displayGlucoseUnitObservable = DisplayGlucoseUnitObservable(displayGlucoseUnit: .milligramsPerDeciliter)
+                displayGlucosePreference = DisplayGlucosePreference(displayGlucoseUnit: .milligramsPerDeciliter)
             case .mmolL:
-                displayGlucoseUnitObservable = DisplayGlucoseUnitObservable(displayGlucoseUnit: .millimolesPerLiter)
+                displayGlucosePreference = DisplayGlucosePreference(displayGlucoseUnit: .millimolesPerLiter)
             }
 
             switch CGMType {
             case .dexcomG5:
                 setupViewController = G5CGMManager.setupViewController(
                     bluetoothProvider: bluetoothManager,
-                    displayGlucoseUnitObservable: displayGlucoseUnitObservable,
+                    displayGlucosePreference: displayGlucosePreference,
                     colorPalette: .default,
                     allowDebugFeatures: false
                 )
             case .dexcomG6:
                 setupViewController = G6CGMManager.setupViewController(
                     bluetoothProvider: bluetoothManager,
-                    displayGlucoseUnitObservable: displayGlucoseUnitObservable,
+                    displayGlucosePreference: displayGlucosePreference,
                     colorPalette: .default,
                     allowDebugFeatures: false
                 )
@@ -48,9 +48,10 @@ extension CGM {
                 setupViewController =
                     G7CGMManager.setupViewController(
                         bluetoothProvider: bluetoothManager,
-                        displayGlucoseUnitObservable: displayGlucoseUnitObservable,
+                        displayGlucosePreference: displayGlucosePreference,
                         colorPalette: .default,
-                        allowDebugFeatures: false
+                        allowDebugFeatures: false,
+                        prefersToSkipUserInteraction: false
                     )
             default:
                 break

+ 7 - 4
FreeAPS/Sources/Modules/PumpConfig/View/PumpSetupView.swift

@@ -37,7 +37,8 @@ extension PumpConfig {
                     initialSettings: initialSettings,
                     bluetoothProvider: bluetoothManager,
                     colorPalette: .default,
-                    allowDebugFeatures: false,
+                    allowDebugFeatures: true,
+                    prefersToSkipUserInteraction: false,
                     allowedInsulinTypes: [.apidra, .humalog, .novolog, .fiasp, .lyumjev]
                 )
             case .omnipod:
@@ -45,7 +46,8 @@ extension PumpConfig {
                     initialSettings: initialSettings,
                     bluetoothProvider: bluetoothManager,
                     colorPalette: .default,
-                    allowDebugFeatures: false,
+                    allowDebugFeatures: true,
+                    prefersToSkipUserInteraction: false,
                     allowedInsulinTypes: [.apidra, .humalog, .novolog, .fiasp, .lyumjev]
                 )
             case .omnipodBLE:
@@ -53,7 +55,7 @@ extension PumpConfig {
                     initialSettings: initialSettings,
                     bluetoothProvider: bluetoothManager,
                     colorPalette: .default,
-                    allowDebugFeatures: false,
+                    allowDebugFeatures: true,
                     allowedInsulinTypes: [.apidra, .humalog, .novolog, .fiasp, .lyumjev]
                 )
             case .simulator:
@@ -61,7 +63,8 @@ extension PumpConfig {
                     initialSettings: initialSettings,
                     bluetoothProvider: bluetoothManager,
                     colorPalette: .default,
-                    allowDebugFeatures: false,
+                    allowDebugFeatures: true,
+                    prefersToSkipUserInteraction: false,
                     allowedInsulinTypes: [.apidra, .humalog, .novolog, .fiasp, .lyumjev]
                 )
             }