Skip to content

Commit d433579

Browse files
committed
Unit compability fix
1 parent a7e7242 commit d433579

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

Sources/LoopAlgorithmToPython/LoopAlgorithmToPython.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,15 +436,20 @@ public func getDynamicCarbsOnBoard(jsonData: UnsafePointer<Int8>?) -> Double {
436436

437437
let startDate = dateFormatter.date(from: input.inputICE[0].startAt)!
438438
let endDate = dateFormatter.date(from: input.inputICE.last!.startAt)!
439-
let carbRatio = [AbsoluteScheduleValue(
439+
440+
// This uses the compatibility layer to work on all platforms
441+
let carbRatio = [AbsoluteScheduleValue<AlgorithmValue>.universal(
440442
startDate: startDate,
441443
endDate: endDate,
442-
value: LoopQuantity(unit: LoopUnit(from: "g/U"), doubleValue: input.carbRatio)
444+
value: input.carbRatio,
445+
unit: "g/U"
443446
)]
444-
let isf = [AbsoluteScheduleValue(
447+
448+
let isf = [AbsoluteScheduleValue<AlgorithmValue>.universal(
445449
startDate: startDate,
446450
endDate: endDate,
447-
value: LoopQuantity(unit: LoopUnit(from: "mg/dL/U"), doubleValue: input.sensitivity)
451+
value: input.sensitivity,
452+
unit: "mg/dL/U"
448453
)]
449454
let statuses = [carbEntries[0]].map(
450455
to: inputICE,

0 commit comments

Comments
 (0)