fix BolusProgressDialog closing

This commit is contained in:
Milos Kozak 2022-06-21 18:51:55 +02:00
parent be201f0177
commit bbcbf3f905
25 changed files with 55 additions and 50 deletions

View file

@ -321,9 +321,9 @@ class CommandQueueImplementation @Inject constructor(
} }
@Synchronized @Synchronized
override fun cancelAllBoluses(timestamp: Long) { override fun cancelAllBoluses(id: Long) {
if (!isRunning(CommandType.BOLUS)) { if (!isRunning(CommandType.BOLUS)) {
rxBus.send(EventDismissBolusProgressIfRunning(PumpEnactResult(injector).success(true).enacted(false), timestamp)) rxBus.send(EventDismissBolusProgressIfRunning(PumpEnactResult(injector).success(true).enacted(false), id))
} }
removeAll(CommandType.BOLUS) removeAll(CommandType.BOLUS)
removeAll(CommandType.SMB_BOLUS) removeAll(CommandType.SMB_BOLUS)
@ -598,12 +598,12 @@ class CommandQueueImplementation @Inject constructor(
if (detailedBolusInfo.context != null) { if (detailedBolusInfo.context != null) {
val bolusProgressDialog = BolusProgressDialog() val bolusProgressDialog = BolusProgressDialog()
bolusProgressDialog.setInsulin(detailedBolusInfo.insulin) bolusProgressDialog.setInsulin(detailedBolusInfo.insulin)
bolusProgressDialog.setTimestamp(detailedBolusInfo.timestamp) bolusProgressDialog.setId(detailedBolusInfo.id)
bolusProgressDialog.show((detailedBolusInfo.context as AppCompatActivity).supportFragmentManager, "BolusProgress") bolusProgressDialog.show((detailedBolusInfo.context as AppCompatActivity).supportFragmentManager, "BolusProgress")
} else { } else {
val i = Intent() val i = Intent()
i.putExtra("insulin", detailedBolusInfo.insulin) i.putExtra("insulin", detailedBolusInfo.insulin)
i.putExtra("timestamp", detailedBolusInfo.timestamp) i.putExtra("id", detailedBolusInfo.id)
i.setClass(context, BolusProgressHelperActivity::class.java) i.setClass(context, BolusProgressHelperActivity::class.java)
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(i) context.startActivity(i)

View file

@ -26,7 +26,7 @@ class CommandBolus(
val r = activePlugin.activePump.deliverTreatment(detailedBolusInfo) val r = activePlugin.activePump.deliverTreatment(detailedBolusInfo)
if (r.success) carbsRunnable.run() if (r.success) carbsRunnable.run()
BolusProgressDialog.bolusEnded = true BolusProgressDialog.bolusEnded = true
rxBus.send(EventDismissBolusProgressIfRunning(r, detailedBolusInfo.timestamp)) rxBus.send(EventDismissBolusProgressIfRunning(r, detailedBolusInfo.id))
aapsLogger.debug(LTag.PUMPQUEUE, "Result success: ${r.success} enacted: ${r.enacted}") aapsLogger.debug(LTag.PUMPQUEUE, "Result success: ${r.success} enacted: ${r.enacted}")
callback?.result(r)?.run() callback?.result(r)?.run()
} }

View file

@ -566,7 +566,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
return new PumpEnactResult(getInjector()).success(true).enacted(false); return new PumpEnactResult(getInjector()).success(true).enacted(false);
} }
EventOverviewBolusProgress.Treatment treatment = new EventOverviewBolusProgress.Treatment(0.0, 0, detailedBolusInfo.getBolusType() == DetailedBolusInfo.BolusType.SMB); EventOverviewBolusProgress.Treatment treatment = new EventOverviewBolusProgress.Treatment(0.0, 0,detailedBolusInfo.getBolusType() == DetailedBolusInfo.BolusType.SMB, detailedBolusInfo.getId());
EventOverviewBolusProgress.INSTANCE.setT(treatment); EventOverviewBolusProgress.INSTANCE.setT(treatment);
// start bolus delivery // start bolus delivery

View file

@ -9,7 +9,7 @@ class BolusProgressHelperActivity : DialogAppCompatActivity() {
BolusProgressDialog() BolusProgressDialog()
.setHelperActivity(this) .setHelperActivity(this)
.setInsulin(intent.getDoubleExtra("insulin", 0.0)) .setInsulin(intent.getDoubleExtra("insulin", 0.0))
.setTimestamp(intent.getLongExtra("timestamp", 0L)) .setId(intent.getLongExtra("id", 0L))
.show(supportFragmentManager, "BolusProgress") .show(supportFragmentManager, "BolusProgress")
} }
} }

View file

@ -14,6 +14,8 @@ import info.nightscout.androidaps.utils.T
class DetailedBolusInfo { class DetailedBolusInfo {
val id = System.currentTimeMillis()
// Requesting parameters for driver // Requesting parameters for driver
@JvmField var insulin = 0.0 @JvmField var insulin = 0.0
@JvmField var carbs = 0.0 @JvmField var carbs = 0.0

View file

@ -48,12 +48,12 @@ class BolusProgressDialog : DaggerDialogFragment() {
private var running = true private var running = true
private var amount = 0.0 private var amount = 0.0
var timestamp: Long = 0L var id: Long = 0L
private var state: String? = null private var state: String? = null
private var helpActivity: BolusProgressHelperActivity? = null private var helpActivity: BolusProgressHelperActivity? = null
fun setTimestamp(timestamp: Long): BolusProgressDialog { fun setId(id: Long): BolusProgressDialog {
this.timestamp = timestamp this.id = id
return this return this
} }
@ -88,7 +88,7 @@ class BolusProgressDialog : DaggerDialogFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
savedInstanceState?.let { savedInstanceState?.let {
amount = it.getDouble("amount") amount = it.getDouble("amount")
timestamp = it.getLong("timestamp") id = it.getLong("id")
state = it.getString("state") ?: rh.gs(R.string.waitingforpump) state = it.getString("state") ?: rh.gs(R.string.waitingforpump)
} }
binding.title.text = rh.gs(R.string.goingtodeliver, amount) binding.title.text = rh.gs(R.string.goingtodeliver, amount)
@ -98,7 +98,7 @@ class BolusProgressDialog : DaggerDialogFragment() {
binding.stoppressed.visibility = View.VISIBLE binding.stoppressed.visibility = View.VISIBLE
binding.stop.visibility = View.INVISIBLE binding.stop.visibility = View.INVISIBLE
uel.log(Action.CANCEL_BOLUS, Sources.Overview, state) uel.log(Action.CANCEL_BOLUS, Sources.Overview, state)
commandQueue.cancelAllBoluses(timestamp) commandQueue.cancelAllBoluses(id)
} }
binding.progressbar.max = 100 binding.progressbar.max = 100
binding.status.text = state binding.status.text = state
@ -127,22 +127,24 @@ class BolusProgressDialog : DaggerDialogFragment() {
.toObservable(EventDismissBolusProgressIfRunning::class.java) .toObservable(EventDismissBolusProgressIfRunning::class.java)
.observeOn(aapsSchedulers.main) .observeOn(aapsSchedulers.main)
.subscribe({ .subscribe({
aapsLogger.debug(LTag.PUMP, "Running timestamp $timestamp. Close request timestamp ${it.bolusTimestamp}") aapsLogger.debug(LTag.PUMP, "Running id $id. Close request id ${it.id}")
if (it.bolusTimestamp == null || it.bolusTimestamp == timestamp) if (it.id == null || it.id == id)
if (running) dismiss() if (running) dismiss()
}, fabricPrivacy::logException) }, fabricPrivacy::logException)
disposable += rxBus disposable += rxBus
.toObservable(EventOverviewBolusProgress::class.java) .toObservable(EventOverviewBolusProgress::class.java)
.observeOn(aapsSchedulers.main) .observeOn(aapsSchedulers.main)
.subscribe({ .subscribe({
aapsLogger.debug(LTag.UI, "Status: ${it.status} Percent: ${it.percent}") if (it.t?.id == id) {
binding.status.text = it.status aapsLogger.debug(LTag.UI, "Status: ${it.status} Percent: ${it.percent}")
binding.progressbar.progress = it.percent binding.status.text = it.status
if (it.percent == 100) { binding.progressbar.progress = it.percent
binding.stop.visibility = View.INVISIBLE if (it.percent == 100) {
scheduleDismiss() binding.stop.visibility = View.INVISIBLE
scheduleDismiss()
}
state = it.status
} }
state = it.status
}, fabricPrivacy::logException) }, fabricPrivacy::logException)
} }
@ -170,7 +172,7 @@ class BolusProgressDialog : DaggerDialogFragment() {
super.onSaveInstanceState(outState) super.onSaveInstanceState(outState)
outState.putString("state", state) outState.putString("state", state)
outState.putDouble("amount", amount) outState.putDouble("amount", amount)
outState.putLong("timestamp", timestamp) outState.putLong("id", id)
} }
override fun onDestroyView() { override fun onDestroyView() {

View file

@ -17,7 +17,7 @@ interface CommandQueue {
fun independentConnect(reason: String, callback: Callback?) fun independentConnect(reason: String, callback: Callback?)
fun bolusInQueue(): Boolean fun bolusInQueue(): Boolean
fun bolus(detailedBolusInfo: DetailedBolusInfo, callback: Callback?): Boolean fun bolus(detailedBolusInfo: DetailedBolusInfo, callback: Callback?): Boolean
fun cancelAllBoluses(running: Long) fun cancelAllBoluses(id: Long)
fun stopPump(callback: Callback?) fun stopPump(callback: Callback?)
fun startPump(callback: Callback?) fun startPump(callback: Callback?)
fun setTBROverNotification(callback: Callback?, enable: Boolean) fun setTBROverNotification(callback: Callback?, enable: Boolean)

View file

@ -3,4 +3,4 @@ package info.nightscout.androidaps.plugins.general.overview.events
import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.events.Event import info.nightscout.androidaps.events.Event
class EventDismissBolusProgressIfRunning(val result: PumpEnactResult?, val bolusTimestamp: Long?) : Event() class EventDismissBolusProgressIfRunning(val result: PumpEnactResult?, val id: Long?) : Event()

View file

@ -4,7 +4,7 @@ import info.nightscout.androidaps.events.Event
object EventOverviewBolusProgress : Event() { object EventOverviewBolusProgress : Event() {
data class Treatment constructor(@JvmField var insulin: Double = 0.0, @JvmField var carbs: Int = 0, @JvmField var isSMB: Boolean) data class Treatment constructor(var insulin: Double = 0.0, var carbs: Int = 0, var isSMB: Boolean, var id: Long)
var status = "" var status = ""
var t: Treatment? = null var t: Treatment? = null

View file

@ -122,7 +122,7 @@ class DanaRKoreanPlugin @Inject constructor(
detailedBolusInfo.insulin = constraintChecker.applyBolusConstraints(Constraint(detailedBolusInfo.insulin)).value() detailedBolusInfo.insulin = constraintChecker.applyBolusConstraints(Constraint(detailedBolusInfo.insulin)).value()
if (detailedBolusInfo.carbs > 0) throw IllegalArgumentException() if (detailedBolusInfo.carbs > 0) throw IllegalArgumentException()
return if (detailedBolusInfo.insulin > 0) { return if (detailedBolusInfo.insulin > 0) {
val t = EventOverviewBolusProgress.Treatment(0.0, 0, detailedBolusInfo.bolusType == DetailedBolusInfo.BolusType.SMB) val t = EventOverviewBolusProgress.Treatment(0.0, 0, detailedBolusInfo.bolusType == DetailedBolusInfo.BolusType.SMB, detailedBolusInfo.id)
var connectionOK = false var connectionOK = false
if (detailedBolusInfo.insulin > 0) if (detailedBolusInfo.insulin > 0)
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, detailedBolusInfo.carbs.toInt(), detailedBolusInfo.carbsTimestamp connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, detailedBolusInfo.carbs.toInt(), detailedBolusInfo.carbsTimestamp

View file

@ -278,7 +278,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
if (!danaPump.getBolusStopped()) { if (!danaPump.getBolusStopped()) {
mSerialIOThread.sendMessage(start); mSerialIOThread.sendMessage(start);
} else { } else {
t.insulin = 0d; t.setInsulin(0d);
return false; return false;
} }
while (!danaPump.getBolusStopped() && !start.getFailed()) { while (!danaPump.getBolusStopped() && !start.getFailed()) {

View file

@ -185,16 +185,17 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
detailedBolusInfoStorage.add(detailedBolusInfo); // will be picked up on reading history detailedBolusInfoStorage.add(detailedBolusInfo); // will be picked up on reading history
EventOverviewBolusProgress.Treatment t = new EventOverviewBolusProgress.Treatment(0, 0, detailedBolusInfo.getBolusType() == DetailedBolusInfo.BolusType.SMB); EventOverviewBolusProgress.Treatment t = new EventOverviewBolusProgress.Treatment(0, 0, detailedBolusInfo.getBolusType() == DetailedBolusInfo.BolusType.SMB, detailedBolusInfo.getId());
boolean connectionOK = false; boolean connectionOK = false;
if (detailedBolusInfo.insulin > 0 || carbs > 0) if (detailedBolusInfo.insulin > 0 || carbs > 0)
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) carbs, carbTimeStamp, t); connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) carbs, carbTimeStamp, t);
PumpEnactResult result = new PumpEnactResult(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
result.success(connectionOK && Math.abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.getBolusStep()) result.success(connectionOK && Math.abs(detailedBolusInfo.insulin - t.getInsulin()) < pumpDescription.getBolusStep())
.bolusDelivered(t.insulin) .bolusDelivered(t.getInsulin())
.carbsDelivered(detailedBolusInfo.carbs); .carbsDelivered(detailedBolusInfo.carbs);
if (!result.getSuccess()) if (!result.getSuccess())
result.comment(rh.gs(R.string.boluserrorcode, detailedBolusInfo.insulin, t.insulin, danaPump.getBolusStartErrorCode())); result.comment(rh.gs(R.string.boluserrorcode, detailedBolusInfo.insulin, t.getInsulin(),
danaPump.getBolusStartErrorCode()));
else else
result.comment(R.string.ok); result.comment(R.string.ok);
aapsLogger.debug(LTag.PUMP, "deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.getBolusDelivered()); aapsLogger.debug(LTag.PUMP, "deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.getBolusDelivered());

View file

@ -362,7 +362,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
if (!danaPump.getBolusStopped()) { if (!danaPump.getBolusStopped()) {
mSerialIOThread.sendMessage(start); mSerialIOThread.sendMessage(start);
} else { } else {
t.insulin = 0d; t.setInsulin(0d);
return false; return false;
} }
while (!danaPump.getBolusStopped() && !start.getFailed()) { while (!danaPump.getBolusStopped() && !start.getFailed()) {

View file

@ -161,20 +161,20 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) { public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
detailedBolusInfo.insulin = constraintChecker.applyBolusConstraints(new Constraint<>(detailedBolusInfo.insulin)).value(); detailedBolusInfo.insulin = constraintChecker.applyBolusConstraints(new Constraint<>(detailedBolusInfo.insulin)).value();
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) { if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) {
EventOverviewBolusProgress.Treatment t = new EventOverviewBolusProgress.Treatment(0, 0, detailedBolusInfo.getBolusType() == DetailedBolusInfo.BolusType.SMB); EventOverviewBolusProgress.Treatment t = new EventOverviewBolusProgress.Treatment(0, 0, detailedBolusInfo.getBolusType() == DetailedBolusInfo.BolusType.SMB, detailedBolusInfo.getId());
boolean connectionOK = false; boolean connectionOK = false;
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, detailedBolusInfo.getCarbsTimestamp() != null ? detailedBolusInfo.getCarbsTimestamp() : detailedBolusInfo.timestamp, t); connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, detailedBolusInfo.getCarbsTimestamp() != null ? detailedBolusInfo.getCarbsTimestamp() : detailedBolusInfo.timestamp, t);
PumpEnactResult result = new PumpEnactResult(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
result.success(connectionOK && Math.abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.getBolusStep()) result.success(connectionOK && Math.abs(detailedBolusInfo.insulin - t.getInsulin()) < pumpDescription.getBolusStep())
.bolusDelivered(t.insulin) .bolusDelivered(t.getInsulin())
.carbsDelivered(detailedBolusInfo.carbs); .carbsDelivered(detailedBolusInfo.carbs);
if (!result.getSuccess()) if (!result.getSuccess())
result.comment(rh.gs(R.string.boluserrorcode, detailedBolusInfo.insulin, t.insulin, danaPump.getBolusStartErrorCode())); result.comment(rh.gs(R.string.boluserrorcode, detailedBolusInfo.insulin, t.getInsulin(), danaPump.getBolusStartErrorCode()));
else else
result.comment(R.string.ok); result.comment(R.string.ok);
aapsLogger.debug(LTag.PUMP, "deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.getBolusDelivered()); aapsLogger.debug(LTag.PUMP, "deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.getBolusDelivered());
detailedBolusInfo.insulin = t.insulin; detailedBolusInfo.insulin = t.getInsulin();
detailedBolusInfo.timestamp = System.currentTimeMillis(); detailedBolusInfo.timestamp = System.currentTimeMillis();
if (detailedBolusInfo.insulin > 0) if (detailedBolusInfo.insulin > 0)
pumpSync.syncBolusWithPumpId( pumpSync.syncBolusWithPumpId(

View file

@ -219,7 +219,7 @@ public abstract class AbstractDanaRExecutionService extends DaggerService {
} }
public void bolusStop() { public void bolusStop() {
aapsLogger.debug(LTag.PUMP, "bolusStop >>>>> @ " + (danaPump.getBolusingTreatment() == null ? "" : danaPump.getBolusingTreatment().insulin)); aapsLogger.debug(LTag.PUMP, "bolusStop >>>>> @ " + (danaPump.getBolusingTreatment() == null ? "" : danaPump.getBolusingTreatment().getInsulin()));
MsgBolusStop stop = new MsgBolusStop(injector); MsgBolusStop stop = new MsgBolusStop(injector);
danaPump.setBolusStopForced(true); danaPump.setBolusStopForced(true);
if (isConnected()) { if (isConnected()) {

View file

@ -290,7 +290,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
if (!danaPump.getBolusStopped()) { if (!danaPump.getBolusStopped()) {
mSerialIOThread.sendMessage(start); mSerialIOThread.sendMessage(start);
} else { } else {
t.insulin = 0d; t.setInsulin(0d);
return false; return false;
} }
while (!danaPump.getBolusStopped() && !start.getFailed()) { while (!danaPump.getBolusStopped() && !start.getFailed()) {
@ -322,7 +322,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
break; break;
} }
// try to find real amount if bolusing was interrupted or comm failed // try to find real amount if bolusing was interrupted or comm failed
if (t.insulin != amount) { if (t.getInsulin() != amount) {
disconnect("bolusingInterrupted"); disconnect("bolusingInterrupted");
long bolusDurationInMSec = (long) (amount * speed * 1000); long bolusDurationInMSec = (long) (amount * speed * 1000);
long expectedEnd = bolusStart + bolusDurationInMSec + 3000; long expectedEnd = bolusStart + bolusDurationInMSec + 3000;
@ -340,7 +340,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
@Override @Override
public void run() { public void run() {
if (danaPump.getLastBolusTime() > System.currentTimeMillis() - 60 * 1000L) { // last bolus max 1 min old if (danaPump.getLastBolusTime() > System.currentTimeMillis() - 60 * 1000L) { // last bolus max 1 min old
t.insulin = danaPump.getLastBolusAmount(); t.setInsulin(danaPump.getLastBolusAmount());
aapsLogger.debug(LTag.PUMP, "Used bolus amount from history: " + danaPump.getLastBolusAmount()); aapsLogger.debug(LTag.PUMP, "Used bolus amount from history: " + danaPump.getLastBolusAmount());
} else { } else {
aapsLogger.debug(LTag.PUMP, "Bolus amount in history too old: " + dateUtil.dateAndTimeString(danaPump.getLastBolusTime())); aapsLogger.debug(LTag.PUMP, "Bolus amount in history too old: " + dateUtil.dateAndTimeString(danaPump.getLastBolusTime()));

View file

@ -12,7 +12,7 @@ class MsgBolusProgressTest : DanaRTestBase() {
@Test fun runTest() { @Test fun runTest() {
`when`(rh.gs(ArgumentMatchers.eq(R.string.bolusdelivering), ArgumentMatchers.anyDouble())).thenReturn("Delivering %1\$.2fU") `when`(rh.gs(ArgumentMatchers.eq(R.string.bolusdelivering), ArgumentMatchers.anyDouble())).thenReturn("Delivering %1\$.2fU")
danaPump.bolusingTreatment = EventOverviewBolusProgress.Treatment(0.0, 0, true) danaPump.bolusingTreatment = EventOverviewBolusProgress.Treatment(0.0, 0, true, 0)
danaPump.bolusAmountToBeDelivered = 3.0 danaPump.bolusAmountToBeDelivered = 3.0
val packet = MsgBolusProgress(injector) val packet = MsgBolusProgress(injector)

View file

@ -11,7 +11,7 @@ class MsgBolusStopTest : DanaRTestBase() {
@Test fun runTest() { @Test fun runTest() {
`when`(rh.gs(R.string.overview_bolusprogress_delivered)).thenReturn("Delivered") `when`(rh.gs(R.string.overview_bolusprogress_delivered)).thenReturn("Delivered")
danaPump.bolusingTreatment = EventOverviewBolusProgress.Treatment(0.0, 0, true) danaPump.bolusingTreatment = EventOverviewBolusProgress.Treatment(0.0, 0, true, 0)
val packet = MsgBolusStop(injector) val packet = MsgBolusStop(injector)
// test message decoding // test message decoding

View file

@ -286,7 +286,7 @@ class DanaRSPlugin @Inject constructor(
var carbTimeStamp = detailedBolusInfo.carbsTimestamp ?: detailedBolusInfo.timestamp var carbTimeStamp = detailedBolusInfo.carbsTimestamp ?: detailedBolusInfo.timestamp
if (carbTimeStamp == detailedBolusInfo.timestamp) carbTimeStamp -= T.mins(1).msecs() // better set 1 min back to prevents clash with insulin if (carbTimeStamp == detailedBolusInfo.timestamp) carbTimeStamp -= T.mins(1).msecs() // better set 1 min back to prevents clash with insulin
detailedBolusInfoStorage.add(detailedBolusInfo) // will be picked up on reading history detailedBolusInfoStorage.add(detailedBolusInfo) // will be picked up on reading history
val t = EventOverviewBolusProgress.Treatment(0.0, 0, detailedBolusInfo.bolusType == DetailedBolusInfo.BolusType.SMB) val t = EventOverviewBolusProgress.Treatment(0.0, 0, detailedBolusInfo.bolusType == DetailedBolusInfo.BolusType.SMB, detailedBolusInfo.id)
var connectionOK = false var connectionOK = false
if (detailedBolusInfo.insulin > 0 || carbs > 0) connectionOK = danaRSService?.bolus(detailedBolusInfo.insulin, carbs.toInt(), carbTimeStamp, t) if (detailedBolusInfo.insulin > 0 || carbs > 0) connectionOK = danaRSService?.bolus(detailedBolusInfo.insulin, carbs.toInt(), carbTimeStamp, t)
?: false ?: false

View file

@ -30,7 +30,7 @@ class DanaRSPacketNotifyDeliveryCompleteTest : DanaRSTestBase() {
@Test fun runTest() { @Test fun runTest() {
`when`(rh.gs(anyInt(), anyDouble())).thenReturn("SomeString") `when`(rh.gs(anyInt(), anyDouble())).thenReturn("SomeString")
danaPump.bolusingTreatment = EventOverviewBolusProgress.Treatment(0.0, 0, true) danaPump.bolusingTreatment = EventOverviewBolusProgress.Treatment(0.0, 0, true, 0)
val packet = DanaRSPacketNotifyDeliveryComplete(packetInjector) val packet = DanaRSPacketNotifyDeliveryComplete(packetInjector)
// test params // test params
Assert.assertEquals(0, packet.getRequestParams().size) Assert.assertEquals(0, packet.getRequestParams().size)

View file

@ -29,7 +29,7 @@ class DanaRsPacketBolusSetStepBolusStopTest : DanaRSTestBase() {
@Test fun runTest() { @Test fun runTest() {
`when`(rh.gs(Mockito.anyInt())).thenReturn("SomeString") `when`(rh.gs(Mockito.anyInt())).thenReturn("SomeString")
danaPump.bolusingTreatment = EventOverviewBolusProgress.Treatment(0.0, 0, true) danaPump.bolusingTreatment = EventOverviewBolusProgress.Treatment(0.0, 0, true, 0)
val testPacket = DanaRSPacketBolusSetStepBolusStop(packetInjector) val testPacket = DanaRSPacketBolusSetStepBolusStop(packetInjector)
// test message decoding // test message decoding
testPacket.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte())) testPacket.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))

View file

@ -61,6 +61,6 @@ class DanaRsPacketNotifyDeliveryRateDisplayTest : DanaRSTestBase() {
@Before @Before
fun mock() { fun mock() {
danaRSPlugin = DanaRSPlugin(packetInjector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, profileFunction, sp, commandQueue, danaPump, pumpSync, detailedBolusInfoStorage, temporaryBasalStorage, fabricPrivacy, dateUtil) danaRSPlugin = DanaRSPlugin(packetInjector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, profileFunction, sp, commandQueue, danaPump, pumpSync, detailedBolusInfoStorage, temporaryBasalStorage, fabricPrivacy, dateUtil)
danaPump.bolusingTreatment = EventOverviewBolusProgress.Treatment(0.0, 0, true) danaPump.bolusingTreatment = EventOverviewBolusProgress.Treatment(0.0, 0, true, 0)
} }
} }

View file

@ -256,7 +256,7 @@ class DiaconnG8Plugin @Inject constructor(
var carbTimeStamp = detailedBolusInfo.carbsTimestamp ?: detailedBolusInfo.timestamp var carbTimeStamp = detailedBolusInfo.carbsTimestamp ?: detailedBolusInfo.timestamp
if (carbTimeStamp == detailedBolusInfo.timestamp) carbTimeStamp -= T.mins(1).msecs() // better set 1 min back to prevents clash with insulin if (carbTimeStamp == detailedBolusInfo.timestamp) carbTimeStamp -= T.mins(1).msecs() // better set 1 min back to prevents clash with insulin
detailedBolusInfoStorage.add(detailedBolusInfo) // will be picked up on reading history detailedBolusInfoStorage.add(detailedBolusInfo) // will be picked up on reading history
val t = EventOverviewBolusProgress.Treatment(0.0, 0, detailedBolusInfo.bolusType == DetailedBolusInfo.BolusType.SMB) val t = EventOverviewBolusProgress.Treatment(0.0, 0, detailedBolusInfo.bolusType == DetailedBolusInfo.BolusType.SMB, detailedBolusInfo.id)
var connectionOK = false var connectionOK = false
if (detailedBolusInfo.insulin > 0 || carbs > 0) connectionOK = diaconnG8Service?.bolus(detailedBolusInfo.insulin, carbs.toInt(), carbTimeStamp, t) if (detailedBolusInfo.insulin > 0 || carbs > 0) connectionOK = diaconnG8Service?.bolus(detailedBolusInfo.insulin, carbs.toInt(), carbTimeStamp, t)
?: false ?: false

View file

@ -587,7 +587,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai
bolusCancelled = false; bolusCancelled = false;
} }
result.success(true).enacted(true); result.success(true).enacted(true);
EventOverviewBolusProgress.Treatment t = new EventOverviewBolusProgress.Treatment(0, 0, detailedBolusInfo.getBolusType() == DetailedBolusInfo.BolusType.SMB); EventOverviewBolusProgress.Treatment t = new EventOverviewBolusProgress.Treatment(0, 0, detailedBolusInfo.getBolusType() == DetailedBolusInfo.BolusType.SMB, detailedBolusInfo.getId());
final EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.INSTANCE; final EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.INSTANCE;
bolusingEvent.setT(t); bolusingEvent.setT(t);
bolusingEvent.setStatus(rh.gs(R.string.insight_delivered, 0d, insulin)); bolusingEvent.setStatus(rh.gs(R.string.insight_delivered, 0d, insulin));

View file

@ -329,7 +329,7 @@ abstract class PumpPluginAbstract protected constructor(
pumpSyncStorage.addCarbs(PumpDbEntryCarbs(detailedBolusInfo, this)) pumpSyncStorage.addCarbs(PumpDbEntryCarbs(detailedBolusInfo, this))
val bolusingEvent = EventOverviewBolusProgress val bolusingEvent = EventOverviewBolusProgress
bolusingEvent.t = EventOverviewBolusProgress.Treatment(0.0, detailedBolusInfo.carbs.toInt(), detailedBolusInfo.bolusType === DetailedBolusInfo.BolusType.SMB) bolusingEvent.t = EventOverviewBolusProgress.Treatment(0.0, detailedBolusInfo.carbs.toInt(), detailedBolusInfo.bolusType === DetailedBolusInfo.BolusType.SMB, detailedBolusInfo.id)
bolusingEvent.percent = 100 bolusingEvent.percent = 100
rxBus.send(bolusingEvent) rxBus.send(bolusingEvent)
aapsLogger.debug(LTag.PUMP, "deliverTreatment: Carb only treatment.") aapsLogger.debug(LTag.PUMP, "deliverTreatment: Carb only treatment.")