Skip to content

Commit

Permalink
Merge pull request #359 from kskandis/dev
Browse files Browse the repository at this point in the history
set default state and image for simulatorPump
  • Loading branch information
MikePlante1 authored Jul 23, 2024
2 parents f5a8d97 + 40f9b33 commit dff37ac
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions FreeAPS/Sources/APS/DeviceDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,29 @@ final class BaseDeviceDataManager: DeviceDataManager, Injectable {
}
pumpExpiresAtDate.send(endTime)
}
if let simulatorPump = pumpManager as? MockPumpManager {
pumpDisplayState.value = PumpDisplayState(name: simulatorPump.localizedTitle, image: simulatorPump.smallImage)
pumpName.send(simulatorPump.localizedTitle)
storage.save(Decimal(simulatorPump.pumpReservoirCapacity), as: OpenAPS.Monitor.reservoir)
DispatchQueue.main.async {
self.broadcaster.notify(PumpReservoirObserver.self, on: .main) {
$0.pumpReservoirDidChange(Decimal(simulatorPump.state.reservoirUnitsRemaining))
}
}
let batteryPercent = Int((simulatorPump.state.pumpBatteryChargeRemaining ?? 1) * 100)
let battery = Battery(
percent: batteryPercent,
voltage: nil,
string: batteryPercent >= 10 ? .normal : .low,
display: simulatorPump.state.pumpBatteryChargeRemaining != nil
)
storage.save(battery, as: OpenAPS.Monitor.battery)
DispatchQueue.main.async {
self.broadcaster.notify(PumpBatteryObserver.self, on: .main) {
$0.pumpBatteryDidChange(battery)
}
}
}
} else {
pumpDisplayState.value = nil
pumpExpiresAtDate.send(nil)
Expand Down

0 comments on commit dff37ac

Please sign in to comment.