Przeglądaj źródła

Merge pull request #571 from nightscout/oref-swift-eventual-bg-from-forecasts

Update eventualBG from CoB and UAM forecasts
Deniz Cengiz 9 miesięcy temu
rodzic
commit
274219e93d

+ 7 - 11
Trio/Sources/APS/OpenAPSSwift/Forecasts/ForecastGenerator.swift

@@ -117,25 +117,21 @@ enum ForecastGenerator {
             currentGlucose: glucose
         )
 
-        // FIXME: Revisit this after I get predBG working
-        /*
-         var eventualGlucose = eventualGlucose
-         if let finalCOBGlucose = cobForecast.last {
-             eventualGlucose = max(eventualGlucose, finalCOBGlucose)
-         }
-         if let finalUAMGlucose = uamForecast.last {
-             eventualGlucose = max(eventualGlucose, finalUAMGlucose)
-         }
-          */
-
+        var eventualGlucose = eventualGlucose
         var finalCobForecast: [Decimal]?
         if mealData.mealCOB > 0, carbImpact > 0 || carbImpactParams.remainingCarbImpactPeak > 0 {
             finalCobForecast = cobForecast
+            if let lastCobGlucose = cobForecast.last {
+                eventualGlucose = max(eventualGlucose, lastCobGlucose)
+            }
         }
 
         var finalUamForecast: [Decimal]?
         if profile.enableUAM, carbImpact > 0 || carbImpactParams.remainingCarbImpactPeak > 0 {
             finalUamForecast = uamForecast
+            if let lastUamGlucose = uamForecast.last {
+                eventualGlucose = max(eventualGlucose, lastUamGlucose)
+            }
         }
 
         return ForecastResult(

+ 5 - 1
Trio/Sources/APS/OpenAPSSwift/Logging/JSONCompare.swift

@@ -143,7 +143,11 @@ enum JSONCompare {
                     resultType: .comparisonError,
                     jsDuration: javascriptDuration,
                     swiftDuration: swiftDuration,
-                    comparisonError: AlgorithmException(error: error)
+                    comparisonError: AlgorithmException(error: error),
+                    iobInputs: iobInputs,
+                    mealInputs: mealInputs,
+                    autosensInputs: autosensInputs,
+                    determineBasalInputs: determineBasalInputs
                 )
             }
 

+ 2 - 3
Trio/Sources/APS/OpenAPSSwift/Logging/OrefFunction.swift

@@ -72,9 +72,7 @@ enum OrefFunction: String, Codable {
                 // in Swift but not in JS
                 "timestamp",
                 "minGuardBG",
-                "minPredBG",
-                // In both but not ready to test yet
-                "eventualBG"
+                "minPredBG"
             ])
         }
     }
@@ -117,6 +115,7 @@ enum OrefFunction: String, Codable {
             return [
                 "sensitivityRatio": 0.011,
                 "expectedDelta": 0.11,
+                "eventualBG": 1.1,
                 "IOB": 1.1,
                 "ZT": 1.1,
                 "UAM": 1.1,

Plik diff jest za duży
+ 1 - 1
TrioTests/OpenAPSSwiftTests/javascript/bundle/determine-basal.js