EOPATCH: fix setting of profile

This commit is contained in:
Milos Kozak 2022-12-04 12:26:56 +01:00
parent b24fcbfb93
commit 0c833d087b
6 changed files with 46 additions and 34 deletions

View file

@ -163,6 +163,8 @@
<string name="dia">DIA</string>
<string name="ic_short">IC</string>
<string name="isf_short">ISF</string>
<string name="canceling_tbr_failed">Canceling of temporary basal failed</string>
<string name="canceling_eb_failed">Canceling of extended bolus failed</string>
<!-- Protection-->
<string name="wrongpassword">Wrong password</string>

View file

@ -823,7 +823,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
);
return new PumpEnactResult(getInjector()).isTempCancel(true).success(true).enacted(true);
} else {
return new PumpEnactResult(getInjector()).success(false).enacted(false);
return new PumpEnactResult(getInjector()).success(false).enacted(false).comment(info.nightscout.core.ui.R.string.canceling_eb_failed);
}
} else if (activeTemp == null) {
return new PumpEnactResult(getInjector()).success(true).enacted(false);

View file

@ -334,7 +334,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
serialNumber()
);
} else
result.success(false).enacted(false).isTempCancel(true);
result.success(false).enacted(false).isTempCancel(true).comment(info.nightscout.core.ui.R.string.canceling_eb_failed);
} else {
result.success(true).comment(info.nightscout.core.ui.R.string.ok).isTempCancel(true);
getAapsLogger().debug(LTag.PUMP, "cancelExtendedBolus: OK");

View file

@ -353,9 +353,9 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
getPumpDescription().getPumpType(),
serialNumber()
);
result.success(true).enacted(true).isTempCancel(true);
result.success(true).enacted(true).isTempCancel(true).comment(info.nightscout.core.ui.R.string.ok);
} else
result.success(false).enacted(false).isTempCancel(true);
result.success(false).enacted(false).isTempCancel(true).comment(info.nightscout.core.ui.R.string.canceling_eb_failed);
} else {
result.success(true).isTempCancel(true).comment(info.nightscout.core.ui.R.string.ok);
aapsLogger.debug(LTag.PUMP, "cancelRealTempBasal: OK");

View file

@ -522,35 +522,40 @@ class DanaRSPlugin @Inject constructor(
@Synchronized
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult {
val result = PumpEnactResult(injector)
if (danaPump.isTempBasalInProgress) {
aapsLogger.debug(LTag.PUMP, "cancelRealTempBasal: Failed")
danaRSService?.tempBasalStop()
result.success = !danaPump.isTempBasalInProgress
result.enacted = true
result.isTempCancel = true
return PumpEnactResult(injector)
.success(!danaPump.isTempBasalInProgress)
.enacted(true)
.isTempCancel(true)
.comment(info.nightscout.core.ui.R.string.canceling_tbr_failed)
} else {
result.success = true
result.enacted = false
result.isTempCancel = true
result.comment = rh.gs(info.nightscout.core.ui.R.string.ok)
aapsLogger.debug(LTag.PUMP, "cancelRealTempBasal: OK")
return PumpEnactResult(injector)
.success(true)
.enacted(false)
.isTempCancel(true)
.comment(info.nightscout.core.ui.R.string.ok)
}
return result
}
@Synchronized override fun cancelExtendedBolus(): PumpEnactResult {
val result = PumpEnactResult(injector)
if (danaPump.isExtendedInProgress) {
danaRSService?.extendedBolusStop()
result.success = !danaPump.isExtendedInProgress
result.enacted = true
aapsLogger.debug(LTag.PUMP, "cancelExtendedBolus: Failed")
return PumpEnactResult(injector)
.success(!danaPump.isExtendedInProgress)
.enacted(true)
.comment(info.nightscout.core.ui.R.string.canceling_eb_failed)
} else {
result.success = true
result.enacted = false
result.comment = rh.gs(info.nightscout.core.ui.R.string.ok)
aapsLogger.debug(LTag.PUMP, "cancelExtendedBolus: OK")
return PumpEnactResult(injector)
.success(true)
.enacted(false)
.isTempCancel(true)
.comment(info.nightscout.core.ui.R.string.ok)
}
return result
}
override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject {

View file

@ -176,19 +176,25 @@ class EopatchPumpPlugin @Inject constructor(
override fun setNewBasalProfile(profile: Profile): PumpEnactResult {
mLastDataTime = System.currentTimeMillis()
if (patchManager.isActivated) {
if (patchManager.patchState.isTempBasalActive || patchManager.patchState.isBolusActive) {
return PumpEnactResult(injector)
} else {
var isSuccess: Boolean? = null
val result: BehaviorSubject<Boolean> = BehaviorSubject.create()
val disposable = result.hide()
.subscribe {
isSuccess = it
}
if (patchManager.patchState.isTempBasalActive) {
val cancelResult = cancelTempBasal(true)
if (!cancelResult.success) return PumpEnactResult(injector).isTempCancel(true).comment(info.nightscout.core.ui.R.string.canceling_tbr_failed)
}
val nb = preferenceManager.getNormalBasalManager().convertProfileToNormalBasal(profile)
mDisposables.add(
patchManager.startBasal(nb)
if (patchManager.patchState.isExtBolusActive) {
val cancelResult = cancelExtendedBolus()
if (!cancelResult.success) return PumpEnactResult(injector).comment(info.nightscout.core.ui.R.string.canceling_eb_failed)
}
var isSuccess: Boolean? = null
val result: BehaviorSubject<Boolean> = BehaviorSubject.create()
val disposable = result.hide()
.subscribe {
isSuccess = it
}
val nb = preferenceManager.getNormalBasalManager().convertProfileToNormalBasal(profile)
mDisposables.add(
patchManager.startBasal(nb)
.observeOn(aapsSchedulers.main)
.subscribe({ response ->
result.onNext(response.isSuccess)
@ -209,7 +215,6 @@ class EopatchPumpPlugin @Inject constructor(
} else {
return PumpEnactResult(injector)
}
}
} else {
preferenceManager.getNormalBasalManager().setNormalBasal(profile)
preferenceManager.flushNormalBasalManager()
@ -479,7 +484,7 @@ class EopatchPumpPlugin @Inject constructor(
.map { PumpEnactResult(injector).success(true).enacted(true).isTempCancel(true) }
.onErrorReturnItem(
PumpEnactResult(injector).success(false).enacted(false)
.comment(rh.gs(info.nightscout.core.ui.R.string.error))
.comment(rh.gs(info.nightscout.core.ui.R.string.canceling_eb_failed))
)
.blockingGet()
} else {