Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommendation Bolus Breakdown #2148

Open
wants to merge 55 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
bcb4ed9
Merge pull request #1949 from LoopKit/dev
ps2 Mar 17, 2023
3074148
Merge pull request #1964 from LoopKit/dev
ps2 Mar 21, 2023
01eb876
Bump version for main to 3.2.1
ps2 Mar 21, 2023
8177980
readlink -f (#1984)
bjorkert Apr 24, 2023
befcbcb
Bump version to 3.2.2 for Xcode 14.3 archiving
ps2 Apr 24, 2023
085a805
Backport cyclic dependency changes from dev for building on Xcode 15
ps2 Sep 19, 2023
976c9fc
Bump version
ps2 Sep 19, 2023
c6b058b
Merge pull request #2069 from LoopKit/xcode-15-main
ps2 Sep 19, 2023
0883440
Recommend for carbs only, excluding corrections
Dec 28, 2023
d16fbea
Support carb prediction for testing recommendations
Dec 29, 2023
d4ba097
Add feature flag to control whether used or not
Dec 30, 2023
742352d
Enable recommendation bolus breakdown
Dec 31, 2023
332f2e3
Use chevron icon
Jan 1, 2024
ac655eb
Fix spacing issue
Jan 1, 2024
1464933
Work in progress for breakdown
Jan 2, 2024
6c61b0a
Fix up calculations. Add support for max bolus to breakdown
Jan 3, 2024
27d6485
Merge pull request #12 from motinis/temp-breakdown
motinis Jan 3, 2024
9600aa6
Add unit tests
Jan 3, 2024
8bcfcb0
Fixup correction calc when clamped by max bolus
Jan 3, 2024
eb785de
Round to 2 fractional digits in UI
Jan 3, 2024
b66ce5b
Change icon for bidi languages
Jan 3, 2024
2ce4777
Add support for Limit to 0 Bolus
Jan 4, 2024
ed552c7
Don't calc correction when in range
Jan 4, 2024
2e5a709
Don't calc correction when in range
Jan 4, 2024
816fb6a
initial update for cob and bg correction split
Mar 23, 2024
0538ac7
Merge branch 'LoopKit:dev' into bolus-breakdown-cob
motinis Mar 23, 2024
01b8917
refine COB calculation
Mar 24, 2024
2145564
initial unit testing
Mar 25, 2024
b2d568c
Updates to tests, add controls to UI
Mar 27, 2024
8d88f77
Support both maxBolusExcess and safetyLimit
Mar 28, 2024
9ba70fe
Fix rounding mode
Mar 29, 2024
21de7b2
Merge remote-tracking branch 'origin/main' into release-3.4
ps2 Jul 13, 2024
49feb51
Bump version for release
ps2 Jul 13, 2024
4074b04
Merge pull request #2189 from LoopKit/release-3.4
ps2 Jul 13, 2024
5c3b01f
Bump version to 3.4.1 for release (#2194)
marionbarker Jul 19, 2024
e8a17e5
Merge pull request #13 from LoopKit/dev
motinis Aug 2, 2024
7522d54
Fixes
Aug 23, 2024
79efd20
Separate out recommendation from UI interaction. Fix slowdown too
Aug 23, 2024
a3696e7
Add Diable BG Correction options. Only use carbs and insulin for max …
Aug 24, 2024
546d25c
Handle negative insulin better for COB
Aug 28, 2024
f4345d9
in progress
Sep 23, 2024
35e1063
Xcode 16 profile support for main branch (#2228)
marionbarker Oct 5, 2024
a91352a
Bump version to 3.4.3 (#2236)
marionbarker Oct 6, 2024
20c313c
Patch for Loop 3.4.4 to restore TestFlight expiration date (#2242)
marionbarker Oct 9, 2024
afceef4
Unify code paths. Tests not yet passing
Oct 10, 2024
4d1d0df
After refactoring. Tests passing
Oct 11, 2024
20409ad
Add comment and minor generalization
Oct 11, 2024
ae6fb73
Add test for missing insulin due to suspend threshold effects on dosage
Oct 11, 2024
8c2a86d
Fix display calculations for max and safety limits
Oct 13, 2024
7d781ee
Merge branch 'main-custom' into bolus-breakdown-cob
motinis Oct 25, 2024
f208d25
Add Auto-Bolus Carbs Experiment
Dec 26, 2024
621973d
Add missing tests and fix beneath correction range
Dec 26, 2024
b6dff3f
Support automaticDosingIOBLimit for ABC
Jan 5, 2025
9e4c32a
Fix potential rounding issues that can occur with temp basals
Jan 7, 2025
1ee8993
Refactor so to optimize ABC
Jan 7, 2025
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
15 changes: 14 additions & 1 deletion Common/FeatureFlags.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ struct FeatureFlagConfiguration: Decodable {
let profileExpirationSettingsViewEnabled: Bool
let missedMealNotifications: Bool
let allowAlgorithmExperiments: Bool

let correctionWithCarbBolus: Bool
let bgCorrectionWithCarbBolus: Bool

fileprivate init() {
// Swift compiler config is inverse, since the default state is enabled.
Expand Down Expand Up @@ -232,6 +233,18 @@ struct FeatureFlagConfiguration: Decodable {
#else
self.allowAlgorithmExperiments = false
#endif

#if DISABLE_CORRECTION_WITH_CARB_BOLUS
self.correctionWithCarbBolus = false
#else
self.correctionWithCarbBolus = true
#endif

#if DISABLE_BG_CORRECTION_WITH_CARB_BOLUS
self.bgCorrectionWithCarbBolus = false
#else
self.bgCorrectionWithCarbBolus = true
#endif
}
}

Expand Down
8 changes: 4 additions & 4 deletions Common/Models/BuildDetails.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class BuildDetails {

init() {
guard let url = Bundle.main.url(forResource: "BuildDetails", withExtension: ".plist"),
let data = try? Data(contentsOf: url),
let parsed = try? PropertyListSerialization.propertyList(from: data, format: nil) as? [String: Any] else
let data = try? Data(contentsOf: url),
let parsed = try? PropertyListSerialization.propertyList(from: data, format: nil) as? [String: Any] else
{
dict = [:]
return
Expand Down Expand Up @@ -63,7 +63,7 @@ class BuildDetails {
}

var workspaceGitBranch: String? {
return dict["com-loopkit-LoopWorkspace-git-branch"] as? String
}
return dict["com-loopkit-LoopWorkspace-git-branch"] as? String
}
}

4 changes: 4 additions & 0 deletions Loop.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
12F04F012D19791B002B2121 /* AutoBolusCarbsSelectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12F04F002D197907002B2121 /* AutoBolusCarbsSelectionView.swift */; };
1419606428D9550400BA86E0 /* LoopKitUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 437AFEE6203688CF008C4892 /* LoopKitUI.framework */; };
1419606928D9554E00BA86E0 /* LoopKitUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 437AFEE6203688CF008C4892 /* LoopKitUI.framework */; };
1419606A28D955BC00BA86E0 /* MockKitUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C101947127DD473C004E7EB8 /* MockKitUI.framework */; };
Expand Down Expand Up @@ -743,6 +744,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
12F04F002D197907002B2121 /* AutoBolusCarbsSelectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoBolusCarbsSelectionView.swift; sourceTree = "<group>"; };
142CB7582A60BF2E0075748A /* EditMode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EditMode.swift; sourceTree = "<group>"; };
142CB75A2A60BFC30075748A /* FavoriteFoodsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FavoriteFoodsView.swift; sourceTree = "<group>"; };
1452F4A82A851C9400F8B9E4 /* AddEditFavoriteFoodViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddEditFavoriteFoodViewModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2244,6 +2246,7 @@
43F5C2CF1B92A2ED003EB13D /* Views */ = {
isa = PBXGroup;
children = (
12F04F002D197907002B2121 /* AutoBolusCarbsSelectionView.swift */,
1452F4AA2A851EDF00F8B9E4 /* AddEditFavoriteFoodView.swift */,
B4001CED28CBBC82002FB414 /* AlertManagementView.swift */,
897A5A9524C2175B00C4E71D /* BolusEntryView.swift */,
Expand Down Expand Up @@ -3736,6 +3739,7 @@
149A28E42A8A63A700052EDF /* FavoriteFoodDetailView.swift in Sources */,
1DDE274024AEA4F200796622 /* NotificationsCriticalAlertPermissionsView.swift in Sources */,
A9A056B524B94123007CF06D /* CriticalEventLogExportViewModel.swift in Sources */,
12F04F012D19791B002B2121 /* AutoBolusCarbsSelectionView.swift in Sources */,
434FF1EE1CF27EEF000DB779 /* UITableViewCell.swift in Sources */,
439BED2A1E76093C00B0AED5 /* CGMManager.swift in Sources */,
C16B983E26B4893300256B05 /* DoseEnactor.swift in Sources */,
Expand Down
438 changes: 349 additions & 89 deletions Loop/Managers/LoopDataManager.swift

Large diffs are not rendered by default.

26 changes: 24 additions & 2 deletions Loop/View Controllers/StatusTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,8 @@ final class StatusTableViewController: LoopChartsTableViewController {
} else {
self.currentCOBDescription = nil
}
// FIXME need to trigger an update of this value when the UserDefaults are changed
self.currentAutoBolusCarbsActive = self.deviceManager.loopManager.autoBolusCarbsEnabledAndActive

self.tableView.beginUpdates()
if let hudView = self.hudView {
Expand Down Expand Up @@ -677,6 +679,8 @@ final class StatusTableViewController: LoopChartsTableViewController {
// MARK: COB

private var currentCOBDescription: String?

private var currentAutoBolusCarbsActive = false

// MARK: - Loop Status Section Data

Expand Down Expand Up @@ -1003,7 +1007,15 @@ final class StatusTableViewController: LoopChartsTableViewController {
cell.setChartGenerator(generator: { [weak self] (frame) in
return self?.statusCharts.cobChart(withFrame: frame)?.view
})
cell.setTitleLabelText(label: NSLocalizedString("Active Carbohydrates", comment: "The title of the Carbs On-Board graph"))

let label = NSLocalizedString("Active Carbohydrates", comment: "The title of the Carbs On-Board graph");

// FIXME need to put in place a proper image indicating AutoBolusCarbs
if currentAutoBolusCarbsActive {
cell.setTitleLabelText(label: String(format: "%@ %@", label, "🔸"))
} else {
cell.setTitleLabelText(label: label)
}
}

self.tableView(tableView, updateSubtitleFor: cell, at: indexPath)
Expand Down Expand Up @@ -1165,6 +1177,15 @@ final class StatusTableViewController: LoopChartsTableViewController {
} else {
cell.setSubtitleLabel(label: nil)
}

let label = NSLocalizedString("Active Carbohydrates", comment: "The title of the Carbs On-Board graph");

// FIXME need to put in place a proper image indicating AutoBolusCarbs
if currentAutoBolusCarbsActive {
cell.setTitleLabelText(label: String(format: "%@ %@", label, "🔸"))
} else {
cell.setTitleLabelText(label: label)
}
}
case .hud, .status, .alertWarning:
break
Expand Down Expand Up @@ -1233,7 +1254,7 @@ final class StatusTableViewController: LoopChartsTableViewController {
case .preMeal, .legacyWorkout:
break
default:
let vc = AddEditOverrideTableViewController(glucoseUnit: statusCharts.glucose.glucoseUnit)
let vc = AddEditOverrideTableViewController(glucoseUnit: statusCharts.glucose.glucoseUnit, autoBolusCarbsEnabled: UserDefaults.standard.autoBolusCarbsEnabled)
vc.inputMode = .editOverride(override)
vc.delegate = self
show(vc, sender: tableView.cellForRow(at: indexPath))
Expand Down Expand Up @@ -1342,6 +1363,7 @@ final class StatusTableViewController: LoopChartsTableViewController {
vc.glucoseUnit = statusCharts.glucose.glucoseUnit
vc.overrideHistory = deviceManager.loopManager.overrideHistory.getEvents()
vc.delegate = self
vc.autoBolusCarbsEnabled = UserDefaults.standard.autoBolusCarbsEnabled
case let vc as PredictionTableViewController:
vc.deviceManager = deviceManager
default:
Expand Down
Loading