Просмотр исходного кода

Merge pull request #582 from nightscout/oref-swift-lgs-and-skip-neutral-temp

Implement low glucose suspend and skip neutral temp dosing logic
Deniz Cengiz 9 месяцев назад
Родитель
Сommit
12fb016edc

+ 0 - 6
Model/JSONImporter.swift

@@ -553,7 +553,6 @@ extension Determination: Codable {
         isf = try container.decodeIfPresent(Decimal.self, forKey: .isf)
         isf = try container.decodeIfPresent(Decimal.self, forKey: .isf)
         current_target = try container.decodeIfPresent(Decimal.self, forKey: .current_target)
         current_target = try container.decodeIfPresent(Decimal.self, forKey: .current_target)
         tdd = try container.decodeIfPresent(Decimal.self, forKey: .tdd)
         tdd = try container.decodeIfPresent(Decimal.self, forKey: .tdd)
-        insulinForManualBolus = try container.decodeIfPresent(Decimal.self, forKey: .insulinForManualBolus)
         manualBolusErrorString = try container.decodeIfPresent(Decimal.self, forKey: .manualBolusErrorString)
         manualBolusErrorString = try container.decodeIfPresent(Decimal.self, forKey: .manualBolusErrorString)
         minDelta = try container.decodeIfPresent(Decimal.self, forKey: .minDelta)
         minDelta = try container.decodeIfPresent(Decimal.self, forKey: .minDelta)
         expectedDelta = try container.decodeIfPresent(Decimal.self, forKey: .expectedDelta)
         expectedDelta = try container.decodeIfPresent(Decimal.self, forKey: .expectedDelta)
@@ -595,7 +594,6 @@ extension Determination: Codable {
         try container.encodeIfPresent(isf, forKey: .isf)
         try container.encodeIfPresent(isf, forKey: .isf)
         try container.encodeIfPresent(current_target, forKey: .current_target)
         try container.encodeIfPresent(current_target, forKey: .current_target)
         try container.encodeIfPresent(tdd, forKey: .tdd)
         try container.encodeIfPresent(tdd, forKey: .tdd)
-        try container.encodeIfPresent(insulinForManualBolus, forKey: .insulinForManualBolus)
         try container.encodeIfPresent(manualBolusErrorString, forKey: .manualBolusErrorString)
         try container.encodeIfPresent(manualBolusErrorString, forKey: .manualBolusErrorString)
         try container.encodeIfPresent(minDelta, forKey: .minDelta)
         try container.encodeIfPresent(minDelta, forKey: .minDelta)
         try container.encodeIfPresent(expectedDelta, forKey: .expectedDelta)
         try container.encodeIfPresent(expectedDelta, forKey: .expectedDelta)
@@ -637,9 +635,6 @@ extension Determination: Codable {
         guard let manualBolusErrorString = manualBolusErrorString else {
         guard let manualBolusErrorString = manualBolusErrorString else {
             throw JSONImporterError.missingRequiredPropertyInDetermination("manualBolusErrorString")
             throw JSONImporterError.missingRequiredPropertyInDetermination("manualBolusErrorString")
         }
         }
-        guard let insulinForManualBolus = insulinForManualBolus else {
-            throw JSONImporterError.missingRequiredPropertyInDetermination("insulinForManualBolus")
-        }
         guard let cob = cob else {
         guard let cob = cob else {
             throw JSONImporterError.missingRequiredPropertyInDetermination("COB")
             throw JSONImporterError.missingRequiredPropertyInDetermination("COB")
         }
         }
@@ -676,7 +671,6 @@ extension Determination: Codable {
         newOrefDetermination.deliverAt = deliverAt
         newOrefDetermination.deliverAt = deliverAt
         newOrefDetermination.timestamp = timestamp
         newOrefDetermination.timestamp = timestamp
         newOrefDetermination.enacted = received ?? false
         newOrefDetermination.enacted = received ?? false
-        newOrefDetermination.insulinForManualBolus = decimalToNSDecimalNumber(insulinForManualBolus)
         newOrefDetermination.carbRatio = decimalToNSDecimalNumber(carbRatio)
         newOrefDetermination.carbRatio = decimalToNSDecimalNumber(carbRatio)
         newOrefDetermination.glucose = decimalToNSDecimalNumber(bg)
         newOrefDetermination.glucose = decimalToNSDecimalNumber(bg)
         newOrefDetermination.reservoir = decimalToNSDecimalNumber(reservoir)
         newOrefDetermination.reservoir = decimalToNSDecimalNumber(reservoir)

+ 0 - 1
Trio/Sources/APS/OpenAPS/OpenAPS.swift

@@ -40,7 +40,6 @@ final class OpenAPS {
             newOrefDetermination.currentTarget = self.decimalToNSDecimalNumber(determination.current_target)
             newOrefDetermination.currentTarget = self.decimalToNSDecimalNumber(determination.current_target)
             newOrefDetermination.eventualBG = determination.eventualBG.map(NSDecimalNumber.init)
             newOrefDetermination.eventualBG = determination.eventualBG.map(NSDecimalNumber.init)
             newOrefDetermination.deliverAt = determination.deliverAt
             newOrefDetermination.deliverAt = determination.deliverAt
-            newOrefDetermination.insulinForManualBolus = self.decimalToNSDecimalNumber(determination.insulinForManualBolus)
             newOrefDetermination.carbRatio = self.decimalToNSDecimalNumber(determination.carbRatio)
             newOrefDetermination.carbRatio = self.decimalToNSDecimalNumber(determination.carbRatio)
             newOrefDetermination.glucose = self.decimalToNSDecimalNumber(determination.bg)
             newOrefDetermination.glucose = self.decimalToNSDecimalNumber(determination.bg)
             newOrefDetermination.reservoir = self.decimalToNSDecimalNumber(determination.reservoir)
             newOrefDetermination.reservoir = self.decimalToNSDecimalNumber(determination.reservoir)

+ 42 - 13
Trio/Sources/APS/OpenAPSSwift/DetermineBasal/DetermineBasalGenerator.swift

@@ -109,7 +109,6 @@ enum DeterminationGenerator {
                 timestamp: currentTime,
                 timestamp: currentTime,
                 tdd: nil,
                 tdd: nil,
                 current_target: profile.targetBg,
                 current_target: profile.targetBg,
-                insulinForManualBolus: nil,
                 manualBolusErrorString: nil,
                 manualBolusErrorString: nil,
                 minDelta: nil,
                 minDelta: nil,
                 expectedDelta: nil,
                 expectedDelta: nil,
@@ -128,7 +127,6 @@ enum DeterminationGenerator {
             trioCustomOrefVariables: trioCustomOrefVariables
             trioCustomOrefVariables: trioCustomOrefVariables
         )
         )
 
 
-        // TODO: We need to add the dynamicIsfResult to our forcasting functions
         if let dynamicIsfResult = dynamicIsfResult {
         if let dynamicIsfResult = dynamicIsfResult {
             autosensData = Autosens(
             autosensData = Autosens(
                 ratio: dynamicIsfResult.ratio,
                 ratio: dynamicIsfResult.ratio,
@@ -289,20 +287,22 @@ enum DeterminationGenerator {
             meal: mealData,
             meal: mealData,
             currentGlucose: currentGlucose,
             currentGlucose: currentGlucose,
             adjustedTargetGlucose: adjustedGlucoseTargets.targetGlucose,
             adjustedTargetGlucose: adjustedGlucoseTargets.targetGlucose,
-            adjustedSensitivity: adjustedSensitivity,
             minGuardGlucose: forecastResult.minGuardGlucose,
             minGuardGlucose: forecastResult.minGuardGlucose,
-            eventualGlucose: forecastResult.eventualGlucose,
             threshold: threshold,
             threshold: threshold,
             glucoseStatus: glucoseStatus,
             glucoseStatus: glucoseStatus,
             trioCustomOrefVariables: trioCustomOrefVariables,
             trioCustomOrefVariables: trioCustomOrefVariables,
             clock: currentTime
             clock: currentTime
         )
         )
 
 
-        // TODO: STOPPING at LINE 1264
+        let smbIsEnabled = smbDecision.isEnabled
+        var reason = dosingInputs.reason
+        if let smbReason = smbDecision.reason {
+            reason += smbReason
+        }
 
 
         var determination = Determination(
         var determination = Determination(
             id: UUID(),
             id: UUID(),
-            reason: dosingInputs.reason,
+            reason: reason,
             units: nil,
             units: nil,
             insulinReq: nil,
             insulinReq: nil,
             eventualBG: Int(forecastResult.eventualGlucose.jsRounded()),
             eventualBG: Int(forecastResult.eventualGlucose.jsRounded()),
@@ -326,16 +326,48 @@ enum DeterminationGenerator {
             timestamp: currentTime,
             timestamp: currentTime,
             tdd: nil,
             tdd: nil,
             current_target: nil,
             current_target: nil,
-            insulinForManualBolus: nil,
-            manualBolusErrorString: nil,
+            manualBolusErrorString: smbDecision.manualBolusError.map { Decimal($0) },
             minDelta: nil,
             minDelta: nil,
             expectedDelta: expectedDelta,
             expectedDelta: expectedDelta,
-            minGuardBG: forecastResult.minGuardGlucose,
+            minGuardBG: smbDecision.minGuardGlucose ?? forecastResult.minGuardGlucose,
             minPredBG: forecastResult.minForecastedGlucose,
             minPredBG: forecastResult.minForecastedGlucose,
             threshold: threshold.jsRounded(),
             threshold: threshold.jsRounded(),
             carbRatio: forecastResult.adjustedCarbRatio.jsRounded(scale: 1),
             carbRatio: forecastResult.adjustedCarbRatio.jsRounded(scale: 1),
-            received: false,
+            received: false
+        )
+
+        // MARK: - Core dosing logic
+
+        let (setTempBasalForLowGlucoseSuspend, lowGlucoseSuspendDetermination) = try DosingEngine.lowGlucoseSuspend(
+            currentGlucose: currentGlucose,
+            minGuardGlucose: forecastResult.minGuardGlucose,
+            iob: currentIob,
+            minDelta: minDelta,
+            expectedDelta: expectedDelta,
+            threshold: threshold,
+            overrideFactor: trioCustomOrefVariables.overrideFactor(),
+            profile: profile,
+            adjustedSensitivity: adjustedSensitivity,
+            targetGlucose: adjustedGlucoseTargets.targetGlucose,
+            currentTemp: currentTemp,
+            determination: determination
+        )
+        determination = lowGlucoseSuspendDetermination
+        if setTempBasalForLowGlucoseSuspend {
+            return determination
+        }
+
+        let (setTempBasalForSkipNeutralTemp, skipNeutralTempDetermination) = try DosingEngine.skipNeutralTempBasal(
+            smbIsEnabled: smbIsEnabled,
+            profile: profile,
+            clock: currentTime,
+            currentTemp: currentTemp,
+            determination: determination
         )
         )
+        determination = skipNeutralTempDetermination
+        if setTempBasalForSkipNeutralTemp {
+            return determination
+        }
 
 
         // TODO: how to handle output?
         // TODO: how to handle output?
         // TODO: how to handle logging?
         // TODO: how to handle logging?
@@ -456,7 +488,6 @@ enum DeterminationGenerator {
                 timestamp: currentTime,
                 timestamp: currentTime,
                 tdd: nil,
                 tdd: nil,
                 current_target: profile.targetBg,
                 current_target: profile.targetBg,
-                insulinForManualBolus: nil,
                 manualBolusErrorString: nil,
                 manualBolusErrorString: nil,
                 minDelta: minDelta,
                 minDelta: minDelta,
                 expectedDelta: nil,
                 expectedDelta: nil,
@@ -490,7 +521,6 @@ enum DeterminationGenerator {
                 timestamp: currentTime,
                 timestamp: currentTime,
                 tdd: nil,
                 tdd: nil,
                 current_target: profile.targetBg,
                 current_target: profile.targetBg,
-                insulinForManualBolus: nil,
                 manualBolusErrorString: nil,
                 manualBolusErrorString: nil,
                 minDelta: minDelta,
                 minDelta: minDelta,
                 expectedDelta: nil,
                 expectedDelta: nil,
@@ -524,7 +554,6 @@ enum DeterminationGenerator {
                 timestamp: currentTime,
                 timestamp: currentTime,
                 tdd: nil,
                 tdd: nil,
                 current_target: profile.targetBg,
                 current_target: profile.targetBg,
-                insulinForManualBolus: nil,
                 manualBolusErrorString: nil,
                 manualBolusErrorString: nil,
                 minDelta: minDelta,
                 minDelta: minDelta,
                 expectedDelta: nil,
                 expectedDelta: nil,

+ 115 - 6
Trio/Sources/APS/OpenAPSSwift/DetermineBasal/DosingEngine.swift

@@ -10,7 +10,6 @@ enum DosingEngine {
     struct SMBDecision {
     struct SMBDecision {
         let isEnabled: Bool
         let isEnabled: Bool
         let manualBolusError: Int?
         let manualBolusError: Int?
-        let insulinForManualBolus: Decimal?
         let minGuardGlucose: Decimal?
         let minGuardGlucose: Decimal?
         let reason: String?
         let reason: String?
     }
     }
@@ -111,9 +110,7 @@ enum DosingEngine {
         meal: ComputedCarbs,
         meal: ComputedCarbs,
         currentGlucose: Decimal,
         currentGlucose: Decimal,
         adjustedTargetGlucose: Decimal,
         adjustedTargetGlucose: Decimal,
-        adjustedSensitivity: Decimal,
         minGuardGlucose: Decimal,
         minGuardGlucose: Decimal,
-        eventualGlucose: Decimal,
         threshold: Decimal,
         threshold: Decimal,
         glucoseStatus: GlucoseStatus,
         glucoseStatus: GlucoseStatus,
         trioCustomOrefVariables: TrioCustomOrefVariables,
         trioCustomOrefVariables: TrioCustomOrefVariables,
@@ -133,12 +130,10 @@ enum DosingEngine {
         // in one place. Note: We can't shortcut the return value because
         // in one place. Note: We can't shortcut the return value because
         // the determineBasal logic always evaluates this logic
         // the determineBasal logic always evaluates this logic
         var manualBolusError: Int?
         var manualBolusError: Int?
-        var insulinForManualBolus: Decimal?
         var minGuardGlucoseDecision: Decimal?
         var minGuardGlucoseDecision: Decimal?
         var reason: String?
         var reason: String?
         if smbIsEnabled, minGuardGlucose < threshold {
         if smbIsEnabled, minGuardGlucose < threshold {
             manualBolusError = 1
             manualBolusError = 1
-            insulinForManualBolus = ((eventualGlucose - adjustedTargetGlucose) / adjustedSensitivity).jsRounded(scale: 2)
             minGuardGlucoseDecision = minGuardGlucose
             minGuardGlucoseDecision = minGuardGlucose
             smbIsEnabled = false
             smbIsEnabled = false
         }
         }
@@ -153,7 +148,6 @@ enum DosingEngine {
         return SMBDecision(
         return SMBDecision(
             isEnabled: smbIsEnabled,
             isEnabled: smbIsEnabled,
             manualBolusError: manualBolusError,
             manualBolusError: manualBolusError,
-            insulinForManualBolus: insulinForManualBolus,
             minGuardGlucose: minGuardGlucoseDecision,
             minGuardGlucose: minGuardGlucoseDecision,
             reason: reason
             reason: reason
         )
         )
@@ -271,4 +265,119 @@ enum DosingEngine {
 
 
         return nil
         return nil
     }
     }
+
+    /// Determines if a low glucose suspend is warranted.
+    ///
+    /// This function checks for low glucose conditions and may modify the determination object
+    /// with a suspend recommendation and an updated reason string.
+    ///
+    /// - Returns: A tuple containing:
+    ///   - `setTempBasal`: A `Bool` that is `true` if `determineBasal` should exit and apply the recommendation immediately.
+    ///   - `determination`: The (potentially modified) determination object.
+    static func lowGlucoseSuspend(
+        currentGlucose: Decimal,
+        minGuardGlucose: Decimal,
+        iob: Decimal,
+        minDelta: Decimal,
+        expectedDelta: Decimal,
+        threshold: Decimal,
+        overrideFactor: Decimal,
+        profile: Profile,
+        adjustedSensitivity: Decimal,
+        targetGlucose: Decimal,
+        currentTemp: TempBasal,
+        determination: Determination
+    ) throws -> (shouldSetTempBasal: Bool, determination: Determination) {
+        var newDetermination = determination
+
+        guard let currentBasal = profile.currentBasal else {
+            // Should have been checked earlier
+            throw TempBasalFunctionError.invalidBasalRateOnProfile
+        }
+
+        let suspendThreshold = -currentBasal * overrideFactor * 20 / 60
+        if currentGlucose < threshold, iob < suspendThreshold, minDelta > 0, minDelta > expectedDelta {
+            let iobString = String(describing: iob)
+            let suspendString = String(describing: suspendThreshold.jsRounded(scale: 2))
+            let minDeltaString = String(describing: convertGlucose(profile: profile, glucose: minDelta))
+            let expectedDeltaString = String(describing: convertGlucose(profile: profile, glucose: expectedDelta))
+
+            newDetermination
+                .reason +=
+                "IOB \(iobString) < \(suspendString) and minDelta \(minDeltaString) > expectedDelta \(expectedDeltaString); "
+            return (shouldSetTempBasal: false, determination: newDetermination)
+        } else if currentGlucose < threshold || minGuardGlucose < threshold {
+            let minGuardGlucoseString = String(describing: convertGlucose(profile: profile, glucose: minGuardGlucose))
+            let thresholdString = String(describing: convertGlucose(profile: profile, glucose: threshold))
+            newDetermination.reason += "minGuardBG \(minGuardGlucoseString) < \(thresholdString)"
+
+            let glucoseUndershoot = targetGlucose - minGuardGlucose
+            if minGuardGlucose < threshold {
+                newDetermination.manualBolusErrorString = 2
+                newDetermination.minGuardBG = minGuardGlucose
+            }
+
+            let worstCaseInsulinRequired = glucoseUndershoot / adjustedSensitivity
+            var durationRequired = (60 * worstCaseInsulinRequired / (currentBasal * overrideFactor)).jsRounded()
+            durationRequired = (durationRequired / 30).jsRounded() * 30
+            durationRequired = max(30, min(120, durationRequired))
+
+            let finalDetermination = try TempBasalFunctions.setTempBasal(
+                rate: 0,
+                duration: durationRequired,
+                profile: profile,
+                determination: newDetermination,
+                currentTemp: currentTemp
+            )
+            return (shouldSetTempBasal: true, determination: finalDetermination)
+        }
+
+        return (shouldSetTempBasal: false, determination: determination)
+    }
+
+    /// Determines if a neutral temp basal should be skipped to avoid pump alerts.
+    ///
+    /// - Returns: A tuple containing:
+    ///   - `shouldSetTempBasal`: A `Bool` that is `true` if `determineBasal` should exit and apply the recommendation immediately.
+    ///   - `determination`: The (potentially modified) determination object.
+    static func skipNeutralTempBasal(
+        smbIsEnabled: Bool,
+        profile: Profile,
+        clock: Date,
+        currentTemp: TempBasal,
+        determination: Determination
+    ) throws -> (shouldSetTempBasal: Bool, determination: Determination) {
+        guard profile.skipNeutralTemps else {
+            return (shouldSetTempBasal: false, determination: determination)
+        }
+        guard let totalMinutes = clock.minutesSinceMidnight else {
+            throw CalendarError.invalidCalendar
+        }
+
+        let minute = totalMinutes % 60
+        guard minute >= 55 else {
+            return (shouldSetTempBasal: false, determination: determination)
+        }
+
+        if !smbIsEnabled {
+            var newDetermination = determination
+            let minutesLeft = 60 - minute
+            newDetermination
+                .reason +=
+                "; Canceling temp at \(minutesLeft)min before turn of the hour to avoid beeping of MDT. SMB are disabled anyways."
+
+            let finalDetermination = try TempBasalFunctions.setTempBasal(
+                rate: 0,
+                duration: 0,
+                profile: profile,
+                determination: newDetermination,
+                currentTemp: currentTemp
+            )
+            return (shouldSetTempBasal: true, determination: finalDetermination)
+        } else {
+            // In the JS, this path logs to the console but does not modify determination.
+            // We will do nothing here to match that behavior.
+            return (shouldSetTempBasal: false, determination: determination)
+        }
+    }
 }
 }

+ 0 - 1
Trio/Sources/APS/Storage/DeterminationStorage.swift

@@ -183,7 +183,6 @@ final class BaseDeterminationStorage: DeterminationStorage, Injectable {
                         isf: self.decimal(from: orefDetermination.insulinSensitivity),
                         isf: self.decimal(from: orefDetermination.insulinSensitivity),
                         timestamp: orefDetermination.timestamp,
                         timestamp: orefDetermination.timestamp,
                         current_target: self.decimal(from: orefDetermination.currentTarget),
                         current_target: self.decimal(from: orefDetermination.currentTarget),
-                        insulinForManualBolus: self.decimal(from: orefDetermination.insulinForManualBolus),
                         manualBolusErrorString: self.decimal(from: orefDetermination.manualBolusErrorString),
                         manualBolusErrorString: self.decimal(from: orefDetermination.manualBolusErrorString),
                         minDelta: self.decimal(from: orefDetermination.minDelta),
                         minDelta: self.decimal(from: orefDetermination.minDelta),
                         expectedDelta: self.decimal(from: orefDetermination.expectedDelta),
                         expectedDelta: self.decimal(from: orefDetermination.expectedDelta),

+ 1 - 2
Trio/Sources/Models/Determination.swift

@@ -29,8 +29,7 @@ struct Determination: JSON, Equatable {
     var tdd: Decimal?
     var tdd: Decimal?
 
 
     var current_target: Decimal?
     var current_target: Decimal?
-    let insulinForManualBolus: Decimal?
-    let manualBolusErrorString: Decimal?
+    var manualBolusErrorString: Decimal?
     var minDelta: Decimal?
     var minDelta: Decimal?
     var expectedDelta: Decimal?
     var expectedDelta: Decimal?
     var minGuardBG: Decimal?
     var minGuardBG: Decimal?

+ 0 - 1
Trio/Sources/Modules/Treatments/TreatmentsStateModel.swift

@@ -875,7 +875,6 @@ extension Treatments.StateModel {
                     carbsReq: 0,
                     carbsReq: 0,
                     temp: nil,
                     temp: nil,
                     reservoir: 0,
                     reservoir: 0,
-                    insulinForManualBolus: 0,
                     manualBolusErrorString: 0,
                     manualBolusErrorString: 0,
                     carbRatio: 0,
                     carbRatio: 0,
                     received: false
                     received: false

+ 0 - 1
TrioTests/JSONImporterTests.swift

@@ -276,7 +276,6 @@ class BundleReference {}
         #expect(determination.reservoir == Decimal(string: "3735928559").map(NSDecimalNumber.init))
         #expect(determination.reservoir == Decimal(string: "3735928559").map(NSDecimalNumber.init))
         #expect(determination.insulinSensitivity == Decimal(string: "4.6").map(NSDecimalNumber.init))
         #expect(determination.insulinSensitivity == Decimal(string: "4.6").map(NSDecimalNumber.init))
         #expect(determination.currentTarget == Decimal(string: "94").map(NSDecimalNumber.init))
         #expect(determination.currentTarget == Decimal(string: "94").map(NSDecimalNumber.init))
-        #expect(determination.insulinForManualBolus == Decimal(string: "0.8").map(NSDecimalNumber.init))
         #expect(determination.manualBolusErrorString == Decimal(string: "0").map(NSDecimalNumber.init))
         #expect(determination.manualBolusErrorString == Decimal(string: "0").map(NSDecimalNumber.init))
         #expect(determination.minDelta == NSDecimalNumber(5))
         #expect(determination.minDelta == NSDecimalNumber(5))
         #expect(determination.expectedDelta == Decimal(string: "-5.9").map(NSDecimalNumber.init))
         #expect(determination.expectedDelta == Decimal(string: "-5.9").map(NSDecimalNumber.init))

+ 85 - 2
TrioTests/OpenAPSSwiftTests/DetermineBasalEarlyExitTests.swift

@@ -3,7 +3,7 @@ import Testing
 @testable import Trio
 @testable import Trio
 
 
 @Suite("DetermineBasal early exits before core dosing logic") struct DetermineBasalEarlyExitTests {
 @Suite("DetermineBasal early exits before core dosing logic") struct DetermineBasalEarlyExitTests {
-    private func createDefaultInputs() -> (
+    private func createDefaultInputs(currentTime: Date = Date()) -> (
         profile: Profile,
         profile: Profile,
         preferences: Preferences,
         preferences: Preferences,
         currentTemp: TempBasal,
         currentTemp: TempBasal,
@@ -15,7 +15,6 @@ import Testing
         trioCustomOrefVariables: TrioCustomOrefVariables,
         trioCustomOrefVariables: TrioCustomOrefVariables,
         currentTime: Date
         currentTime: Date
     ) {
     ) {
-        let currentTime = Date()
         var profile = Profile()
         var profile = Profile()
         profile.maxIob = 2.5
         profile.maxIob = 2.5
         profile.dia = 3
         profile.dia = 3
@@ -467,4 +466,88 @@ import Testing
             )
             )
         }
         }
     }
     }
+
+    // Test 9 from JS
+    @Test("should low-temp if BG is below threshold") func lowGlucoseSuspend() throws {
+        let (
+            profile,
+            preferences,
+            currentTemp,
+            iobData,
+            mealData,
+            autosensData,
+            reservoirData,
+            _,
+            trioCustomOrefVariables,
+            currentTime
+        ) = createDefaultInputs()
+
+        let glucoseStatus = GlucoseStatus(
+            delta: 0,
+            glucose: 70,
+            noise: 1,
+            shortAvgDelta: 0,
+            longAvgDelta: 0.1,
+            date: currentTime,
+            lastCalIndex: nil,
+            device: "test"
+        )
+
+        let result = try DeterminationGenerator.determineBasal(
+            profile: profile,
+            preferences: preferences,
+            currentTemp: currentTemp,
+            iobData: iobData,
+            mealData: mealData,
+            autosensData: autosensData,
+            reservoirData: reservoirData,
+            glucoseStatus: glucoseStatus,
+            trioCustomOrefVariables: trioCustomOrefVariables,
+            currentTime: currentTime
+        )
+
+        #expect(result?.rate == 0)
+        #expect((result?.duration ?? 0) >= 30)
+        #expect(result?.reason.contains("minGuardBG") == true)
+    }
+
+    // Test 10 from JS
+    @Test("should cancel temp before the hour if not doing SMB") func skipNeutralTemp() throws {
+        // Create a date that is 56 minutes past the hour
+        var components = Calendar.current.dateComponents(in: .current, from: Date())
+        components.minute = 56
+        let currentTime = Calendar.current.date(from: components)!
+
+        var (
+            profile,
+            preferences,
+            currentTemp,
+            iobData,
+            mealData,
+            autosensData,
+            reservoirData,
+            glucoseStatus,
+            trioCustomOrefVariables,
+            _
+        ) = createDefaultInputs(currentTime: currentTime)
+
+        profile.skipNeutralTemps = true
+
+        let result = try DeterminationGenerator.determineBasal(
+            profile: profile,
+            preferences: preferences,
+            currentTemp: currentTemp,
+            iobData: iobData,
+            mealData: mealData,
+            autosensData: autosensData,
+            reservoirData: reservoirData,
+            glucoseStatus: glucoseStatus,
+            trioCustomOrefVariables: trioCustomOrefVariables,
+            currentTime: currentTime
+        )
+
+        #expect(result?.rate == 0)
+        #expect(result?.duration == 0)
+        #expect(result?.reason.contains("Canceling temp") == true)
+    }
 }
 }

+ 38 - 43
TrioTests/OpenAPSSwiftTests/DetermineBasalEnableSmbTests.swift

@@ -10,9 +10,7 @@ import Testing
         meal: ComputedCarbs,
         meal: ComputedCarbs,
         currentGlucose: Decimal,
         currentGlucose: Decimal,
         adjustedTargetGlucose: Decimal,
         adjustedTargetGlucose: Decimal,
-        adjustedSensitivity: Decimal,
         minGuardGlucose: Decimal,
         minGuardGlucose: Decimal,
-        eventualGlucose: Decimal,
         threshold: Decimal,
         threshold: Decimal,
         glucoseStatus: GlucoseStatus,
         glucoseStatus: GlucoseStatus,
         trioCustomOrefVariables: TrioCustomOrefVariables,
         trioCustomOrefVariables: TrioCustomOrefVariables,
@@ -75,9 +73,7 @@ import Testing
             meal: meal,
             meal: meal,
             currentGlucose: 120,
             currentGlucose: 120,
             adjustedTargetGlucose: 100,
             adjustedTargetGlucose: 100,
-            adjustedSensitivity: 50,
             minGuardGlucose: 110,
             minGuardGlucose: 110,
-            eventualGlucose: 115,
             threshold: 70,
             threshold: 70,
             glucoseStatus: glucoseStatus,
             glucoseStatus: glucoseStatus,
             trioCustomOrefVariables: trioCustomOrefVariables,
             trioCustomOrefVariables: trioCustomOrefVariables,
@@ -91,8 +87,8 @@ import Testing
         let inputs = createDefaultInputs()
         let inputs = createDefaultInputs()
         let decision = try DosingEngine.makeSMBDosingDecision(
         let decision = try DosingEngine.makeSMBDosingDecision(
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
-            adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
-            minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
+            adjustedTargetGlucose: inputs.adjustedTargetGlucose,
+            minGuardGlucose: inputs.minGuardGlucose,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
         )
         )
@@ -106,8 +102,8 @@ import Testing
 
 
         let decision = try DosingEngine.makeSMBDosingDecision(
         let decision = try DosingEngine.makeSMBDosingDecision(
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
-            adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
-            minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
+            adjustedTargetGlucose: inputs.adjustedTargetGlucose,
+            minGuardGlucose: inputs.minGuardGlucose,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
         )
         )
@@ -121,8 +117,8 @@ import Testing
 
 
         let decision = try DosingEngine.makeSMBDosingDecision(
         let decision = try DosingEngine.makeSMBDosingDecision(
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
-            adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
-            minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
+            adjustedTargetGlucose: inputs.adjustedTargetGlucose,
+            minGuardGlucose: inputs.minGuardGlucose,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
         )
         )
@@ -137,8 +133,8 @@ import Testing
 
 
         let decision = try DosingEngine.makeSMBDosingDecision(
         let decision = try DosingEngine.makeSMBDosingDecision(
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
-            adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
-            minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
+            adjustedTargetGlucose: inputs.adjustedTargetGlucose,
+            minGuardGlucose: inputs.minGuardGlucose,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
         )
         )
@@ -153,15 +149,14 @@ import Testing
 
 
         let decision = try DosingEngine.makeSMBDosingDecision(
         let decision = try DosingEngine.makeSMBDosingDecision(
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
-            adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
-            minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
+            adjustedTargetGlucose: inputs.adjustedTargetGlucose,
+            minGuardGlucose: inputs.minGuardGlucose,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
         )
         )
         #expect(decision.isEnabled == false)
         #expect(decision.isEnabled == false)
         #expect(decision.manualBolusError == 1)
         #expect(decision.manualBolusError == 1)
         #expect(decision.minGuardGlucose == 65)
         #expect(decision.minGuardGlucose == 65)
-        #expect(decision.insulinForManualBolus != nil)
     }
     }
 
 
     @Test("Should disable SMB when maxDelta is too high") func disableWhenMaxDeltaTooHigh() throws {
     @Test("Should disable SMB when maxDelta is too high") func disableWhenMaxDeltaTooHigh() throws {
@@ -183,8 +178,8 @@ import Testing
 
 
         let decision = try DosingEngine.makeSMBDosingDecision(
         let decision = try DosingEngine.makeSMBDosingDecision(
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
-            adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
-            minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
+            adjustedTargetGlucose: inputs.adjustedTargetGlucose,
+            minGuardGlucose: inputs.minGuardGlucose,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
         )
         )
@@ -200,8 +195,8 @@ import Testing
 
 
         let decision = try DosingEngine.makeSMBDosingDecision(
         let decision = try DosingEngine.makeSMBDosingDecision(
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
-            adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
-            minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
+            adjustedTargetGlucose: inputs.adjustedTargetGlucose,
+            minGuardGlucose: inputs.minGuardGlucose,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
         )
         )
@@ -225,8 +220,8 @@ import Testing
 
 
         let decision = try DosingEngine.makeSMBDosingDecision(
         let decision = try DosingEngine.makeSMBDosingDecision(
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
-            adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
-            minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
+            adjustedTargetGlucose: inputs.adjustedTargetGlucose,
+            minGuardGlucose: inputs.minGuardGlucose,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
         )
         )
@@ -250,8 +245,8 @@ import Testing
 
 
         let decision = try DosingEngine.makeSMBDosingDecision(
         let decision = try DosingEngine.makeSMBDosingDecision(
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
-            adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
-            minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
+            adjustedTargetGlucose: inputs.adjustedTargetGlucose,
+            minGuardGlucose: inputs.minGuardGlucose,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
         )
         )
@@ -266,8 +261,8 @@ import Testing
 
 
         let decision = try DosingEngine.makeSMBDosingDecision(
         let decision = try DosingEngine.makeSMBDosingDecision(
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
-            adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
-            minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
+            adjustedTargetGlucose: inputs.adjustedTargetGlucose,
+            minGuardGlucose: inputs.minGuardGlucose,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
         )
         )
@@ -282,8 +277,8 @@ import Testing
 
 
         let decision = try DosingEngine.makeSMBDosingDecision(
         let decision = try DosingEngine.makeSMBDosingDecision(
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
-            adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
-            minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
+            adjustedTargetGlucose: inputs.adjustedTargetGlucose,
+            minGuardGlucose: inputs.minGuardGlucose,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
         )
         )
@@ -302,8 +297,8 @@ import Testing
 
 
         let decision = try DosingEngine.makeSMBDosingDecision(
         let decision = try DosingEngine.makeSMBDosingDecision(
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
-            adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
-            minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
+            adjustedTargetGlucose: inputs.adjustedTargetGlucose,
+            minGuardGlucose: inputs.minGuardGlucose,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
         )
         )
@@ -320,8 +315,8 @@ import Testing
 
 
         let decision = try DosingEngine.makeSMBDosingDecision(
         let decision = try DosingEngine.makeSMBDosingDecision(
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
-            adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
-            minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
+            adjustedTargetGlucose: inputs.adjustedTargetGlucose,
+            minGuardGlucose: inputs.minGuardGlucose,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
         )
         )
@@ -340,8 +335,8 @@ import Testing
 
 
         let decision = try DosingEngine.makeSMBDosingDecision(
         let decision = try DosingEngine.makeSMBDosingDecision(
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
-            adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
-            minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
+            adjustedTargetGlucose: inputs.adjustedTargetGlucose,
+            minGuardGlucose: inputs.minGuardGlucose,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
         )
         )
@@ -360,8 +355,8 @@ import Testing
 
 
         let decision = try DosingEngine.makeSMBDosingDecision(
         let decision = try DosingEngine.makeSMBDosingDecision(
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
-            adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
-            minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
+            adjustedTargetGlucose: inputs.adjustedTargetGlucose,
+            minGuardGlucose: inputs.minGuardGlucose,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
         )
         )
@@ -378,8 +373,8 @@ import Testing
 
 
         let decision = try DosingEngine.makeSMBDosingDecision(
         let decision = try DosingEngine.makeSMBDosingDecision(
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
-            adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
-            minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
+            adjustedTargetGlucose: inputs.adjustedTargetGlucose,
+            minGuardGlucose: inputs.minGuardGlucose,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
         )
         )
@@ -396,8 +391,8 @@ import Testing
 
 
         let decision = try DosingEngine.makeSMBDosingDecision(
         let decision = try DosingEngine.makeSMBDosingDecision(
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
-            adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
-            minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
+            adjustedTargetGlucose: inputs.adjustedTargetGlucose,
+            minGuardGlucose: inputs.minGuardGlucose,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
         )
         )
@@ -414,8 +409,8 @@ import Testing
 
 
         let decision = try DosingEngine.makeSMBDosingDecision(
         let decision = try DosingEngine.makeSMBDosingDecision(
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
-            adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
-            minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
+            adjustedTargetGlucose: inputs.adjustedTargetGlucose,
+            minGuardGlucose: inputs.minGuardGlucose,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
         )
         )
@@ -432,8 +427,8 @@ import Testing
 
 
         let decision = try DosingEngine.makeSMBDosingDecision(
         let decision = try DosingEngine.makeSMBDosingDecision(
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
             profile: inputs.profile, meal: inputs.meal, currentGlucose: inputs.currentGlucose,
-            adjustedTargetGlucose: inputs.adjustedTargetGlucose, adjustedSensitivity: inputs.adjustedSensitivity,
-            minGuardGlucose: inputs.minGuardGlucose, eventualGlucose: inputs.eventualGlucose,
+            adjustedTargetGlucose: inputs.adjustedTargetGlucose,
+            minGuardGlucose: inputs.minGuardGlucose,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             threshold: inputs.threshold, glucoseStatus: inputs.glucoseStatus,
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
         )
         )

+ 0 - 1
TrioTests/OpenAPSSwiftTests/SetTempBasalTests.swift

@@ -48,7 +48,6 @@ import Testing
             timestamp: Date(),
             timestamp: Date(),
             tdd: nil,
             tdd: nil,
             current_target: nil,
             current_target: nil,
-            insulinForManualBolus: nil,
             manualBolusErrorString: nil,
             manualBolusErrorString: nil,
             minDelta: nil,
             minDelta: nil,
             expectedDelta: nil,
             expectedDelta: nil,