Skip to content

Read reservoir before bolusing #2

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

Merged
merged 5 commits into from
May 27, 2016
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
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ github "loudnate/LoopKit" ~> 0.3
github "loudnate/xDripG5" ~> 0.4
github "loudnate/SwiftCharts" "loudnate/naterade"
github "mddub/dexcom-share-client-swift" ~> 0.1
github "ps2/rileylink_ios" ~> 0.3
github "ps2/rileylink_ios" "dev"
github "mpurland/Amplitude-iOS" "framework"
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ github "loudnate/Crypto" "e0ef5b498f2c373d676135dabf5d1803b8558509"
github "loudnate/LoopKit" "v0.3.2"
github "loudnate/SwiftCharts" "448b80f4025bbf592a4d8ca9d079e9684bc0b64b"
github "mddub/dexcom-share-client-swift" "v0.1.0"
github "ps2/rileylink_ios" "v0.3.0"
github "ps2/rileylink_ios" "4305a83f897c19bd343c6b4f6fcdaaba0985ea64"
github "loudnate/xDripG5" "0.4.1"
2 changes: 1 addition & 1 deletion Loop/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>0.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
29 changes: 22 additions & 7 deletions Loop/Managers/LoopDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -516,15 +516,30 @@ class LoopDataManager {
return
}

ops.setNormalBolus(units) { (error) in
if let error = error {
self.deviceDataManager.logger?.addError(error, fromSource: "Bolus")
ops.readRemainingInsulin { (result) in
switch result {
case .Success(let unitVolume):
self.deviceDataManager.doseStore.addReservoirValue(unitVolume, atDate: NSDate()) { (_, _, error) in
if let error = error {
self.deviceDataManager.logger?.addError(error, fromSource: "Bolus")
resultsHandler(success: false, error: .CommunicationError)
} else {
ops.setNormalBolus(units) { (error) in
if let error = error {
self.deviceDataManager.logger?.addError(error, fromSource: "Bolus")
resultsHandler(success: false, error: .CommunicationError)
} else {
self.lastBolus = (units: units, date: NSDate())
resultsHandler(success: true, error: nil)
}

self.notify()
}
}
}
case .Failure(let error):
self.deviceDataManager.logger?.addError(error, fromSource: "Bolus")
resultsHandler(success: false, error: .CommunicationError)
} else {
self.lastBolus = (units: units, date: NSDate())

resultsHandler(success: true, error: nil)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion LoopTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>0.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion WatchApp Extension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>0.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion WatchApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>0.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down