Skip to content

Commit 65f64f9

Browse files
authored
Merge pull request #19 from loopandlearn/compilation_conditions
Adjustment for compilation conditions
2 parents d8d6cda + eff7aa2 commit 65f64f9

File tree

4 files changed

+1528
-401
lines changed

4 files changed

+1528
-401
lines changed

algorithm_experiments/main_combined_1988_2008.patch renamed to algorithm_experiments/2023-08-16_ae_main.patch

Lines changed: 39 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Submodule Loop befcbcb..a7b2444:
1+
Submodule Loop befcbcb..4d65b26:
22
diff --git a/Loop/Common/Extensions/GlucoseRangeSchedule.swift b/Loop/Common/Extensions/GlucoseRangeSchedule.swift
33
index c8ef74fe..ccc75b0b 100644
44
--- a/Loop/Common/Extensions/GlucoseRangeSchedule.swift
@@ -11,8 +11,8 @@ index c8ef74fe..ccc75b0b 100644
1111
+ return HKQuantity(unit: unit, doubleValue: value(at: date).maxValue)
1212
+ }
1313
}
14-
15-
14+
15+
1616
diff --git a/Loop/Common/FeatureFlags.swift b/Loop/Common/FeatureFlags.swift
1717
index b2f0953e..b5c39d73 100644
1818
--- a/Loop/Common/FeatureFlags.swift
@@ -22,8 +22,8 @@ index b2f0953e..b5c39d73 100644
2222
let adultChildInsulinModelSelectionEnabled: Bool
2323
let profileExpirationSettingsViewEnabled: Bool
2424
+ let allowAlgorithmExperiments: Bool
25-
26-
25+
26+
2727
fileprivate init() {
2828
@@ -220,6 +221,11 @@ struct FeatureFlagConfiguration: Decodable {
2929
#else
@@ -36,7 +36,7 @@ index b2f0953e..b5c39d73 100644
3636
+ #endif
3737
}
3838
}
39-
39+
4040
@@ -253,7 +259,8 @@ extension FeatureFlagConfiguration : CustomDebugStringConvertible {
4141
"* usePositiveMomentumAndRCForManualBoluses: \(usePositiveMomentumAndRCForManualBoluses)",
4242
"* dynamicCarbAbsorptionEnabled: \(dynamicCarbAbsorptionEnabled)",
@@ -153,21 +153,21 @@ index 31b6ebff..6800c7f2 100644
153153
431A8C401EC6E8AB00823B9C /* CircleMaskView.swift in Sources */,
154154
1D05219D2469F1F5000EBBDE /* AlertStore.swift in Sources */,
155155
diff --git a/Loop/Loop/Managers/LoopDataManager.swift b/Loop/Loop/Managers/LoopDataManager.swift
156-
index 18a08166..5f3c1625 100644
156+
index 18a08166..726878ed 100644
157157
--- a/Loop/Loop/Managers/LoopDataManager.swift
158158
+++ b/Loop/Loop/Managers/LoopDataManager.swift
159159
@@ -123,8 +123,6 @@ final class LoopDataManager {
160-
160+
161161
self.trustedTimeOffset = trustedTimeOffset
162-
162+
163163
- retrospectiveCorrection = settings.enabledRetrospectiveCorrectionAlgorithm
164164
-
165165
overrideIntentObserver = UserDefaults.appGroup?.observe(\.intentExtensionOverrideToSet, options: [.new], changeHandler: {[weak self] (defaults, change) in
166166
guard let name = change.newValue??.lowercased(), let appGroup = UserDefaults.appGroup else {
167167
return
168168
@@ -435,7 +433,23 @@ final class LoopDataManager {
169169
}
170-
170+
171171
// Confined to dataAccessQueue
172172
- private var retrospectiveCorrection: RetrospectiveCorrection
173173
+ private var lastIntegralRetrospectiveCorrectionEnabled: Bool?
@@ -187,13 +187,13 @@ index 18a08166..5f3c1625 100644
187187
+
188188
+ return cachedRetrospectiveCorrection!
189189
+ }
190-
190+
191191
// MARK: - Background task management
192-
192+
193193
@@ -1696,7 +1710,23 @@ extension LoopDataManager {
194194
return self.delegate?.roundBolusVolume(units: units) ?? units
195195
}
196-
196+
197197
- let maxAutomaticBolus = min(iobHeadroom, maxBolus! * LoopConstants.bolusPartialApplicationFactor)
198198
+ // Create dosing strategy based on user setting
199199
+ let applicationFactorStrategy: ApplicationFactorStrategy = UserDefaults.standard.glucoseBasedApplicationFactorEnabled
@@ -212,7 +212,7 @@ index 18a08166..5f3c1625 100644
212212
+
213213
+ // If a user customizes maxPartialApplicationFactor > 1; this respects maxBolus
214214
+ let maxAutomaticBolus = min(iobHeadroom, maxBolus! * min(effectiveBolusApplicationFactor, 1.0))
215-
215+
216216
dosingRecommendation = predictedGlucose.recommendedAutomaticDose(
217217
to: glucoseTargetRange!,
218218
@@ -1706,7 +1736,7 @@ extension LoopDataManager {
@@ -227,7 +227,7 @@ index 18a08166..5f3c1625 100644
227227
@@ -2102,9 +2132,11 @@ extension LoopDataManager {
228228
}),
229229
"]",
230-
230+
231231
+ "integralRetrospectiveCorrectionEnabled: \(UserDefaults.standard.integralRetrospectiveCorrectionEnabled)",
232232
+
233233
"retrospectiveGlucoseDiscrepancies: [",
@@ -349,23 +349,21 @@ index 00000000..41caa3d7
349349
+ }
350350
+}
351351
diff --git a/Loop/Loop/Models/LoopSettings+Loop.swift b/Loop/Loop/Models/LoopSettings+Loop.swift
352-
index ce7433a9..fd35b641 100644
352+
index ce7433a9..c285fb89 100644
353353
--- a/Loop/Loop/Models/LoopSettings+Loop.swift
354354
+++ b/Loop/Loop/Models/LoopSettings+Loop.swift
355-
@@ -19,9 +19,5 @@ extension LoopSettings {
356-
}
357-
355+
@@ -20,8 +20,4 @@ extension LoopSettings {
356+
358357
static let retrospectiveCorrectionEffectDuration = TimeInterval(hours: 1)
359-
-
358+
360359
- /// Creates an instance of the enabled retrospective correction implementation
361360
- var enabledRetrospectiveCorrectionAlgorithm: RetrospectiveCorrection {
362361
- return StandardRetrospectiveCorrection(effectDuration: LoopSettings.retrospectiveCorrectionEffectDuration)
363362
- }
364-
+
365363
}
366364
diff --git a/Loop/Loop/Models/RetrospectiveCorrection/IntegralRetrospectiveCorrection.swift b/Loop/Loop/Models/RetrospectiveCorrection/IntegralRetrospectiveCorrection.swift
367365
new file mode 100644
368-
index 00000000..e6ece1c7
366+
index 00000000..b3b9445a
369367
--- /dev/null
370368
+++ b/Loop/Loop/Models/RetrospectiveCorrection/IntegralRetrospectiveCorrection.swift
371369
@@ -0,0 +1,231 @@
@@ -601,16 +599,13 @@ index 00000000..e6ece1c7
601599
+
602600
+}
603601
diff --git a/Loop/Loop/View Controllers/PredictionTableViewController.swift b/Loop/Loop/View Controllers/PredictionTableViewController.swift
604-
index 10ed414a..55ade065 100644
605-
--- a/Loop/Loop/View Controllers/PredictionTableViewController.swift
606-
+++ b/Loop/Loop/View Controllers/PredictionTableViewController.swift
602+
index 10ed414a..52e71ccf 100644
603+
--- a/Loop/Loop/View Controllers/PredictionTableViewController.swift
604+
+++ b/Loop/Loop/View Controllers/PredictionTableViewController.swift
607605
@@ -276,9 +276,26 @@ class PredictionTableViewController: LoopChartsTableViewController, Identifiable
608606
format: NSLocalizedString("Predicted: %1$@\nActual: %2$@ (%3$@)", comment: "Format string describing retrospective glucose prediction comparison. (1: Predicted glucose)(2: Actual glucose)(3: difference)"),
609607
values[0], values[1], values[2]
610608
)
611-
-
612-
- // Standard retrospective correction
613-
- subtitleText = String(format: "%@\n%@", subtitleText, retro)
614609
+ let isIntegralRetrospectiveCorrectionEnabled = UserDefaults.standard.integralRetrospectiveCorrectionEnabled
615610
+
616611
+ if isIntegralRetrospectiveCorrectionEnabled {
@@ -630,9 +625,11 @@ index 10ed414a..55ade065 100644
630625
+ } else {
631626
+ subtitleText = String(format: "%@\n%@", subtitleText, retro)
632627
+ }
633-
+
628+
629+
- // Standard retrospective correction
630+
- subtitleText = String(format: "%@\n%@", subtitleText, retro)
634631
}
635-
632+
636633
cell.subtitleLabel?.text = subtitleText
637634
diff --git a/Loop/Loop/Views/GlucoseBasedApplicationFactorSelectionView.swift b/Loop/Loop/Views/GlucoseBasedApplicationFactorSelectionView.swift
638635
new file mode 100644
@@ -703,7 +700,7 @@ index 00000000..09a68d58
703700
+}
704701
diff --git a/Loop/Loop/Views/IntegralRetrospectiveCorrectionSelectionView.swift b/Loop/Loop/Views/IntegralRetrospectiveCorrectionSelectionView.swift
705702
new file mode 100644
706-
index 00000000..dfeb37d5
703+
index 00000000..38e7c7f2
707704
--- /dev/null
708705
+++ b/Loop/Loop/Views/IntegralRetrospectiveCorrectionSelectionView.swift
709706
@@ -0,0 +1,46 @@
@@ -866,18 +863,9 @@ index 00000000..54bd2c71
866863
+
867864
+}
868865
diff --git a/Loop/Loop/Views/SettingsView.swift b/Loop/Loop/Views/SettingsView.swift
869-
index 90859273..347adb52 100644
866+
index 90859273..68af9eda 100644
870867
--- a/Loop/Loop/Views/SettingsView.swift
871868
+++ b/Loop/Loop/Views/SettingsView.swift
872-
@@ -30,7 +30,7 @@ public struct SettingsView: View {
873-
@State private var therapySettingsIsPresented: Bool = false
874-
@State private var deletePumpDataAlertIsPresented = false
875-
@State private var deleteCGMDataAlertIsPresented = false
876-
-
877-
+
878-
public init(viewModel: SettingsViewModel) {
879-
self.viewModel = viewModel
880-
self.versionUpdateViewModel = viewModel.versionUpdateViewModel
881869
@@ -177,6 +177,10 @@ extension SettingsView {
882870
ForEach(configurationMenuItemsForSupportPlugins) { item in
883871
item.view
@@ -888,15 +876,15 @@ index 90859273..347adb52 100644
888876
+ }
889877
}
890878
}
891-
879+
892880
diff --git a/Loop/Loop/en.lproj/Localizable.strings b/Loop/Loop/en.lproj/Localizable.strings
893881
index 78907ea3..54d0ee57 100644
894882
--- a/Loop/Loop/en.lproj/Localizable.strings
895883
+++ b/Loop/Loop/en.lproj/Localizable.strings
896884
@@ -246,6 +246,12 @@
897885
/* The title text for the issue report cell */
898886
"Issue Report" = "Issue Report";
899-
887+
900888
+/* Format string describing retrospective glucose prediction comparison. (1: Predicted glucose)(2: Actual glucose)(3: difference) */
901889
+"prediction-description-retrospective-correction" = "Predicted: %1$@\nActual: %2$@ (%3$@)";
902890
+
@@ -905,17 +893,16 @@ index 78907ea3..54d0ee57 100644
905893
+
906894
/* Glucose HUD accessibility hint */
907895
"Launches CGM app" = "Launches CGM app";
908-
896+
909897
diff --git a/LoopConfigOverride.xcconfig b/LoopConfigOverride.xcconfig
910-
index 3ffab2c..bcf7df7 100644
898+
index 3ffab2c..2714276 100644
911899
--- a/LoopConfigOverride.xcconfig
912900
+++ b/LoopConfigOverride.xcconfig
913-
@@ -10,7 +10,7 @@
914-
//URL_SCHEME_NAME = $(MAIN_APP_DISPLAY_NAME)
915-
916-
// Features
917-
-SWIFT_ACTIVE_COMPILATION_CONDITIONS = $(inherited) SIMULATORS_ENABLED //DEBUG_FEATURES_ENABLED
918-
+SWIFT_ACTIVE_COMPILATION_CONDITIONS = $(inherited) SIMULATORS_ENABLED ALLOW_ALGORITHM_EXPERIMENTS //DEBUG_FEATURES_ENABLED
919-
901+
@@ -14,3 +14,6 @@ SWIFT_ACTIVE_COMPILATION_CONDITIONS = $(inherited) SIMULATORS_ENABLED //DEBUG_FE
902+
920903
// Put your team id here for signing
921904
//LOOP_DEVELOPMENT_TEAM = UY678SP37Q
905+
+
906+
+// Add ALLOW_ALGORITHM_EXPERIMENTS to compilation conditions
907+
+SWIFT_ACTIVE_COMPILATION_CONDITIONS = $(SWIFT_ACTIVE_COMPILATION_CONDITIONS) ALLOW_ALGORITHM_EXPERIMENTS
908+
\ No newline at end of file

0 commit comments

Comments
 (0)