Преглед изворни кода

Merge remote-tracking branch 'origin/dontTest' into dontTest

Jon B.M пре 3 година
родитељ
комит
f2a2aef547

Разлика између датотеке није приказан због своје велике величине
+ 1 - 1
FreeAPS/Resources/javascript/bundle/determine-basal.js


+ 4 - 4
FreeAPS/Sources/APS/APSManager.swift

@@ -654,7 +654,7 @@ final class BaseAPSManager: APSManager, Injectable {
             storage.transaction { storage in
             storage.transaction { storage in
                 storage.append(tdd, to: file, uniqBy: \.id)
                 storage.append(tdd, to: file, uniqBy: \.id)
                 uniqEvents = storage.retrieve(file, as: [TDD].self)?
                 uniqEvents = storage.retrieve(file, as: [TDD].self)?
-                    .filter { $0.timestamp.addingTimeInterval(7.days.timeInterval) > Date() }
+                    .filter { $0.timestamp.addingTimeInterval(14.days.timeInterval) > Date() }
                     .sorted { $0.timestamp > $1.timestamp } ?? []
                     .sorted { $0.timestamp > $1.timestamp } ?? []
 
 
                 var total: Decimal = 0
                 var total: Decimal = 0
@@ -689,13 +689,13 @@ final class BaseAPSManager: APSManager, Injectable {
                     nrOfIndeces = 1
                     nrOfIndeces = 1
                 }
                 }
 
 
-                let average7 = total / indeces
+                let average14 = total / indeces
                 let average2hours = totalAmount / nrOfIndeces
                 let average2hours = totalAmount / nrOfIndeces
                 let weight = preferences.weightPercentage
                 let weight = preferences.weightPercentage
-                let weighted_average = weight * average2hours + (1 - weight) * average7
+                let weighted_average = weight * average2hours + (1 - weight) * average14
 
 
                 let averages = TDD_averages(
                 let averages = TDD_averages(
-                    average_7days: average7,
+                    average_total_data: average14,
                     weightedAverage: weighted_average,
                     weightedAverage: weighted_average,
                     past2hoursAverage: average2hours,
                     past2hoursAverage: average2hours,
                     date: Date()
                     date: Date()

+ 1 - 8
FreeAPS/Sources/APS/CGM/HeartBeatManager.swift

@@ -36,7 +36,6 @@ class HeartBeatManager {
 
 
             // set to nil, this will force recreation of bluetooth transmitter at app startup
             // set to nil, this will force recreation of bluetooth transmitter at app startup
             UserDefaults.standard.cgmTransmitterDeviceAddress = nil
             UserDefaults.standard.cgmTransmitterDeviceAddress = nil
-            
         }
         }
 
 
         if UserDefaults.standard.cgmTransmitterDeviceAddress != sharedUserDefaults
         if UserDefaults.standard.cgmTransmitterDeviceAddress != sharedUserDefaults
@@ -46,34 +45,28 @@ class HeartBeatManager {
                 .deviceManager,
                 .deviceManager,
                 "UserDefaults.standard.cgmTransmitterDeviceAddress != sharedUserDefaults.string(forKey: keyForcgmTransmitterDeviceAddress)"
                 "UserDefaults.standard.cgmTransmitterDeviceAddress != sharedUserDefaults.string(forKey: keyForcgmTransmitterDeviceAddress)"
             )
             )
-
-            debug(.deviceManager, "UserDefaults.standard.cgmTransmitterDeviceAddress != sharedUserDefaults.string(forKey: keyForcgmTransmitterDeviceAddress)")
             if let sharedTransmitterAddress = sharedUserDefaults.string(forKey: keyForcgmTransmitterDeviceAddress) {
             if let sharedTransmitterAddress = sharedUserDefaults.string(forKey: keyForcgmTransmitterDeviceAddress) {
                 debug(.deviceManager, "in checkCGMBluetoothTransmitter, sharedTransmitterAddress = \(sharedTransmitterAddress)")
                 debug(.deviceManager, "in checkCGMBluetoothTransmitter, sharedTransmitterAddress = \(sharedTransmitterAddress)")
             } else {
             } else {
                 debug(.deviceManager, "in checkCGMBluetoothTransmitter, sharedTransmitterAddress = nil")
                 debug(.deviceManager, "in checkCGMBluetoothTransmitter, sharedTransmitterAddress = nil")
             }
             }
-            
+
             // assign local copy of cgmTransmitterDeviceAddress to the value stored in sharedUserDefaults (possibly nil value)
             // assign local copy of cgmTransmitterDeviceAddress to the value stored in sharedUserDefaults (possibly nil value)
             UserDefaults.standard.cgmTransmitterDeviceAddress = sharedUserDefaults
             UserDefaults.standard.cgmTransmitterDeviceAddress = sharedUserDefaults
                 .string(forKey: keyForcgmTransmitterDeviceAddress)
                 .string(forKey: keyForcgmTransmitterDeviceAddress)
 
 
             // assign new bluetoothTransmitter. If return value is nil, and if it was not nil before, and if it was currently connected then it will disconnect automatically, because there's no other reference to it, hence deinit will be called
             // assign new bluetoothTransmitter. If return value is nil, and if it was not nil before, and if it was currently connected then it will disconnect automatically, because there's no other reference to it, hence deinit will be called
             bluetoothTransmitter = setupBluetoothTransmitter(sharedData: sharedUserDefaults)
             bluetoothTransmitter = setupBluetoothTransmitter(sharedData: sharedUserDefaults)
-                
         }
         }
     }
     }
 
 
     private func setupBluetoothTransmitter(sharedData: UserDefaults) -> BluetoothTransmitter? {
     private func setupBluetoothTransmitter(sharedData: UserDefaults) -> BluetoothTransmitter? {
-        
         // if sharedUserDefaults.cgmTransmitterDeviceAddress is not nil then, create a new bluetoothTranmsitter instance
         // if sharedUserDefaults.cgmTransmitterDeviceAddress is not nil then, create a new bluetoothTranmsitter instance
         if let cgmTransmitterDeviceAddress = sharedData.string(forKey: keyForcgmTransmitterDeviceAddress) {
         if let cgmTransmitterDeviceAddress = sharedData.string(forKey: keyForcgmTransmitterDeviceAddress) {
-            
             // unwrap cgmTransmitter_CBUUID_Service and cgmTransmitter_CBUUID_Receive
             // unwrap cgmTransmitter_CBUUID_Service and cgmTransmitter_CBUUID_Receive
             if let cgmTransmitter_CBUUID_Service = sharedData.string(forKey: keyForcgmTransmitter_CBUUID_Service),
             if let cgmTransmitter_CBUUID_Service = sharedData.string(forKey: keyForcgmTransmitter_CBUUID_Service),
                let cgmTransmitter_CBUUID_Receive = sharedData.string(forKey: keycgmTransmitter_CBUUID_Receive)
                let cgmTransmitter_CBUUID_Receive = sharedData.string(forKey: keycgmTransmitter_CBUUID_Receive)
             {
             {
-                
                 // a new cgm transmitter has been setup in xDrip4iOS
                 // a new cgm transmitter has been setup in xDrip4iOS
                 // we will connect to the same transmitter here so it can be used as heartbeat
                 // we will connect to the same transmitter here so it can be used as heartbeat
                 let newBluetoothTransmitter = BluetoothTransmitter(
                 let newBluetoothTransmitter = BluetoothTransmitter(

+ 4 - 4
FreeAPS/Sources/Models/TDD_averages.swift

@@ -1,18 +1,18 @@
 import Foundation
 import Foundation
 
 
 struct TDD_averages: JSON, Equatable {
 struct TDD_averages: JSON, Equatable {
-    var average_7days: Decimal
+    var average_total_data: Decimal
     var weightedAverage: Decimal
     var weightedAverage: Decimal
     var past2hoursAverage: Decimal
     var past2hoursAverage: Decimal
     var date: Date
     var date: Date
 
 
     init(
     init(
-        average_7days: Decimal,
+        average_total_data: Decimal,
         weightedAverage: Decimal,
         weightedAverage: Decimal,
         past2hoursAverage: Decimal,
         past2hoursAverage: Decimal,
         date: Date
         date: Date
     ) {
     ) {
-        self.average_7days = average_7days
+        self.average_total_data = average_total_data
         self.weightedAverage = weightedAverage
         self.weightedAverage = weightedAverage
         self.past2hoursAverage = past2hoursAverage
         self.past2hoursAverage = past2hoursAverage
         self.date = date
         self.date = date
@@ -21,7 +21,7 @@ struct TDD_averages: JSON, Equatable {
 
 
 extension TDD_averages {
 extension TDD_averages {
     private enum CodingKeys: String, CodingKey {
     private enum CodingKeys: String, CodingKey {
-        case average_7days
+        case average_total_data
         case weightedAverage
         case weightedAverage
         case past2hoursAverage
         case past2hoursAverage
         case date
         case date

+ 1 - 1
FreeAPS/Sources/Modules/PreferencesEditor/PreferencesEditorStateModel.swift

@@ -134,7 +134,7 @@ extension PreferencesEditor {
                     displayName: "Weighted Average of TDD. Weight of past 24 hours:",
                     displayName: "Weighted Average of TDD. Weight of past 24 hours:",
                     type: .decimal(keypath: \.weightPercentage),
                     type: .decimal(keypath: \.weightPercentage),
                     infoText: NSLocalizedString(
                     infoText: NSLocalizedString(
-                        "Has to be > 0 and <= 1.\nDefault is 0.65 (65 %) * past 24 hours. The rest will be from 7 days TDD average (0.35). To only use past 24 hours, set this to 1.\nTo avoid sudden fluctuations, an average of past 2 hours of TDD calc is used as past 24 hours TDD.",
+                        "Has to be > 0 and <= 1.\nDefault is 0.65 (65 %) * past 24 hours. The rest will be from average of total data (14 days) of all TDD calculations (0.35). To only use past 24 hours, set this to 1.\nTo avoid sudden fluctuations, an average of the past 2 hours of TDD calcs is used instead of just the current TDD (past 24 hours at this moment).",
                         comment: "Weight of past 24 hours of TDD"
                         comment: "Weight of past 24 hours of TDD"
                     ),
                     ),
                     settable: self
                     settable: self

+ 3 - 2
FreeAPS/Sources/Views/TagCloudView.swift

@@ -63,11 +63,12 @@ struct TagCloudView: View {
                 return .zt
                 return .zt
             case textTag where textTag.contains("SMB Delivery Ratio:"):
             case textTag where textTag.contains("SMB Delivery Ratio:"):
                 return .uam
                 return .uam
+            case textTag where textTag.contains("Weighted avg:"),
+                 textTag where textTag.contains("Total data avg:"):
+                return .gray
             case textTag where textTag.contains("Parabolic Fit"):
             case textTag where textTag.contains("Parabolic Fit"):
                 return .loopRed
                 return .loopRed
             case textTag where textTag.contains("TDD:"),
             case textTag where textTag.contains("TDD:"),
-                 textTag where textTag.contains("Weighted avg:"),
-                 textTag where textTag.contains("Total data avg:"),
                  textTag where textTag.contains("Original formula"),
                  textTag where textTag.contains("Original formula"),
                  textTag where textTag.contains("Logarithmic formula"),
                  textTag where textTag.contains("Logarithmic formula"),
                  textTag where textTag.contains("AF:"),
                  textTag where textTag.contains("AF:"),