EOPatch2: log insulin change on activation
This commit is contained in:
parent
8641273d7c
commit
7ae9ad1105
5 changed files with 66 additions and 43 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
@ -104,7 +105,7 @@ import io.reactivex.rxjava3.functions.Consumer;
|
|||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
|
||||
@Singleton
|
||||
public class PatchManagerImpl{
|
||||
public class PatchManagerImpl {
|
||||
@Inject IPreferenceManager pm;
|
||||
@Inject Context context;
|
||||
@Inject SP sp;
|
||||
|
@ -169,7 +170,7 @@ public class PatchManagerImpl{
|
|||
dateTimeChanged.startWith(Observable.just(new Intent())),
|
||||
(connected, lifeCycle, value) -> (connected && lifeCycle.isActivated()))
|
||||
.subscribeOn(aapsSchedulers.getIo())
|
||||
.doOnNext(v -> aapsLogger.debug(LTag.PUMP,"Has the date or time changed? "+v))
|
||||
.doOnNext(v -> aapsLogger.debug(LTag.PUMP, "Has the date or time changed? " + v))
|
||||
.filter(ok -> ok)
|
||||
.doOnNext(v -> TaskBase.enqueue(TaskFunc.SET_GLOBAL_TIME))
|
||||
.doOnError(e -> aapsLogger.error(LTag.PUMP, "Failed to set EOPatch time."))
|
||||
|
@ -233,7 +234,7 @@ public class PatchManagerImpl{
|
|||
}
|
||||
})
|
||||
.flatMap(integer -> {
|
||||
if(pc.getLowReservoirAlertAmount() != doseUnit || pc.getPatchExpireAlertTime() != hours) {
|
||||
if (pc.getLowReservoirAlertAmount() != doseUnit || pc.getPatchExpireAlertTime() != hours) {
|
||||
return setLowReservoir(doseUnit, hours)
|
||||
.doOnSuccess(patchBooleanResponse -> {
|
||||
pc.setLowReservoirAlertAmount(doseUnit);
|
||||
|
@ -244,7 +245,7 @@ public class PatchManagerImpl{
|
|||
return Single.just(true);
|
||||
})
|
||||
.flatMap(ret -> {
|
||||
if(pc.getInfoReminder() != buzzer) {
|
||||
if (pc.getInfoReminder() != buzzer) {
|
||||
return infoReminderSet(buzzer)
|
||||
.doOnSuccess(patchBooleanResponse -> {
|
||||
pc.setInfoReminder(buzzer);
|
||||
|
@ -256,7 +257,7 @@ public class PatchManagerImpl{
|
|||
.subscribe());
|
||||
}
|
||||
|
||||
if(!connected && activated){
|
||||
if (!connected && activated) {
|
||||
pm.getPatchConfig().updatetDisconnectedTime();
|
||||
}
|
||||
}
|
||||
|
@ -304,7 +305,7 @@ public class PatchManagerImpl{
|
|||
|
||||
NormalBasal normalBasal = pm.getNormalBasalManager().getNormalBasal();
|
||||
|
||||
if(normalBasal.updateNormalBasalIndex()) {
|
||||
if (normalBasal.updateNormalBasalIndex()) {
|
||||
pm.flushNormalBasalManager();
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -482,7 +490,7 @@ public class PatchManagerImpl{
|
|||
return stopExtBolusTask.stop().timeout(DEFAULT_API_TIME_OUT, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public Single<ComboBolusStopResponse> stopComboBolus(){
|
||||
public Single<ComboBolusStopResponse> stopComboBolus() {
|
||||
return stopComboBolusTask.stop().timeout(DEFAULT_API_TIME_OUT, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -566,7 +577,7 @@ public class PatchManagerImpl{
|
|||
patchStateManager.updatePatchState(PatchState.create(notification.patchState, System.currentTimeMillis()));
|
||||
|
||||
if (pm.getPatchConfig().isActivated()) {
|
||||
if(!patch.isSeqReady()){
|
||||
if (!patch.isSeqReady()) {
|
||||
getSequence().subscribe();
|
||||
}
|
||||
updateBasal();
|
||||
|
@ -731,7 +742,7 @@ public class PatchManagerImpl{
|
|||
return patch.observeConnectionState();
|
||||
}
|
||||
|
||||
public void updateMacAddress(String mac, boolean b){
|
||||
public void updateMacAddress(String mac, boolean b) {
|
||||
patch.updateMacAddress(mac, b);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue