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)
if (pump.model() == PumpType.OMNIPOD_EROS || pump.model() == PumpType.OMNIPOD_DASH) {
handlePatchReservoirLevel(careportal_reservoir_level, R.string.key_statuslights_res_critical, 10.0, R.string.key_statuslights_res_warning, 80.0, pump.reservoirLevel, insulinUnit,
OmnipodConstants.MAX_RESERVOIR_READING)
} else if (pump.model() == PumpType.EOFLOW_EOPATCH2) {
handlePatchReservoirLevel(careportal_reservoir_level, R.string.key_statuslights_res_critical, 10.0, R.string.key_statuslights_res_warning, 80.0, pump.reservoirLevel, insulinUnit,
AppConstant.MAX_RESERVOIR_READING)
} else {
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,
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)
}
if (!config.NSCLIENT) {
if (bgSource.sensorBatteryLevel != -1)

View file

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

View file

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

View file

@ -25,6 +25,5 @@ interface AppConstant {
const val DAY_START_MINUTE = 0 * 60
const val DAY_END_MINUTE = 24 * 60
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.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.alarm.AlarmCode;
import info.nightscout.androidaps.plugins.pump.eopatch.ble.task.ActivateTask;
@ -319,7 +320,7 @@ public class PatchManagerImpl{
/**
* getPatchConnection() 사용해야 한다.
* 아직 Life Cycle Activated 아님.
*
* <p>
* Activation Process task #1 Get Patch Information from Patch
* Fragment: fragment_patch_connect_new
*/
@ -382,6 +383,13 @@ public class PatchManagerImpl{
TaskBase.enqueue(TaskFunc.LOW_RESERVOIR);
TaskBase.enqueue(TaskFunc.INFO_REMINDER);
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
DeactivateTask deactivateTask;
// Patch Activation Tasks
public Single<DeactivationStatus> deactivate(long timeout, boolean force) {
return deactivateTask.run(force, timeout);
@ -538,12 +547,14 @@ public class PatchManagerImpl{
@Inject
SetLowReservoirTask setLowReservoirTask;
public Single<PatchBooleanResponse> setLowReservoir(int doseUnit, int hours) {
return setLowReservoirTask.set(doseUnit, hours).timeout(DEFAULT_API_TIME_OUT, TimeUnit.SECONDS);
}
@Inject
UpdateConnectionTask updateConnectionTask;
public Single<PatchState> updateConnection() {
return updateConnectionTask.update();
}