Skip to content

Tidepool Merge #15

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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 MinimedKit/PumpManager/EnliteSensorDisplayable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
import HealthKit
import LoopKit

import LoopAlgorithm

struct EnliteSensorDisplayable: Equatable, GlucoseDisplayable {
public let isStateValid: Bool
Expand Down
16 changes: 10 additions & 6 deletions MinimedKit/PumpManager/MinimedPumpManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public protocol MinimedPumpManagerStateObserver: AnyObject {

public class MinimedPumpManager: RileyLinkPumpManager {

public static let pluginIdentifier = "Minimed500"
public static let managerIdentifier = "Minimed500"

public var pluginIdentifier: String { Self.managerIdentifier }

// Primarily used for testing
public let dateGenerator: () -> Date
Expand All @@ -28,7 +30,7 @@ public class MinimedPumpManager: RileyLinkPumpManager {
self.dateGenerator = dateGenerator

self.hkDevice = HKDevice(
name: MinimedPumpManager.pluginIdentifier,
name: MinimedPumpManager.managerIdentifier,
manufacturer: "Medtronic",
model: state.pumpModel.rawValue,
hardwareVersion: nil,
Expand Down Expand Up @@ -489,7 +491,7 @@ extension MinimedPumpManager {
}

private static var pumpBatteryLowAlertIdentifier: Alert.Identifier {
return Alert.Identifier(managerIdentifier: pluginIdentifier, alertIdentifier: "PumpBatteryLow")
return Alert.Identifier(managerIdentifier: managerIdentifier, alertIdentifier: "PumpBatteryLow")
}

private var pumpBatteryLowAlert: Alert {
Expand Down Expand Up @@ -554,7 +556,7 @@ extension MinimedPumpManager {
}

private static var pumpReservoirEmptyAlertIdentifier: Alert.Identifier {
return Alert.Identifier(managerIdentifier: pluginIdentifier, alertIdentifier: "PumpReservoirEmpty")
return Alert.Identifier(managerIdentifier: managerIdentifier, alertIdentifier: "PumpReservoirEmpty")
}

private var pumpReservoirEmptyAlert: Alert {
Expand All @@ -565,7 +567,7 @@ extension MinimedPumpManager {
}

private static var pumpReservoirLowAlertIdentifier: Alert.Identifier {
return Alert.Identifier(managerIdentifier: pluginIdentifier, alertIdentifier: "PumpReservoirLow")
return Alert.Identifier(managerIdentifier: managerIdentifier, alertIdentifier: "PumpReservoirLow")
}

private func pumpReservoirLowAlertForAmount(_ units: Double, andTimeRemaining remaining: TimeInterval?) -> Alert {
Expand Down Expand Up @@ -755,9 +757,11 @@ extension MinimedPumpManager {

// During reconciliation, some pump events may be reconciled as pending doses and removed. Remaining events should be annotated with current insulinType
let remainingHistoryEvents = self.reconcilePendingDosesWith(newPumpEvents, fetchedAt: self.dateGenerator()).map { (event) -> NewPumpEvent in
var dose = event.dose
dose?.insulinType = insulinType
return NewPumpEvent(
date: event.date,
dose: event.dose?.annotated(with: insulinType),
dose: dose,
raw: event.raw,
title: event.title,
type: event.type)
Expand Down
2 changes: 1 addition & 1 deletion MinimedKitUI/MinimedHUDProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import SwiftUI
class MinimedHUDProvider: HUDProvider {

var managerIdentifier: String {
return MinimedPumpManager.pluginIdentifier
return MinimedPumpManager.managerIdentifier
}

private var state: MinimedPumpManagerState {
Expand Down
10 changes: 5 additions & 5 deletions MinimedKitUI/Views/MinimedPumpSettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class MinimedPumpSettingsViewModel: ObservableObject {
switch basalDeliveryState {
case .active(_), .initiatingTempBasal:
return true
case .tempBasal(_), .cancelingTempBasal, .suspending, .suspended(_), .resuming, .none:
default:
return false
}
}
Expand All @@ -188,15 +188,15 @@ class MinimedPumpSettingsViewModel: ObservableObject {

var basalDeliveryRate: Double? {
switch basalDeliveryState {
case .suspending, .resuming, .suspended, .none, .initiatingTempBasal, .cancelingTempBasal:
return nil
case .active:
// return scheduled basal rate
var calendar = Calendar(identifier: .gregorian)
calendar.timeZone = pumpManager.state.timeZone
return pumpManager.state.basalSchedule.currentRate(using: calendar)
case .tempBasal(let dose):
return dose.unitsPerHour
default:
return nil
}
}

Expand Down Expand Up @@ -273,7 +273,7 @@ extension PumpManagerStatus.BasalDeliveryState {

var shownAction: SuspendResumeAction {
switch self {
case .active, .suspending, .tempBasal, .cancelingTempBasal, .initiatingTempBasal:
case .active, .suspending, .tempBasal, .cancelingTempBasal, .initiatingTempBasal, .pumpInoperable:
return .suspend
case .suspended, .resuming:
return .resume
Expand All @@ -286,7 +286,7 @@ extension PumpManagerStatus.BasalDeliveryState {
return LocalizedString("Suspend Delivery", comment: "Title text for button to suspend insulin delivery")
case .suspending:
return LocalizedString("Suspending", comment: "Title text for button when insulin delivery is in the process of being stopped")
case .suspended:
case .suspended, .pumpInoperable:
return LocalizedString("Resume Delivery", comment: "Title text for button to resume insulin delivery")
case .resuming:
return LocalizedString("Resuming", comment: "Title text for button when insulin delivery is in the process of being resumed")
Expand Down