Преглед изворни кода

Merge pull request #589 from nightscout/oref-swift-remove-400-guard

Remove 400 Guard for oref-swift
Sam King пре 6 месеци
родитељ
комит
749d79b8ae

+ 7 - 7
Trio/Sources/APS/OpenAPSSwift/DetermineBasal/DetermineBasalGenerator.swift

@@ -535,15 +535,15 @@ enum DeterminationGenerator {
             glucose == 38 ||
             noise >= 3 ||
             minAgo > 12 ||
-            minAgo < -5 ||
-            (shortAvgDelta == 0 && longAvgDelta == 0)
+            minAgo < -5
 
         // === IF ERROR, CANCEL/SHORTEN TEMPS ===
         guard errorDetected, let currentTemp = currentTemp else { return nil }
 
-        if currentTemp.rate >= basal {
-            // Cancel high temp: set 0U/hr for 0m (neutralizes)
-            let reasonWithAction = reason + ". Canceling high temp basal of \(currentTemp.rate)U/hr."
+        if currentTemp.rate >= basal { // high temp is running
+            // Replace high temp with neutral temp at scheduled basal rate for 30min
+            let reasonWithAction = reason +
+                ". Replacing high temp basal of \(currentTemp.rate)U/hr with neutral temp of \(basal)U/hr"
             return Determination(
                 id: UUID(),
                 reason: reasonWithAction,
@@ -551,8 +551,8 @@ enum DeterminationGenerator {
                 insulinReq: nil,
                 eventualBG: nil,
                 sensitivityRatio: nil,
-                rate: 0,
-                duration: 0,
+                rate: basal,
+                duration: 30,
                 iob: nil,
                 cob: nil,
                 predictions: nil,

+ 1 - 1
Trio/Sources/Models/TrioCustomOrefVariables.swift

@@ -42,7 +42,7 @@ struct TrioCustomOrefVariables: JSON, Equatable {
         start: Decimal,
         end: Decimal,
         smbMinutes: Decimal,
-        uamMinutes: Decimal,
+        uamMinutes: Decimal
     ) {
         self.average_total_data = average_total_data
         self.weightedAverage = weightedAverage

+ 4 - 5
TrioTests/OpenAPSSwiftTests/DetermineBasalEarlyExitTests.swift

@@ -113,8 +113,7 @@ import Testing
             start: 0,
             end: 0,
             smbMinutes: 30,
-            uamMinutes: 30,
-            shouldProtectDueToHIGH: false
+            uamMinutes: 30
         )
 
         return (
@@ -204,9 +203,9 @@ import Testing
             currentTime: currentTime
         )
 
-        #expect(result?.rate == 0)
-        #expect(result?.duration == 0)
-        #expect(result?.reason.contains("Canceling high temp basal") == true)
+        #expect(result?.rate == profile.currentBasal)
+        #expect(result?.duration == 30)
+        #expect(result?.reason.contains("Replacing high temp basal") == true)
     }
 
     // Test 3 from JS

+ 1 - 17
TrioTests/OpenAPSSwiftTests/DetermineBasalEnableSmbTests.swift

@@ -64,8 +64,7 @@ import Testing
             start: 0,
             end: 0,
             smbMinutes: 0,
-            uamMinutes: 0,
-            shouldProtectDueToHIGH: false
+            uamMinutes: 0
         )
 
         return (
@@ -110,21 +109,6 @@ import Testing
         #expect(decision.isEnabled == false)
     }
 
-    @Test("Should disable SMB when shouldProtectDueToHIGH is true") func disableWhenProtectDueToHigh() throws {
-        var inputs = createDefaultInputs()
-        inputs.trioCustomOrefVariables.shouldProtectDueToHIGH = true
-        inputs.profile.enableSMBAlways = true // Ensure protection takes precedence
-
-        let decision = try DosingEngine.makeSMBDosingDecision(
-            profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
-            adjustedTargetGlucose: inputs.adjustedTargetGlucose,
-            minGuardGlucose: inputs.minGuardGlucose,
-            threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
-            trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
-        )
-        #expect(decision.isEnabled == false)
-    }
-
     @Test("Should disable SMB with high temp target when not allowed") func disableWithHighTempTarget() throws {
         var inputs = createDefaultInputs()
         inputs.profile.allowSMBWithHighTemptarget = false

+ 1 - 2
TrioTests/OpenAPSSwiftTests/DynamicISFTests.swift

@@ -55,8 +55,7 @@ import Testing
             start: 0,
             end: 0,
             smbMinutes: 30,
-            uamMinutes: 30,
-            shouldProtectDueToHIGH: false
+            uamMinutes: 30
         )
 
         return (profile, preferences, glucose, trioVars)

Разлика између датотеке није приказан због своје велике величине
+ 1 - 1
TrioTests/OpenAPSSwiftTests/javascript/bundle/determine-basal.js