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="dia">DIA</string>
<string name="ic_short">IC</string> <string name="ic_short">IC</string>
<string name="isf_short">ISF</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--> <!-- Protection-->
<string name="wrongpassword">Wrong password</string> <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); return new PumpEnactResult(getInjector()).isTempCancel(true).success(true).enacted(true);
} else { } 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) { } else if (activeTemp == null) {
return new PumpEnactResult(getInjector()).success(true).enacted(false); return new PumpEnactResult(getInjector()).success(true).enacted(false);

View file

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

View file

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

View file

@ -522,35 +522,40 @@ class DanaRSPlugin @Inject constructor(
@Synchronized @Synchronized
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult { override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult {
val result = PumpEnactResult(injector)
if (danaPump.isTempBasalInProgress) { if (danaPump.isTempBasalInProgress) {
aapsLogger.debug(LTag.PUMP, "cancelRealTempBasal: Failed")
danaRSService?.tempBasalStop() danaRSService?.tempBasalStop()
result.success = !danaPump.isTempBasalInProgress return PumpEnactResult(injector)
result.enacted = true .success(!danaPump.isTempBasalInProgress)
result.isTempCancel = true .enacted(true)
.isTempCancel(true)
.comment(info.nightscout.core.ui.R.string.canceling_tbr_failed)
} else { } 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") 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 { @Synchronized override fun cancelExtendedBolus(): PumpEnactResult {
val result = PumpEnactResult(injector)
if (danaPump.isExtendedInProgress) { if (danaPump.isExtendedInProgress) {
danaRSService?.extendedBolusStop() danaRSService?.extendedBolusStop()
result.success = !danaPump.isExtendedInProgress aapsLogger.debug(LTag.PUMP, "cancelExtendedBolus: Failed")
result.enacted = true return PumpEnactResult(injector)
.success(!danaPump.isExtendedInProgress)
.enacted(true)
.comment(info.nightscout.core.ui.R.string.canceling_eb_failed)
} else { } else {
result.success = true
result.enacted = false
result.comment = rh.gs(info.nightscout.core.ui.R.string.ok)
aapsLogger.debug(LTag.PUMP, "cancelExtendedBolus: 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 { 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 { override fun setNewBasalProfile(profile: Profile): PumpEnactResult {
mLastDataTime = System.currentTimeMillis() mLastDataTime = System.currentTimeMillis()
if (patchManager.isActivated) { if (patchManager.isActivated) {
if (patchManager.patchState.isTempBasalActive || patchManager.patchState.isBolusActive) { if (patchManager.patchState.isTempBasalActive) {
return PumpEnactResult(injector) val cancelResult = cancelTempBasal(true)
} else { if (!cancelResult.success) return PumpEnactResult(injector).isTempCancel(true).comment(info.nightscout.core.ui.R.string.canceling_tbr_failed)
var isSuccess: Boolean? = null }
val result: BehaviorSubject<Boolean> = BehaviorSubject.create()
val disposable = result.hide()
.subscribe {
isSuccess = it
}
val nb = preferenceManager.getNormalBasalManager().convertProfileToNormalBasal(profile) if (patchManager.patchState.isExtBolusActive) {
mDisposables.add( val cancelResult = cancelExtendedBolus()
patchManager.startBasal(nb) 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) .observeOn(aapsSchedulers.main)
.subscribe({ response -> .subscribe({ response ->
result.onNext(response.isSuccess) result.onNext(response.isSuccess)
@ -209,7 +215,6 @@ class EopatchPumpPlugin @Inject constructor(
} else { } else {
return PumpEnactResult(injector) return PumpEnactResult(injector)
} }
}
} else { } else {
preferenceManager.getNormalBasalManager().setNormalBasal(profile) preferenceManager.getNormalBasalManager().setNormalBasal(profile)
preferenceManager.flushNormalBasalManager() preferenceManager.flushNormalBasalManager()
@ -479,7 +484,7 @@ class EopatchPumpPlugin @Inject constructor(
.map { PumpEnactResult(injector).success(true).enacted(true).isTempCancel(true) } .map { PumpEnactResult(injector).success(true).enacted(true).isTempCancel(true) }
.onErrorReturnItem( .onErrorReturnItem(
PumpEnactResult(injector).success(false).enacted(false) 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() .blockingGet()
} else { } else {