EOPatch2: log insulin change on activation

This commit is contained in:
Milos Kozak 2022-11-07 09:52:16 +01:00
parent 8641273d7c
commit 7ae9ad1105
5 changed files with 66 additions and 43 deletions

View file

@ -54,15 +54,19 @@ class StatusLightHandler @Inject constructor(
} }
val insulinUnit = rh.gs(R.string.insulin_unit_shortname) val insulinUnit = rh.gs(R.string.insulin_unit_shortname)
if (pump.model() == PumpType.OMNIPOD_EROS || pump.model() == PumpType.OMNIPOD_DASH) { if (pump.pumpDescription.isPatchPump)
handlePatchReservoirLevel(careportal_reservoir_level, R.string.key_statuslights_res_critical, 10.0, R.string.key_statuslights_res_warning, 80.0, pump.reservoirLevel, insulinUnit, handlePatchReservoirLevel(
OmnipodConstants.MAX_RESERVOIR_READING) careportal_reservoir_level,
} else if (pump.model() == PumpType.EOFLOW_EOPATCH2) { R.string.key_statuslights_res_critical,
handlePatchReservoirLevel(careportal_reservoir_level, R.string.key_statuslights_res_critical, 10.0, R.string.key_statuslights_res_warning, 80.0, pump.reservoirLevel, insulinUnit, 10.0,
AppConstant.MAX_RESERVOIR_READING) R.string.key_statuslights_res_warning,
} else { 80.0,
pump.reservoirLevel,
insulinUnit,
pump.pumpDescription.maxResorvoirReading.toDouble()
)
else
handleLevel(careportal_reservoir_level, R.string.key_statuslights_res_critical, 10.0, R.string.key_statuslights_res_warning, 80.0, pump.reservoirLevel, insulinUnit) handleLevel(careportal_reservoir_level, R.string.key_statuslights_res_critical, 10.0, R.string.key_statuslights_res_warning, 80.0, pump.reservoirLevel, insulinUnit)
}
if (!config.NSCLIENT) { if (!config.NSCLIENT) {
if (bgSource.sensorBatteryLevel != -1) if (bgSource.sensorBatteryLevel != -1)

View file

@ -39,6 +39,7 @@ class PumpDescription() {
var needsManualTDDLoad = false var needsManualTDDLoad = false
var hasCustomUnreachableAlertCheck = false var hasCustomUnreachableAlertCheck = false
var isPatchPump = false var isPatchPump = false
var maxResorvoirReading = 50
var useHardwareLink = false var useHardwareLink = false
private fun resetSettings() { private fun resetSettings() {
@ -107,6 +108,7 @@ class PumpDescription() {
is30minBasalRatesCapable = pumpCapability.hasCapability(PumpCapability.BasalRate30min) is30minBasalRatesCapable = pumpCapability.hasCapability(PumpCapability.BasalRate30min)
hasCustomUnreachableAlertCheck = pumpType.hasCustomUnreachableAlertCheck hasCustomUnreachableAlertCheck = pumpType.hasCustomUnreachableAlertCheck
isPatchPump = pumpType.isPatchPump isPatchPump = pumpType.isPatchPump
maxResorvoirReading = pumpType.maxReservoirReading
useHardwareLink = pumpType.useHardwareLink useHardwareLink = pumpType.useHardwareLink
} }

View file

@ -213,6 +213,7 @@ enum class PumpType {
pumpCapability = PumpCapability.OmnipodCapabilities, pumpCapability = PumpCapability.OmnipodCapabilities,
hasCustomUnreachableAlertCheck = true, hasCustomUnreachableAlertCheck = true,
isPatchPump = true, isPatchPump = true,
maxReservoirReading = 50,
useHardwareLink = true, useHardwareLink = true,
supportBatteryLevel = false, supportBatteryLevel = false,
source = Sources.OmnipodEros source = Sources.OmnipodEros
@ -232,6 +233,7 @@ enum class PumpType {
baseBasalStep = 0.05, baseBasalStep = 0.05,
baseBasalSpecialSteps = null, baseBasalSpecialSteps = null,
isPatchPump = true, isPatchPump = true,
maxReservoirReading = 50,
pumpCapability = PumpCapability.OmnipodCapabilities, pumpCapability = PumpCapability.OmnipodCapabilities,
hasCustomUnreachableAlertCheck = false, hasCustomUnreachableAlertCheck = false,
supportBatteryLevel = false supportBatteryLevel = false
@ -392,6 +394,7 @@ enum class PumpType {
baseBasalSpecialSteps = null, baseBasalSpecialSteps = null,
pumpCapability = PumpCapability.EopatchCapabilities, pumpCapability = PumpCapability.EopatchCapabilities,
isPatchPump = true, isPatchPump = true,
maxReservoirReading = 50,
source = Sources.EOPatch2); source = Sources.EOPatch2);
val description: String val description: String
@ -435,6 +438,8 @@ enum class PumpType {
private set private set
var isPatchPump = false var isPatchPump = false
private set private set
var maxReservoirReading = 50
private set
var supportBatteryLevel = true var supportBatteryLevel = true
private set private set
var useHardwareLink = false var useHardwareLink = false
@ -510,6 +515,7 @@ enum class PumpType {
pumpCapability: PumpCapability, pumpCapability: PumpCapability,
hasCustomUnreachableAlertCheck: Boolean = false, hasCustomUnreachableAlertCheck: Boolean = false,
isPatchPump: Boolean = false, isPatchPump: Boolean = false,
maxReservoirReading: Int = 50,
supportBatteryLevel: Boolean = true, supportBatteryLevel: Boolean = true,
useHardwareLink: Boolean = false, useHardwareLink: Boolean = false,
source: Sources = Sources.VirtualPump source: Sources = Sources.VirtualPump
@ -530,6 +536,7 @@ enum class PumpType {
this.pumpCapability = pumpCapability this.pumpCapability = pumpCapability
this.hasCustomUnreachableAlertCheck = hasCustomUnreachableAlertCheck this.hasCustomUnreachableAlertCheck = hasCustomUnreachableAlertCheck
this.isPatchPump = isPatchPump this.isPatchPump = isPatchPump
this.maxReservoirReading = maxReservoirReading
this.supportBatteryLevel = supportBatteryLevel this.supportBatteryLevel = supportBatteryLevel
this.useHardwareLink = useHardwareLink this.useHardwareLink = useHardwareLink
this.source = source this.source = source

View file

@ -25,6 +25,5 @@ interface AppConstant {
const val DAY_START_MINUTE = 0 * 60 const val DAY_START_MINUTE = 0 * 60
const val DAY_END_MINUTE = 24 * 60 const val DAY_END_MINUTE = 24 * 60
const val INSULIN_DURATION_MIN = 2.0f const val INSULIN_DURATION_MIN = 2.0f
const val MAX_RESERVOIR_READING = 50.0
} }
} }

View file

@ -35,6 +35,7 @@ import javax.inject.Singleton;
import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.interfaces.PumpSync; import info.nightscout.androidaps.interfaces.PumpSync;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
import info.nightscout.androidaps.plugins.pump.eopatch.EoPatchRxBus; import info.nightscout.androidaps.plugins.pump.eopatch.EoPatchRxBus;
import info.nightscout.androidaps.plugins.pump.eopatch.alarm.AlarmCode; import info.nightscout.androidaps.plugins.pump.eopatch.alarm.AlarmCode;
import info.nightscout.androidaps.plugins.pump.eopatch.ble.task.ActivateTask; import info.nightscout.androidaps.plugins.pump.eopatch.ble.task.ActivateTask;
@ -319,7 +320,7 @@ public class PatchManagerImpl{
/** /**
* getPatchConnection() 사용해야 한다. * getPatchConnection() 사용해야 한다.
* 아직 Life Cycle Activated 아님. * 아직 Life Cycle Activated 아님.
* * <p>
* Activation Process task #1 Get Patch Information from Patch * Activation Process task #1 Get Patch Information from Patch
* Fragment: fragment_patch_connect_new * Fragment: fragment_patch_connect_new
*/ */
@ -382,6 +383,13 @@ public class PatchManagerImpl{
TaskBase.enqueue(TaskFunc.LOW_RESERVOIR); TaskBase.enqueue(TaskFunc.LOW_RESERVOIR);
TaskBase.enqueue(TaskFunc.INFO_REMINDER); TaskBase.enqueue(TaskFunc.INFO_REMINDER);
pumpSync.connectNewPump(true); pumpSync.connectNewPump(true);
pumpSync.insertTherapyEventIfNewWithTimestamp(
System.currentTimeMillis(),
DetailedBolusInfo.EventType.INSULIN_CHANGE,
null,
null,
PumpType.EOFLOW_EOPATCH2,
null);
} }
}); });
} }
@ -524,6 +532,7 @@ public class PatchManagerImpl{
@Inject @Inject
DeactivateTask deactivateTask; DeactivateTask deactivateTask;
// Patch Activation Tasks // Patch Activation Tasks
public Single<DeactivationStatus> deactivate(long timeout, boolean force) { public Single<DeactivationStatus> deactivate(long timeout, boolean force) {
return deactivateTask.run(force, timeout); return deactivateTask.run(force, timeout);
@ -538,12 +547,14 @@ public class PatchManagerImpl{
@Inject @Inject
SetLowReservoirTask setLowReservoirTask; SetLowReservoirTask setLowReservoirTask;
public Single<PatchBooleanResponse> setLowReservoir(int doseUnit, int hours) { public Single<PatchBooleanResponse> setLowReservoir(int doseUnit, int hours) {
return setLowReservoirTask.set(doseUnit, hours).timeout(DEFAULT_API_TIME_OUT, TimeUnit.SECONDS); return setLowReservoirTask.set(doseUnit, hours).timeout(DEFAULT_API_TIME_OUT, TimeUnit.SECONDS);
} }
@Inject @Inject
UpdateConnectionTask updateConnectionTask; UpdateConnectionTask updateConnectionTask;
public Single<PatchState> updateConnection() { public Single<PatchState> updateConnection() {
return updateConnectionTask.update(); return updateConnectionTask.update();
} }