|
|
@@ -10,6 +10,7 @@ import MinimedKit
|
|
|
import MockKit
|
|
|
import OmniBLE
|
|
|
import OmniKit
|
|
|
+import OmnipodKit
|
|
|
import ShareClient
|
|
|
import SwiftDate
|
|
|
import Swinject
|
|
|
@@ -39,6 +40,7 @@ private let staticPumpManagers: [PumpManagerUI.Type] = [
|
|
|
MinimedPumpManager.self,
|
|
|
OmnipodPumpManager.self,
|
|
|
OmniBLEPumpManager.self,
|
|
|
+ OmniPumpManager.self,
|
|
|
DanaKitPumpManager.self,
|
|
|
MedtrumPumpManager.self,
|
|
|
MockPumpManager.self
|
|
|
@@ -48,6 +50,7 @@ private let staticPumpManagersByIdentifier: [String: PumpManagerUI.Type] = [
|
|
|
MinimedPumpManager.pluginIdentifier: MinimedPumpManager.self,
|
|
|
OmnipodPumpManager.pluginIdentifier: OmnipodPumpManager.self,
|
|
|
OmniBLEPumpManager.pluginIdentifier: OmniBLEPumpManager.self,
|
|
|
+ OmniPumpManager.pluginIdentifier: OmniPumpManager.self,
|
|
|
DanaKitPumpManager.pluginIdentifier: DanaKitPumpManager.self,
|
|
|
MedtrumPumpManager.pluginIdentifier: MedtrumPumpManager.self,
|
|
|
MockPumpManager.pluginIdentifier: MockPumpManager.self
|
|
|
@@ -142,6 +145,13 @@ final class BaseDeviceDataManager: DeviceDataManager, Injectable {
|
|
|
pumpActivatedAtDate.send(medtrumPump.state.patchActivatedAt)
|
|
|
}
|
|
|
}
|
|
|
+ if let omni = pumpManager as? OmniPumpManager {
|
|
|
+ guard let endTime = omni.state.podState?.expiresAt else {
|
|
|
+ pumpExpiresAtDate.send(nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ pumpExpiresAtDate.send(endTime)
|
|
|
+ }
|
|
|
if let simulatorPump = pumpManager as? MockPumpManager {
|
|
|
pumpDisplayState.value = PumpDisplayState(name: simulatorPump.localizedTitle, image: simulatorPump.smallImage)
|
|
|
pumpName.send(simulatorPump.localizedTitle)
|
|
|
@@ -554,6 +564,39 @@ extension BaseDeviceDataManager: PumpManagerDelegate {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if let omni = pumpManager as? OmniPumpManager {
|
|
|
+ let reservoirVal = omni.state.podState?.lastInsulinMeasurements?.reservoirLevel ?? 0xDEAD_BEEF
|
|
|
+ // TODO: find the value Pod.maximumReservoirReading
|
|
|
+ let reservoir = Decimal(reservoirVal) > 50.0 ? 0xDEAD_BEEF : reservoirVal
|
|
|
+
|
|
|
+ storage.save(Decimal(reservoir), as: OpenAPS.Monitor.reservoir)
|
|
|
+ broadcaster.notify(PumpReservoirObserver.self, on: processQueue) {
|
|
|
+ $0.pumpReservoirDidChange(Decimal(reservoir))
|
|
|
+ }
|
|
|
+
|
|
|
+ // manual temp basal on
|
|
|
+ if let tempBasal = omni.state.podState?.unfinalizedTempBasal, !tempBasal.isFinished(),
|
|
|
+ !tempBasal.automatic
|
|
|
+ {
|
|
|
+ // the manual basal temp is launch - block every thing
|
|
|
+ debug(.deviceManager, "manual temp basal")
|
|
|
+ manualTempBasal.send(true)
|
|
|
+ } else {
|
|
|
+ // no more manual Temp Basal !
|
|
|
+ manualTempBasal.send(false)
|
|
|
+ }
|
|
|
+
|
|
|
+ guard let endTime = omni.state.podState?.expiresAt else {
|
|
|
+ pumpExpiresAtDate.send(nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ pumpExpiresAtDate.send(endTime)
|
|
|
+
|
|
|
+ if let startTime = omni.state.podState?.activatedAt {
|
|
|
+ storage.save(startTime, as: OpenAPS.Monitor.podAge)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if let simulatorPump = pumpManager as? MockPumpManager {
|
|
|
broadcaster.notify(PumpReservoirObserver.self, on: processQueue) {
|
|
|
$0.pumpReservoirDidChange(Decimal(simulatorPump.state.reservoirUnitsRemaining))
|