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
4 changes: 4 additions & 0 deletions Loop.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
43F78D4E1C914197002152D1 /* InsulinKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 43F78D4A1C914197002152D1 /* InsulinKit.framework */; };
43F78D4F1C914197002152D1 /* LoopKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 43F78D4B1C914197002152D1 /* LoopKit.framework */; };
C10428971D17BAD400DD539A /* NightscoutUploadKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C10428961D17BAD400DD539A /* NightscoutUploadKit.framework */; };
C51F56121D3B91CD004C46ED /* PumpModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C51F56111D3B91CD004C46ED /* PumpModel.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -350,6 +351,7 @@
43F78D4A1C914197002152D1 /* InsulinKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = InsulinKit.framework; path = Carthage/Build/iOS/InsulinKit.framework; sourceTree = "<group>"; };
43F78D4B1C914197002152D1 /* LoopKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LoopKit.framework; path = Carthage/Build/iOS/LoopKit.framework; sourceTree = "<group>"; };
C10428961D17BAD400DD539A /* NightscoutUploadKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NightscoutUploadKit.framework; path = Carthage/Build/iOS/NightscoutUploadKit.framework; sourceTree = "<group>"; };
C51F56111D3B91CD004C46ED /* PumpModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PumpModel.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -573,6 +575,7 @@
43E344A01B9E144300C85C07 /* Extensions */ = {
isa = PBXGroup;
children = (
C51F56111D3B91CD004C46ED /* PumpModel.swift */,
4331E0771C85302200FBE832 /* CGPoint.swift */,
4346D1F51C78501000ABAFE3 /* ChartPoint.swift */,
43649A621C7A347F00523D7F /* CollectionType.swift */,
Expand Down Expand Up @@ -949,6 +952,7 @@
buildActionMask = 2147483647;
files = (
434F54571D287FDB002A9274 /* NibLoadable.swift in Sources */,
C51F56121D3B91CD004C46ED /* PumpModel.swift in Sources */,
4315D28A1CA5F45E00589052 /* DiagnosticLogger+LoopKit.swift in Sources */,
43C418B51CE0575200405B6A /* ShareGlucose+GlucoseKit.swift in Sources */,
434F24C91CFCA8940004498F /* TransmitterGlucose.swift in Sources */,
Expand Down
27 changes: 27 additions & 0 deletions Loop/Extensions/PumpModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// PumpModel.swift
// Loop
//
// Created by Jerermy Lucas on 7/16/16.
// Copyright © 2016 Nathan Racklyeft. All rights reserved.
//

import Foundation
import MinimedKit

extension PumpModel {
private var size: Int {
return Int(rawValue)! / 100
}

var reservoirCapacity: Double {
switch size {
case 5:
return 176
case 7:
return 300
default:
fatalError("Unknown reservoir capacity for PumpModel.\(self)")
}
}
}
7 changes: 6 additions & 1 deletion Loop/View Controllers/StatusTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,12 @@ class StatusTableViewController: UITableViewController, UIGestureRecognizerDeleg
}

reservoirVolume = dataManager.latestReservoirValue?.unitVolume


if let capacity = dataManager.pumpState?.pumpModel?.reservoirCapacity,
resVol = reservoirVolume {
reservoirLevel = min(1, max(0, Double(resVol / capacity)))
}

if let status = dataManager.latestPumpStatus {
reservoirLevel = Double(status.reservoirRemainingPercent) / 100
batteryLevel = Double(status.batteryRemainingPercent) / 100
Expand Down