Skip to content

Commit 15ce8b2

Browse files
authored
[COASTAL-734] renaming ClosedLoopStatus -> AutomaticDosingStatus (#550)
1 parent 2fade07 commit 15ce8b2

10 files changed

+77
-76
lines changed

Loop.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@
445445
B4CAD8792549D2540057946B /* LoopCompletionFreshnessTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4CAD8782549D2540057946B /* LoopCompletionFreshnessTests.swift */; };
446446
B4D4534128E5CA7900F1A8D9 /* AlertMuterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4D4534028E5CA7900F1A8D9 /* AlertMuterTests.swift */; };
447447
B4D620D424D9EDB900043B3C /* GuidanceColors.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4D620D324D9EDB900043B3C /* GuidanceColors.swift */; };
448-
B4E202302661063E009421B5 /* ClosedLoopStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4E2022F2661063E009421B5 /* ClosedLoopStatus.swift */; };
448+
B4E202302661063E009421B5 /* AutomaticDosingStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4E2022F2661063E009421B5 /* AutomaticDosingStatus.swift */; };
449449
B4E96D4B248A6B6E002DABAD /* DeviceStatusHUDView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4E96D4A248A6B6E002DABAD /* DeviceStatusHUDView.swift */; };
450450
B4E96D4F248A6E20002DABAD /* CGMStatusHUDView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4E96D4E248A6E20002DABAD /* CGMStatusHUDView.swift */; };
451451
B4E96D53248A7386002DABAD /* GlucoseValueHUDView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4E96D52248A7386002DABAD /* GlucoseValueHUDView.swift */; };
@@ -1428,7 +1428,7 @@
14281428
B4CAD8782549D2540057946B /* LoopCompletionFreshnessTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoopCompletionFreshnessTests.swift; sourceTree = "<group>"; };
14291429
B4D4534028E5CA7900F1A8D9 /* AlertMuterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertMuterTests.swift; sourceTree = "<group>"; };
14301430
B4D620D324D9EDB900043B3C /* GuidanceColors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GuidanceColors.swift; sourceTree = "<group>"; };
1431-
B4E2022F2661063E009421B5 /* ClosedLoopStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClosedLoopStatus.swift; sourceTree = "<group>"; };
1431+
B4E2022F2661063E009421B5 /* AutomaticDosingStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutomaticDosingStatus.swift; sourceTree = "<group>"; };
14321432
B4E96D4A248A6B6E002DABAD /* DeviceStatusHUDView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceStatusHUDView.swift; sourceTree = "<group>"; };
14331433
B4E96D4E248A6E20002DABAD /* CGMStatusHUDView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CGMStatusHUDView.swift; sourceTree = "<group>"; };
14341434
B4E96D52248A7386002DABAD /* GlucoseValueHUDView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlucoseValueHUDView.swift; sourceTree = "<group>"; };
@@ -1862,7 +1862,7 @@
18621862
43511CDD21FD80AD00566C63 /* RetrospectiveCorrection */,
18631863
A9FB75F0252BE320004C7D3F /* BolusDosingDecision.swift */,
18641864
C17824A41E1AD4D100D9D25C /* ManualBolusRecommendation.swift */,
1865-
B4E2022F2661063E009421B5 /* ClosedLoopStatus.swift */,
1865+
B4E2022F2661063E009421B5 /* AutomaticDosingStatus.swift */,
18661866
B40D07C6251A89D500C1C6D7 /* GlucoseDisplay.swift */,
18671867
43C2FAE01EB656A500364AFF /* GlucoseEffectVelocity.swift */,
18681868
436A0DA41D236A2A00104B24 /* LoopError.swift */,
@@ -3638,7 +3638,7 @@
36383638
1D49795824E7289700948F05 /* ServicesViewModel.swift in Sources */,
36393639
1D4A3E2D2478628500FD601B /* StoredAlert+CoreDataClass.swift in Sources */,
36403640
892D7C5123B54A15008A9656 /* CarbEntryViewController.swift in Sources */,
3641-
B4E202302661063E009421B5 /* ClosedLoopStatus.swift in Sources */,
3641+
B4E202302661063E009421B5 /* AutomaticDosingStatus.swift in Sources */,
36423642
C191D2A125B3ACAA00C26C0B /* DosingStrategySelectionView.swift in Sources */,
36433643
43DBF0591C93F73800B3C386 /* CarbEntryTableViewController.swift in Sources */,
36443644
A977A2F424ACFECF0059C207 /* CriticalEventLogExportManager.swift in Sources */,

Loop/Managers/DeviceDataManager.swift

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ final class DeviceDataManager {
4747

4848
@Published var pumpIsAllowingAutomation: Bool
4949

50-
private let closedLoopStatus: ClosedLoopStatus
50+
private let automaticDosingStatus: AutomaticDosingStatus
5151

5252
var closedLoopDisallowedLocalizedDescription: String? {
5353
if !cgmHasValidSensorSession {
@@ -232,7 +232,7 @@ final class DeviceDataManager {
232232
settingsManager: SettingsManager,
233233
bluetoothProvider: BluetoothProvider,
234234
alertPresenter: AlertPresenter,
235-
closedLoopStatus: ClosedLoopStatus,
235+
automaticDosingStatus: AutomaticDosingStatus,
236236
cacheStore: PersistenceController,
237237
localCacheDuration: TimeInterval,
238238
overrideHistory: TemporaryScheduleOverrideHistory,
@@ -317,7 +317,7 @@ final class DeviceDataManager {
317317

318318
self.cgmHasValidSensorSession = false
319319
self.pumpIsAllowingAutomation = true
320-
self.closedLoopStatus = closedLoopStatus
320+
self.automaticDosingStatus = automaticDosingStatus
321321

322322
// HealthStorePreferredGlucoseUnitDidChange will be notified once the user completes the health access form. Set to .milligramsPerDeciliter until then
323323
displayGlucoseUnitObservable = DisplayGlucoseUnitObservable(displayGlucoseUnit: glucoseStore.preferredUnit ?? .milligramsPerDeciliter)
@@ -350,7 +350,7 @@ final class DeviceDataManager {
350350
}
351351

352352
//TODO The instantiation of these non-device related managers should be moved to LoopAppManager, and then LoopAppManager can wire up the connections between them.
353-
statusExtensionManager = ExtensionDataManager(deviceDataManager: self, closedLoopStatus: closedLoopStatus)
353+
statusExtensionManager = ExtensionDataManager(deviceDataManager: self, automaticDosingStatus: automaticDosingStatus)
354354

355355
loopManager = LoopDataManager(
356356
lastLoopCompleted: ExtensionDataManager.lastLoopCompleted,
@@ -365,7 +365,7 @@ final class DeviceDataManager {
365365
dosingDecisionStore: dosingDecisionStore,
366366
latestStoredSettingsProvider: settingsManager,
367367
pumpInsulinType: pumpManager?.status.insulinType,
368-
automaticDosingStatus: closedLoopStatus,
368+
automaticDosingStatus: automaticDosingStatus,
369369
trustedTimeOffset: { trustedTimeChecker.detectedSystemTimeOffset }
370370
)
371371
cacheStore.delegate = loopManager
@@ -423,7 +423,7 @@ final class DeviceDataManager {
423423
.map { $0 && $1 }
424424
.receive(on: RunLoop.main)
425425
.removeDuplicates()
426-
.assign(to: \.closedLoopStatus.isClosedLoopAllowed, on: self)
426+
.assign(to: \.automaticDosingStatus.isAutomaticDosingAllowed, on: self)
427427
.store(in: &cancellables)
428428

429429
NotificationCenter.default.addObserver(forName: .HealthStorePreferredGlucoseUnitDidChange, object: glucoseStore.healthStore, queue: nil) { [weak self] _ in
@@ -437,7 +437,6 @@ final class DeviceDataManager {
437437
}
438438
}
439439
}
440-
441440

442441
var availablePumpManagers: [PumpManagerDescriptor] {
443442
return pluginManager.availablePumpManagers + availableStaticPumpManagers
@@ -1138,6 +1137,10 @@ extension DeviceDataManager: PumpManagerDelegate {
11381137
dispatchPrecondition(condition: .onQueue(queue))
11391138
return doseStore.pumpEventQueryAfterDate
11401139
}
1140+
1141+
var automaticDosingEnabled: Bool {
1142+
automaticDosingStatus.automaticDosingEnabled
1143+
}
11411144
}
11421145

11431146
// MARK: - PumpManagerOnboardingDelegate

Loop/Managers/ExtensionDataManager.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import LoopKit
1313

1414
final class ExtensionDataManager {
1515
unowned let deviceManager: DeviceDataManager
16-
private let closedLoopStatus: ClosedLoopStatus
16+
private let automaticDosingStatus: AutomaticDosingStatus
1717

1818
init(deviceDataManager: DeviceDataManager,
19-
closedLoopStatus: ClosedLoopStatus)
19+
automaticDosingStatus: AutomaticDosingStatus)
2020
{
2121
self.deviceManager = deviceDataManager
22-
self.closedLoopStatus = closedLoopStatus
22+
self.automaticDosingStatus = automaticDosingStatus
2323

2424
NotificationCenter.default.addObserver(self, selector: #selector(notificationReceived(_:)), name: .LoopDataUpdated, object: deviceDataManager.loopManager)
2525
NotificationCenter.default.addObserver(self, selector: #selector(notificationReceived(_:)), name: .PumpManagerChanged, object: nil)
@@ -119,7 +119,7 @@ final class ExtensionDataManager {
119119

120120
context.lastLoopCompleted = lastLoopCompleted
121121

122-
context.isClosedLoop = self.closedLoopStatus.isClosedLoop
122+
context.isClosedLoop = self.automaticDosingStatus.automaticDosingEnabled
123123

124124
// Drop the first element in predictedGlucose because it is the currentGlucose
125125
// and will have a different interval to the next element

Loop/Managers/LoopAppManager.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class LoopAppManager: NSObject {
8080
private let log = DiagnosticLog(category: "LoopAppManager")
8181
private let widgetLog = DiagnosticLog(category: "LoopWidgets")
8282

83-
private let closedLoopStatus = ClosedLoopStatus(isClosedLoop: false, isClosedLoopAllowed: false)
83+
private let automaticDosingStatus = AutomaticDosingStatus(automaticDosingEnabled: false, isAutomaticDosingAllowed: false)
8484

8585
lazy private var cancellables = Set<AnyCancellable>()
8686

@@ -176,7 +176,7 @@ class LoopAppManager: NSObject {
176176
settingsManager: settingsManager,
177177
bluetoothProvider: bluetoothStateManager,
178178
alertPresenter: self,
179-
closedLoopStatus: closedLoopStatus,
179+
automaticDosingStatus: automaticDosingStatus,
180180
cacheStore: cacheStore,
181181
localCacheDuration: localCacheDuration,
182182
overrideHistory: overrideHistory,
@@ -208,10 +208,10 @@ class LoopAppManager: NSObject {
208208
servicesManager: deviceDataManager.servicesManager,
209209
alertIssuer: alertManager)
210210

211-
closedLoopStatus.$isClosedLoopAllowed
211+
automaticDosingStatus.$isAutomaticDosingAllowed
212212
.combineLatest(deviceDataManager.loopManager.$dosingEnabled)
213213
.map { $0 && $1 }
214-
.assign(to: \.closedLoopStatus.isClosedLoop, on: self)
214+
.assign(to: \.automaticDosingStatus.automaticDosingEnabled, on: self)
215215
.store(in: &cancellables)
216216

217217
self.state = state.next
@@ -237,7 +237,7 @@ class LoopAppManager: NSObject {
237237
let statusTableViewController = storyboard.instantiateViewController(withIdentifier: "MainStatusViewController") as! StatusTableViewController
238238
statusTableViewController.alertPermissionsChecker = alertPermissionsChecker
239239
statusTableViewController.alertMuter = alertManager.alertMuter
240-
statusTableViewController.closedLoopStatus = closedLoopStatus
240+
statusTableViewController.automaticDosingStatus = automaticDosingStatus
241241
statusTableViewController.deviceManager = deviceDataManager
242242
statusTableViewController.onboardingManager = onboardingManager
243243
statusTableViewController.supportManager = supportManager

Loop/Managers/LoopDataManager.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,15 @@ final class LoopDataManager {
188188
// Turn off preMeal when going into closed loop off mode
189189
// Cancel any active temp basal when going into closed loop off mode
190190
// The dispatch is necessary in case this is coming from a didSet already on the settings struct.
191-
self.automaticDosingStatus.$isClosedLoop
191+
self.automaticDosingStatus.$automaticDosingEnabled
192192
.removeDuplicates()
193193
.dropFirst()
194194
.receive(on: DispatchQueue.main)
195195
.sink { if !$0 {
196196
self.mutateSettings { settings in
197197
settings.clearOverride(matching: .preMeal)
198198
}
199-
self.cancelActiveTempBasal(for: .closedLoopDisabled)
199+
self.cancelActiveTempBasal(for: .automaticDosingDisabled)
200200
} }
201201
.store(in: &cancellables)
202202
}
@@ -527,7 +527,7 @@ extension LoopDataManager {
527527
}
528528

529529
private enum CancelActiveTempBasalReason: String {
530-
case closedLoopDisabled
530+
case automaticDosingDisabled
531531
case unreliableCGMData
532532
case maximumBasalRateChanged
533533
}
@@ -786,7 +786,7 @@ extension LoopDataManager {
786786

787787
var (dosingDecision, error) = self.update(for: .loop)
788788

789-
if error == nil, self.automaticDosingStatus.isClosedLoop == true {
789+
if error == nil, self.automaticDosingStatus.automaticDosingEnabled == true {
790790
error = self.enactRecommendedAutomaticDose()
791791
} else {
792792
self.logger.default("Not adjusting dosing during open loop.")
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// AutomaticDosingStatus.swift
3+
// Loop
4+
//
5+
// Created by Nathaniel Hamming on 2021-05-28.
6+
// Copyright © 2021 LoopKit Authors. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
class AutomaticDosingStatus {
12+
@Published var automaticDosingEnabled: Bool
13+
@Published var isAutomaticDosingAllowed: Bool
14+
15+
init(automaticDosingEnabled: Bool,
16+
isAutomaticDosingAllowed: Bool)
17+
{
18+
self.automaticDosingEnabled = automaticDosingEnabled
19+
self.isAutomaticDosingAllowed = isAutomaticDosingAllowed
20+
}
21+
}

Loop/Models/ClosedLoopStatus.swift

Lines changed: 0 additions & 23 deletions
This file was deleted.

Loop/View Controllers/CarbAbsorptionViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class CarbAbsorptionViewController: LoopChartsTableViewController, Identif
2828

2929
var isOnboardingComplete: Bool = true
3030

31-
var closedLoopStatus: ClosedLoopStatus!
31+
var automaticDosingStatus: AutomaticDosingStatus!
3232

3333
override func viewDidLoad() {
3434
super.viewDidLoad()
@@ -64,7 +64,7 @@ final class CarbAbsorptionViewController: LoopChartsTableViewController, Identif
6464

6565
navigationItem.rightBarButtonItem?.isEnabled = isOnboardingComplete
6666

67-
allowEditing = closedLoopStatus.isClosedLoop || !FeatureFlags.simpleBolusCalculatorEnabled
67+
allowEditing = automaticDosingStatus.automaticDosingEnabled || !FeatureFlags.simpleBolusCalculatorEnabled
6868

6969
if allowEditing {
7070
navigationItem.rightBarButtonItems?.append(editButtonItem)
@@ -502,7 +502,7 @@ final class CarbAbsorptionViewController: LoopChartsTableViewController, Identif
502502

503503
@IBAction func presentCarbEntryScreen() {
504504
let navigationWrapper: UINavigationController
505-
if FeatureFlags.simpleBolusCalculatorEnabled && !closedLoopStatus.isClosedLoop {
505+
if FeatureFlags.simpleBolusCalculatorEnabled && !automaticDosingStatus.automaticDosingEnabled {
506506
let viewModel = SimpleBolusViewModel(delegate: deviceManager, displayMealEntry: true)
507507
let bolusEntryView = SimpleBolusView(viewModel: viewModel).environmentObject(DisplayGlucoseUnitObservable(displayGlucoseUnit: .milligramsPerDeciliter))
508508
let hostingController = DismissibleHostingController(rootView: bolusEntryView, isModalInPresentation: false)

0 commit comments

Comments
 (0)