|
@@ -65,8 +65,7 @@ enum DeterminationGenerator {
|
|
|
currentTemp: currentTemp,
|
|
currentTemp: currentTemp,
|
|
|
iobData: iobData,
|
|
iobData: iobData,
|
|
|
profile: profile,
|
|
profile: profile,
|
|
|
- trioCustomOrefVariables: trioCustomOrefVariables,
|
|
|
|
|
- currentTime: currentTime,
|
|
|
|
|
|
|
+ trioCustomOrefVariables: trioCustomOrefVariables
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
let currentGlucose: Decimal = glucoseStatus.glucose
|
|
let currentGlucose: Decimal = glucoseStatus.glucose
|
|
@@ -508,8 +507,7 @@ enum DeterminationGenerator {
|
|
|
currentTemp _: TempBasal?,
|
|
currentTemp _: TempBasal?,
|
|
|
iobData: [IobResult]?,
|
|
iobData: [IobResult]?,
|
|
|
profile: Profile?,
|
|
profile: Profile?,
|
|
|
- trioCustomOrefVariables: TrioCustomOrefVariables,
|
|
|
|
|
- currentTime: Date = Date()
|
|
|
|
|
|
|
+ trioCustomOrefVariables: TrioCustomOrefVariables
|
|
|
) throws {
|
|
) throws {
|
|
|
guard let glucoseStatus = glucoseStatus else {
|
|
guard let glucoseStatus = glucoseStatus else {
|
|
|
throw DeterminationError.missingGlucoseStatus
|
|
throw DeterminationError.missingGlucoseStatus
|
|
@@ -520,10 +518,6 @@ enum DeterminationGenerator {
|
|
|
guard profile.profileTarget(trioCustomOrefVariables: trioCustomOrefVariables) != nil else {
|
|
guard profile.profileTarget(trioCustomOrefVariables: trioCustomOrefVariables) != nil else {
|
|
|
throw DeterminationError.invalidProfileTarget
|
|
throw DeterminationError.invalidProfileTarget
|
|
|
}
|
|
}
|
|
|
- let glucoseAge = currentTime.timeIntervalSince(glucoseStatus.date)
|
|
|
|
|
- if glucoseAge > 15 * 60 {
|
|
|
|
|
- throw DeterminationError.staleGlucoseData(ageMinutes: glucoseAge / 60)
|
|
|
|
|
- }
|
|
|
|
|
// we have to allow 38 values so that we can cancel high temps
|
|
// we have to allow 38 values so that we can cancel high temps
|
|
|
if glucoseStatus.glucose < 38 || glucoseStatus.glucose > 600 {
|
|
if glucoseStatus.glucose < 38 || glucoseStatus.glucose > 600 {
|
|
|
throw DeterminationError.glucoseOutOfRange(glucose: glucoseStatus.glucose)
|
|
throw DeterminationError.glucoseOutOfRange(glucose: glucoseStatus.glucose)
|
|
@@ -612,7 +606,7 @@ enum DeterminationGenerator {
|
|
|
deliverAt: currentTime,
|
|
deliverAt: currentTime,
|
|
|
carbsReq: nil,
|
|
carbsReq: nil,
|
|
|
temp: .absolute,
|
|
temp: .absolute,
|
|
|
- bg: glucose,
|
|
|
|
|
|
|
+ bg: nil,
|
|
|
reservoir: nil,
|
|
reservoir: nil,
|
|
|
isf: profile.sens,
|
|
isf: profile.sens,
|
|
|
timestamp: currentTime,
|
|
timestamp: currentTime,
|
|
@@ -623,7 +617,7 @@ enum DeterminationGenerator {
|
|
|
minGuardBG: nil,
|
|
minGuardBG: nil,
|
|
|
minPredBG: nil,
|
|
minPredBG: nil,
|
|
|
threshold: nil,
|
|
threshold: nil,
|
|
|
- carbRatio: profile.carbRatio,
|
|
|
|
|
|
|
+ carbRatio: nil,
|
|
|
received: false
|
|
received: false
|
|
|
)
|
|
)
|
|
|
} else if currentTemp.rate == 0, currentTemp.duration > 30 {
|
|
} else if currentTemp.rate == 0, currentTemp.duration > 30 {
|
|
@@ -644,7 +638,7 @@ enum DeterminationGenerator {
|
|
|
deliverAt: currentTime,
|
|
deliverAt: currentTime,
|
|
|
carbsReq: nil,
|
|
carbsReq: nil,
|
|
|
temp: .absolute,
|
|
temp: .absolute,
|
|
|
- bg: glucose,
|
|
|
|
|
|
|
+ bg: nil,
|
|
|
reservoir: nil,
|
|
reservoir: nil,
|
|
|
isf: profile.sens,
|
|
isf: profile.sens,
|
|
|
timestamp: currentTime,
|
|
timestamp: currentTime,
|
|
@@ -655,7 +649,7 @@ enum DeterminationGenerator {
|
|
|
minGuardBG: nil,
|
|
minGuardBG: nil,
|
|
|
minPredBG: nil,
|
|
minPredBG: nil,
|
|
|
threshold: nil,
|
|
threshold: nil,
|
|
|
- carbRatio: profile.carbRatio,
|
|
|
|
|
|
|
+ carbRatio: nil,
|
|
|
received: false
|
|
received: false
|
|
|
)
|
|
)
|
|
|
} else {
|
|
} else {
|
|
@@ -676,7 +670,7 @@ enum DeterminationGenerator {
|
|
|
deliverAt: currentTime,
|
|
deliverAt: currentTime,
|
|
|
carbsReq: nil,
|
|
carbsReq: nil,
|
|
|
temp: currentTemp.temp,
|
|
temp: currentTemp.temp,
|
|
|
- bg: glucose,
|
|
|
|
|
|
|
+ bg: nil,
|
|
|
reservoir: nil,
|
|
reservoir: nil,
|
|
|
isf: profile.sens,
|
|
isf: profile.sens,
|
|
|
timestamp: currentTime,
|
|
timestamp: currentTime,
|
|
@@ -687,7 +681,7 @@ enum DeterminationGenerator {
|
|
|
minGuardBG: nil,
|
|
minGuardBG: nil,
|
|
|
minPredBG: nil,
|
|
minPredBG: nil,
|
|
|
threshold: nil,
|
|
threshold: nil,
|
|
|
- carbRatio: profile.carbRatio,
|
|
|
|
|
|
|
+ carbRatio: nil,
|
|
|
received: false
|
|
received: false
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|