From f290ed302b596e63be13660866ae9c728e9e7502 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 25 Jun 2018 15:58:59 -0700 Subject: [PATCH] Refactor Common Models into a more consistent paradigm with more clearly defined semantics. 1. Contexts - one way data from Loop to the Status & Watch extensions 2. Settings - internal only models used to store Loop settings 3. Types - largely internal enums 4. UserInfos - dictionaries passed back from the watch to Loop --- Common/Extensions/NSUserDefaults.swift | 4 +- Common/Extensions/UserDefaults+CGM.swift | 4 +- Common/Models/Contexts/GlucoseContext.swift | 21 ++ Common/Models/Contexts/NetBasalContext.swift | 45 ++++ .../Contexts/PredictedGlucoseContext.swift | 56 +++++ .../Contexts/SensorDisplayableContext.swift | 61 ++++++ .../Contexts/StatusExtensionContext.swift | 67 ++++++ .../Models/{ => Contexts}/WatchContext.swift | 26 +-- .../GlucoseThresholdSetting.swift} | 27 ++- .../InsulinModelSettings.swift | 8 +- .../Models/{ => Settings}/LoopSettings.swift | 6 +- Common/Models/StatusExtensionContext.swift | 207 ------------------ Common/Models/Types/AbsorptionTimeType.swift | 45 ++++ .../Models/{CGM.swift => Types/CGMType.swift} | 21 +- .../ExponentialInsulinModelPresetType.swift} | 10 +- .../GlucoseTrendType.swift} | 2 +- .../BolusSuggestionUserInfo.swift | 13 +- .../{ => UserInfos}/CarbEntryUserInfo.swift | 43 +--- ...GlucoseRangeScheduleOverrideUserInfo.swift | 3 +- .../{ => UserInfos}/SetBolusUserInfo.swift | 0 .../{Insulin => }/WalshInsulinModel.swift | 0 Loop.xcodeproj/project.pbxproj | 142 ++++++++---- Loop/Managers/CGM/CGMManager.swift | 2 +- Loop/Managers/DeviceDataManager.swift | 2 +- Loop/Managers/WatchDataManager.swift | 7 +- Loop/Models/EnliteSensorDisplayable.swift | 4 +- Loop/Models/Glucose.swift | 2 +- Loop/Models/GlucoseG4.swift | 4 +- .../MySentryPumpStatusMessageBody.swift | 2 +- Loop/Models/ShareGlucose+GlucoseKit.swift | 4 +- Loop/Models/WatchContext+LoopKit.swift | 22 -- .../InsulinModelSettingsViewController.swift | 14 +- .../SettingsTableViewController.swift | 2 +- LoopUI/Models/SensorDisplayable.swift | 2 +- WatchApp Extension/ExtensionDelegate.swift | 2 +- .../Extensions/CLKComplicationTemplate.swift | 2 +- .../Extensions/WatchContext+WatchApp.swift | 4 +- 37 files changed, 479 insertions(+), 407 deletions(-) create mode 100644 Common/Models/Contexts/GlucoseContext.swift create mode 100644 Common/Models/Contexts/NetBasalContext.swift create mode 100644 Common/Models/Contexts/PredictedGlucoseContext.swift create mode 100644 Common/Models/Contexts/SensorDisplayableContext.swift create mode 100644 Common/Models/Contexts/StatusExtensionContext.swift rename Common/Models/{ => Contexts}/WatchContext.swift (90%) rename Common/Models/{GlucoseThreshold.swift => Settings/GlucoseThresholdSetting.swift} (70%) rename Common/Models/{Insulin => Settings}/InsulinModelSettings.swift (90%) rename Common/Models/{ => Settings}/LoopSettings.swift (93%) delete mode 100644 Common/Models/StatusExtensionContext.swift create mode 100644 Common/Models/Types/AbsorptionTimeType.swift rename Common/Models/{CGM.swift => Types/CGMType.swift} (83%) rename Common/Models/{Insulin/ExponentialInsulinModelPreset.swift => Types/ExponentialInsulinModelPresetType.swift} (89%) rename Common/Models/{GlucoseTrend.swift => Types/GlucoseTrendType.swift} (97%) rename Common/Models/{ => UserInfos}/BolusSuggestionUserInfo.swift (76%) rename Common/Models/{ => UserInfos}/CarbEntryUserInfo.swift (60%) rename Common/Models/{ => UserInfos}/GlucoseRangeScheduleOverrideUserInfo.swift (98%) rename Common/Models/{ => UserInfos}/SetBolusUserInfo.swift (100%) rename Common/Models/{Insulin => }/WalshInsulinModel.swift (100%) delete mode 100644 Loop/Models/WatchContext+LoopKit.swift diff --git a/Common/Extensions/NSUserDefaults.swift b/Common/Extensions/NSUserDefaults.swift index 4ba5a594f5..41cc3ae6a8 100644 --- a/Common/Extensions/NSUserDefaults.swift +++ b/Common/Extensions/NSUserDefaults.swift @@ -103,9 +103,9 @@ extension UserDefaults { glucoseTargetRangeSchedule = nil } - let suspendThreshold: GlucoseThreshold? + let suspendThreshold: GlucoseThresholdSetting? if let rawValue = dictionary(forKey: "com.loopkit.Loop.MinimumBGGuard") { - suspendThreshold = GlucoseThreshold(rawValue: rawValue) + suspendThreshold = GlucoseThresholdSetting(rawValue: rawValue) } else { suspendThreshold = nil } diff --git a/Common/Extensions/UserDefaults+CGM.swift b/Common/Extensions/UserDefaults+CGM.swift index ca286bcef3..b2fcf92fbf 100644 --- a/Common/Extensions/UserDefaults+CGM.swift +++ b/Common/Extensions/UserDefaults+CGM.swift @@ -13,10 +13,10 @@ extension UserDefaults { case cgmSettings = "com.loopkit.Loop.cgmSettings" } - var cgm: CGM? { + var cgm: CGMType? { get { if let rawValue = dictionary(forKey: Key.cgmSettings.rawValue) { - return CGM(rawValue: rawValue) + return CGMType(rawValue: rawValue) } else { return nil } diff --git a/Common/Models/Contexts/GlucoseContext.swift b/Common/Models/Contexts/GlucoseContext.swift new file mode 100644 index 0000000000..c135bec979 --- /dev/null +++ b/Common/Models/Contexts/GlucoseContext.swift @@ -0,0 +1,21 @@ +// +// GlucoseContext.swift +// Loop +// +// Created by Bharat Mediratta on 6/25/18. +// Copyright © 2018 LoopKit Authors. All rights reserved. +// + +import Foundation +import HealthKit + + +struct GlucoseContext { + let value: Double + let unit: HKUnit + let startDate: Date + + var quantity: HKQuantity { + return HKQuantity(unit: unit, doubleValue: value) + } +} diff --git a/Common/Models/Contexts/NetBasalContext.swift b/Common/Models/Contexts/NetBasalContext.swift new file mode 100644 index 0000000000..d77b0a009f --- /dev/null +++ b/Common/Models/Contexts/NetBasalContext.swift @@ -0,0 +1,45 @@ +// +// NetBasalContext.swift +// Loop +// +// Created by Bharat Mediratta on 6/25/18. +// Copyright © 2018 LoopKit Authors. All rights reserved. +// + +import Foundation + +struct NetBasalContext { + let rate: Double + let percentage: Double + let start: Date + let end: Date +} + +extension NetBasalContext: RawRepresentable { + typealias RawValue = [String: Any] + + var rawValue: RawValue { + return [ + "rate": rate, + "percentage": percentage, + "start": start, + "end": end + ] + } + + init?(rawValue: RawValue) { + guard + let rate = rawValue["rate"] as? Double, + let percentage = rawValue["percentage"] as? Double, + let start = rawValue["start"] as? Date, + let end = rawValue["end"] as? Date + else { + return nil + } + + self.rate = rate + self.percentage = percentage + self.start = start + self.end = end + } +} diff --git a/Common/Models/Contexts/PredictedGlucoseContext.swift b/Common/Models/Contexts/PredictedGlucoseContext.swift new file mode 100644 index 0000000000..d75d80fc2a --- /dev/null +++ b/Common/Models/Contexts/PredictedGlucoseContext.swift @@ -0,0 +1,56 @@ +// +// PredictedGlucoseContext.swift +// Loop +// +// Created by Bharat Mediratta on 6/25/18. +// Copyright © 2018 LoopKit Authors. All rights reserved. +// + +import Foundation +import HealthKit + + +struct PredictedGlucoseContext { + let values: [Double] + let unit: HKUnit + let startDate: Date + let interval: TimeInterval + + var samples: [GlucoseContext] { + var result: [GlucoseContext] = [] + for (i, v) in values.enumerated() { + result.append(GlucoseContext(value: v, unit: unit, startDate: startDate.addingTimeInterval(Double(i) * interval))) + } + return result + } +} + + +extension PredictedGlucoseContext: RawRepresentable { + typealias RawValue = [String: Any] + + var rawValue: RawValue { + return [ + "values": values, + "unit": unit.unitString, + "startDate": startDate, + "interval": interval + ] + } + + init?(rawValue: RawValue) { + guard + let values = rawValue["values"] as? [Double], + let unitString = rawValue["unit"] as? String, + let startDate = rawValue["startDate"] as? Date, + let interval = rawValue["interval"] as? TimeInterval + else { + return nil + } + + self.values = values + self.unit = HKUnit(from: unitString) + self.startDate = startDate + self.interval = interval + } +} diff --git a/Common/Models/Contexts/SensorDisplayableContext.swift b/Common/Models/Contexts/SensorDisplayableContext.swift new file mode 100644 index 0000000000..0ee67eb3b0 --- /dev/null +++ b/Common/Models/Contexts/SensorDisplayableContext.swift @@ -0,0 +1,61 @@ +// +// SensorDisplayableContext.swift +// Loop +// +// Created by Bharat Mediratta on 6/25/18. +// Copyright © 2018 LoopKit Authors. All rights reserved. +// + +import Foundation +import LoopUI + + +struct SensorDisplayableContext: SensorDisplayable { + let isStateValid: Bool + let stateDescription: String + let trendType: GlucoseTrendType? + let isLocal: Bool +} + + +extension SensorDisplayableContext: RawRepresentable { + typealias RawValue = [String: Any] + + var rawValue: RawValue { + var raw: RawValue = [ + "isStateValid": isStateValid, + "stateDescription": stateDescription, + "isLocal": isLocal + ] + raw["trendType"] = trendType?.rawValue + + return raw + } + + init(_ other: SensorDisplayable) { + isStateValid = other.isStateValid + stateDescription = other.stateDescription + isLocal = other.isLocal + trendType = other.trendType + } + + init?(rawValue: RawValue) { + guard + let isStateValid = rawValue["isStateValid"] as? Bool, + let stateDescription = rawValue["stateDescription"] as? String, + let isLocal = rawValue["isLocal"] as? Bool + else { + return nil + } + + self.isStateValid = isStateValid + self.stateDescription = stateDescription + self.isLocal = isLocal + + if let rawValue = rawValue["trendType"] as? GlucoseTrendType.RawValue { + trendType = GlucoseTrendType(rawValue: rawValue) + } else { + trendType = nil + } + } +} diff --git a/Common/Models/Contexts/StatusExtensionContext.swift b/Common/Models/Contexts/StatusExtensionContext.swift new file mode 100644 index 0000000000..4f74a76173 --- /dev/null +++ b/Common/Models/Contexts/StatusExtensionContext.swift @@ -0,0 +1,67 @@ +// +// StatusExtensionContext.swift +// Loop Status Extension +// +// Created by Bharat Mediratta on 11/25/16. +// Copyright © 2016 LoopKit Authors. All rights reserved. +// +// This class allows Loop to pass context data to the Loop Status Extension. + +import Foundation +import HealthKit +import LoopKit + + +struct StatusExtensionContext: RawRepresentable { + var predictedGlucose: PredictedGlucoseContext? + var lastLoopCompleted: Date? + var netBasal: NetBasalContext? + var batteryPercentage: Double? + var sensor: SensorDisplayableContext? +} + + +extension StatusExtensionContext { + typealias RawValue = [String: Any] + static let version = 4 + + init?(rawValue: RawValue) { + guard let version = rawValue["version"] as? Int, version == type(of: self).version else { + return nil + } + + if let rawValue = rawValue["predictedGlucose"] as? PredictedGlucoseContext.RawValue { + predictedGlucose = PredictedGlucoseContext(rawValue: rawValue) + } + + if let rawValue = rawValue["netBasal"] as? NetBasalContext.RawValue { + netBasal = NetBasalContext(rawValue: rawValue) + } + + lastLoopCompleted = rawValue["lastLoopCompleted"] as? Date + batteryPercentage = rawValue["batteryPercentage"] as? Double + + if let rawValue = rawValue["sensor"] as? SensorDisplayableContext.RawValue { + sensor = SensorDisplayableContext(rawValue: rawValue) + } + } + + var rawValue: RawValue { + var raw: RawValue = [ + "version": type(of: self).version + ] + + raw["predictedGlucose"] = predictedGlucose?.rawValue + raw["lastLoopCompleted"] = lastLoopCompleted + raw["netBasal"] = netBasal?.rawValue + raw["batteryPercentage"] = batteryPercentage + raw["sensor"] = sensor?.rawValue + return raw + } +} + +extension StatusExtensionContext: CustomDebugStringConvertible { + var debugDescription: String { + return String(reflecting: rawValue) + } +} diff --git a/Common/Models/WatchContext.swift b/Common/Models/Contexts/WatchContext.swift similarity index 90% rename from Common/Models/WatchContext.swift rename to Common/Models/Contexts/WatchContext.swift index 8620c9e111..44d6265774 100644 --- a/Common/Models/WatchContext.swift +++ b/Common/Models/Contexts/WatchContext.swift @@ -9,11 +9,7 @@ import Foundation import HealthKit -final class WatchContext: NSObject, RawRepresentable { - typealias RawValue = [String: Any] - - private let version = 3 - +struct WatchContext { var preferredGlucoseUnit: HKUnit? var maxBolus: Double? @@ -42,16 +38,16 @@ final class WatchContext: NSObject, RawRepresentable { var reservoirPercentage: Double? var batteryPercentage: Double? - var cgm: CGM? + var cgm: CGMType? +} - override init() { - super.init() - } +extension WatchContext: RawRepresentable { + typealias RawValue = [String: Any] - required init?(rawValue: RawValue) { - super.init() + static let version = 3 - guard rawValue["v"] as? Int == version else { + init?(rawValue: RawValue) { + guard rawValue["v"] as? Int == type(of: self).version else { return nil } @@ -93,14 +89,14 @@ final class WatchContext: NSObject, RawRepresentable { COB = rawValue["cob"] as? Double maxBolus = rawValue["mb"] as? Double - if let cgmRawValue = rawValue["cgm"] as? CGM.RawValue { - cgm = CGM(rawValue: cgmRawValue) + if let cgmRawValue = rawValue["cgm"] as? CGMType.RawValue { + cgm = CGMType(rawValue: cgmRawValue) } } var rawValue: RawValue { var raw: [String: Any] = [ - "v": version + "v": type(of: self).version ] raw["ba"] = lastNetTempBasalDose diff --git a/Common/Models/GlucoseThreshold.swift b/Common/Models/Settings/GlucoseThresholdSetting.swift similarity index 70% rename from Common/Models/GlucoseThreshold.swift rename to Common/Models/Settings/GlucoseThresholdSetting.swift index 8fa3b589c7..edbba59341 100644 --- a/Common/Models/GlucoseThreshold.swift +++ b/Common/Models/Settings/GlucoseThresholdSetting.swift @@ -9,21 +9,20 @@ import Foundation import HealthKit -struct GlucoseThreshold: RawRepresentable { - typealias RawValue = [String: Any] - - let value: Double + +struct GlucoseThresholdSetting { let unit: HKUnit - - public var quantity: HKQuantity { + let value: Double + + var quantity: HKQuantity { return HKQuantity(unit: unit, doubleValue: value) } - - public init(unit: HKUnit, value: Double) { - self.value = value - self.unit = unit - } - +} + + +extension GlucoseThresholdSetting: RawRepresentable { + typealias RawValue = [String: Any] + init?(rawValue: RawValue) { guard let unitsStr = rawValue["units"] as? String, let value = rawValue["value"] as? Double else { return nil @@ -41,8 +40,8 @@ struct GlucoseThreshold: RawRepresentable { } -extension GlucoseThreshold: Equatable { - static func ==(lhs: GlucoseThreshold, rhs: GlucoseThreshold) -> Bool { +extension GlucoseThresholdSetting: Equatable { + static func ==(lhs: GlucoseThresholdSetting, rhs: GlucoseThresholdSetting) -> Bool { return lhs.value == rhs.value } } diff --git a/Common/Models/Insulin/InsulinModelSettings.swift b/Common/Models/Settings/InsulinModelSettings.swift similarity index 90% rename from Common/Models/Insulin/InsulinModelSettings.swift rename to Common/Models/Settings/InsulinModelSettings.swift index 0d6eb295c4..2f7b1d6644 100644 --- a/Common/Models/Insulin/InsulinModelSettings.swift +++ b/Common/Models/Settings/InsulinModelSettings.swift @@ -9,7 +9,7 @@ import LoopKit enum InsulinModelSettings { - case exponentialPreset(ExponentialInsulinModelPreset) + case exponentialPreset(ExponentialInsulinModelPresetType) case walsh(WalshInsulinModel) var model: InsulinModel { @@ -23,7 +23,7 @@ enum InsulinModelSettings { init?(model: InsulinModel) { switch model { - case let model as ExponentialInsulinModelPreset: + case let model as ExponentialInsulinModelPresetType: self = .exponentialPreset(model) case let model as WalshInsulinModel: self = .walsh(model) @@ -62,8 +62,8 @@ extension InsulinModelSettings: RawRepresentable { switch type { case .exponentialPreset: - guard let modelRaw = rawValue["model"] as? ExponentialInsulinModelPreset.RawValue, - let model = ExponentialInsulinModelPreset(rawValue: modelRaw) + guard let modelRaw = rawValue["model"] as? ExponentialInsulinModelPresetType.RawValue, + let model = ExponentialInsulinModelPresetType(rawValue: modelRaw) else { return nil } diff --git a/Common/Models/LoopSettings.swift b/Common/Models/Settings/LoopSettings.swift similarity index 93% rename from Common/Models/LoopSettings.swift rename to Common/Models/Settings/LoopSettings.swift index fbab2c1656..78dea52748 100644 --- a/Common/Models/LoopSettings.swift +++ b/Common/Models/Settings/LoopSettings.swift @@ -20,7 +20,7 @@ struct LoopSettings { var maximumBolus: Double? - var suspendThreshold: GlucoseThreshold? = nil + var suspendThreshold: GlucoseThresholdSetting? = nil var retrospectiveCorrectionEnabled = true @@ -61,8 +61,8 @@ extension LoopSettings: RawRepresentable { self.maximumBolus = rawValue["maximumBolus"] as? Double - if let rawThreshold = rawValue["minimumBGGuard"] as? GlucoseThreshold.RawValue { - self.suspendThreshold = GlucoseThreshold(rawValue: rawThreshold) + if let rawThreshold = rawValue["minimumBGGuard"] as? GlucoseThresholdSetting.RawValue { + self.suspendThreshold = GlucoseThresholdSetting(rawValue: rawThreshold) } if let retrospectiveCorrectionEnabled = rawValue["retrospectiveCorrectionEnabled"] as? Bool { diff --git a/Common/Models/StatusExtensionContext.swift b/Common/Models/StatusExtensionContext.swift deleted file mode 100644 index c64f5b72cd..0000000000 --- a/Common/Models/StatusExtensionContext.swift +++ /dev/null @@ -1,207 +0,0 @@ -// -// StatusExtensionContext.swift -// Loop Status Extension -// -// Created by Bharat Mediratta on 11/25/16. -// Copyright © 2016 LoopKit Authors. All rights reserved. -// -// This class allows Loop to pass context data to the Loop Status Extension. - -import Foundation -import HealthKit -import LoopKit -import LoopUI - - -struct NetBasalContext { - let rate: Double - let percentage: Double - let start: Date - let end: Date -} - -struct SensorDisplayableContext: SensorDisplayable { - let isStateValid: Bool - let stateDescription: String - let trendType: GlucoseTrend? - let isLocal: Bool -} - -struct GlucoseContext { - let value: Double - let unit: HKUnit - let startDate: Date - - var quantity: HKQuantity { - return HKQuantity(unit: unit, doubleValue: value) - } -} - -struct PredictedGlucoseContext { - let values: [Double] - let unit: HKUnit - let startDate: Date - let interval: TimeInterval - - var samples: [GlucoseContext] { - var result: [GlucoseContext] = [] - for (i, v) in values.enumerated() { - result.append(GlucoseContext(value: v, unit: unit, startDate: startDate.addingTimeInterval(Double(i) * interval))) - } - return result - } -} - -extension NetBasalContext: RawRepresentable { - typealias RawValue = [String: Any] - - var rawValue: RawValue { - return [ - "rate": rate, - "percentage": percentage, - "start": start, - "end": end - ] - } - - init?(rawValue: RawValue) { - guard - let rate = rawValue["rate"] as? Double, - let percentage = rawValue["percentage"] as? Double, - let start = rawValue["start"] as? Date, - let end = rawValue["end"] as? Date - else { - return nil - } - - self.rate = rate - self.percentage = percentage - self.start = start - self.end = end - } -} - -extension SensorDisplayableContext: RawRepresentable { - typealias RawValue = [String: Any] - - var rawValue: RawValue { - var raw: RawValue = [ - "isStateValid": isStateValid, - "stateDescription": stateDescription, - "isLocal": isLocal - ] - raw["trendType"] = trendType?.rawValue - - return raw - } - - init(_ other: SensorDisplayable) { - isStateValid = other.isStateValid - stateDescription = other.stateDescription - isLocal = other.isLocal - trendType = other.trendType - } - - init?(rawValue: RawValue) { - guard - let isStateValid = rawValue["isStateValid"] as? Bool, - let stateDescription = rawValue["stateDescription"] as? String, - let isLocal = rawValue["isLocal"] as? Bool - else { - return nil - } - - self.isStateValid = isStateValid - self.stateDescription = stateDescription - self.isLocal = isLocal - - if let rawValue = rawValue["trendType"] as? GlucoseTrend.RawValue { - trendType = GlucoseTrend(rawValue: rawValue) - } else { - trendType = nil - } - } -} - -extension PredictedGlucoseContext: RawRepresentable { - typealias RawValue = [String: Any] - - var rawValue: RawValue { - return [ - "values": values, - "unit": unit.unitString, - "startDate": startDate, - "interval": interval - ] - } - - init?(rawValue: RawValue) { - guard - let values = rawValue["values"] as? [Double], - let unitString = rawValue["unit"] as? String, - let startDate = rawValue["startDate"] as? Date, - let interval = rawValue["interval"] as? TimeInterval - else { - return nil - } - - self.values = values - self.unit = HKUnit(from: unitString) - self.startDate = startDate - self.interval = interval - } -} - -struct StatusExtensionContext: RawRepresentable { - typealias RawValue = [String: Any] - private let version = 4 - - var predictedGlucose: PredictedGlucoseContext? - var lastLoopCompleted: Date? - var netBasal: NetBasalContext? - var batteryPercentage: Double? - var sensor: SensorDisplayableContext? - - init() { } - - init?(rawValue: RawValue) { - guard let version = rawValue["version"] as? Int, version == self.version else { - return nil - } - - if let rawValue = rawValue["predictedGlucose"] as? PredictedGlucoseContext.RawValue { - predictedGlucose = PredictedGlucoseContext(rawValue: rawValue) - } - - if let rawValue = rawValue["netBasal"] as? NetBasalContext.RawValue { - netBasal = NetBasalContext(rawValue: rawValue) - } - - lastLoopCompleted = rawValue["lastLoopCompleted"] as? Date - batteryPercentage = rawValue["batteryPercentage"] as? Double - - if let rawValue = rawValue["sensor"] as? SensorDisplayableContext.RawValue { - sensor = SensorDisplayableContext(rawValue: rawValue) - } - } - - var rawValue: RawValue { - var raw: RawValue = [ - "version": version - ] - - raw["predictedGlucose"] = predictedGlucose?.rawValue - raw["lastLoopCompleted"] = lastLoopCompleted - raw["netBasal"] = netBasal?.rawValue - raw["batteryPercentage"] = batteryPercentage - raw["sensor"] = sensor?.rawValue - return raw - } -} - - -extension StatusExtensionContext: CustomDebugStringConvertible { - var debugDescription: String { - return String(reflecting: rawValue) - } -} diff --git a/Common/Models/Types/AbsorptionTimeType.swift b/Common/Models/Types/AbsorptionTimeType.swift new file mode 100644 index 0000000000..c48e6ed2c6 --- /dev/null +++ b/Common/Models/Types/AbsorptionTimeType.swift @@ -0,0 +1,45 @@ +// +// AbsorptionTimeType.swift +// Loop +// +// Created by Bharat Mediratta on 6/25/18. +// Copyright © 2018 LoopKit Authors. All rights reserved. +// + +import Foundation + + +enum AbsorptionTimeType { + case fast + case medium + case slow +} + + +extension AbsorptionTimeType: RawRepresentable { + typealias RawValue = Int + + init?(rawValue: RawValue) { + switch rawValue { + case 0: + self = .fast + case 1: + self = .medium + case 2: + self = .slow + default: + return nil + } + } + + var rawValue: RawValue { + switch self { + case .fast: + return 0 + case .medium: + return 1 + case .slow: + return 2 + } + } +} diff --git a/Common/Models/CGM.swift b/Common/Models/Types/CGMType.swift similarity index 83% rename from Common/Models/CGM.swift rename to Common/Models/Types/CGMType.swift index a5efda95e6..c5d90c7521 100644 --- a/Common/Models/CGM.swift +++ b/Common/Models/Types/CGMType.swift @@ -1,5 +1,5 @@ // -// CGM.swift +// CGMType.swift // Loop // // Copyright © 2017 LoopKit Authors. All rights reserved. @@ -8,7 +8,7 @@ import Foundation -enum CGM { +enum CGMType { case g5(transmitterID: String?) case g4 case enlite @@ -33,20 +33,20 @@ enum CGM { } -extension CGM: RawRepresentable { +extension CGMType: RawRepresentable { typealias RawValue = [String: Any] private static let version = 1 init?(rawValue: RawValue) { guard let version = rawValue["version"] as? Int, - version == CGM.version, + version == CGMType.version, let type = rawValue["type"] as? String else { return nil } - switch CGMType(rawValue: type) { + switch InternalType(rawValue: type) { case .g5?: self = .g5(transmitterID: rawValue["transmitterID"] as? String) case .g4?: @@ -58,13 +58,13 @@ extension CGM: RawRepresentable { } } - private enum CGMType: String { + private enum InternalType: String { case g5 case g4 case enlite } - private var type: CGMType { + private var type: InternalType { switch self { case .g5: return .g5 case .g4: return .g4 @@ -74,7 +74,7 @@ extension CGM: RawRepresentable { var rawValue: [String: Any] { var raw: RawValue = [ - "version": CGM.version, + "version": CGMType.version, "type": type.rawValue ] @@ -87,8 +87,8 @@ extension CGM: RawRepresentable { } -extension CGM: Equatable { - static func ==(lhs: CGM, rhs: CGM) -> Bool { +extension CGMType: Equatable { + static func ==(lhs: CGMType, rhs: CGMType) -> Bool { switch (lhs, rhs) { case (.g4, .g4), (.enlite, .enlite): return true @@ -99,3 +99,4 @@ extension CGM: Equatable { } } } + diff --git a/Common/Models/Insulin/ExponentialInsulinModelPreset.swift b/Common/Models/Types/ExponentialInsulinModelPresetType.swift similarity index 89% rename from Common/Models/Insulin/ExponentialInsulinModelPreset.swift rename to Common/Models/Types/ExponentialInsulinModelPresetType.swift index 66644da1b8..f67a30ad6e 100644 --- a/Common/Models/Insulin/ExponentialInsulinModelPreset.swift +++ b/Common/Models/Types/ExponentialInsulinModelPresetType.swift @@ -8,7 +8,7 @@ import LoopKit -enum ExponentialInsulinModelPreset: String { +enum ExponentialInsulinModelPresetType: String { case humalogNovologAdult case humalogNovologChild case fiasp @@ -16,7 +16,7 @@ enum ExponentialInsulinModelPreset: String { // MARK: - Model generation -extension ExponentialInsulinModelPreset { +extension ExponentialInsulinModelPresetType { var actionDuration: TimeInterval { switch self { case .humalogNovologAdult: @@ -46,7 +46,7 @@ extension ExponentialInsulinModelPreset { // MARK: - Localization -extension ExponentialInsulinModelPreset { +extension ExponentialInsulinModelPresetType { var title: String { switch self { case .humalogNovologAdult: @@ -71,7 +71,7 @@ extension ExponentialInsulinModelPreset { } -extension ExponentialInsulinModelPreset: InsulinModel { +extension ExponentialInsulinModelPresetType: InsulinModel { var effectDuration: TimeInterval { return model.effectDuration } @@ -82,7 +82,7 @@ extension ExponentialInsulinModelPreset: InsulinModel { } -extension ExponentialInsulinModelPreset: CustomDebugStringConvertible { +extension ExponentialInsulinModelPresetType: CustomDebugStringConvertible { var debugDescription: String { return "\(self.rawValue)(\(String(reflecting: model))" } diff --git a/Common/Models/GlucoseTrend.swift b/Common/Models/Types/GlucoseTrendType.swift similarity index 97% rename from Common/Models/GlucoseTrend.swift rename to Common/Models/Types/GlucoseTrendType.swift index 99b2999708..8bb5c4860a 100644 --- a/Common/Models/GlucoseTrend.swift +++ b/Common/Models/Types/GlucoseTrendType.swift @@ -9,7 +9,7 @@ import Foundation -public enum GlucoseTrend: Int { +public enum GlucoseTrendType: Int { case upUpUp = 1 case upUp = 2 case up = 3 diff --git a/Common/Models/BolusSuggestionUserInfo.swift b/Common/Models/UserInfos/BolusSuggestionUserInfo.swift similarity index 76% rename from Common/Models/BolusSuggestionUserInfo.swift rename to Common/Models/UserInfos/BolusSuggestionUserInfo.swift index 0bc8119f1b..c7701e26cc 100644 --- a/Common/Models/BolusSuggestionUserInfo.swift +++ b/Common/Models/UserInfos/BolusSuggestionUserInfo.swift @@ -9,22 +9,19 @@ import Foundation -final class BolusSuggestionUserInfo: RawRepresentable { +struct BolusSuggestionUserInfo { let recommendedBolus: Double let maxBolus: Double? +} - init(recommendedBolus: Double, maxBolus: Double? = nil) { - self.recommendedBolus = recommendedBolus - self.maxBolus = maxBolus - } - // MARK: - RawRepresentable +extension BolusSuggestionUserInfo: RawRepresentable { typealias RawValue = [String: Any] - static let version = 1 + private static let version = 1 static let name = "BolusSuggestionUserInfo" - required init?(rawValue: RawValue) { + init?(rawValue: RawValue) { guard rawValue["v"] as? Int == type(of: self).version && rawValue["name"] as? String == BolusSuggestionUserInfo.name, let recommendedBolus = rawValue["br"] as? Double else { diff --git a/Common/Models/CarbEntryUserInfo.swift b/Common/Models/UserInfos/CarbEntryUserInfo.swift similarity index 60% rename from Common/Models/CarbEntryUserInfo.swift rename to Common/Models/UserInfos/CarbEntryUserInfo.swift index 4b1a6285a4..d985aa30fb 100644 --- a/Common/Models/CarbEntryUserInfo.swift +++ b/Common/Models/UserInfos/CarbEntryUserInfo.swift @@ -8,59 +8,18 @@ import Foundation -enum AbsorptionTimeType { - case fast - case medium - case slow -} - struct CarbEntryUserInfo { let value: Double let absorptionTimeType: AbsorptionTimeType let startDate: Date - - init(value: Double, absorptionTimeType: AbsorptionTimeType, startDate: Date) { - self.value = value - self.absorptionTimeType = absorptionTimeType - self.startDate = startDate - } -} - - -extension AbsorptionTimeType: RawRepresentable { - typealias RawValue = Int - - init?(rawValue: RawValue) { - switch rawValue { - case 0: - self = .fast - case 1: - self = .medium - case 2: - self = .slow - default: - return nil - } - } - - var rawValue: RawValue { - switch self { - case .fast: - return 0 - case .medium: - return 1 - case .slow: - return 2 - } - } } extension CarbEntryUserInfo: RawRepresentable { typealias RawValue = [String: Any] - static let version = 1 + private static let version = 1 static let name = "CarbEntryUserInfo" init?(rawValue: RawValue) { diff --git a/Common/Models/GlucoseRangeScheduleOverrideUserInfo.swift b/Common/Models/UserInfos/GlucoseRangeScheduleOverrideUserInfo.swift similarity index 98% rename from Common/Models/GlucoseRangeScheduleOverrideUserInfo.swift rename to Common/Models/UserInfos/GlucoseRangeScheduleOverrideUserInfo.swift index 0145d0cb2c..b6c36d83c0 100644 --- a/Common/Models/GlucoseRangeScheduleOverrideUserInfo.swift +++ b/Common/Models/UserInfos/GlucoseRangeScheduleOverrideUserInfo.swift @@ -32,10 +32,11 @@ struct GlucoseRangeScheduleOverrideUserInfo { } } + extension GlucoseRangeScheduleOverrideUserInfo: RawRepresentable { typealias RawValue = [String: Any] - static let version = 1 + private static let version = 1 static let name = "GlucoseRangeScheduleOverrideUserInfo" init?(rawValue: RawValue) { diff --git a/Common/Models/SetBolusUserInfo.swift b/Common/Models/UserInfos/SetBolusUserInfo.swift similarity index 100% rename from Common/Models/SetBolusUserInfo.swift rename to Common/Models/UserInfos/SetBolusUserInfo.swift diff --git a/Common/Models/Insulin/WalshInsulinModel.swift b/Common/Models/WalshInsulinModel.swift similarity index 100% rename from Common/Models/Insulin/WalshInsulinModel.swift rename to Common/Models/WalshInsulinModel.swift diff --git a/Loop.xcodeproj/project.pbxproj b/Loop.xcodeproj/project.pbxproj index c9e63e32c3..b13f32628c 100644 --- a/Loop.xcodeproj/project.pbxproj +++ b/Loop.xcodeproj/project.pbxproj @@ -29,12 +29,12 @@ 43045E581F25AC1700FD9CE1 /* RileyLinkDeviceManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43045E571F25AC1700FD9CE1 /* RileyLinkDeviceManager.swift */; }; 43076BF31DFDBC4B0012A723 /* it.lproj in Resources */ = {isa = PBXBuildFile; fileRef = 43076BF21DFDBC4B0012A723 /* it.lproj */; }; 4309786C1E73D2F500BEBC82 /* it.lproj in Resources */ = {isa = PBXBuildFile; fileRef = 4309786B1E73D2F500BEBC82 /* it.lproj */; }; - 4309786E1E73DAD100BEBC82 /* CGM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4309786D1E73DAD100BEBC82 /* CGM.swift */; }; + 4309786E1E73DAD100BEBC82 /* CGMType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4309786D1E73DAD100BEBC82 /* CGMType.swift */; }; 430B298A2041F54A00BA9F93 /* NSUserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430B29892041F54A00BA9F93 /* NSUserDefaults.swift */; }; 430B298B2041F55700BA9F93 /* NSUserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430B29892041F54A00BA9F93 /* NSUserDefaults.swift */; }; 430B298E2041F56500BA9F93 /* LoopSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430B298C2041F56500BA9F93 /* LoopSettings.swift */; }; - 430B298F2041F56500BA9F93 /* GlucoseThreshold.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430B298D2041F56500BA9F93 /* GlucoseThreshold.swift */; }; - 430B29902041F57000BA9F93 /* GlucoseThreshold.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430B298D2041F56500BA9F93 /* GlucoseThreshold.swift */; }; + 430B298F2041F56500BA9F93 /* GlucoseThresholdSetting.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430B298D2041F56500BA9F93 /* GlucoseThresholdSetting.swift */; }; + 430B29902041F57000BA9F93 /* GlucoseThresholdSetting.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430B298D2041F56500BA9F93 /* GlucoseThresholdSetting.swift */; }; 430B29912041F57200BA9F93 /* LoopSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430B298C2041F56500BA9F93 /* LoopSettings.swift */; }; 430B29932041F5B300BA9F93 /* UserDefaults+Loop.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430B29922041F5B200BA9F93 /* UserDefaults+Loop.swift */; }; 430B29952041F5CB00BA9F93 /* LoopSettings+Loop.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430B29942041F5CB00BA9F93 /* LoopSettings+Loop.swift */; }; @@ -55,7 +55,6 @@ 4328E02A1CFBE2C500E199AA /* UIColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4328E0241CFBE2C500E199AA /* UIColor.swift */; }; 4328E02B1CFBE2C500E199AA /* WKAlertAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4328E0251CFBE2C500E199AA /* WKAlertAction.swift */; }; 4328E02F1CFBF81800E199AA /* WKInterfaceImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4328E02E1CFBF81800E199AA /* WKInterfaceImage.swift */; }; - 4328E0331CFC091100E199AA /* WatchContext+LoopKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4328E0311CFC068900E199AA /* WatchContext+LoopKit.swift */; }; 4328E0351CFC0AE100E199AA /* WatchDataManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4328E0341CFC0AE100E199AA /* WatchDataManager.swift */; }; 432CF87520D8AC950066B889 /* NSUserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4328E0231CFBE2C500E199AA /* NSUserDefaults.swift */; }; 432E73CB1D24B3D6009AD15D /* RemoteDataManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 432E73CA1D24B3D6009AD15D /* RemoteDataManager.swift */; }; @@ -76,7 +75,7 @@ 434B2886206628B3000EE07B /* PersistenceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 431E73471FF95A900069B5F7 /* PersistenceController.swift */; }; 434B2887206B4F07000EE07B /* WalshInsulinModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 435CB6261F37AE5600C320C7 /* WalshInsulinModel.swift */; }; 434B2888206B4F0A000EE07B /* InsulinModelSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 435CB6281F37B01300C320C7 /* InsulinModelSettings.swift */; }; - 434B2889206B4F0C000EE07B /* ExponentialInsulinModelPreset.swift in Sources */ = {isa = PBXBuildFile; fileRef = 435CB6241F37ABFC00C320C7 /* ExponentialInsulinModelPreset.swift */; }; + 434B2889206B4F0C000EE07B /* ExponentialInsulinModelPresetType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 435CB6241F37ABFC00C320C7 /* ExponentialInsulinModelPresetType.swift */; }; 434F54571D287FDB002A9274 /* NibLoadable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 434F54561D287FDB002A9274 /* NibLoadable.swift */; }; 434F54591D28805E002A9274 /* ButtonTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 434F54581D28805E002A9274 /* ButtonTableViewCell.xib */; }; 434F545B1D2880D4002A9274 /* AuthenticationTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 434F545A1D2880D4002A9274 /* AuthenticationTableViewCell.xib */; }; @@ -92,10 +91,10 @@ 435400341C9F878D00D5819C /* SetBolusUserInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 435400331C9F878D00D5819C /* SetBolusUserInfo.swift */; }; 435400351C9F878D00D5819C /* SetBolusUserInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 435400331C9F878D00D5819C /* SetBolusUserInfo.swift */; }; 435CB6231F37967800C320C7 /* InsulinModelSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 435CB6221F37967800C320C7 /* InsulinModelSettingsViewController.swift */; }; - 435CB6251F37ABFC00C320C7 /* ExponentialInsulinModelPreset.swift in Sources */ = {isa = PBXBuildFile; fileRef = 435CB6241F37ABFC00C320C7 /* ExponentialInsulinModelPreset.swift */; }; + 435CB6251F37ABFC00C320C7 /* ExponentialInsulinModelPresetType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 435CB6241F37ABFC00C320C7 /* ExponentialInsulinModelPresetType.swift */; }; 435CB6271F37AE5600C320C7 /* WalshInsulinModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 435CB6261F37AE5600C320C7 /* WalshInsulinModel.swift */; }; 435CB6291F37B01300C320C7 /* InsulinModelSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 435CB6281F37B01300C320C7 /* InsulinModelSettings.swift */; }; - 4365050520A793FA00EA8D7A /* CGM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4309786D1E73DAD100BEBC82 /* CGM.swift */; }; + 4365050520A793FA00EA8D7A /* CGMType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4309786D1E73DAD100BEBC82 /* CGMType.swift */; }; 436961911F19D11E00447E89 /* ChartPointsContextFillLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4369618F1F19C86400447E89 /* ChartPointsContextFillLayer.swift */; }; 436A0DA51D236A2A00104B24 /* LoopError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 436A0DA41D236A2A00104B24 /* LoopError.swift */; }; 436D9BF81F6F4EA100CFA75F /* recommended_temp_start_low_end_just_above_range.json in Resources */ = {isa = PBXBuildFile; fileRef = 436D9BF71F6F4EA100CFA75F /* recommended_temp_start_low_end_just_above_range.json */; }; @@ -158,7 +157,7 @@ 43C0944A1CACCC73001F6403 /* NotificationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C094491CACCC73001F6403 /* NotificationManager.swift */; }; 43C246A81D89990F0031F8D1 /* Crypto.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 43C246A71D89990F0031F8D1 /* Crypto.framework */; }; 43C2FAE11EB656A500364AFF /* GlucoseEffectVelocity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C2FAE01EB656A500364AFF /* GlucoseEffectVelocity.swift */; }; - 43C3B6ED20B884500026CAFA /* GlucoseThreshold.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430B298D2041F56500BA9F93 /* GlucoseThreshold.swift */; }; + 43C3B6ED20B884500026CAFA /* GlucoseThresholdSetting.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430B298D2041F56500BA9F93 /* GlucoseThresholdSetting.swift */; }; 43C418B51CE0575200405B6A /* ShareGlucose+GlucoseKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C418B41CE0575200405B6A /* ShareGlucose+GlucoseKit.swift */; }; 43C513191E864C4E001547C7 /* GlucoseRangeSchedule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C513181E864C4E001547C7 /* GlucoseRangeSchedule.swift */; }; 43CA93371CB98079000026B5 /* MinimedKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 43CA93361CB98079000026B5 /* MinimedKit.framework */; }; @@ -218,7 +217,6 @@ 4F20AE621E6B879C00D07A06 /* ReservoirVolumeHUDView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 437CEEC71CD84CBB003C8C80 /* ReservoirVolumeHUDView.swift */; }; 4F20AE631E6B87B100D07A06 /* ChartContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4313EDDF1D8A6BF90060FA79 /* ChartContainerView.swift */; }; 4F2C15741E0209F500E160D4 /* NSTimeInterval.swift in Sources */ = {isa = PBXBuildFile; fileRef = 439897341CD2F7DE00223065 /* NSTimeInterval.swift */; }; - 4F2C15751E0209FA00E160D4 /* GlucoseTrend.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43EA285E1D50ED3D001BC233 /* GlucoseTrend.swift */; }; 4F2C15811E0495B200E160D4 /* WatchContext+WatchApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F2C15801E0495B200E160D4 /* WatchContext+WatchApp.swift */; }; 4F2C15821E074FC600E160D4 /* NSTimeInterval.swift in Sources */ = {isa = PBXBuildFile; fileRef = 439897341CD2F7DE00223065 /* NSTimeInterval.swift */; }; 4F2C15831E0757E600E160D4 /* HKUnit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F526D5E1DF2459000A04910 /* HKUnit.swift */; }; @@ -248,7 +246,7 @@ 4F7528A21DFE200B00C322D6 /* LevelMaskView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43FBEDD71D73843700B21F22 /* LevelMaskView.swift */; }; 4F7528A51DFE208C00C322D6 /* NSTimeInterval.swift in Sources */ = {isa = PBXBuildFile; fileRef = 439897341CD2F7DE00223065 /* NSTimeInterval.swift */; }; 4F7528A71DFE20CE00C322D6 /* SensorDisplayable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43EA28611D517E42001BC233 /* SensorDisplayable.swift */; }; - 4F7528A91DFE212600C322D6 /* GlucoseTrend.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43EA285E1D50ED3D001BC233 /* GlucoseTrend.swift */; }; + 4F7528A91DFE212600C322D6 /* GlucoseTrendType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43EA285E1D50ED3D001BC233 /* GlucoseTrendType.swift */; }; 4F7528AA1DFE215100C322D6 /* HKUnit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F526D5E1DF2459000A04910 /* HKUnit.swift */; }; 4FAC02541E22F6B20087A773 /* NSTimeInterval.swift in Sources */ = {isa = PBXBuildFile; fileRef = 439897341CD2F7DE00223065 /* NSTimeInterval.swift */; }; 4FB76FB01E8C3E8000B39636 /* SwiftCharts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4346D1EF1C781BEA00ABAFE3 /* SwiftCharts.framework */; }; @@ -265,6 +263,17 @@ 4FB76FCE1E8C835D00B39636 /* ChartColorPalette.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FB76FCD1E8C835D00B39636 /* ChartColorPalette.swift */; }; 4FC8C8011DEB93E400A1452E /* NSUserDefaults+StatusExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FC8C8001DEB93E400A1452E /* NSUserDefaults+StatusExtension.swift */; }; 4FC8C8021DEB943800A1452E /* NSUserDefaults+StatusExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FC8C8001DEB93E400A1452E /* NSUserDefaults+StatusExtension.swift */; }; + 4FF0F74A20E194D900FC6291 /* NetBasalContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0F74920E194D900FC6291 /* NetBasalContext.swift */; }; + 4FF0F74C20E194FA00FC6291 /* SensorDisplayableContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0F74B20E194FA00FC6291 /* SensorDisplayableContext.swift */; }; + 4FF0F74E20E1951F00FC6291 /* PredictedGlucoseContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0F74D20E1951F00FC6291 /* PredictedGlucoseContext.swift */; }; + 4FF0F75020E1953400FC6291 /* GlucoseContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0F74F20E1953400FC6291 /* GlucoseContext.swift */; }; + 4FF0F75220E1963C00FC6291 /* AbsorptionTimeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0F75120E1963C00FC6291 /* AbsorptionTimeType.swift */; }; + 4FF0F75320E19EF600FC6291 /* AbsorptionTimeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0F75120E1963C00FC6291 /* AbsorptionTimeType.swift */; }; + 4FF0F75420E1A4C400FC6291 /* PredictedGlucoseContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0F74D20E1951F00FC6291 /* PredictedGlucoseContext.swift */; }; + 4FF0F75520E1A4CC00FC6291 /* NetBasalContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0F74920E194D900FC6291 /* NetBasalContext.swift */; }; + 4FF0F75620E1A4D300FC6291 /* SensorDisplayableContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0F74B20E194FA00FC6291 /* SensorDisplayableContext.swift */; }; + 4FF0F75720E1A4FF00FC6291 /* GlucoseContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0F74F20E1953400FC6291 /* GlucoseContext.swift */; }; + 4FF0F75920E1A5F000FC6291 /* GlucoseTrendType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43EA285E1D50ED3D001BC233 /* GlucoseTrendType.swift */; }; 4FF4D0F81E1725B000846527 /* NibLoadable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 434F54561D287FDB002A9274 /* NibLoadable.swift */; }; 4FF4D0F91E17268800846527 /* IdentifiableClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 434FF1E91CF26C29000DB779 /* IdentifiableClass.swift */; }; 4FF4D1001E18374700846527 /* WatchContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF4D0FF1E18374700846527 /* WatchContext.swift */; }; @@ -442,10 +451,10 @@ 43045E571F25AC1700FD9CE1 /* RileyLinkDeviceManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RileyLinkDeviceManager.swift; sourceTree = ""; }; 43076BF21DFDBC4B0012A723 /* it.lproj */ = {isa = PBXFileReference; lastKnownFileType = folder; path = it.lproj; sourceTree = ""; }; 4309786B1E73D2F500BEBC82 /* it.lproj */ = {isa = PBXFileReference; lastKnownFileType = folder; path = it.lproj; sourceTree = ""; }; - 4309786D1E73DAD100BEBC82 /* CGM.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGM.swift; sourceTree = ""; }; + 4309786D1E73DAD100BEBC82 /* CGMType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGMType.swift; sourceTree = ""; }; 430B29892041F54A00BA9F93 /* NSUserDefaults.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSUserDefaults.swift; sourceTree = ""; }; 430B298C2041F56500BA9F93 /* LoopSettings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoopSettings.swift; sourceTree = ""; }; - 430B298D2041F56500BA9F93 /* GlucoseThreshold.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GlucoseThreshold.swift; sourceTree = ""; }; + 430B298D2041F56500BA9F93 /* GlucoseThresholdSetting.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GlucoseThresholdSetting.swift; sourceTree = ""; }; 430B29922041F5B200BA9F93 /* UserDefaults+Loop.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UserDefaults+Loop.swift"; sourceTree = ""; }; 430B29942041F5CB00BA9F93 /* LoopSettings+Loop.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "LoopSettings+Loop.swift"; sourceTree = ""; }; 430C1ABC1E5568A80067F1AE /* StatusChartsManager+LoopKit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "StatusChartsManager+LoopKit.swift"; sourceTree = ""; }; @@ -468,7 +477,6 @@ 4328E0241CFBE2C500E199AA /* UIColor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIColor.swift; sourceTree = ""; }; 4328E0251CFBE2C500E199AA /* WKAlertAction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WKAlertAction.swift; sourceTree = ""; }; 4328E02E1CFBF81800E199AA /* WKInterfaceImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WKInterfaceImage.swift; sourceTree = ""; }; - 4328E0311CFC068900E199AA /* WatchContext+LoopKit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "WatchContext+LoopKit.swift"; sourceTree = ""; }; 4328E0341CFC0AE100E199AA /* WatchDataManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = WatchDataManager.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; 432E73CA1D24B3D6009AD15D /* RemoteDataManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemoteDataManager.swift; sourceTree = ""; }; 4337615E1D52F487004A3647 /* GlucoseHUDView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GlucoseHUDView.swift; sourceTree = ""; }; @@ -499,7 +507,7 @@ 435400301C9F744E00D5819C /* BolusSuggestionUserInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BolusSuggestionUserInfo.swift; sourceTree = ""; }; 435400331C9F878D00D5819C /* SetBolusUserInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SetBolusUserInfo.swift; sourceTree = ""; }; 435CB6221F37967800C320C7 /* InsulinModelSettingsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InsulinModelSettingsViewController.swift; sourceTree = ""; }; - 435CB6241F37ABFC00C320C7 /* ExponentialInsulinModelPreset.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExponentialInsulinModelPreset.swift; sourceTree = ""; }; + 435CB6241F37ABFC00C320C7 /* ExponentialInsulinModelPresetType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExponentialInsulinModelPresetType.swift; sourceTree = ""; }; 435CB6261F37AE5600C320C7 /* WalshInsulinModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WalshInsulinModel.swift; sourceTree = ""; }; 435CB6281F37B01300C320C7 /* InsulinModelSettings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InsulinModelSettings.swift; sourceTree = ""; }; 43649A621C7A347F00523D7F /* CollectionType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionType.swift; sourceTree = ""; }; @@ -610,7 +618,7 @@ 43E3449E1B9D68E900C85C07 /* StatusTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = StatusTableViewController.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; 43E397A21D56B9E40028E321 /* Glucose.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Glucose.swift; sourceTree = ""; }; 43E5292A205F718500ACEB3B /* SensorValueGlucoseEvent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SensorValueGlucoseEvent.swift; sourceTree = ""; }; - 43EA285E1D50ED3D001BC233 /* GlucoseTrend.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GlucoseTrend.swift; sourceTree = ""; }; + 43EA285E1D50ED3D001BC233 /* GlucoseTrendType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GlucoseTrendType.swift; sourceTree = ""; }; 43EA28611D517E42001BC233 /* SensorDisplayable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SensorDisplayable.swift; sourceTree = ""; }; 43EDEE6B1CF2E12A00393BE3 /* Loop.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = Loop.entitlements; sourceTree = ""; }; 43F41C361D3BF32400C11ED6 /* UIAlertController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIAlertController.swift; sourceTree = ""; }; @@ -653,6 +661,11 @@ 4FB76FC51E8C57B100B39636 /* StatusChartsManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusChartsManager.swift; sourceTree = ""; }; 4FB76FCD1E8C835D00B39636 /* ChartColorPalette.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChartColorPalette.swift; sourceTree = ""; }; 4FC8C8001DEB93E400A1452E /* NSUserDefaults+StatusExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSUserDefaults+StatusExtension.swift"; sourceTree = ""; }; + 4FF0F74920E194D900FC6291 /* NetBasalContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetBasalContext.swift; sourceTree = ""; }; + 4FF0F74B20E194FA00FC6291 /* SensorDisplayableContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SensorDisplayableContext.swift; sourceTree = ""; }; + 4FF0F74D20E1951F00FC6291 /* PredictedGlucoseContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PredictedGlucoseContext.swift; sourceTree = ""; }; + 4FF0F74F20E1953400FC6291 /* GlucoseContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlucoseContext.swift; sourceTree = ""; }; + 4FF0F75120E1963C00FC6291 /* AbsorptionTimeType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AbsorptionTimeType.swift; sourceTree = ""; }; 4FF4D0FF1E18374700846527 /* WatchContext.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WatchContext.swift; sourceTree = ""; }; 540DED961E14C75F002B2491 /* EnliteSensorDisplayable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EnliteSensorDisplayable.swift; sourceTree = ""; }; 7D68AAA91FE2DB0A00522C49 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/LaunchScreen.strings; sourceTree = ""; }; @@ -810,16 +823,6 @@ path = Extensions; sourceTree = ""; }; - 43673E2E1F37BDA10058AC7C /* Insulin */ = { - isa = PBXGroup; - children = ( - 435CB6241F37ABFC00C320C7 /* ExponentialInsulinModelPreset.swift */, - 435CB6281F37B01300C320C7 /* InsulinModelSettings.swift */, - 435CB6261F37AE5600C320C7 /* WalshInsulinModel.swift */, - ); - path = Insulin; - sourceTree = ""; - }; 43757D131C06F26C00910CB9 /* Models */ = { isa = PBXGroup; children = ( @@ -840,7 +843,6 @@ 43D848AF1E7DCBE100DADCBC /* Result.swift */, 43C418B41CE0575200405B6A /* ShareGlucose+GlucoseKit.swift */, 43441A9B1EDB34810087958C /* StatusExtensionContext+LoopKit.swift */, - 4328E0311CFC068900E199AA /* WatchContext+LoopKit.swift */, ); path = Models; sourceTree = ""; @@ -1183,30 +1185,69 @@ path = Extensions; sourceTree = ""; }; - 4FF4D0FA1E1834BD00846527 /* Common */ = { + 4FF0F75A20E1AA2600FC6291 /* Types */ = { isa = PBXGroup; children = ( - 4FF4D0FC1E1834CC00846527 /* Extensions */, - 4FF4D0FB1E1834C400846527 /* Models */, + 4FF0F75120E1963C00FC6291 /* AbsorptionTimeType.swift */, + 4309786D1E73DAD100BEBC82 /* CGMType.swift */, + 43EA285E1D50ED3D001BC233 /* GlucoseTrendType.swift */, + 435CB6241F37ABFC00C320C7 /* ExponentialInsulinModelPresetType.swift */, ); - path = Common; + path = Types; sourceTree = ""; }; - 4FF4D0FB1E1834C400846527 /* Models */ = { + 4FF0F75B20E1AA4500FC6291 /* UserInfos */ = { isa = PBXGroup; children = ( - 43673E2E1F37BDA10058AC7C /* Insulin */, 435400301C9F744E00D5819C /* BolusSuggestionUserInfo.swift */, 43DE92581C5479E4001FFDE1 /* CarbEntryUserInfo.swift */, - 4309786D1E73DAD100BEBC82 /* CGM.swift */, 894B91CC1FF9F45900DA65F5 /* GlucoseRangeScheduleOverrideUserInfo.swift */, - 430B298D2041F56500BA9F93 /* GlucoseThreshold.swift */, - 43EA285E1D50ED3D001BC233 /* GlucoseTrend.swift */, - 430B298C2041F56500BA9F93 /* LoopSettings.swift */, 435400331C9F878D00D5819C /* SetBolusUserInfo.swift */, + ); + path = UserInfos; + sourceTree = ""; + }; + 4FF0F75C20E1AA6000FC6291 /* Contexts */ = { + isa = PBXGroup; + children = ( + 4FF0F74F20E1953400FC6291 /* GlucoseContext.swift */, + 4FF0F74920E194D900FC6291 /* NetBasalContext.swift */, + 4FF0F74D20E1951F00FC6291 /* PredictedGlucoseContext.swift */, + 4FF0F74B20E194FA00FC6291 /* SensorDisplayableContext.swift */, 4F70C2111DE900EA006380B7 /* StatusExtensionContext.swift */, 4FF4D0FF1E18374700846527 /* WatchContext.swift */, ); + path = Contexts; + sourceTree = ""; + }; + 4FF0F75D20E1AA7800FC6291 /* Settings */ = { + isa = PBXGroup; + children = ( + 430B298D2041F56500BA9F93 /* GlucoseThresholdSetting.swift */, + 435CB6281F37B01300C320C7 /* InsulinModelSettings.swift */, + 430B298C2041F56500BA9F93 /* LoopSettings.swift */, + ); + path = Settings; + sourceTree = ""; + }; + 4FF4D0FA1E1834BD00846527 /* Common */ = { + isa = PBXGroup; + children = ( + 4FF4D0FC1E1834CC00846527 /* Extensions */, + 4FF4D0FB1E1834C400846527 /* Models */, + ); + path = Common; + sourceTree = ""; + }; + 4FF4D0FB1E1834C400846527 /* Models */ = { + isa = PBXGroup; + children = ( + 4FF0F75C20E1AA6000FC6291 /* Contexts */, + 4FF0F75D20E1AA7800FC6291 /* Settings */, + 4FF0F75A20E1AA2600FC6291 /* Types */, + 4FF0F75B20E1AA4500FC6291 /* UserInfos */, + 435CB6261F37AE5600C320C7 /* WalshInsulinModel.swift */, + ); path = Models; sourceTree = ""; }; @@ -1731,6 +1772,7 @@ 43BFF0CB1E466C0900FF19A9 /* StateColorPalette.swift in Sources */, 43F5C2DB1B92A5E1003EB13D /* SettingsTableViewController.swift in Sources */, 434FF1EA1CF26C29000DB779 /* IdentifiableClass.swift in Sources */, + 4FF0F75020E1953400FC6291 /* GlucoseContext.swift in Sources */, 437CCADE1D2858FD0075D2C3 /* AuthenticationViewController.swift in Sources */, 43A5676B1C96155700334FAC /* SwitchTableViewCell.swift in Sources */, 43A567691C94880B00334FAC /* LoopDataManager.swift in Sources */, @@ -1746,9 +1788,9 @@ 43E3449F1B9D68E900C85C07 /* StatusTableViewController.swift in Sources */, 43DBF0531C93EC8200B3C386 /* DeviceDataManager.swift in Sources */, 43E2D8C81D208D5B004DA55F /* KeychainManager+Loop.swift in Sources */, - 430B298F2041F56500BA9F93 /* GlucoseThreshold.swift in Sources */, + 430B298F2041F56500BA9F93 /* GlucoseThresholdSetting.swift in Sources */, C17824A01E19CF9800D9D25C /* GlucoseThresholdTableViewController.swift in Sources */, - 435CB6251F37ABFC00C320C7 /* ExponentialInsulinModelPreset.swift in Sources */, + 435CB6251F37ABFC00C320C7 /* ExponentialInsulinModelPresetType.swift in Sources */, 4346D1E71C77F5FE00ABAFE3 /* ChartTableViewCell.swift in Sources */, 437CEEE41CDE5C0A003C8C80 /* UIImage.swift in Sources */, 43DBF0591C93F73800B3C386 /* CarbEntryTableViewController.swift in Sources */, @@ -1762,9 +1804,10 @@ 438849EA1D297CB6003B3F23 /* NightscoutService.swift in Sources */, 438172D91F4E9E37003C3328 /* NewPumpEvent.swift in Sources */, 437CCADC1D284B830075D2C3 /* ButtonTableViewCell.swift in Sources */, + 4FF0F74E20E1951F00FC6291 /* PredictedGlucoseContext.swift in Sources */, 4389916B1E91B689000EEF90 /* ChartSettings+Loop.swift in Sources */, 4315D2871CA5CC3B00589052 /* CarbEntryEditTableViewController.swift in Sources */, - 4309786E1E73DAD100BEBC82 /* CGM.swift in Sources */, + 4309786E1E73DAD100BEBC82 /* CGMType.swift in Sources */, 43F5173D1D713DB0000FA422 /* RadioSelectionTableViewController.swift in Sources */, C178249A1E1999FA00D9D25C /* CaseCountable.swift in Sources */, 43DBF04C1C93B8D700B3C386 /* BolusViewController.swift in Sources */, @@ -1778,6 +1821,7 @@ 437CCAE01D285C7B0075D2C3 /* ServiceAuthentication.swift in Sources */, 4FC8C8011DEB93E400A1452E /* NSUserDefaults+StatusExtension.swift in Sources */, 4302F4E51D4EA75100F0FCAF /* DoseStore.swift in Sources */, + 4FF0F74C20E194FA00FC6291 /* SensorDisplayableContext.swift in Sources */, 430DA5901D4B0E4C0097D1CA /* MySentryPumpStatusMessageBody.swift in Sources */, 4D5B7A4B1D457CCA00796CA9 /* GlucoseG4.swift in Sources */, 438849EC1D29EC34003B3F23 /* AmplitudeService.swift in Sources */, @@ -1789,11 +1833,11 @@ 894B91CD1FF9F45900DA65F5 /* GlucoseRangeScheduleOverrideUserInfo.swift in Sources */, 43F41C371D3BF32400C11ED6 /* UIAlertController.swift in Sources */, 433EA4C41D9F71C800CD78FB /* CommandResponseViewController.swift in Sources */, + 4FF0F75220E1963C00FC6291 /* AbsorptionTimeType.swift in Sources */, 43D2E8231F00425400AE5CBF /* BolusViewController+LoopDataManager.swift in Sources */, 434F545F1D288345002A9274 /* ShareService.swift in Sources */, 430B29952041F5CB00BA9F93 /* LoopSettings+Loop.swift in Sources */, 43CEE6E61E56AFD400CB9116 /* NightscoutUploader.swift in Sources */, - 4328E0331CFC091100E199AA /* WatchContext+LoopKit.swift in Sources */, 4F526D611DF8D9A900A04910 /* NetBasal.swift in Sources */, 540DED971E14C75F002B2491 /* EnliteSensorDisplayable.swift in Sources */, 436A0DA51D236A2A00104B24 /* LoopError.swift in Sources */, @@ -1802,6 +1846,7 @@ 431E73481FF95A900069B5F7 /* PersistenceController.swift in Sources */, 439BED2C1E760A7A00B0AED5 /* DexCGMManager.swift in Sources */, 433EA4C21D9F39C900CD78FB /* PumpIDTableViewController.swift in Sources */, + 4FF0F74A20E194D900FC6291 /* NetBasalContext.swift in Sources */, 43F78D261C8FC000002152D1 /* DoseMath.swift in Sources */, 438D42F91D7C88BC003244B0 /* PredictionInputEffect.swift in Sources */, 434F54611D28859B002A9274 /* ServiceCredential.swift in Sources */, @@ -1829,7 +1874,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 4F2C15751E0209FA00E160D4 /* GlucoseTrend.swift in Sources */, 4F2C15741E0209F500E160D4 /* NSTimeInterval.swift in Sources */, 4FF4D1011E18375000846527 /* WatchContext.swift in Sources */, 435400311C9F744E00D5819C /* BolusSuggestionUserInfo.swift in Sources */, @@ -1841,11 +1885,12 @@ 4328E02A1CFBE2C500E199AA /* UIColor.swift in Sources */, 4328E01B1CFBE1DA00E199AA /* BolusInterfaceController.swift in Sources */, 4328E02B1CFBE2C500E199AA /* WKAlertAction.swift in Sources */, - 4365050520A793FA00EA8D7A /* CGM.swift in Sources */, + 4365050520A793FA00EA8D7A /* CGMType.swift in Sources */, 4344628E20A7ADD100C4BE6F /* UserDefaults+CGM.swift in Sources */, 894B91CE1FF9F45900DA65F5 /* GlucoseRangeScheduleOverrideUserInfo.swift in Sources */, 4328E0281CFBE2C500E199AA /* CLKComplicationTemplate.swift in Sources */, 4328E01E1CFBE25F00E199AA /* AddCarbsInterfaceController.swift in Sources */, + 4FF0F75920E1A5F000FC6291 /* GlucoseTrendType.swift in Sources */, 43846ADB1D91057000799272 /* ContextUpdatable.swift in Sources */, 4328E0261CFBE2C500E199AA /* IdentifiableClass.swift in Sources */, 432CF87520D8AC950066B889 /* NSUserDefaults.swift in Sources */, @@ -1856,6 +1901,7 @@ 43BFF0B51E45C1E700FF19A9 /* NumberFormatter.swift in Sources */, 43A9438E1B926B7B0051FA24 /* ComplicationController.swift in Sources */, 4328E01A1CFBE1DA00E199AA /* StatusInterfaceController.swift in Sources */, + 4FF0F75320E19EF600FC6291 /* AbsorptionTimeType.swift in Sources */, 435400351C9F878D00D5819C /* SetBolusUserInfo.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1864,7 +1910,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 43C3B6ED20B884500026CAFA /* GlucoseThreshold.swift in Sources */, + 43C3B6ED20B884500026CAFA /* GlucoseThresholdSetting.swift in Sources */, 43947D731F529FAA00A07D31 /* GlucoseRangeSchedule.swift in Sources */, 43E2D8DC1D20C049004DA55F /* DoseMath.swift in Sources */, 43E2D8DB1D20C03B004DA55F /* NSTimeInterval.swift in Sources */, @@ -1889,19 +1935,23 @@ files = ( 4FAC02541E22F6B20087A773 /* NSTimeInterval.swift in Sources */, 434B2888206B4F0A000EE07B /* InsulinModelSettings.swift in Sources */, + 4FF0F75420E1A4C400FC6291 /* PredictedGlucoseContext.swift in Sources */, + 4FF0F75520E1A4CC00FC6291 /* NetBasalContext.swift in Sources */, 4FB76FBA1E8C42CE00B39636 /* UIColor.swift in Sources */, 4F2C15831E0757E600E160D4 /* HKUnit.swift in Sources */, - 430B29902041F57000BA9F93 /* GlucoseThreshold.swift in Sources */, + 430B29902041F57000BA9F93 /* GlucoseThresholdSetting.swift in Sources */, 434B2887206B4F07000EE07B /* WalshInsulinModel.swift in Sources */, 43E93FB51E4675E800EAB8DB /* NumberFormatter.swift in Sources */, 43BFF0CD1E466C8400FF19A9 /* StateColorPalette.swift in Sources */, 430B29912041F57200BA9F93 /* LoopSettings.swift in Sources */, 4F526D621DF9D95200A04910 /* NSBundle.swift in Sources */, 4FC8C8021DEB943800A1452E /* NSUserDefaults+StatusExtension.swift in Sources */, - 434B2889206B4F0C000EE07B /* ExponentialInsulinModelPreset.swift in Sources */, + 434B2889206B4F0C000EE07B /* ExponentialInsulinModelPresetType.swift in Sources */, 434B2886206628B3000EE07B /* PersistenceController.swift in Sources */, 43BFF0C71E465A4F00FF19A9 /* UIColor+HIG.swift in Sources */, + 4FF0F75720E1A4FF00FC6291 /* GlucoseContext.swift in Sources */, 43BFF0BF1E45C8EA00FF19A9 /* UIColor+Widget.swift in Sources */, + 4FF0F75620E1A4D300FC6291 /* SensorDisplayableContext.swift in Sources */, 4F70C2121DE900EA006380B7 /* StatusExtensionContext.swift in Sources */, 4F70C1E11DE8DCA7006380B7 /* StatusViewController.swift in Sources */, 430B298B2041F55700BA9F93 /* NSUserDefaults.swift in Sources */, @@ -1920,7 +1970,7 @@ 4326BA641F3A44D9007CCAD4 /* ChartLineModel.swift in Sources */, 4374B5F0209D857E00D17AA8 /* OSLog.swift in Sources */, 4F7528AA1DFE215100C322D6 /* HKUnit.swift in Sources */, - 4F7528A91DFE212600C322D6 /* GlucoseTrend.swift in Sources */, + 4F7528A91DFE212600C322D6 /* GlucoseTrendType.swift in Sources */, 4F7528A71DFE20CE00C322D6 /* SensorDisplayable.swift in Sources */, 4FB76FB61E8C426900B39636 /* ChartPointsTouchHighlightLayerViewCache.swift in Sources */, 4F2C15931E09BF2C00E160D4 /* HUDView.swift in Sources */, diff --git a/Loop/Managers/CGM/CGMManager.swift b/Loop/Managers/CGM/CGMManager.swift index 801f52aad6..46b6f5abbb 100644 --- a/Loop/Managers/CGM/CGMManager.swift +++ b/Loop/Managers/CGM/CGMManager.swift @@ -61,7 +61,7 @@ protocol CGMManager: CustomDebugStringConvertible { } -extension CGM { +extension CGMType { func createManager() -> CGMManager? { switch self { case .enlite: diff --git a/Loop/Managers/DeviceDataManager.swift b/Loop/Managers/DeviceDataManager.swift index d4a6d294a1..1da0215046 100644 --- a/Loop/Managers/DeviceDataManager.swift +++ b/Loop/Managers/DeviceDataManager.swift @@ -617,7 +617,7 @@ final class DeviceDataManager { // MARK: - CGM - var cgm: CGM? = UserDefaults.appGroup.cgm { + var cgm: CGMType? = UserDefaults.appGroup.cgm { didSet { if cgm != oldValue { setupCGM() diff --git a/Loop/Managers/WatchDataManager.swift b/Loop/Managers/WatchDataManager.swift index 07ed7ab91c..3ef4c441ee 100644 --- a/Loop/Managers/WatchDataManager.swift +++ b/Loop/Managers/WatchDataManager.swift @@ -119,9 +119,12 @@ final class WatchDataManager: NSObject, WCSessionDelegate { loopManager.getLoopState { (manager, state) in let eventualGlucose = state.predictedGlucose?.last - let context = WatchContext(glucose: glucose, eventualGlucose: eventualGlucose, glucoseUnit: manager.glucoseStore.preferredUnit) + var context = WatchContext() + context.glucose = glucose?.quantity + context.glucoseDate = glucose?.startDate + context.eventualGlucose = eventualGlucose?.quantity + context.preferredGlucoseUnit = manager.glucoseStore.preferredUnit context.reservoir = reservoir?.unitVolume - context.loopLastRunDate = manager.lastLoopCompleted context.recommendedBolusDose = state.recommendedBolus?.recommendation.amount context.maxBolus = manager.settings.maximumBolus diff --git a/Loop/Models/EnliteSensorDisplayable.swift b/Loop/Models/EnliteSensorDisplayable.swift index aeb891616b..689a901152 100644 --- a/Loop/Models/EnliteSensorDisplayable.swift +++ b/Loop/Models/EnliteSensorDisplayable.swift @@ -13,7 +13,7 @@ import MinimedKit struct EnliteSensorDisplayable: SensorDisplayable { public let isStateValid: Bool - public let trendType: LoopUI.GlucoseTrend? + public let trendType: LoopUI.GlucoseTrendType? public let isLocal: Bool public init?(_ event: RelativeTimestampedGlucoseEvent) { @@ -28,7 +28,7 @@ extension RelativeTimestampedGlucoseEvent { return self is SensorValueGlucoseEvent } - var trendType: LoopUI.GlucoseTrend? { + var trendType: LoopUI.GlucoseTrendType? { return nil } diff --git a/Loop/Models/Glucose.swift b/Loop/Models/Glucose.swift index 791ba627f9..f98129252f 100644 --- a/Loop/Models/Glucose.swift +++ b/Loop/Models/Glucose.swift @@ -30,7 +30,7 @@ extension Glucose: SensorDisplayable { return String(format: "%1$@ %2$@", String(describing: state), status) } - public var trendType: GlucoseTrend? { + public var trendType: GlucoseTrendType? { guard trend < Int(Int8.max) else { return nil } diff --git a/Loop/Models/GlucoseG4.swift b/Loop/Models/GlucoseG4.swift index 380ad48c1b..29c3b3f81d 100644 --- a/Loop/Models/GlucoseG4.swift +++ b/Loop/Models/GlucoseG4.swift @@ -37,8 +37,8 @@ extension GlucoseG4: SensorDisplayable { } } - public var trendType: GlucoseTrend? { - return GlucoseTrend(rawValue: Int(trend)) + public var trendType: GlucoseTrendType? { + return GlucoseTrendType(rawValue: Int(trend)) } public var isLocal: Bool { diff --git a/Loop/Models/MySentryPumpStatusMessageBody.swift b/Loop/Models/MySentryPumpStatusMessageBody.swift index e2d4830fdf..8ac87145d9 100644 --- a/Loop/Models/MySentryPumpStatusMessageBody.swift +++ b/Loop/Models/MySentryPumpStatusMessageBody.swift @@ -21,7 +21,7 @@ extension MySentryPumpStatusMessageBody: SensorDisplayable { } } - public var trendType: LoopUI.GlucoseTrend? { + public var trendType: LoopUI.GlucoseTrendType? { guard case .active = glucose else { return nil } diff --git a/Loop/Models/ShareGlucose+GlucoseKit.swift b/Loop/Models/ShareGlucose+GlucoseKit.swift index 51e7508c2d..0e25130bc1 100644 --- a/Loop/Models/ShareGlucose+GlucoseKit.swift +++ b/Loop/Models/ShareGlucose+GlucoseKit.swift @@ -29,8 +29,8 @@ extension ShareGlucose: SensorDisplayable { return glucose >= 39 } - public var trendType: GlucoseTrend? { - return GlucoseTrend(rawValue: Int(trend)) + public var trendType: GlucoseTrendType? { + return GlucoseTrendType(rawValue: Int(trend)) } public var isLocal: Bool { diff --git a/Loop/Models/WatchContext+LoopKit.swift b/Loop/Models/WatchContext+LoopKit.swift deleted file mode 100644 index 24a67c6854..0000000000 --- a/Loop/Models/WatchContext+LoopKit.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// WatchContext+LoopKit.swift -// Loop -// -// Created by Nathan Racklyeft on 5/29/16. -// Copyright © 2016 Nathan Racklyeft. All rights reserved. -// - -import Foundation -import HealthKit -import LoopKit - -extension WatchContext { - convenience init(glucose: GlucoseValue?, eventualGlucose: GlucoseValue?, glucoseUnit: HKUnit?) { - self.init() - - self.glucose = glucose?.quantity - self.glucoseDate = glucose?.startDate - self.eventualGlucose = eventualGlucose?.quantity - self.preferredGlucoseUnit = glucoseUnit - } -} diff --git a/Loop/View Controllers/InsulinModelSettingsViewController.swift b/Loop/View Controllers/InsulinModelSettingsViewController.swift index 855d0096f5..f3a9457ed1 100644 --- a/Loop/View Controllers/InsulinModelSettingsViewController.swift +++ b/Loop/View Controllers/InsulinModelSettingsViewController.swift @@ -58,9 +58,9 @@ class InsulinModelSettingsViewController: ChartsTableViewController, Identifiabl private var allModels: [InsulinModel] = [ WalshInsulinModel(actionDuration: .hours(6)), - ExponentialInsulinModelPreset.humalogNovologAdult, - ExponentialInsulinModelPreset.humalogNovologChild, - ExponentialInsulinModelPreset.fiasp + ExponentialInsulinModelPresetType.humalogNovologAdult, + ExponentialInsulinModelPresetType.humalogNovologChild, + ExponentialInsulinModelPresetType.fiasp ] private var selectedModelIndex: Int? { @@ -69,9 +69,9 @@ class InsulinModelSettingsViewController: ChartsTableViewController, Identifiabl return nil case is WalshInsulinModel: return walshModelIndex - case let selectedModel as ExponentialInsulinModelPreset: + case let selectedModel as ExponentialInsulinModelPresetType: for index in 1.. CLKComplicationTemplate? { + static func templateForFamily(_ family: CLKComplicationFamily, glucose: HKQuantity, unit: HKUnit, date: Date?, trend: GlucoseTrendType?, eventualGlucose: HKQuantity?) -> CLKComplicationTemplate? { let formatter = NumberFormatter.glucoseFormatter(for: unit) diff --git a/WatchApp Extension/Extensions/WatchContext+WatchApp.swift b/WatchApp Extension/Extensions/WatchContext+WatchApp.swift index aff2dc566e..2c1e081a82 100644 --- a/WatchApp Extension/Extensions/WatchContext+WatchApp.swift +++ b/WatchApp Extension/Extensions/WatchContext+WatchApp.swift @@ -9,10 +9,10 @@ import Foundation extension WatchContext { - var glucoseTrend: GlucoseTrend? { + var glucoseTrend: GlucoseTrendType? { get { if let glucoseTrendRawValue = glucoseTrendRawValue { - return GlucoseTrend(rawValue: glucoseTrendRawValue) + return GlucoseTrendType(rawValue: glucoseTrendRawValue) } else { return nil }