Skip to content

Commit fefe085

Browse files
authored
Merge pull request #408 from LoopKit/cgm-refactor
refactor of CGM device management
2 parents e3efa6d + 787fd41 commit fefe085

File tree

10 files changed

+304
-548
lines changed

10 files changed

+304
-548
lines changed

Loop.xcodeproj/project.pbxproj

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
4302F4E31D4EA54200F0FCAF /* InsulinDeliveryTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4302F4E21D4EA54200F0FCAF /* InsulinDeliveryTableViewController.swift */; };
1313
4302F4E51D4EA75100F0FCAF /* DoseStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4302F4E41D4EA75100F0FCAF /* DoseStore.swift */; };
1414
43076BF31DFDBC4B0012A723 /* it.lproj in Resources */ = {isa = PBXBuildFile; fileRef = 43076BF21DFDBC4B0012A723 /* it.lproj */; };
15+
4309786C1E73D2F500BEBC82 /* it.lproj in Resources */ = {isa = PBXBuildFile; fileRef = 4309786B1E73D2F500BEBC82 /* it.lproj */; };
16+
4309786E1E73DAD100BEBC82 /* CGM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4309786D1E73DAD100BEBC82 /* CGM.swift */; };
1517
430C1ABD1E5568A80067F1AE /* StatusChartManager+LoopKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430C1ABC1E5568A80067F1AE /* StatusChartManager+LoopKit.swift */; };
1618
430DA58E1D4AEC230097D1CA /* NSBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430DA58D1D4AEC230097D1CA /* NSBundle.swift */; };
1719
430DA5901D4B0E4C0097D1CA /* MySentryPumpStatusMessageBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430DA58F1D4B0E4C0097D1CA /* MySentryPumpStatusMessageBody.swift */; };
@@ -74,6 +76,9 @@
7476
438D42FB1D7D11A4003244B0 /* PredictionInputEffectTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 438D42FA1D7D11A4003244B0 /* PredictionInputEffectTableViewCell.swift */; };
7577
439897371CD2F80600223065 /* AnalyticsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 439897361CD2F80600223065 /* AnalyticsManager.swift */; };
7678
4398973B1CD2FC2000223065 /* NSDateFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4398973A1CD2FC2000223065 /* NSDateFormatter.swift */; };
79+
439BED2A1E76093C00B0AED5 /* CGMManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 439BED291E76093C00B0AED5 /* CGMManager.swift */; };
80+
439BED2C1E760A7A00B0AED5 /* DexCGMManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 439BED2B1E760A7A00B0AED5 /* DexCGMManager.swift */; };
81+
439BED2E1E760BC600B0AED5 /* EnliteCGMManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 439BED2D1E760BC600B0AED5 /* EnliteCGMManager.swift */; };
7782
43A567691C94880B00334FAC /* LoopDataManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43A567681C94880B00334FAC /* LoopDataManager.swift */; };
7883
43A5676B1C96155700334FAC /* SwitchTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43A5676A1C96155700334FAC /* SwitchTableViewCell.swift */; };
7984
43A943761B926B7B0051FA24 /* Interface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 43A943741B926B7B0051FA24 /* Interface.storyboard */; };
@@ -209,10 +214,7 @@
209214
C17824A61E1AF91F00D9D25C /* BolusRecommendation.swift in Sources */ = {isa = PBXBuildFile; fileRef = C17824A41E1AD4D100D9D25C /* BolusRecommendation.swift */; };
210215
C17884631D51A7A400405663 /* BatteryIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C17884621D51A7A400405663 /* BatteryIndicator.swift */; };
211216
C18C8C511D5A351900E043FB /* NightscoutDataManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C18C8C501D5A351900E043FB /* NightscoutDataManager.swift */; };
212-
C1C6591A1E1B1F430025CC58 /* (null) in Sources */ = {isa = PBXBuildFile; };
213217
C1C6591C1E1B1FDA0025CC58 /* recommend_temp_basal_dropping_then_rising.json in Resources */ = {isa = PBXBuildFile; fileRef = C1C6591B1E1B1FDA0025CC58 /* recommend_temp_basal_dropping_then_rising.json */; };
214-
C1C73F021DE3D0250022FC89 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = C1C73F041DE3D0250022FC89 /* Localizable.strings */; };
215-
C1C73F081DE3D0260022FC89 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = C1C73F0A1DE3D0260022FC89 /* InfoPlist.strings */; };
216218
C1C73F0D1DE3D0270022FC89 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = C1C73F0F1DE3D0270022FC89 /* InfoPlist.strings */; };
217219
C9886AE51E5B2FAD00473BB8 /* gallery.ckcomplication in Resources */ = {isa = PBXBuildFile; fileRef = C9886AE41E5B2FAD00473BB8 /* gallery.ckcomplication */; };
218220
/* End PBXBuildFile section */
@@ -335,6 +337,8 @@
335337
4302F4E21D4EA54200F0FCAF /* InsulinDeliveryTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InsulinDeliveryTableViewController.swift; sourceTree = "<group>"; };
336338
4302F4E41D4EA75100F0FCAF /* DoseStore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoseStore.swift; sourceTree = "<group>"; };
337339
43076BF21DFDBC4B0012A723 /* it.lproj */ = {isa = PBXFileReference; lastKnownFileType = folder; path = it.lproj; sourceTree = "<group>"; };
340+
4309786B1E73D2F500BEBC82 /* it.lproj */ = {isa = PBXFileReference; lastKnownFileType = folder; path = it.lproj; sourceTree = "<group>"; };
341+
4309786D1E73DAD100BEBC82 /* CGM.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGM.swift; sourceTree = "<group>"; };
338342
430C1ABC1E5568A80067F1AE /* StatusChartManager+LoopKit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "StatusChartManager+LoopKit.swift"; sourceTree = "<group>"; };
339343
430DA58D1D4AEC230097D1CA /* NSBundle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSBundle.swift; sourceTree = "<group>"; };
340344
430DA58F1D4B0E4C0097D1CA /* MySentryPumpStatusMessageBody.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MySentryPumpStatusMessageBody.swift; sourceTree = "<group>"; };
@@ -407,6 +411,9 @@
407411
439897341CD2F7DE00223065 /* NSTimeInterval.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSTimeInterval.swift; sourceTree = "<group>"; };
408412
439897361CD2F80600223065 /* AnalyticsManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = AnalyticsManager.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
409413
4398973A1CD2FC2000223065 /* NSDateFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSDateFormatter.swift; sourceTree = "<group>"; };
414+
439BED291E76093C00B0AED5 /* CGMManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGMManager.swift; sourceTree = "<group>"; };
415+
439BED2B1E760A7A00B0AED5 /* DexCGMManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DexCGMManager.swift; sourceTree = "<group>"; };
416+
439BED2D1E760BC600B0AED5 /* EnliteCGMManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EnliteCGMManager.swift; sourceTree = "<group>"; };
410417
43A567681C94880B00334FAC /* LoopDataManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = LoopDataManager.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
411418
43A5676A1C96155700334FAC /* SwitchTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwitchTableViewCell.swift; sourceTree = "<group>"; };
412419
43A943721B926B7B0051FA24 /* WatchApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WatchApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -518,8 +525,6 @@
518525
C17884621D51A7A400405663 /* BatteryIndicator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BatteryIndicator.swift; sourceTree = "<group>"; };
519526
C18C8C501D5A351900E043FB /* NightscoutDataManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NightscoutDataManager.swift; sourceTree = "<group>"; };
520527
C1C6591B1E1B1FDA0025CC58 /* recommend_temp_basal_dropping_then_rising.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = recommend_temp_basal_dropping_then_rising.json; sourceTree = "<group>"; };
521-
C1C73F031DE3D0250022FC89 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/Localizable.strings; sourceTree = "<group>"; };
522-
C1C73F091DE3D0260022FC89 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/InfoPlist.strings; sourceTree = "<group>"; };
523528
C1C73F0E1DE3D0270022FC89 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/InfoPlist.strings; sourceTree = "<group>"; };
524529
C9886AE41E5B2FAD00473BB8 /* gallery.ckcomplication */ = {isa = PBXFileReference; lastKnownFileType = folder; path = gallery.ckcomplication; sourceTree = "<group>"; };
525530
/* End PBXFileReference section */
@@ -627,20 +632,21 @@
627632
children = (
628633
43880F961D9D8052009061A8 /* ServiceAuthentication */,
629634
43DE92601C555C26001FFDE1 /* AbsorptionTimeType+CarbKit.swift */,
635+
C17824A41E1AD4D100D9D25C /* BolusRecommendation.swift */,
636+
4309786D1E73DAD100BEBC82 /* CGM.swift */,
630637
4331E0791C85650D00FBE832 /* ChartAxisValueDoubleLog.swift */,
631638
43F41C321D3A17AA00C11ED6 /* ChartAxisValueDoubleUnit.swift */,
639+
540DED961E14C75F002B2491 /* EnliteSensorDisplayable.swift */,
632640
43E397A21D56B9E40028E321 /* Glucose.swift */,
633641
4D5B7A4A1D457CCA00796CA9 /* GlucoseG4.swift */,
642+
C178249D1E19B62300D9D25C /* GlucoseThreshold.swift */,
634643
436FACED1D0BA636004E2427 /* InsulinDataSource.swift */,
635644
436A0DA41D236A2A00104B24 /* LoopError.swift */,
636645
430DA58F1D4B0E4C0097D1CA /* MySentryPumpStatusMessageBody.swift */,
637646
4F526D601DF8D9A900A04910 /* NetBasal.swift */,
638647
438D42F81D7C88BC003244B0 /* PredictionInputEffect.swift */,
639648
43C418B41CE0575200405B6A /* ShareGlucose+GlucoseKit.swift */,
640649
4328E0311CFC068900E199AA /* WatchContext+LoopKit.swift */,
641-
C178249D1E19B62300D9D25C /* GlucoseThreshold.swift */,
642-
C17824A41E1AD4D100D9D25C /* BolusRecommendation.swift */,
643-
540DED961E14C75F002B2491 /* EnliteSensorDisplayable.swift */,
644650
);
645651
path = Models;
646652
sourceTree = "<group>";
@@ -680,12 +686,11 @@
680686
isa = PBXGroup;
681687
children = (
682688
C9886AE41E5B2FAD00473BB8 /* gallery.ckcomplication */,
689+
4309786B1E73D2F500BEBC82 /* it.lproj */,
683690
43EDEE6B1CF2E12A00393BE3 /* Loop.entitlements */,
684691
43F5C2D41B92A4A6003EB13D /* Info.plist */,
685692
43776F8F1B8022E90074EA36 /* AppDelegate.swift */,
686693
43776F981B8022E90074EA36 /* Assets.xcassets */,
687-
C1C73F0A1DE3D0260022FC89 /* InfoPlist.strings */,
688-
C1C73F041DE3D0250022FC89 /* Localizable.strings */,
689694
43776F9A1B8022E90074EA36 /* LaunchScreen.storyboard */,
690695
43776F951B8022E90074EA36 /* Main.storyboard */,
691696
43E344A01B9E144300C85C07 /* Extensions */,
@@ -710,6 +715,16 @@
710715
path = ServiceAuthentication;
711716
sourceTree = "<group>";
712717
};
718+
439BED281E76091600B0AED5 /* CGM */ = {
719+
isa = PBXGroup;
720+
children = (
721+
439BED291E76093C00B0AED5 /* CGMManager.swift */,
722+
439BED2B1E760A7A00B0AED5 /* DexCGMManager.swift */,
723+
439BED2D1E760BC600B0AED5 /* EnliteCGMManager.swift */,
724+
);
725+
path = CGM;
726+
sourceTree = "<group>";
727+
};
713728
43A943731B926B7B0051FA24 /* WatchApp */ = {
714729
isa = PBXGroup;
715730
children = (
@@ -842,6 +857,7 @@
842857
43F5C2E41B93C5D4003EB13D /* Managers */ = {
843858
isa = PBXGroup;
844859
children = (
860+
439BED281E76091600B0AED5 /* CGM */,
845861
439897361CD2F80600223065 /* AnalyticsManager.swift */,
846862
43DBF0521C93EC8200B3C386 /* DeviceDataManager.swift */,
847863
43F4EF1C1BA2A57600526CE1 /* DiagnosticLogger.swift */,
@@ -1238,13 +1254,12 @@
12381254
isa = PBXResourcesBuildPhase;
12391255
buildActionMask = 2147483647;
12401256
files = (
1241-
C1C73F081DE3D0260022FC89 /* InfoPlist.strings in Resources */,
12421257
43FCBBC21E51710B00343C1B /* LaunchScreen.storyboard in Resources */,
12431258
43776F991B8022E90074EA36 /* Assets.xcassets in Resources */,
12441259
434F54591D28805E002A9274 /* ButtonTableViewCell.xib in Resources */,
1245-
C1C73F021DE3D0250022FC89 /* Localizable.strings in Resources */,
12461260
43776F971B8022E90074EA36 /* Main.storyboard in Resources */,
12471261
C9886AE51E5B2FAD00473BB8 /* gallery.ckcomplication in Resources */,
1262+
4309786C1E73D2F500BEBC82 /* it.lproj in Resources */,
12481263
434F545B1D2880D4002A9274 /* AuthenticationTableViewCell.xib in Resources */,
12491264
);
12501265
runOnlyForDeploymentPostprocessing = 0;
@@ -1362,6 +1377,7 @@
13621377
430DA58E1D4AEC230097D1CA /* NSBundle.swift in Sources */,
13631378
43776F901B8022E90074EA36 /* AppDelegate.swift in Sources */,
13641379
437CCADA1D284ADF0075D2C3 /* AuthenticationTableViewCell.swift in Sources */,
1380+
439BED2E1E760BC600B0AED5 /* EnliteCGMManager.swift in Sources */,
13651381
43CE7CDE1CA8B63E003CC1B0 /* Data.swift in Sources */,
13661382
43BFF0CB1E466C0900FF19A9 /* StateColorPalette.swift in Sources */,
13671383
43F41C331D3A17AA00C11ED6 /* ChartAxisValueDoubleUnit.swift in Sources */,
@@ -1393,10 +1409,12 @@
13931409
43BFF0BC1E45C80600FF19A9 /* UIColor+Loop.swift in Sources */,
13941410
43C0944A1CACCC73001F6403 /* NotificationManager.swift in Sources */,
13951411
434FF1EE1CF27EEF000DB779 /* UITableViewCell.swift in Sources */,
1412+
439BED2A1E76093C00B0AED5 /* CGMManager.swift in Sources */,
13961413
C18C8C511D5A351900E043FB /* NightscoutDataManager.swift in Sources */,
13971414
438849EA1D297CB6003B3F23 /* NightscoutService.swift in Sources */,
13981415
437CCADC1D284B830075D2C3 /* ButtonTableViewCell.swift in Sources */,
13991416
4315D2871CA5CC3B00589052 /* CarbEntryEditTableViewController.swift in Sources */,
1417+
4309786E1E73DAD100BEBC82 /* CGM.swift in Sources */,
14001418
43F5173D1D713DB0000FA422 /* RadioSelectionTableViewController.swift in Sources */,
14011419
4331E0781C85302200FBE832 /* CGPoint.swift in Sources */,
14021420
C178249A1E1999FA00D9D25C /* CaseCountable.swift in Sources */,
@@ -1424,6 +1442,7 @@
14241442
540DED971E14C75F002B2491 /* EnliteSensorDisplayable.swift in Sources */,
14251443
436A0DA51D236A2A00104B24 /* LoopError.swift in Sources */,
14261444
43E2D8C61D204678004DA55F /* KeychainManager.swift in Sources */,
1445+
439BED2C1E760A7A00B0AED5 /* DexCGMManager.swift in Sources */,
14271446
433EA4C21D9F39C900CD78FB /* PumpIDTableViewController.swift in Sources */,
14281447
43BFF0B21E45C18400FF19A9 /* UIColor.swift in Sources */,
14291448
43F78D261C8FC000002152D1 /* DoseMath.swift in Sources */,
@@ -1484,7 +1503,6 @@
14841503
43E2D8DB1D20C03B004DA55F /* NSTimeInterval.swift in Sources */,
14851504
43E2D8D41D20BF42004DA55F /* DoseMathTests.swift in Sources */,
14861505
C11C87DE1E21EAAD00BB71D3 /* HKUnit.swift in Sources */,
1487-
C1C6591A1E1B1F430025CC58 /* (null) in Sources */,
14881506
C17824A61E1AF91F00D9D25C /* BolusRecommendation.swift in Sources */,
14891507
);
14901508
runOnlyForDeploymentPostprocessing = 0;
@@ -1609,22 +1627,6 @@
16091627
name = MainInterface.storyboard;
16101628
sourceTree = "<group>";
16111629
};
1612-
C1C73F041DE3D0250022FC89 /* Localizable.strings */ = {
1613-
isa = PBXVariantGroup;
1614-
children = (
1615-
C1C73F031DE3D0250022FC89 /* it */,
1616-
);
1617-
name = Localizable.strings;
1618-
sourceTree = "<group>";
1619-
};
1620-
C1C73F0A1DE3D0260022FC89 /* InfoPlist.strings */ = {
1621-
isa = PBXVariantGroup;
1622-
children = (
1623-
C1C73F091DE3D0260022FC89 /* it */,
1624-
);
1625-
name = InfoPlist.strings;
1626-
sourceTree = "<group>";
1627-
};
16281630
C1C73F0F1DE3D0270022FC89 /* InfoPlist.strings */ = {
16291631
isa = PBXVariantGroup;
16301632
children = (

Loop/AppDelegate.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
1616

1717
var window: UIWindow?
1818

19-
private(set) lazy var dataManager = DeviceDataManager()
19+
private(set) lazy var deviceManager = DeviceDataManager()
2020

2121
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
2222
window?.tintColor = UIColor.tintColor
@@ -27,7 +27,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
2727

2828
if let navVC = window?.rootViewController as? UINavigationController,
2929
let statusVC = navVC.viewControllers.first as? StatusTableViewController {
30-
statusVC.dataManager = dataManager
30+
statusVC.dataManager = deviceManager
3131
}
3232

3333
return true
@@ -49,8 +49,6 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
4949

5050
func applicationDidBecomeActive(_ application: UIApplication) {
5151
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
52-
53-
dataManager.transmitter?.resumeScanning()
5452
}
5553

5654
func applicationWillTerminate(_ application: UIApplication) {
@@ -79,7 +77,7 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
7977
{
8078
AnalyticsManager.sharedManager.didRetryBolus()
8179

82-
dataManager.enactBolus(units: units) { (error) in
80+
deviceManager.enactBolus(units: units) { (error) in
8381
if error != nil {
8482
NotificationManager.sendBolusFailureNotificationForAmount(units, atStartDate: startDate)
8583
}

0 commit comments

Comments
 (0)