فهرست منبع

Some fiddling around to add SMB flag for treatment history

dnzxy 2 سال پیش
والد
کامیت
11c3a0372f

+ 2 - 1
FreeAPS/Sources/APS/Storage/PumpHistoryStorage.swift

@@ -44,7 +44,8 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable {
                         durationMin: nil,
                         durationMin: nil,
                         rate: nil,
                         rate: nil,
                         temp: nil,
                         temp: nil,
-                        carbInput: nil
+                        carbInput: nil,
+                        isSMB: dose.automatic
                     )]
                     )]
                 case .tempBasal:
                 case .tempBasal:
                     guard let dose = event.dose else { return [] }
                     guard let dose = event.dose else { return [] }

+ 5 - 1
FreeAPS/Sources/Models/PumpHistoryEvent.swift

@@ -11,6 +11,7 @@ struct PumpHistoryEvent: JSON, Equatable {
     let temp: TempType?
     let temp: TempType?
     let carbInput: Int?
     let carbInput: Int?
     let note: String?
     let note: String?
+    let isSMB: Bool?
 
 
     init(
     init(
         id: String,
         id: String,
@@ -22,7 +23,8 @@ struct PumpHistoryEvent: JSON, Equatable {
         rate: Decimal? = nil,
         rate: Decimal? = nil,
         temp: TempType? = nil,
         temp: TempType? = nil,
         carbInput: Int? = nil,
         carbInput: Int? = nil,
-        note: String? = nil
+        note: String? = nil,
+        isSMB: Bool? = nil
     ) {
     ) {
         self.id = id
         self.id = id
         self.type = type
         self.type = type
@@ -34,6 +36,7 @@ struct PumpHistoryEvent: JSON, Equatable {
         self.temp = temp
         self.temp = temp
         self.carbInput = carbInput
         self.carbInput = carbInput
         self.note = note
         self.note = note
+        self.isSMB = isSMB
     }
     }
 }
 }
 
 
@@ -80,5 +83,6 @@ extension PumpHistoryEvent {
         case temp
         case temp
         case carbInput = "carb_input"
         case carbInput = "carb_input"
         case note
         case note
+        case isSMB
     }
     }
 }
 }

+ 14 - 8
FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift

@@ -66,8 +66,9 @@ enum DataTable {
         let isFPU: Bool?
         let isFPU: Bool?
         let fpuID: String?
         let fpuID: String?
         let note: String?
         let note: String?
+        let isSMB: Bool?
 
 
-        private var numberFormater: NumberFormatter {
+        private var numberFormatter: NumberFormatter {
             let formatter = NumberFormatter()
             let formatter = NumberFormatter()
             formatter.numberStyle = .decimal
             formatter.numberStyle = .decimal
             formatter.maximumFractionDigits = 2
             formatter.maximumFractionDigits = 2
@@ -92,7 +93,8 @@ enum DataTable {
             idPumpEvent: String? = nil,
             idPumpEvent: String? = nil,
             isFPU: Bool? = false,
             isFPU: Bool? = false,
             fpuID: String? = nil,
             fpuID: String? = nil,
-            note: String? = nil
+            note: String? = nil,
+            isSMB: Bool? = nil
         ) {
         ) {
             self.units = units
             self.units = units
             self.type = type
             self.type = type
@@ -105,6 +107,7 @@ enum DataTable {
             self.isFPU = isFPU
             self.isFPU = isFPU
             self.fpuID = fpuID
             self.fpuID = fpuID
             self.note = note
             self.note = note
+            self.isSMB = isSMB
         }
         }
 
 
         static func == (lhs: Treatment, rhs: Treatment) -> Bool {
         static func == (lhs: Treatment, rhs: Treatment) -> Bool {
@@ -126,14 +129,17 @@ enum DataTable {
 
 
             switch type {
             switch type {
             case .carbs:
             case .carbs:
-                return numberFormater.string(from: amount as NSNumber)! + NSLocalizedString(" g", comment: "gram of carbs")
+                return numberFormatter
+                    .string(from: amount as NSNumber)! + NSLocalizedString(" g", comment: "gram of carbs")
             case .fpus:
             case .fpus:
-                return numberFormater
+                return numberFormatter
                     .string(from: amount as NSNumber)! + NSLocalizedString(" g", comment: "gram of carb equilvalents")
                     .string(from: amount as NSNumber)! + NSLocalizedString(" g", comment: "gram of carb equilvalents")
             case .bolus:
             case .bolus:
-                return numberFormater.string(from: amount as NSNumber)! + NSLocalizedString(" U", comment: "Insulin unit")
+                return numberFormatter
+                    .string(from: amount as NSNumber)! + NSLocalizedString(" U", comment: "Insulin unit") +
+                    "\((isSMB ?? true)! ? " SMB" : " Manual")"
             case .tempBasal:
             case .tempBasal:
-                return numberFormater
+                return numberFormatter
                     .string(from: amount as NSNumber)! + NSLocalizedString(" U/hr", comment: "Unit insulin per hour")
                     .string(from: amount as NSNumber)! + NSLocalizedString(" U/hr", comment: "Unit insulin per hour")
             case .tempTarget:
             case .tempTarget:
                 var converted = amount
                 var converted = amount
@@ -142,7 +148,7 @@ enum DataTable {
                 }
                 }
 
 
                 guard var secondAmount = secondAmount else {
                 guard var secondAmount = secondAmount else {
-                    return numberFormater.string(from: converted as NSNumber)! + " \(units.rawValue)"
+                    return numberFormatter.string(from: converted as NSNumber)! + " \(units.rawValue)"
                 }
                 }
                 if units == .mmolL {
                 if units == .mmolL {
                     secondAmount = secondAmount.asMmolL
                     secondAmount = secondAmount.asMmolL
@@ -177,7 +183,7 @@ enum DataTable {
             guard let duration = duration, duration > 0 else {
             guard let duration = duration, duration > 0 else {
                 return nil
                 return nil
             }
             }
-            return numberFormater.string(from: duration as NSNumber)! + " min"
+            return numberFormatter.string(from: duration as NSNumber)! + " min"
         }
         }
     }
     }
 
 

+ 1 - 0
FreeAPS/Sources/Services/UserNotifiactions/UserNotificationsManager.swift

@@ -232,6 +232,7 @@ final class BaseUserNotificationsManager: NSObject, UserNotificationsManager, In
             }
             }
         }
         }
     }
     }
+
     private func glucoseText(glucoseValue: Int, delta: Int?, direction: BloodGlucose.Direction?) -> String {
     private func glucoseText(glucoseValue: Int, delta: Int?, direction: BloodGlucose.Direction?) -> String {
         let units = settingsManager.settings.units
         let units = settingsManager.settings.units
         let glucoseText = glucoseFormatter
         let glucoseText = glucoseFormatter