Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
36a2a53
Omnikit
ps2 Sep 2, 2018
5746df1
Add OmniKit frameworks
ps2 Sep 11, 2018
6988bb8
fix cartfile
ps2 Sep 12, 2018
1b23177
Track lastAddedPumpData, including lastAddedPumpEvents
ps2 Sep 15, 2018
6b4544c
Fix carthage copy frameworks script
ps2 Sep 19, 2018
5e9f41a
rebase
ps2 Sep 20, 2018
096b347
update deps
ps2 Sep 25, 2018
65e3c9e
Initialize setupViewController with existing pump settings
ps2 Sep 26, 2018
2ee5feb
Suspend/Resume
ps2 Sep 28, 2018
ad73ea8
Use normal separator behavior
ps2 Sep 28, 2018
230a441
Reload pump section after adding pumpmanager
ps2 Sep 29, 2018
83f2943
LoopKit PumpManagerStatus updates
ps2 Oct 11, 2018
ff978b4
Merge in dev
ps2 Oct 11, 2018
d0c4a91
PumpManagerUI vended HUD views
ps2 Oct 18, 2018
b2a68e0
Add missing file
ps2 Oct 22, 2018
63932d1
Update to LoopKit naming changes
ps2 Oct 22, 2018
8524093
Push instead of present pumpmanager vended vc in response to HUD view…
ps2 Oct 23, 2018
37ef4aa
Add prep_workspace.sh script
ps2 Oct 23, 2018
996bc3d
HUDProvider updates
ps2 Oct 26, 2018
c32cd8c
Fix hud clearing after removing pump manager. Show boluses that take …
ps2 Oct 31, 2018
76c8f26
PumpManager returns DoseEntry for requested bolus, including duration
ps2 Nov 4, 2018
bdaea1d
Example jumpstart
ps2 Nov 6, 2018
b535cfc
Suspend/Resume with new PumpManager status updates
ps2 Nov 20, 2018
3a12b02
Fix issue with DeviceDataManager missing from issue report
ps2 Nov 26, 2018
b4276a1
Handle LoopKit and rileylink_ios updates
ps2 Dec 2, 2018
511f0c2
Cleanup testing code
ps2 Dec 5, 2018
fb006e5
Update Loop today widget when HUD views change
ps2 Dec 9, 2018
3624d1a
Renaming updates from LoopKit
ps2 Jan 11, 2019
8598af6
Updates for recent LoopKit pumpmanager-changes branch
ps2 Jan 22, 2019
6a9ce73
update prep script for CGMBLEKit branch change
Kdisimone Jan 22, 2019
0334c23
Merge pull request #12 from ps2/Kdisimone-patch-1
ps2 Jan 22, 2019
849916d
Updates for hud provider delegate change
ps2 Jan 29, 2019
a7f89ca
Merge branch 'omnikit' of github.com:ps2/loop-priv into omnikit
ps2 Jan 29, 2019
8a152ee
Pumpmanager updates
ps2 Jan 30, 2019
dd2e2c3
Update prep script
ps2 Jan 30, 2019
a18cfb4
Fix permissions on prep workspace script
ps2 Jan 30, 2019
2683aa5
Merge in dev
ps2 Jan 31, 2019
e22f4b0
Pumpmanager changes
ps2 Feb 2, 2019
c0c2242
Update to pumpmanager-updates
ps2 Feb 3, 2019
7cff7b4
Back out DEVELOPMENT_TEAM settings
ps2 Feb 5, 2019
ebd1e2b
Context object does not need HUDProvider reference
ps2 Feb 5, 2019
ba571a7
Include dose in enactBolus completion
ps2 Feb 5, 2019
e54617a
Bump dependency revisions
ps2 Feb 6, 2019
6a24216
Update HUD set of views only on PumpManager change
ps2 Feb 7, 2019
9a6f219
Merge branch 'pumpmanager-changes' of github.com:LoopKit/Loop into pu…
ps2 Feb 7, 2019
8a893b6
Remove unused file
ps2 Feb 7, 2019
23842de
synchronize deviceDataManager.pumpManagerStatus access
ps2 Feb 8, 2019
9a729c6
Bump dep revisions
ps2 Feb 8, 2019
509573c
Remove unused files
ps2 Feb 8, 2019
26e0ea5
Remove unneeded reloadSections calls
ps2 Feb 8, 2019
3e8f83c
Merge branch 'pumpmanager-changes' of github.com:LoopKit/Loop into pu…
ps2 Feb 8, 2019
14ae518
Fix build issue when carthage is run from Xcode
ps2 Feb 8, 2019
995c3e2
Use bolus end date to clear lastRequestedBolus
ps2 Feb 11, 2019
83b1e2e
present instead of show settings vc
ps2 Feb 11, 2019
82e66f0
small refactorings
ps2 Feb 11, 2019
4f652a8
Improvements from @mpangburn's review
ps2 Feb 13, 2019
2985424
Update active flag on HUDProvider when hud is visible and app is active
ps2 Feb 15, 2019
be5f843
Remove signing team changes
ps2 Feb 15, 2019
9e27c6b
HUDProvider active -> visible
ps2 Feb 16, 2019
7f4fd58
Use LoopKit dev
ps2 Feb 19, 2019
f8e4f58
Use constant for battery replacement detection threshold
ps2 Feb 19, 2019
ee07fcf
Force git protocol 1 to fix travis builds
ps2 Feb 19, 2019
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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ osx_image: xcode10
# xcode_project: Loop.xcodeproj
# xcode_scheme: Loop
before_script:
- git config --global protocol.version 1
- set -o pipefail && xcodebuild -project Loop.xcodeproj -target Cartfile
script:
# Build the app target
Expand Down
11 changes: 5 additions & 6 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

github "LoopKit/LoopKit" == 2.2.1
github "LoopKit/CGMBLEKit" == 3.0
github "LoopKit/LoopKit" "dev"
github "LoopKit/CGMBLEKit" "dev"
github "i-schuetz/SwiftCharts" == 0.6.2
github "LoopKit/dexcom-share-client-swift" == 1.0
github "LoopKit/G4ShareSpy" == 1.0
github "ps2/rileylink_ios" == 2.1.0
github "LoopKit/dexcom-share-client-swift" "dev"
github "LoopKit/G4ShareSpy" "dev"
github "ps2/rileylink_ios" "dev"
github "LoopKit/Amplitude-iOS" "decreepify"
10 changes: 5 additions & 5 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github "LoopKit/Amplitude-iOS" "2137d5fd44bf630ed33e1e72d7af6d8f8612f270"
github "LoopKit/CGMBLEKit" "v3.0"
github "LoopKit/G4ShareSpy" "v1.0"
github "LoopKit/LoopKit" "v2.2.1"
github "LoopKit/dexcom-share-client-swift" "v1.0"
github "LoopKit/CGMBLEKit" "ea1267791c66e884f1013fffd36faf4555cc6eaf"
github "LoopKit/G4ShareSpy" "fed5a389e3e47e3a1953878dd21852aa5f44b360"
github "LoopKit/LoopKit" "bf4166bc77f89e22971f2030ad006967881ff082"
github "LoopKit/dexcom-share-client-swift" "b0419edf55c7f389b36cb47dd5c376bbd3d03d69"
github "i-schuetz/SwiftCharts" "0.6.2"
github "ps2/rileylink_ios" "v2.1.0"
github "ps2/rileylink_ios" "46ed2c845e7c4b88c721994d8e8432e86be4c699"
File renamed without changes.
37 changes: 37 additions & 0 deletions Common/Models/PumpManagerUI.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// PumpManagerUI.swift
// Loop
//
// Created by Pete Schwamb on 10/18/18.
// Copyright © 2018 LoopKit Authors. All rights reserved.
//

import Foundation
import LoopKit
import LoopKitUI
import MinimedKit
import MinimedKitUI

private let managersByIdentifier: [String: PumpManagerUI.Type] = allPumpManagers.compactMap{ $0 as? PumpManagerUI.Type}.reduce(into: [:]) { (map, Type) in
map[Type.managerIdentifier] = Type
}

typealias PumpManagerHUDViewsRawValue = [String: Any]

func PumpManagerHUDViewsFromRawValue(_ rawValue: PumpManagerHUDViewsRawValue) -> [BaseHUDView]? {
guard let rawState = rawValue["hudProviderViews"] as? HUDProvider.HUDViewsRawState,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are your thoughts regarding making these raw strings as constants to avoid typos and such?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the current pattern of RawRepresentable use in Loop rarely defines constants for raw strings. Probably a good idea to begin that transition.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I've had typos cause issues while developing. Constants don't completely prevent that (you can still use the wrong constant!), and create more clutter. I'm not opposed to it; I just question if it's really worth it.

let managerIdentifier = rawValue["managerIdentifier"] as? String,
let manager = managersByIdentifier[managerIdentifier]
else {
return nil
}

return manager.createHUDViews(rawValue: rawState)
}

func PumpManagerHUDViewsRawValueFromHudProvider(_ hudProvider: HUDProvider) -> PumpManagerHUDViewsRawValue {
return [
"managerIdentifier": hudProvider.managerIdentifier,
"hudProviderViews": hudProvider.hudViewsRawState
]
}
34 changes: 34 additions & 0 deletions Common/Models/StatusExtensionContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import Foundation
import HealthKit
import LoopKit
import LoopKitUI


struct NetBasalContext {
Expand Down Expand Up @@ -151,6 +152,32 @@ extension PredictedGlucoseContext: RawRepresentable {
}
}

struct PumpManagerHUDViewsContext: RawRepresentable {
typealias RawValue = [String: Any]

let pumpManagerHUDViewsRawValue: PumpManagerHUDViewsRawValue

var hudViews: [BaseHUDView]? {
return PumpManagerHUDViewsFromRawValue(pumpManagerHUDViewsRawValue)
}

init(pumpManagerHUDViewsRawValue: PumpManagerHUDViewsRawValue) {
self.pumpManagerHUDViewsRawValue = pumpManagerHUDViewsRawValue
}

init?(rawValue: RawValue) {
if let pumpManagerHUDViewsRawValue = rawValue["pumpManagerHUDViewsRawValue"] as? PumpManagerHUDViewsRawValue {
self.pumpManagerHUDViewsRawValue = pumpManagerHUDViewsRawValue
} else {
return nil
}
}

var rawValue: RawValue {
return ["pumpManagerHUDViewsRawValue": pumpManagerHUDViewsRawValue]
}
}

struct StatusExtensionContext: RawRepresentable {
typealias RawValue = [String: Any]
private let version = 5
Expand All @@ -161,6 +188,7 @@ struct StatusExtensionContext: RawRepresentable {
var batteryPercentage: Double?
var reservoirCapacity: Double?
var sensor: SensorDisplayableContext?
var pumpManagerHUDViewsContext: PumpManagerHUDViewsContext?

init() { }

Expand All @@ -184,6 +212,10 @@ struct StatusExtensionContext: RawRepresentable {
if let rawValue = rawValue["sensor"] as? SensorDisplayableContext.RawValue {
sensor = SensorDisplayableContext(rawValue: rawValue)
}

if let rawPumpManagerHUDViewsContext = rawValue["pumpManagerHUDViewsContext"] as? PumpManagerHUDViewsContext.RawValue {
pumpManagerHUDViewsContext = PumpManagerHUDViewsContext(rawValue: rawPumpManagerHUDViewsContext)
}
}

var rawValue: RawValue {
Expand All @@ -197,6 +229,8 @@ struct StatusExtensionContext: RawRepresentable {
raw["batteryPercentage"] = batteryPercentage
raw["reservoirCapacity"] = reservoirCapacity
raw["sensor"] = sensor?.rawValue
raw["pumpManagerHUDViewsContext"] = pumpManagerHUDViewsContext?.rawValue

return raw
}
}
Expand Down
1 change: 1 addition & 0 deletions Loop Status Extension/StateColorPalette.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import LoopUI
import LoopKitUI

extension StateColorPalette {
static let loopStatus = StateColorPalette(unknown: .unknownColor, normal: .freshColor, warning: .agingColor, error: .staleColor)
Expand Down
32 changes: 13 additions & 19 deletions Loop Status Extension/StatusViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import CoreData
import HealthKit
import LoopKit
import LoopKitUI
import LoopUI
import NotificationCenter
import UIKit
Expand All @@ -22,8 +23,6 @@ class StatusViewController: UIViewController, NCWidgetProviding {
hudView.glucoseHUD.stateColors = .cgmStatus
hudView.glucoseHUD.tintColor = .glucoseTintColor
hudView.basalRateHUD.tintColor = .doseTintColor
hudView.reservoirVolumeHUD.stateColors = .pumpStatus
hudView.batteryHUD.stateColors = .pumpStatus
}
}
@IBOutlet weak var subtitleLabel: UILabel!
Expand Down Expand Up @@ -159,7 +158,6 @@ class StatusViewController: UIViewController, NCWidgetProviding {
let group = DispatchGroup()

var activeInsulin: Double?
var lastReservoirValue: ReservoirValue?
var glucose: [StoredGlucoseSample] = []

group.enter()
Expand All @@ -173,17 +171,6 @@ class StatusViewController: UIViewController, NCWidgetProviding {
group.leave()
}

group.enter()
doseStore.getReservoirValues(since: .distantPast, limit: 1) { (result) in
switch result {
case .success(let values):
lastReservoirValue = values.first
case .failure:
lastReservoirValue = nil
}
group.leave()
}

charts.startDate = Calendar.current.nextDate(after: Date(timeIntervalSinceNow: .minutes(-5)), matching: DateComponents(minute: 0), matchingPolicy: .strict, direction: .backward) ?? Date()

// Showing the whole history plus full prediction in the glucose plot
Expand All @@ -201,13 +188,20 @@ class StatusViewController: UIViewController, NCWidgetProviding {
return
}

if let batteryPercentage = context.batteryPercentage {
self.hudView.batteryHUD.batteryLevel = Double(batteryPercentage)
let hudViews: [BaseHUDView]

if let hudViewsContext = context.pumpManagerHUDViewsContext,
let contextHUDViews = hudViewsContext.hudViews
{
hudViews = contextHUDViews
} else {
hudViews = [ReservoirVolumeHUDView.instantiate(), BatteryLevelHUDView.instantiate()]
}

if let reservoir = lastReservoirValue, let capacity = context.reservoirCapacity {
self.hudView.reservoirVolumeHUD.reservoirLevel = min(1, max(0, Double(reservoir.unitVolume / capacity)))
self.hudView.reservoirVolumeHUD.setReservoirVolume(volume: reservoir.unitVolume, at: reservoir.startDate)
self.hudView.removePumpManagerProvidedViews()
for view in hudViews {
view.stateColors = .pumpStatus
self.hudView.addHUDView(view)
}

if let netBasal = context.netBasal {
Expand Down
Loading