polscm32 aka Marvout 1 год назад
Родитель
Сommit
a4d76874db

+ 2 - 1
FreeAPS/Sources/Modules/Bolus/BolusStateModel.swift

@@ -98,6 +98,7 @@ extension Bolus {
         @Published var determination: [OrefDetermination] = []
         @Published var preprocessedData: [(id: UUID, forecast: Forecast, forecastValue: ForecastValue)] = []
         @Published var predictionsForChart: Predictions?
+        @Published var simulatedDetermination: Determination?
 
         @Published var minForecast: [Int] = []
         @Published var maxForecast: [Int] = []
@@ -665,7 +666,7 @@ extension Bolus.StateModel {
 
 extension Bolus.StateModel {
     @MainActor func updateForecasts() async {
-        let simulatedDetermination = await apsManager.simulateDetermineBasal(carbs: carbs, iob: amount)
+        simulatedDetermination = await apsManager.simulateDetermineBasal(carbs: carbs, iob: amount)
         predictionsForChart = simulatedDetermination?.predictions
 
         let iob: [Int] = predictionsForChart?.iob ?? []

+ 25 - 1
FreeAPS/Sources/Modules/Bolus/View/ForeCastChart.swift

@@ -16,7 +16,30 @@ struct ForeCastChart: View {
     }
 
     var body: some View {
-        forecastChart
+        VStack {
+            forecastChart
+                .padding(.vertical, 3)
+            HStack {
+                Spacer()
+                Text("evBG").font(.footnote).foregroundStyle(.primary)
+                Image(systemName: "arrow.right").font(.footnote).foregroundStyle(.secondary)
+                
+                if let eventualBG = state.simulatedDetermination?.eventualBG {
+                    HStack {
+                        Text("\(eventualBG)")
+                            .font(.footnote)
+                            .foregroundStyle(.primary)
+                        Text("\(units.rawValue)")
+                            .font(.footnote)
+                            .foregroundStyle(.secondary)
+                    }
+                } else {
+                    Text("")
+                        .font(.footnote)
+                        .foregroundStyle(.primary)
+                }
+            }
+        }
     }
 
     private var forecastChart: some View {
@@ -29,6 +52,7 @@ struct ForeCastChart: View {
         .chartXAxis { forecastChartXAxis }
         .chartXScale(domain: startMarker ... endMarker)
         .chartYAxis { forecastChartYAxis }
+        .chartYScale(domain: 0 ... 300 * conversionFactor)
     }
 
     private func drawGlucose() -> some ChartContent {