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)
|
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)
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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;
|
||||||
|
@ -104,7 +105,7 @@ import io.reactivex.rxjava3.functions.Consumer;
|
||||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class PatchManagerImpl{
|
public class PatchManagerImpl {
|
||||||
@Inject IPreferenceManager pm;
|
@Inject IPreferenceManager pm;
|
||||||
@Inject Context context;
|
@Inject Context context;
|
||||||
@Inject SP sp;
|
@Inject SP sp;
|
||||||
|
@ -154,27 +155,27 @@ public class PatchManagerImpl{
|
||||||
Observable<Intent> dateTimeChanged = RxBroadcastReceiver.Companion.create(context, filter);
|
Observable<Intent> dateTimeChanged = RxBroadcastReceiver.Companion.create(context, filter);
|
||||||
|
|
||||||
compositeDisposable.add(
|
compositeDisposable.add(
|
||||||
Observable.combineLatest(patch.observeConnected(), pm.observePatchLifeCycle(),
|
Observable.combineLatest(patch.observeConnected(), pm.observePatchLifeCycle(),
|
||||||
(connected, lifeCycle) -> (connected && lifeCycle.isActivated()))
|
(connected, lifeCycle) -> (connected && lifeCycle.isActivated()))
|
||||||
.subscribeOn(aapsSchedulers.getIo())
|
.subscribeOn(aapsSchedulers.getIo())
|
||||||
.filter(ok -> ok)
|
.filter(ok -> ok)
|
||||||
.observeOn(aapsSchedulers.getIo())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.doOnNext(v -> TaskBase.enqueue(TaskFunc.UPDATE_CONNECTION))
|
.doOnNext(v -> TaskBase.enqueue(TaskFunc.UPDATE_CONNECTION))
|
||||||
.retry()
|
.retry()
|
||||||
.subscribe());
|
.subscribe());
|
||||||
|
|
||||||
compositeDisposable.add(
|
compositeDisposable.add(
|
||||||
Observable.combineLatest(patch.observeConnected(),
|
Observable.combineLatest(patch.observeConnected(),
|
||||||
pm.observePatchLifeCycle().distinctUntilChanged(),
|
pm.observePatchLifeCycle().distinctUntilChanged(),
|
||||||
dateTimeChanged.startWith(Observable.just(new Intent())),
|
dateTimeChanged.startWith(Observable.just(new Intent())),
|
||||||
(connected, lifeCycle, value) -> (connected && lifeCycle.isActivated()))
|
(connected, lifeCycle, value) -> (connected && lifeCycle.isActivated()))
|
||||||
.subscribeOn(aapsSchedulers.getIo())
|
.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)
|
.filter(ok -> ok)
|
||||||
.doOnNext(v -> TaskBase.enqueue(TaskFunc.SET_GLOBAL_TIME))
|
.doOnNext(v -> TaskBase.enqueue(TaskFunc.SET_GLOBAL_TIME))
|
||||||
.doOnError(e -> aapsLogger.error(LTag.PUMP, "Failed to set EOPatch time."))
|
.doOnError(e -> aapsLogger.error(LTag.PUMP, "Failed to set EOPatch time."))
|
||||||
.retry()
|
.retry()
|
||||||
.subscribe());
|
.subscribe());
|
||||||
|
|
||||||
compositeDisposable.add(
|
compositeDisposable.add(
|
||||||
patch.observeConnected()
|
patch.observeConnected()
|
||||||
|
@ -233,7 +234,7 @@ public class PatchManagerImpl{
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.flatMap(integer -> {
|
.flatMap(integer -> {
|
||||||
if(pc.getLowReservoirAlertAmount() != doseUnit || pc.getPatchExpireAlertTime() != hours) {
|
if (pc.getLowReservoirAlertAmount() != doseUnit || pc.getPatchExpireAlertTime() != hours) {
|
||||||
return setLowReservoir(doseUnit, hours)
|
return setLowReservoir(doseUnit, hours)
|
||||||
.doOnSuccess(patchBooleanResponse -> {
|
.doOnSuccess(patchBooleanResponse -> {
|
||||||
pc.setLowReservoirAlertAmount(doseUnit);
|
pc.setLowReservoirAlertAmount(doseUnit);
|
||||||
|
@ -244,7 +245,7 @@ public class PatchManagerImpl{
|
||||||
return Single.just(true);
|
return Single.just(true);
|
||||||
})
|
})
|
||||||
.flatMap(ret -> {
|
.flatMap(ret -> {
|
||||||
if(pc.getInfoReminder() != buzzer) {
|
if (pc.getInfoReminder() != buzzer) {
|
||||||
return infoReminderSet(buzzer)
|
return infoReminderSet(buzzer)
|
||||||
.doOnSuccess(patchBooleanResponse -> {
|
.doOnSuccess(patchBooleanResponse -> {
|
||||||
pc.setInfoReminder(buzzer);
|
pc.setInfoReminder(buzzer);
|
||||||
|
@ -256,7 +257,7 @@ public class PatchManagerImpl{
|
||||||
.subscribe());
|
.subscribe());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!connected && activated){
|
if (!connected && activated) {
|
||||||
pm.getPatchConfig().updatetDisconnectedTime();
|
pm.getPatchConfig().updatetDisconnectedTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -304,7 +305,7 @@ public class PatchManagerImpl{
|
||||||
|
|
||||||
NormalBasal normalBasal = pm.getNormalBasalManager().getNormalBasal();
|
NormalBasal normalBasal = pm.getNormalBasalManager().getNormalBasal();
|
||||||
|
|
||||||
if(normalBasal.updateNormalBasalIndex()) {
|
if (normalBasal.updateNormalBasalIndex()) {
|
||||||
pm.flushNormalBasalManager();
|
pm.flushNormalBasalManager();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
*/
|
*/
|
||||||
|
@ -348,7 +349,7 @@ public class PatchManagerImpl{
|
||||||
|
|
||||||
public Single<TemperatureResponse> getTemperature() {
|
public Single<TemperatureResponse> getTemperature() {
|
||||||
return TEMPERATURE_GET.get()
|
return TEMPERATURE_GET.get()
|
||||||
.timeout(DEFAULT_API_TIME_OUT, TimeUnit.SECONDS);
|
.timeout(DEFAULT_API_TIME_OUT, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Observable<Long> startPriming(long timeout, long count) {
|
public Observable<Long> startPriming(long timeout, long count) {
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -482,7 +490,7 @@ public class PatchManagerImpl{
|
||||||
return stopExtBolusTask.stop().timeout(DEFAULT_API_TIME_OUT, TimeUnit.SECONDS);
|
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);
|
return stopComboBolusTask.stop().timeout(DEFAULT_API_TIME_OUT, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
|
@ -566,7 +577,7 @@ public class PatchManagerImpl{
|
||||||
patchStateManager.updatePatchState(PatchState.create(notification.patchState, System.currentTimeMillis()));
|
patchStateManager.updatePatchState(PatchState.create(notification.patchState, System.currentTimeMillis()));
|
||||||
|
|
||||||
if (pm.getPatchConfig().isActivated()) {
|
if (pm.getPatchConfig().isActivated()) {
|
||||||
if(!patch.isSeqReady()){
|
if (!patch.isSeqReady()) {
|
||||||
getSequence().subscribe();
|
getSequence().subscribe();
|
||||||
}
|
}
|
||||||
updateBasal();
|
updateBasal();
|
||||||
|
@ -601,11 +612,11 @@ public class PatchManagerImpl{
|
||||||
|
|
||||||
public Single<Boolean> sharedKey() {
|
public Single<Boolean> sharedKey() {
|
||||||
return genKeyPair().flatMap(keyPair -> ECPublicToRawBytes(keyPair)
|
return genKeyPair().flatMap(keyPair -> ECPublicToRawBytes(keyPair)
|
||||||
.flatMap(bytes -> PUBLIC_KEY_SET.send(bytes)
|
.flatMap(bytes -> PUBLIC_KEY_SET.send(bytes)
|
||||||
.map(KeyResponse::getPublicKey)
|
.map(KeyResponse::getPublicKey)
|
||||||
.map(bytes2 -> rawToEncodedECPublicKey(SECP256R1, bytes2))
|
.map(bytes2 -> rawToEncodedECPublicKey(SECP256R1, bytes2))
|
||||||
.map(publicKey -> generateSharedSecret(keyPair.getPrivate(), publicKey))
|
.map(publicKey -> generateSharedSecret(keyPair.getPrivate(), publicKey))
|
||||||
.doOnSuccess(this::saveShared).map(v2 -> true)))
|
.doOnSuccess(this::saveShared).map(v2 -> true)))
|
||||||
.doOnError(e -> aapsLogger.error(LTag.PUMP, "sharedKey error"));
|
.doOnError(e -> aapsLogger.error(LTag.PUMP, "sharedKey error"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -731,7 +742,7 @@ public class PatchManagerImpl{
|
||||||
return patch.observeConnectionState();
|
return patch.observeConnectionState();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMacAddress(String mac, boolean b){
|
public void updateMacAddress(String mac, boolean b) {
|
||||||
patch.updateMacAddress(mac, b);
|
patch.updateMacAddress(mac, b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue