|
@@ -4,6 +4,7 @@ extension BasalProfileEditor {
|
|
|
final class StateModel: BaseStateModel<Provider> {
|
|
final class StateModel: BaseStateModel<Provider> {
|
|
|
@Published var syncInProgress = false
|
|
@Published var syncInProgress = false
|
|
|
@Published var items: [Item] = []
|
|
@Published var items: [Item] = []
|
|
|
|
|
+ @Published var autotuneProfile: [BasalProfileEntry?] = []
|
|
|
|
|
|
|
|
let timeValues = stride(from: 0.0, to: 1.days.timeInterval, by: 30.minutes.timeInterval).map { $0 }
|
|
let timeValues = stride(from: 0.0, to: 1.days.timeInterval, by: 30.minutes.timeInterval).map { $0 }
|
|
|
|
|
|
|
@@ -22,6 +23,21 @@ extension BasalProfileEditor {
|
|
|
let rateIndex = rateValues.firstIndex(of: value.rate) ?? 0
|
|
let rateIndex = rateValues.firstIndex(of: value.rate) ?? 0
|
|
|
return Item(rateIndex: rateIndex, timeIndex: timeIndex)
|
|
return Item(rateIndex: rateIndex, timeIndex: timeIndex)
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ var bp: [BasalProfileEntry?] = []
|
|
|
|
|
+ for p in provider.profile {
|
|
|
|
|
+ var np: BasalProfileEntry?
|
|
|
|
|
+ for b in provider.autotune?.basalProfile ?? [] {
|
|
|
|
|
+ if b.start > p.start {
|
|
|
|
|
+ NSLog("Matched \(p) with \(b)")
|
|
|
|
|
+ break
|
|
|
|
|
+ }
|
|
|
|
|
+ np = b
|
|
|
|
|
+ }
|
|
|
|
|
+ bp.append(np)
|
|
|
|
|
+ }
|
|
|
|
|
+ NSLog("basalProfile \(bp)")
|
|
|
|
|
+ autotuneProfile = bp
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func add() {
|
|
func add() {
|