Sam King 11 месяцев назад
Родитель
Сommit
a910e4b5d6

+ 8 - 0
Trio/Sources/APS/OpenAPSSwift/JSONBridge.swift

@@ -24,6 +24,10 @@ enum JSONBridge {
         try JSONBridge.from(string: from.rawJSON)
     }
 
+    static func trioCustomOrefVariables(from: JSON) throws -> TrioCustomOrefVariables {
+        try JSONBridge.from(string: from.rawJSON)
+    }
+
     static func insulinSensitivities(from: JSON) throws -> InsulinSensitivities {
         try JSONBridge.from(string: from.rawJSON)
     }
@@ -48,6 +52,10 @@ enum JSONBridge {
         try JSONBridge.from(string: from.rawJSON)
     }
 
+    static func currentTemp(from: JSON) throws -> TempBasal {
+        try JSONBridge.from(string: from.rawJSON)
+    }
+
     static func carbs(from: JSON) throws -> [CarbsEntry] {
         try JSONBridge.from(string: from.rawJSON)
     }

+ 3 - 4
Trio/Sources/APS/OpenAPSSwift/Logging/AlgorithmComparison.swift

@@ -82,19 +82,18 @@ struct MealInputs: Codable {
 }
 
 struct DetermineBasalInputs: Codable {
-    // FIXME: Fill in the rest of these properties
     let glucose: [BloodGlucose]
-    // currentTemp
+    let currentTemp: TempBasal
     let iob: [IobResult]
     let profile: Profile
     let autosens: Autosens?
     let meal: ComputedCarbs?
     let microBolusAllowed: Bool
-    // reservoir: JSON
+    let reservoir: Decimal?
     let pumpHistory: [PumpHistoryEvent]
     let preferences: Preferences
     let basalProfile: [BasalProfileEntry]
-    // trioCustomOrefVariables: JSON
+    let trioCustomOrefVariables: TrioCustomOrefVariables
     let clock: Date
 }
 

+ 1 - 1
Trio/Sources/APS/OpenAPSSwift/Models/GlucoseStatus.swift

@@ -3,7 +3,7 @@ import Foundation
 /// Represents the computed status of the most recent CGM reading,
 /// including delta‐rates over various time windows for our
 /// swift-based Oref`DeterminationGenerator`.
-public struct GlucoseStatus {
+public struct GlucoseStatus: Codable {
     /// Immediate delta (mg/dL per 5 m) over the last ~5 m
     public let delta: Decimal
     /// The (“smoothed”) current glucose value (mg/dL)

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

@@ -43,46 +43,50 @@ struct OpenAPSSwift {
 
     static func determineBasal(
         glucose: JSON,
-        currentTemp _: JSON,
+        currentTemp: JSON,
         iob: JSON,
         profile: JSON,
         autosens: JSON,
         meal: JSON,
         microBolusAllowed: Bool,
-        reservoir _: JSON,
+        reservoir: JSON,
         pumpHistory: JSON,
         preferences: JSON,
         basalProfile: JSON,
-        trioCustomOrefVariables _: JSON,
+        trioCustomOrefVariables: JSON,
         clock: Date
     ) -> (OrefFunctionResult, DetermineBasalInputs?) {
         var determineBasalInputs: DetermineBasalInputs?
 
+        print(reservoir)
+
         do {
-            // FIXME: figure out the types for the commented out vars
             let glucose = try JSONBridge.glucose(from: glucose)
-            // currentTemp: JSON,
+            let currentTemp = try JSONBridge.currentTemp(from: currentTemp)
             let iob = try JSONBridge.iobResult(from: iob)
             let profile = try JSONBridge.profile(from: profile)
             let autosens = try JSONBridge.autosens(from: autosens)
             let meal = try JSONBridge.computedCarbs(from: meal)
             let microBolusAllowed = microBolusAllowed
-            // reservoir: JSON
+            let reservoir = Decimal(string: reservoir.rawJSON)
             let pumpHistory = try JSONBridge.pumpHistory(from: pumpHistory)
             let preferences = try JSONBridge.preferences(from: preferences)
             let basalProfile = try JSONBridge.basalProfile(from: basalProfile)
-            // trioCustomOrefVariables: JSON
+            let trioCustomOrefVariables = try JSONBridge.trioCustomOrefVariables(from: trioCustomOrefVariables)
 
             determineBasalInputs = DetermineBasalInputs(
                 glucose: glucose,
+                currentTemp: currentTemp,
                 iob: iob,
                 profile: profile,
                 autosens: autosens,
                 meal: meal,
                 microBolusAllowed: microBolusAllowed,
+                reservoir: reservoir,
                 pumpHistory: pumpHistory,
                 preferences: preferences,
                 basalProfile: basalProfile,
+                trioCustomOrefVariables: trioCustomOrefVariables,
                 clock: clock
             )