Sam King 6 месяцев назад
Родитель
Сommit
5f5f498f06

+ 0 - 3
Trio/Sources/APS/OpenAPSSwift/DetermineBasal/DeterminationError.swift

@@ -5,7 +5,6 @@ enum DeterminationError: LocalizedError, Equatable {
     case missingProfile
     case missingCurrentBasal
     case invalidProfileTarget
-    case staleGlucoseData(ageMinutes: Double)
     case glucoseOutOfRange(glucose: Decimal)
     case cgmNoiseTooHigh(noise: Int)
     case noDelta
@@ -26,8 +25,6 @@ enum DeterminationError: LocalizedError, Equatable {
         case .invalidProfileTarget:
             // string copied from JS including trailing space
             return String(localized: "Error: could not determine target_bg. ")
-        case let .staleGlucoseData(ageMinutes):
-            return String(localized: "Glucose data is too old (\(ageMinutes) min ago).")
         case let .glucoseOutOfRange(glucose):
             return String(localized: "Glucose out of range: \(glucose.description).")
         case let .cgmNoiseTooHigh(noise):

+ 8 - 14
Trio/Sources/APS/OpenAPSSwift/DetermineBasal/DetermineBasalGenerator.swift

@@ -65,8 +65,7 @@ enum DeterminationGenerator {
             currentTemp: currentTemp,
             iobData: iobData,
             profile: profile,
-            trioCustomOrefVariables: trioCustomOrefVariables,
-            currentTime: currentTime,
+            trioCustomOrefVariables: trioCustomOrefVariables
         )
 
         let currentGlucose: Decimal = glucoseStatus.glucose
@@ -508,8 +507,7 @@ enum DeterminationGenerator {
         currentTemp _: TempBasal?,
         iobData: [IobResult]?,
         profile: Profile?,
-        trioCustomOrefVariables: TrioCustomOrefVariables,
-        currentTime: Date = Date()
+        trioCustomOrefVariables: TrioCustomOrefVariables
     ) throws {
         guard let glucoseStatus = glucoseStatus else {
             throw DeterminationError.missingGlucoseStatus
@@ -520,10 +518,6 @@ enum DeterminationGenerator {
         guard profile.profileTarget(trioCustomOrefVariables: trioCustomOrefVariables) != nil else {
             throw DeterminationError.invalidProfileTarget
         }
-        let glucoseAge = currentTime.timeIntervalSince(glucoseStatus.date)
-        if glucoseAge > 15 * 60 {
-            throw DeterminationError.staleGlucoseData(ageMinutes: glucoseAge / 60)
-        }
         // we have to allow 38 values so that we can cancel high temps
         if glucoseStatus.glucose < 38 || glucoseStatus.glucose > 600 {
             throw DeterminationError.glucoseOutOfRange(glucose: glucoseStatus.glucose)
@@ -612,7 +606,7 @@ enum DeterminationGenerator {
                 deliverAt: currentTime,
                 carbsReq: nil,
                 temp: .absolute,
-                bg: glucose,
+                bg: nil,
                 reservoir: nil,
                 isf: profile.sens,
                 timestamp: currentTime,
@@ -623,7 +617,7 @@ enum DeterminationGenerator {
                 minGuardBG: nil,
                 minPredBG: nil,
                 threshold: nil,
-                carbRatio: profile.carbRatio,
+                carbRatio: nil,
                 received: false
             )
         } else if currentTemp.rate == 0, currentTemp.duration > 30 {
@@ -644,7 +638,7 @@ enum DeterminationGenerator {
                 deliverAt: currentTime,
                 carbsReq: nil,
                 temp: .absolute,
-                bg: glucose,
+                bg: nil,
                 reservoir: nil,
                 isf: profile.sens,
                 timestamp: currentTime,
@@ -655,7 +649,7 @@ enum DeterminationGenerator {
                 minGuardBG: nil,
                 minPredBG: nil,
                 threshold: nil,
-                carbRatio: profile.carbRatio,
+                carbRatio: nil,
                 received: false
             )
         } else {
@@ -676,7 +670,7 @@ enum DeterminationGenerator {
                 deliverAt: currentTime,
                 carbsReq: nil,
                 temp: currentTemp.temp,
-                bg: glucose,
+                bg: nil,
                 reservoir: nil,
                 isf: profile.sens,
                 timestamp: currentTime,
@@ -687,7 +681,7 @@ enum DeterminationGenerator {
                 minGuardBG: nil,
                 minPredBG: nil,
                 threshold: nil,
-                carbRatio: profile.carbRatio,
+                carbRatio: nil,
                 received: false
             )
         }

+ 0 - 3
Trio/Sources/Localizations/Main/Localizable.xcstrings

@@ -118036,9 +118036,6 @@
         }
       }
     },
-    "Glucose data is too old (%lf min ago)." : {
-
-    },
     "Glucose Data used for statistics" : {
       "comment" : "Debug option view Glucose Data used for statistics",
       "extractionState" : "manual",

+ 1 - 1
TrioTests/OpenAPSSwiftTests/DetermineBasalJsonTests.swift

@@ -103,7 +103,7 @@ import Testing
         // this test is meant for one-off analysis so it's ok to hard code
         // a file, just make sure to _not_ check in updates to this to
         // avoid polluting our change logs
-        let algorithmComparison = try await HttpFiles.downloadFile(at: "/files/ccb7fc85-b14b-46cd-83a3-958bdc5b0623.2.json")
+        let algorithmComparison = try await HttpFiles.downloadFile(at: "/files/d247c5ea-b2af-448b-88ce-7ecb3fc09e68.2.json")
         let determineBasalInput = algorithmComparison.determineBasalInput!
 
         let encoder = JSONCoding.encoder