Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
b0ed4a3
Configurable minimum bg guard.
ps2 Jan 2, 2017
b8c34d8
Fix display issues, and clear out stored value when user deletes entr…
ps2 Jan 2, 2017
f6366c2
Return recommendation structure
ps2 Jan 2, 2017
8879699
Adding more context to bolus screen
ps2 Jan 3, 2017
7e1878a
Update bolus notices.
ps2 Jan 3, 2017
2d3d80a
another rev of the bolus ui, showing eventualbg, iob, pending insulin…
ps2 Jan 8, 2017
160e55c
Update tests
ps2 Jan 8, 2017
291e39d
Update tests
ps2 Jan 8, 2017
78b9bae
Configurable minimum bg guard.
ps2 Jan 2, 2017
09202d7
Fix display issues, and clear out stored value when user deletes entr…
ps2 Jan 2, 2017
9326033
Return recommendation structure
ps2 Jan 2, 2017
300d8c9
Adding more context to bolus screen
ps2 Jan 3, 2017
bdc7bd5
Update bolus notices.
ps2 Jan 3, 2017
29ef816
another rev of the bolus ui, showing eventualbg, iob, pending insulin…
ps2 Jan 8, 2017
920beb8
Update tests
ps2 Jan 8, 2017
fc16ca2
Update tests
ps2 Jan 8, 2017
72bab42
DoseMath.recommendBolusFromPredictedGlucose doesn't take lastTempBasal
ps2 Jan 8, 2017
5ed8473
merge
ps2 Jan 8, 2017
36975c1
merge in dev
ps2 Jan 8, 2017
2edfb70
Add HKUnit to DoseMathTests
ps2 Jan 8, 2017
43ddd5f
Move BolusRecommendation notice to enum
ps2 Jan 8, 2017
8e8dcd5
Revert defaultAbsorptionTimes
ps2 Jan 8, 2017
1fe7520
Avoid rounding above pump delivery resolution for small boluses
ps2 Jan 8, 2017
beed2ac
Assume the entirety of BolusViewController is not thread-safe, and do…
ps2 Jan 8, 2017
30acbe8
Make loopManager.getPendingInsulin private, and pass pending insulin …
ps2 Jan 8, 2017
9560db6
Use NumberFormatter.glucoseFormatter for glucose display when setting…
ps2 Jan 8, 2017
662eea9
Use DateComponentsFormatter for formatting age in minutes
ps2 Jan 8, 2017
49fa0a9
Use if case for single enum comparisons
ps2 Jan 9, 2017
7b01253
Avoid reloading tableview with static cells
ps2 Jan 12, 2017
7b72b56
Add new method for displaying glucose with units.
ps2 Feb 11, 2017
6ec4f65
Add warning symbol
ps2 Feb 11, 2017
63e0e0a
Warning symbol was showing unecessarily in some cases
ps2 Feb 11, 2017
87e78b3
Merge in dev
ps2 Feb 13, 2017
19f9a4b
Update minimumBGGuard for new settings layout
ps2 Feb 13, 2017
41ed12e
remove debug print
ps2 Feb 13, 2017
59ac40d
Remove unnecessary dispatches
ps2 Feb 13, 2017
710b75a
Let date components formatter add units string.
ps2 Feb 13, 2017
035d964
Unify how notice label is set
ps2 Feb 13, 2017
97629cd
Add resizing constraints to notice label
ps2 Feb 14, 2017
1acd876
Store age errors as dates for more accurate error messaging
ps2 Feb 19, 2017
4a3831d
Merge in dev
ps2 Feb 19, 2017
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
Prev Previous commit
Next Next commit
Return recommendation structure
  • Loading branch information
ps2 committed Jan 2, 2017
commit f6366c2218178b840bbd7f3e95f2417b7d69a53d
68 changes: 52 additions & 16 deletions DoseMathTests/DoseMathTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,11 @@ class RecommendBolusTests: XCTestCase {
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule,
pendingBolusAmount: 0,
minimumBGGuard: minimumBGGuard
)

XCTAssertEqual(0, dose)
XCTAssertEqual(0, dose.amount)
}

func testStartHighEndInRange() {
Expand All @@ -483,10 +484,11 @@ class RecommendBolusTests: XCTestCase {
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule,
pendingBolusAmount: 0,
minimumBGGuard: minimumBGGuard
)

XCTAssertEqual(0, dose)
XCTAssertEqual(0, dose.amount)

// Don't consider net-negative temp basal
let lastTempBasal = DoseEntry(
Expand All @@ -504,10 +506,11 @@ class RecommendBolusTests: XCTestCase {
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule,
pendingBolusAmount: 0,
minimumBGGuard: minimumBGGuard
)

XCTAssertEqual(0, dose)
XCTAssertEqual(0, dose.amount)
}

func testStartLowEndInRange() {
Expand All @@ -520,10 +523,11 @@ class RecommendBolusTests: XCTestCase {
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule,
pendingBolusAmount: 0,
minimumBGGuard: minimumBGGuard
)

XCTAssertEqual(0, dose)
XCTAssertEqual(0, dose.amount)
}

func testStartHighEndLow() {
Expand All @@ -536,10 +540,11 @@ class RecommendBolusTests: XCTestCase {
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule,
pendingBolusAmount: 0,
minimumBGGuard: minimumBGGuard
)

XCTAssertEqual(0, dose)
XCTAssertEqual(0, dose.amount)
}

func testStartLowEndHigh() {
Expand All @@ -552,10 +557,28 @@ class RecommendBolusTests: XCTestCase {
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule,
pendingBolusAmount: 0,
minimumBGGuard: minimumBGGuard
)

XCTAssertEqual(1.325, dose)
XCTAssertEqual(1.325, dose.amount)
}

func testStartLowEndHighWithPendingBolus() {
let glucose = loadGlucoseValueFixture("recommend_temp_basal_start_low_end_high")

let dose = DoseMath.recommendBolusFromPredictedGlucose(glucose,
atDate: glucose.first!.startDate,
lastTempBasal: nil,
maxBolus: maxBolus,
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule,
pendingBolusAmount: 1,
minimumBGGuard: minimumBGGuard
)

XCTAssertEqual(0.325, dose.amount)
}

func testStartVeryLowEndHigh() {
Expand All @@ -568,10 +591,11 @@ class RecommendBolusTests: XCTestCase {
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule,
pendingBolusAmount: 0,
minimumBGGuard: minimumBGGuard
)

XCTAssertEqual(0, dose)
XCTAssertEqual(0, dose.amount)
}

func testFlatAndHigh() {
Expand All @@ -584,10 +608,11 @@ class RecommendBolusTests: XCTestCase {
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule,
pendingBolusAmount: 0,
minimumBGGuard: minimumBGGuard
)

XCTAssertEqualWithAccuracy(1.333, dose, accuracy: 1.0 / 40.0)
XCTAssertEqualWithAccuracy(1.333, dose.amount, accuracy: 1.0 / 40.0)
}

func testHighAndFalling() {
Expand All @@ -600,10 +625,11 @@ class RecommendBolusTests: XCTestCase {
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule,
pendingBolusAmount: 0,
minimumBGGuard: minimumBGGuard
)

XCTAssertEqualWithAccuracy(0.067, dose, accuracy: 1.0 / 40.0)
XCTAssertEqualWithAccuracy(0.067, dose.amount, accuracy: 1.0 / 40.0)
}

func testInRangeAndRising() {
Expand All @@ -616,10 +642,11 @@ class RecommendBolusTests: XCTestCase {
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule,
pendingBolusAmount: 0,
minimumBGGuard: minimumBGGuard
)

XCTAssertEqualWithAccuracy(0.083, dose, accuracy: 1.0 / 40.0)
XCTAssertEqualWithAccuracy(0.083, dose.amount, accuracy: 1.0 / 40.0)

// Less existing temp
var lastTempBasal = DoseEntry(
Expand All @@ -637,10 +664,11 @@ class RecommendBolusTests: XCTestCase {
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule,
pendingBolusAmount: 0,
minimumBGGuard: minimumBGGuard
)

XCTAssertEqualWithAccuracy(0, dose, accuracy: 1e-13)
XCTAssertEqualWithAccuracy(0, dose.amount, accuracy: 1e-13)

// But not a finished temp
lastTempBasal = DoseEntry(
Expand All @@ -658,10 +686,11 @@ class RecommendBolusTests: XCTestCase {
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule,
pendingBolusAmount: 0,
minimumBGGuard: minimumBGGuard
)

XCTAssertEqualWithAccuracy(0.083, dose, accuracy: 1.0 / 40.0)
XCTAssertEqualWithAccuracy(0.083, dose.amount, accuracy: 1.0 / 40.0)
}

func testHighAndRising() {
Expand All @@ -674,10 +703,11 @@ class RecommendBolusTests: XCTestCase {
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: self.insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule,
pendingBolusAmount: 0,
minimumBGGuard: minimumBGGuard
)

XCTAssertEqual(1.0, dose)
XCTAssertEqual(1.0, dose.amount)

// Use mmol sensitivity value
let insulinSensitivitySchedule = InsulinSensitivitySchedule(unit: HKUnit.millimolesPerLiterUnit(), dailyItems: [RepeatingScheduleValue(startTime: 0.0, value: 10.0 / 3)])!
Expand All @@ -689,18 +719,24 @@ class RecommendBolusTests: XCTestCase {
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule,
pendingBolusAmount: 0,
minimumBGGuard: minimumBGGuard
)

XCTAssertEqualWithAccuracy(1.0, dose, accuracy: 1.0 / 40.0)
XCTAssertEqualWithAccuracy(1.0, dose.amount, accuracy: 1.0 / 40.0)
}

func testNoInputGlucose() {
let dose = DoseMath.recommendBolusFromPredictedGlucose([], lastTempBasal: nil, maxBolus: 4, glucoseTargetRange: glucoseTargetRange, insulinSensitivity: insulinSensitivitySchedule,
let dose = DoseMath.recommendBolusFromPredictedGlucose([],
lastTempBasal: nil,
maxBolus: 4,
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule,
pendingBolusAmount: 0,
minimumBGGuard: minimumBGGuard)

XCTAssertEqual(0, dose)
XCTAssertEqual(0, dose.amount)
}

}
12 changes: 9 additions & 3 deletions Loop.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@
C17824A01E19CF9800D9D25C /* GlucoseThresholdTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C178249F1E19CF9800D9D25C /* GlucoseThresholdTableViewController.swift */; };
C17824A11E19E8C200D9D25C /* GlucoseThreshold.swift in Sources */ = {isa = PBXBuildFile; fileRef = C178249D1E19B62300D9D25C /* GlucoseThreshold.swift */; };
C17824A31E19EAB600D9D25C /* recommend_temp_basal_start_very_low_end_high.json in Resources */ = {isa = PBXBuildFile; fileRef = C17824A21E19EAB600D9D25C /* recommend_temp_basal_start_very_low_end_high.json */; };
C17824A51E1AD4D100D9D25C /* BolusRecommendation.swift in Sources */ = {isa = PBXBuildFile; fileRef = C17824A41E1AD4D100D9D25C /* BolusRecommendation.swift */; };
C17824A61E1AF91F00D9D25C /* BolusRecommendation.swift in Sources */ = {isa = PBXBuildFile; fileRef = C17824A41E1AD4D100D9D25C /* BolusRecommendation.swift */; };
C17884631D51A7A400405663 /* BatteryIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C17884621D51A7A400405663 /* BatteryIndicator.swift */; };
C18C8C511D5A351900E043FB /* NightscoutDataManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C18C8C501D5A351900E043FB /* NightscoutDataManager.swift */; };
C1C73EF71DE3D0230022FC89 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = C1C73EF91DE3D0230022FC89 /* InfoPlist.strings */; };
Expand Down Expand Up @@ -480,6 +482,7 @@
C178249D1E19B62300D9D25C /* GlucoseThreshold.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GlucoseThreshold.swift; sourceTree = "<group>"; };
C178249F1E19CF9800D9D25C /* GlucoseThresholdTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GlucoseThresholdTableViewController.swift; sourceTree = "<group>"; };
C17824A21E19EAB600D9D25C /* recommend_temp_basal_start_very_low_end_high.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = recommend_temp_basal_start_very_low_end_high.json; sourceTree = "<group>"; };
C17824A41E1AD4D100D9D25C /* BolusRecommendation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BolusRecommendation.swift; sourceTree = "<group>"; };
C17884621D51A7A400405663 /* BatteryIndicator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BatteryIndicator.swift; sourceTree = "<group>"; };
C18C8C501D5A351900E043FB /* NightscoutDataManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NightscoutDataManager.swift; sourceTree = "<group>"; };
C1C73EF81DE3D0230022FC89 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/InfoPlist.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -603,6 +606,7 @@
43C418B41CE0575200405B6A /* ShareGlucose+GlucoseKit.swift */,
4328E0311CFC068900E199AA /* WatchContext+LoopKit.swift */,
C178249D1E19B62300D9D25C /* GlucoseThreshold.swift */,
C17824A41E1AD4D100D9D25C /* BolusRecommendation.swift */,
);
path = Models;
sourceTree = "<group>";
Expand Down Expand Up @@ -1081,7 +1085,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0810;
LastUpgradeCheck = 0820;
ORGANIZATIONNAME = "LoopKit Authors";
TargetAttributes = {
43776F8B1B8022E90074EA36 = {
Expand Down Expand Up @@ -1294,6 +1298,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C17824A51E1AD4D100D9D25C /* BolusRecommendation.swift in Sources */,
4F70C2131DE90339006380B7 /* StatusExtensionContext.swift in Sources */,
434F54571D287FDB002A9274 /* NibLoadable.swift in Sources */,
4315D28A1CA5F45E00589052 /* DiagnosticLogger+LoopKit.swift in Sources */,
Expand Down Expand Up @@ -1413,6 +1418,7 @@
43E2D8DC1D20C049004DA55F /* DoseMath.swift in Sources */,
43E2D8DB1D20C03B004DA55F /* NSTimeInterval.swift in Sources */,
43E2D8D41D20BF42004DA55F /* DoseMathTests.swift in Sources */,
C17824A61E1AF91F00D9D25C /* BolusRecommendation.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1900,7 +1906,7 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CODE_SIGN_IDENTITY = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -1927,7 +1933,7 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CODE_SIGN_IDENTITY = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
LastUpgradeVersion = "0820"
version = "2.0">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
LastUpgradeVersion = "0820"
wasCreatedForAppExtension = "YES"
version = "2.0">
<BuildAction
Expand Down
2 changes: 1 addition & 1 deletion Loop.xcodeproj/xcshareddata/xcschemes/Loop.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Loop.xcodeproj/xcshareddata/xcschemes/LoopTests.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
LastUpgradeVersion = "0820"
version = "2.0">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Loop.xcodeproj/xcshareddata/xcschemes/WatchApp.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Loading