Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 36 additions & 36 deletions DoseMathTests/DoseMathTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class RecommendTempBasalTests: XCTestCase {
return InsulinSensitivitySchedule(unit: HKUnit.milligramsPerDeciliter(), dailyItems: [RepeatingScheduleValue(startTime: 0.0, value: 60.0)])!
}

var minimumBGGuard: GlucoseThreshold {
var suspendThreshold: GlucoseThreshold {
return GlucoseThreshold(unit: HKUnit.milligramsPerDeciliter(), value: 55)
}

Expand All @@ -107,7 +107,7 @@ class RecommendTempBasalTests: XCTestCase {
let dose = glucose.recommendedTempBasal(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
basalRates: basalRateSchedule,
Expand All @@ -124,7 +124,7 @@ class RecommendTempBasalTests: XCTestCase {
var dose = glucose.recommendedTempBasal(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
basalRates: basalRateSchedule,
Expand All @@ -146,7 +146,7 @@ class RecommendTempBasalTests: XCTestCase {
dose = glucose.recommendedTempBasal(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
basalRates: basalRateSchedule,
Expand All @@ -164,7 +164,7 @@ class RecommendTempBasalTests: XCTestCase {
var dose = glucose.recommendedTempBasal(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
basalRates: basalRateSchedule,
Expand All @@ -185,7 +185,7 @@ class RecommendTempBasalTests: XCTestCase {
dose = glucose.recommendedTempBasal(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
basalRates: basalRateSchedule,
Expand All @@ -212,7 +212,7 @@ class RecommendTempBasalTests: XCTestCase {
var dose = glucose.recommendedTempBasal(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
basalRates: basalRateSchedule,
Expand All @@ -226,7 +226,7 @@ class RecommendTempBasalTests: XCTestCase {
dose = glucose.recommendedTempBasal(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
basalRates: basalRateSchedule,
Expand All @@ -243,7 +243,7 @@ class RecommendTempBasalTests: XCTestCase {
let dose = glucose.recommendedTempBasal(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
basalRates: basalRateSchedule,
Expand All @@ -261,7 +261,7 @@ class RecommendTempBasalTests: XCTestCase {
var dose = glucose.recommendedTempBasal(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
basalRates: basalRateSchedule,
Expand All @@ -282,7 +282,7 @@ class RecommendTempBasalTests: XCTestCase {
dose = glucose.recommendedTempBasal(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
basalRates: basalRateSchedule,
Expand All @@ -300,7 +300,7 @@ class RecommendTempBasalTests: XCTestCase {
let dose = glucose.recommendedTempBasal(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
basalRates: basalRateSchedule,
Expand All @@ -318,7 +318,7 @@ class RecommendTempBasalTests: XCTestCase {
let dose = glucose.recommendedTempBasal(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
basalRates: basalRateSchedule,
Expand All @@ -336,7 +336,7 @@ class RecommendTempBasalTests: XCTestCase {
let dose = glucose.recommendedTempBasal(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
basalRates: basalRateSchedule,
Expand All @@ -354,7 +354,7 @@ class RecommendTempBasalTests: XCTestCase {
var dose = glucose.recommendedTempBasal(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: self.insulinSensitivitySchedule,
model: insulinModel,
basalRates: basalRateSchedule,
Expand All @@ -371,7 +371,7 @@ class RecommendTempBasalTests: XCTestCase {
dose = glucose.recommendedTempBasal(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
basalRates: basalRateSchedule,
Expand All @@ -389,7 +389,7 @@ class RecommendTempBasalTests: XCTestCase {
let dose = glucose.recommendedTempBasal(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
basalRates: basalRateSchedule,
Expand All @@ -407,7 +407,7 @@ class RecommendTempBasalTests: XCTestCase {
let dose = glucose.recommendedTempBasal(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
basalRates: basalRateSchedule,
Expand All @@ -424,7 +424,7 @@ class RecommendTempBasalTests: XCTestCase {

let dose = glucose.recommendedTempBasal(
to: glucoseTargetRange,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
basalRates: basalRateSchedule,
Expand Down Expand Up @@ -475,7 +475,7 @@ class RecommendBolusTests: XCTestCase {
return InsulinSensitivitySchedule(unit: HKUnit.milligramsPerDeciliter(), dailyItems: [RepeatingScheduleValue(startTime: 0.0, value: 60.0)])!
}

var minimumBGGuard: GlucoseThreshold {
var suspendThreshold: GlucoseThreshold {
return GlucoseThreshold(unit: HKUnit.milligramsPerDeciliter(), value: 55)
}

Expand All @@ -493,7 +493,7 @@ class RecommendBolusTests: XCTestCase {
let dose = glucose.recommendedBolus(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
pendingInsulin: 0,
Expand All @@ -509,7 +509,7 @@ class RecommendBolusTests: XCTestCase {
let dose = glucose.recommendedBolus(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
pendingInsulin: 0,
Expand All @@ -525,7 +525,7 @@ class RecommendBolusTests: XCTestCase {
let dose = glucose.recommendedBolus(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
pendingInsulin: 0,
Expand All @@ -541,7 +541,7 @@ class RecommendBolusTests: XCTestCase {
let dose = glucose.recommendedBolus(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
pendingInsulin: 0,
Expand All @@ -557,7 +557,7 @@ class RecommendBolusTests: XCTestCase {
let dose = glucose.recommendedBolus(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
pendingInsulin: 0,
Expand All @@ -579,7 +579,7 @@ class RecommendBolusTests: XCTestCase {
let dose = glucose.recommendedBolus(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
pendingInsulin: 0,
Expand All @@ -597,7 +597,7 @@ class RecommendBolusTests: XCTestCase {
let dose = glucose.recommendedBolus(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
pendingInsulin: 1,
Expand All @@ -613,7 +613,7 @@ class RecommendBolusTests: XCTestCase {
let dose = glucose.recommendedBolus(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
pendingInsulin: 0,
Expand All @@ -629,7 +629,7 @@ class RecommendBolusTests: XCTestCase {
let dose = glucose.recommendedBolus(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
pendingInsulin: 0,
Expand All @@ -645,7 +645,7 @@ class RecommendBolusTests: XCTestCase {
let dose = glucose.recommendedBolus(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
pendingInsulin: 0,
Expand All @@ -661,7 +661,7 @@ class RecommendBolusTests: XCTestCase {
var dose = glucose.recommendedBolus(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
pendingInsulin: 0,
Expand All @@ -675,7 +675,7 @@ class RecommendBolusTests: XCTestCase {
dose = glucose.recommendedBolus(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
pendingInsulin: 0.8,
Expand All @@ -691,7 +691,7 @@ class RecommendBolusTests: XCTestCase {
var dose = glucose.recommendedBolus(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: self.insulinSensitivitySchedule,
model: insulinModel,
pendingInsulin: 0,
Expand All @@ -706,7 +706,7 @@ class RecommendBolusTests: XCTestCase {
dose = glucose.recommendedBolus(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
pendingInsulin: 0,
Expand All @@ -722,7 +722,7 @@ class RecommendBolusTests: XCTestCase {
let dose = glucose.recommendedBolus(
to: glucoseTargetRange,
at: glucose.first!.startDate,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
pendingInsulin: 0,
Expand All @@ -738,7 +738,7 @@ class RecommendBolusTests: XCTestCase {

let dose = glucose.recommendedBolus(
to: glucoseTargetRange,
suspendThreshold: minimumBGGuard.quantity,
suspendThreshold: suspendThreshold.quantity,
sensitivity: insulinSensitivitySchedule,
model: insulinModel,
pendingInsulin: 0,
Expand Down
8 changes: 4 additions & 4 deletions Loop/Extensions/NSUserDefaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ extension UserDefaults {
glucoseTargetRangeSchedule = nil
}

let minimumBGGuard: GlucoseThreshold?
let suspendThreshold: GlucoseThreshold?
if let rawValue = dictionary(forKey: "com.loopkit.Loop.MinimumBGGuard") {
minimumBGGuard = GlucoseThreshold(rawValue: rawValue)
suspendThreshold = GlucoseThreshold(rawValue: rawValue)
} else {
minimumBGGuard = nil
suspendThreshold = nil
}

var maximumBasalRatePerHour: Double? = double(forKey: "com.loudnate.Naterade.MaximumBasalRatePerHour")
Expand All @@ -146,7 +146,7 @@ extension UserDefaults {
glucoseTargetRangeSchedule: glucoseTargetRangeSchedule,
maximumBasalRatePerHour: maximumBasalRatePerHour,
maximumBolus: maximumBolus,
minimumBGGuard: minimumBGGuard,
suspendThreshold: suspendThreshold,
retrospectiveCorrectionEnabled: bool(forKey: "com.loudnate.Loop.RetrospectiveCorrectionEnabled")
)
self.loopSettings = settings
Expand Down
2 changes: 1 addition & 1 deletion Loop/Managers/AnalyticsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ final class AnalyticsManager: IdentifiableClass {
logEvent("Maximum bolus change")
}

if newValue.minimumBGGuard != oldValue.minimumBGGuard {
if newValue.suspendThreshold != oldValue.suspendThreshold {
logEvent("Minimum BG Guard change")
}
}
Expand Down
4 changes: 2 additions & 2 deletions Loop/Managers/LoopDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ final class LoopDataManager {
lastRequestedBolus == nil, // Don't recommend changes if a bolus was just set
let tempBasal = predictedGlucose.recommendedTempBasal(
to: glucoseTargetRange,
suspendThreshold: settings.minimumBGGuard?.quantity,
suspendThreshold: settings.suspendThreshold?.quantity,
sensitivity: insulinSensitivity,
model: model,
basalRates: basalRates,
Expand Down Expand Up @@ -913,7 +913,7 @@ final class LoopDataManager {

let recommendation = predictedGlucose.recommendedBolus(
to: glucoseTargetRange,
suspendThreshold: settings.minimumBGGuard?.quantity,
suspendThreshold: settings.suspendThreshold?.quantity,
sensitivity: insulinSensitivity,
model: model,
pendingInsulin: pendingInsulin,
Expand Down
2 changes: 1 addition & 1 deletion Loop/Models/BolusRecommendation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extension BolusRecommendationNotice {
case .glucoseBelowSuspendThreshold(minGlucose: let minGlucose):
let glucoseFormatter = NumberFormatter.glucoseFormatter(for: unit)
let bgStr = glucoseFormatter.describingGlucose(minGlucose.quantity, for: unit)!
return String(format: NSLocalizedString("Predicted glucose of %1$@ is below your suspend threshold setting.", comment: "Notice message when recommending bolus when BG is below minimum BG guard. (1: glucose value)"), bgStr)
return String(format: NSLocalizedString("Predicted glucose of %1$@ is below your suspend threshold setting.", comment: "Notice message when recommending bolus when BG is below the suspend threshold. (1: glucose value)"), bgStr)
case .currentGlucoseBelowTarget(glucose: let glucose):
let glucoseFormatter = NumberFormatter.glucoseFormatter(for: unit)
let bgStr = glucoseFormatter.describingGlucose(glucose.quantity, for: unit)!
Expand Down
Loading