Просмотр исходного кода

Merge branch 'dev' into deleted-cgm-store

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

+ 1 - 1
Config.xcconfig

@@ -19,7 +19,7 @@ TRIO_APP_GROUP_ID = group.org.nightscout.$(DEVELOPMENT_TEAM).trio.trio-app-group
 
 // The developers set the version numbers, please leave them alone
 APP_VERSION = 0.6.0
-APP_DEV_VERSION = 0.6.0.11
+APP_DEV_VERSION = 0.6.0.13
 APP_BUILD_NUMBER = 1
 COPYRIGHT_NOTICE =
 

+ 0 - 11
Model/Helper/GlucoseStored+helper.swift

@@ -20,17 +20,6 @@ extension GlucoseStored {
         return request
     }
 
-    static func glucoseIsHIGH(_ glucose: [GlucoseStored]) -> Bool {
-        guard glucose.count >= 4 else { return false }
-
-        let firstValue = glucose.first?.glucose
-
-        /// 400 mg/dL covers all Dexcom CGMs as well as European Libre 2 and most readings from xDrip4iOS.
-        /// U.S. / Canadian Libres can emit up to 500 mg/dL until it reads "HI"
-        /// Our condition considers both these values, 400 and 500, as possible "flat" readings when paired CGM reads HIGH.
-        return glucose.allSatisfy { $0.glucose == firstValue && ($0.glucose == 400 || $0.glucose == 500) }
-    }
-
     // Preview
     @discardableResult static func makePreviewGlucose(count: Int, provider: CoreDataStack) -> [GlucoseStored] {
         let context = provider.persistentContainer.viewContext

Разница между файлами не показана из-за своего большого размера
+ 1 - 1
Trio/Resources/javascript/bundle/determine-basal.js


+ 1 - 2
Trio/Sources/APS/OpenAPS/OpenAPS.swift

@@ -452,8 +452,7 @@ final class OpenAPS {
                 start: (activeOverrides.first?.start ?? 0) as Decimal,
                 end: (activeOverrides.first?.end ?? 0) as Decimal,
                 smbMinutes: activeOverrides.first?.smbMinutes?.decimalValue ?? maxSMBBasalMinutes,
-                uamMinutes: activeOverrides.first?.uamMinutes?.decimalValue ?? maxUAMBasalMinutes,
-                shouldProtectDueToHIGH: GlucoseStored.glucoseIsHIGH(glucose)
+                uamMinutes: activeOverrides.first?.uamMinutes?.decimalValue ?? maxUAMBasalMinutes
             )
 
             // Save and return contents of Trio's custom oref variables

+ 2 - 0
Trio/Sources/Localizations/Main/Localizable.xcstrings

@@ -136160,6 +136160,7 @@
       }
     },
     "Invalid CGM reading (HIGH)." : {
+      "extractionState" : "stale",
       "localizations" : {
         "bg" : {
           "stringUnit" : {
@@ -212843,6 +212844,7 @@
       }
     },
     "SMBs and Non-Zero Temp. Basal Rates are disabled." : {
+      "extractionState" : "stale",
       "localizations" : {
         "bg" : {
           "stringUnit" : {

+ 0 - 4
Trio/Sources/Models/TrioCustomOrefVariables.swift

@@ -21,7 +21,6 @@ struct TrioCustomOrefVariables: JSON, Equatable {
     var end: Decimal
     var smbMinutes: Decimal
     var uamMinutes: Decimal
-    var shouldProtectDueToHIGH: Bool
 
     init(
         average_total_data: Decimal,
@@ -44,7 +43,6 @@ struct TrioCustomOrefVariables: JSON, Equatable {
         end: Decimal,
         smbMinutes: Decimal,
         uamMinutes: Decimal,
-        shouldProtectDueToHIGH: Bool
     ) {
         self.average_total_data = average_total_data
         self.weightedAverage = weightedAverage
@@ -66,7 +64,6 @@ struct TrioCustomOrefVariables: JSON, Equatable {
         self.end = end
         self.smbMinutes = smbMinutes
         self.uamMinutes = uamMinutes
-        self.shouldProtectDueToHIGH = shouldProtectDueToHIGH
     }
 }
 
@@ -92,6 +89,5 @@ extension TrioCustomOrefVariables {
         case end
         case smbMinutes
         case uamMinutes
-        case shouldProtectDueToHIGH
     }
 }

+ 28 - 41
Trio/Sources/Modules/Home/View/Header/LoopStatusView.swift

@@ -53,49 +53,36 @@ struct LoopStatusView: View {
                 }
 
                 if let determination = state.determinationsFromPersistence.first {
-                    if determination.glucose == 400 {
-                        Text("Invalid CGM reading (HIGH).")
-                            .bold()
-                            .padding(.top)
-                            .foregroundStyle(Color.loopRed)
-                            .fixedSize(horizontal: false, vertical: true)
+                    Text("Latest Raw Algorithm Output")
+                        .bold()
+                        .padding(.top)
 
-                        Text("SMBs and Non-Zero Temp. Basal Rates are disabled.")
-                            .font(.subheadline)
-                            .fixedSize(horizontal: false, vertical: true)
+                    Text(
+                        "Trio is currently using these metrics and values as determined by the oref algorithm:"
+                    )
+                    .font(.subheadline)
+                    .lineLimit(nil)
+                    .multilineTextAlignment(.leading)
+                    .fixedSize(horizontal: false, vertical: true)
+
+                    TagCloudView(
+                        tags: getComputedTags(determination),
+                        shouldParseToMmolL: state.units == .mmolL
+                    )
 
-                    } else {
-                        Text("Latest Raw Algorithm Output")
-                            .bold()
-                            .padding(.top)
-
-                        Text(
-                            "Trio is currently using these metrics and values as determined by the oref algorithm:"
-                        )
-                        .font(.subheadline)
-                        .lineLimit(nil)
-                        .multilineTextAlignment(.leading)
-                        .fixedSize(horizontal: false, vertical: true)
-
-                        TagCloudView(
-                            tags: getComputedTags(determination),
-                            shouldParseToMmolL: state.units == .mmolL
-                        )
-
-                        Text("Current Algorithm Reasoning").bold().padding(.top)
-
-                        Text(
-                            self
-                                .parseReasonConclusion(
-                                    determination.reasonConclusion,
-                                    isMmolL: state.units == .mmolL
-                                )
-                        )
-                        .font(.subheadline)
-                        .lineLimit(nil)
-                        .multilineTextAlignment(.leading)
-                        .fixedSize(horizontal: false, vertical: true)
-                    }
+                    Text("Current Algorithm Reasoning").bold().padding(.top)
+
+                    Text(
+                        self
+                            .parseReasonConclusion(
+                                determination.reasonConclusion,
+                                isMmolL: state.units == .mmolL
+                            )
+                    )
+                    .font(.subheadline)
+                    .lineLimit(nil)
+                    .multilineTextAlignment(.leading)
+                    .fixedSize(horizontal: false, vertical: true)
                 } else {
                     Text("No recent oref algorithm determination.")
                 }

+ 4 - 1
oref0_source_version.txt

@@ -1,6 +1,9 @@
-oref0 branch: dev - git version: 37896e5
+oref0 branch: dev - git version: 8282ce7
 
 Last commits:
+8282ce7 Merge pull request #49 from nightscout/remove-400-guard-trio-oref
+2319a16 feat(algo): Remove short and long delta condition to avoid early exit breaking loop; set 30min neutral temp like original openaps/oref0 does
+3aeba68 feat(algo): Remove 400 / shouldProtectDueToHIGH guard #hackdiabetes2025
 37896e5 Merge pull request #48 from nightscout/fix-bundle-naming
 f21a187 Rename output library to trio_[name]
 c0b46d3 Merge pull request #47 from nightscout/fix-400-guard

+ 4 - 13
trio-oref/lib/determine-basal/determine-basal.js

@@ -78,10 +78,6 @@ function enable_smb(profile, microBolusAllowed, meal_data, bg, target_bg, high_b
     } else if (meal_data.bwFound === true && profile.A52_risk_enable === false) {
         console.error("SMB disabled due to Bolus Wizard activity in the last 6 hours.");
         return false;
-    // Disable if invalid CGM reading (HIGH)
-    } else if (!!trio_custom_variables.shouldProtectDueToHIGH) {
-        console.error("Invalid CGM (HIGH). SMBs disabled.");
-        return false;
     }
 
     // enable SMB/UAM if always-on (unless previously disabled for high temptarget)
@@ -444,13 +440,13 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
         }
     }
 
-    if (bg <= 10 || bg === 38 || noise >= 3 || minAgo > 12 || minAgo < -5 || ( glucose_status.short_avgdelta === 0 && glucose_status.long_avgdelta === 0 ) ) {
+    if (bg <= 10 || bg === 38 || noise >= 3 || minAgo > 12 || minAgo < -5) {
         if (currenttemp.rate >= basal) { // high temp is running
-            rT.reason += ". Canceling high temp basal of " + currenttemp.rate;
+            rT.reason += ". Replacing high temp basal of "+currenttemp.rate+" with neutral temp of "+basal;
             rT.deliverAt = deliverAt;
             rT.temp = 'absolute';
-            rT.duration = 0;
-            rT.rate = 0;
+            rT.duration = 30;
+            rT.rate = basal;
             return rT;
             // don't use setTempBasal(), as it has logic that allows <120% high temps to continue running
             //return tempBasalFunctions.setTempBasal(basal, 30, profile, rT, currenttemp);
@@ -1616,11 +1612,6 @@ var maxDelta_bg_threshold;
 
         var maxSafeBasal = tempBasalFunctions.getMaxSafeBasal(profile);
 
-        // set neutral TBR at current basal rate because glucose is considered as requiring dosing Protect due to HIGH (400 mg/dL)
-        if (!!trio_custom_variables.shouldProtectDueToHIGH) {
-            return tempBasalFunctions.setTempBasal(profile.current_basal, 30, profile, rT, currenttemp);
-        }
-
         if (rate > maxSafeBasal) {
             rT.reason += "adj. req. rate: " + rate + " to maxSafeBasal: " + round(maxSafeBasal,2) + ", ";
             rate = round_basal(maxSafeBasal, profile);