Eopatch: handle stopped bolus properly
This commit is contained in:
parent
d5af299692
commit
6a3f833a82
16 changed files with 44 additions and 75 deletions
|
@ -9,7 +9,7 @@ import info.nightscout.plugins.aps.loop.extensions.json
|
||||||
import info.nightscout.plugins.extensions.toText
|
import info.nightscout.plugins.extensions.toText
|
||||||
import info.nightscout.plugins.sync.nsShared.extensions.log
|
import info.nightscout.plugins.sync.nsShared.extensions.log
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import org.junit.Assert
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
|
@ -43,91 +43,84 @@ class PumpEnactResultTest : TestBaseWithProfile() {
|
||||||
val per = PumpEnactResult(injector)
|
val per = PumpEnactResult(injector)
|
||||||
|
|
||||||
per.success(true)
|
per.success(true)
|
||||||
Assert.assertEquals(true, per.success)
|
Assertions.assertEquals(true, per.success)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun enactedTest() {
|
@Test fun enactedTest() {
|
||||||
val per = PumpEnactResult(injector)
|
val per = PumpEnactResult(injector)
|
||||||
|
|
||||||
per.enacted(true)
|
per.enacted(true)
|
||||||
Assert.assertEquals(true, per.enacted)
|
Assertions.assertEquals(true, per.enacted)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun commentTest() {
|
@Test fun commentTest() {
|
||||||
val per = PumpEnactResult(injector)
|
val per = PumpEnactResult(injector)
|
||||||
|
|
||||||
per.comment("SomeComment")
|
per.comment("SomeComment")
|
||||||
Assert.assertEquals("SomeComment", per.comment)
|
Assertions.assertEquals("SomeComment", per.comment)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun durationTest() {
|
@Test fun durationTest() {
|
||||||
val per = PumpEnactResult(injector)
|
val per = PumpEnactResult(injector)
|
||||||
|
|
||||||
per.duration(10)
|
per.duration(10)
|
||||||
Assert.assertEquals(10, per.duration.toLong())
|
Assertions.assertEquals(10, per.duration.toLong())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun absoluteTest() {
|
@Test fun absoluteTest() {
|
||||||
val per = PumpEnactResult(injector)
|
val per = PumpEnactResult(injector)
|
||||||
|
|
||||||
per.absolute(11.0)
|
per.absolute(11.0)
|
||||||
Assert.assertEquals(11.0, per.absolute, 0.01)
|
Assertions.assertEquals(11.0, per.absolute, 0.01)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun percentTest() {
|
@Test fun percentTest() {
|
||||||
val per = PumpEnactResult(injector)
|
val per = PumpEnactResult(injector)
|
||||||
|
|
||||||
per.percent(10)
|
per.percent(10)
|
||||||
Assert.assertEquals(10, per.percent)
|
Assertions.assertEquals(10, per.percent)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun isPercentTest() {
|
@Test fun isPercentTest() {
|
||||||
val per = PumpEnactResult(injector)
|
val per = PumpEnactResult(injector)
|
||||||
|
|
||||||
per.isPercent(true)
|
per.isPercent(true)
|
||||||
Assert.assertEquals(true, per.isPercent)
|
Assertions.assertEquals(true, per.isPercent)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun isTempCancelTest() {
|
@Test fun isTempCancelTest() {
|
||||||
val per = PumpEnactResult(injector)
|
val per = PumpEnactResult(injector)
|
||||||
|
|
||||||
per.isTempCancel(true)
|
per.isTempCancel(true)
|
||||||
Assert.assertEquals(true, per.isTempCancel)
|
Assertions.assertEquals(true, per.isTempCancel)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun bolusDeliveredTest() {
|
@Test fun bolusDeliveredTest() {
|
||||||
val per = PumpEnactResult(injector)
|
val per = PumpEnactResult(injector)
|
||||||
|
|
||||||
per.bolusDelivered(11.0)
|
per.bolusDelivered(11.0)
|
||||||
Assert.assertEquals(11.0, per.bolusDelivered, 0.01)
|
Assertions.assertEquals(11.0, per.bolusDelivered, 0.01)
|
||||||
}
|
|
||||||
|
|
||||||
@Test fun carbsDeliveredTest() {
|
|
||||||
val per = PumpEnactResult(injector)
|
|
||||||
|
|
||||||
per.carbsDelivered(11.0)
|
|
||||||
Assert.assertEquals(11.0, per.carbsDelivered, 0.01)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun queuedTest() {
|
@Test fun queuedTest() {
|
||||||
val per = PumpEnactResult(injector)
|
val per = PumpEnactResult(injector)
|
||||||
|
|
||||||
per.queued(true)
|
per.queued(true)
|
||||||
Assert.assertEquals(true, per.queued)
|
Assertions.assertEquals(true, per.queued)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun logTest() {
|
@Test fun logTest() {
|
||||||
val per = PumpEnactResult(injector)
|
val per = PumpEnactResult(injector)
|
||||||
|
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
"Success: false Enacted: false Comment: Duration: -1 Absolute: -1.0 Percent: -1 IsPercent: false IsTempCancel: false bolusDelivered: 0.0 carbsDelivered: 0.0 Queued: false",
|
"Success: false Enacted: false Comment: Duration: -1 Absolute: -1.0 Percent: -1 IsPercent: false IsTempCancel: false bolusDelivered: 0.0 Queued: false",
|
||||||
per.log()
|
per.log()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun toStringTest() {
|
@Test fun toStringTest() {
|
||||||
var per = PumpEnactResult(injector).enacted(true).bolusDelivered(10.0).comment("AAA")
|
var per = PumpEnactResult(injector).enacted(true).bolusDelivered(10.0).comment("AAA")
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
"""
|
"""
|
||||||
Success: false
|
Success: false
|
||||||
Enacted: true
|
Enacted: true
|
||||||
|
@ -136,7 +129,7 @@ class PumpEnactResultTest : TestBaseWithProfile() {
|
||||||
""".trimIndent(), per.toText(rh)
|
""".trimIndent(), per.toText(rh)
|
||||||
)
|
)
|
||||||
per = PumpEnactResult(injector).enacted(true).isTempCancel(true).comment("AAA")
|
per = PumpEnactResult(injector).enacted(true).isTempCancel(true).comment("AAA")
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
"""
|
"""
|
||||||
Success: false
|
Success: false
|
||||||
Enacted: true
|
Enacted: true
|
||||||
|
@ -145,7 +138,7 @@ class PumpEnactResultTest : TestBaseWithProfile() {
|
||||||
""".trimIndent(), per.toText(rh)
|
""".trimIndent(), per.toText(rh)
|
||||||
)
|
)
|
||||||
per = PumpEnactResult(injector).enacted(true).isPercent(true).percent(90).duration(20).comment("AAA")
|
per = PumpEnactResult(injector).enacted(true).isPercent(true).percent(90).duration(20).comment("AAA")
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
"""
|
"""
|
||||||
Success: false
|
Success: false
|
||||||
Enacted: true
|
Enacted: true
|
||||||
|
@ -155,7 +148,7 @@ class PumpEnactResultTest : TestBaseWithProfile() {
|
||||||
""".trimIndent(), per.toText(rh)
|
""".trimIndent(), per.toText(rh)
|
||||||
)
|
)
|
||||||
per = PumpEnactResult(injector).enacted(true).isPercent(false).absolute(1.0).duration(30).comment("AAA")
|
per = PumpEnactResult(injector).enacted(true).isPercent(false).absolute(1.0).duration(30).comment("AAA")
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
"""
|
"""
|
||||||
Success: false
|
Success: false
|
||||||
Enacted: true
|
Enacted: true
|
||||||
|
@ -165,7 +158,7 @@ class PumpEnactResultTest : TestBaseWithProfile() {
|
||||||
""".trimIndent(), per.toText(rh)
|
""".trimIndent(), per.toText(rh)
|
||||||
)
|
)
|
||||||
per = PumpEnactResult(injector).enacted(false).comment("AAA")
|
per = PumpEnactResult(injector).enacted(false).comment("AAA")
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
"""
|
"""
|
||||||
Success: false
|
Success: false
|
||||||
Comment: AAA
|
Comment: AAA
|
||||||
|
@ -176,15 +169,15 @@ class PumpEnactResultTest : TestBaseWithProfile() {
|
||||||
@Test fun toHtmlTest() {
|
@Test fun toHtmlTest() {
|
||||||
|
|
||||||
var per: PumpEnactResult = PumpEnactResult(injector).enacted(true).bolusDelivered(10.0).comment("AAA")
|
var per: PumpEnactResult = PumpEnactResult(injector).enacted(true).bolusDelivered(10.0).comment("AAA")
|
||||||
Assert.assertEquals("<b>Success</b>: false<br><b>Enacted</b>: true<br><b>Comment</b>: AAA<br><b>SMB</b>: 10.0 U", per.toHtml(rh))
|
Assertions.assertEquals("<b>Success</b>: false<br><b>Enacted</b>: true<br><b>Comment</b>: AAA<br><b>SMB</b>: 10.0 U", per.toHtml(rh))
|
||||||
per = PumpEnactResult(injector).enacted(true).isTempCancel(true).comment("AAA")
|
per = PumpEnactResult(injector).enacted(true).isTempCancel(true).comment("AAA")
|
||||||
Assert.assertEquals("<b>Success</b>: false<br><b>Enacted</b>: true<br><b>Comment</b>: AAA<br>Cancel temp basal", per.toHtml(rh))
|
Assertions.assertEquals("<b>Success</b>: false<br><b>Enacted</b>: true<br><b>Comment</b>: AAA<br>Cancel temp basal", per.toHtml(rh))
|
||||||
per = PumpEnactResult(injector).enacted(true).isPercent(true).percent(90).duration(20).comment("AAA")
|
per = PumpEnactResult(injector).enacted(true).isPercent(true).percent(90).duration(20).comment("AAA")
|
||||||
Assert.assertEquals("<b>Success</b>: false<br><b>Enacted</b>: true<br><b>Comment</b>: AAA<br><b>Duration</b>: 20 min<br><b>Percent</b>: 90%", per.toHtml(rh))
|
Assertions.assertEquals("<b>Success</b>: false<br><b>Enacted</b>: true<br><b>Comment</b>: AAA<br><b>Duration</b>: 20 min<br><b>Percent</b>: 90%", per.toHtml(rh))
|
||||||
per = PumpEnactResult(injector).enacted(true).isPercent(false).absolute(1.0).duration(30).comment("AAA")
|
per = PumpEnactResult(injector).enacted(true).isPercent(false).absolute(1.0).duration(30).comment("AAA")
|
||||||
Assert.assertEquals("<b>Success</b>: false<br><b>Enacted</b>: true<br><b>Comment</b>: AAA<br><b>Duration</b>: 30 min<br><b>Absolute</b>: 1.00 U/h", per.toHtml(rh))
|
Assertions.assertEquals("<b>Success</b>: false<br><b>Enacted</b>: true<br><b>Comment</b>: AAA<br><b>Duration</b>: 30 min<br><b>Absolute</b>: 1.00 U/h", per.toHtml(rh))
|
||||||
per = PumpEnactResult(injector).enacted(false).comment("AAA")
|
per = PumpEnactResult(injector).enacted(false).comment("AAA")
|
||||||
Assert.assertEquals("<b>Success</b>: false<br><b>Comment</b>: AAA", per.toHtml(rh))
|
Assertions.assertEquals("<b>Success</b>: false<br><b>Comment</b>: AAA", per.toHtml(rh))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun jsonTest() {
|
@Test fun jsonTest() {
|
||||||
|
|
|
@ -25,7 +25,6 @@ class PumpEnactResult(injector: HasAndroidInjector) {
|
||||||
|
|
||||||
// Result of treatment delivery
|
// Result of treatment delivery
|
||||||
var bolusDelivered = 0.0 // real value of delivered insulin
|
var bolusDelivered = 0.0 // real value of delivered insulin
|
||||||
var carbsDelivered = 0.0 // real value of delivered carbs
|
|
||||||
var queued = false
|
var queued = false
|
||||||
|
|
||||||
fun success(success: Boolean): PumpEnactResult = this.also { this.success = success }
|
fun success(success: Boolean): PumpEnactResult = this.also { this.success = success }
|
||||||
|
@ -38,6 +37,5 @@ class PumpEnactResult(injector: HasAndroidInjector) {
|
||||||
fun isPercent(isPercent: Boolean): PumpEnactResult = this.also { it.isPercent = isPercent }
|
fun isPercent(isPercent: Boolean): PumpEnactResult = this.also { it.isPercent = isPercent }
|
||||||
fun isTempCancel(isTempCancel: Boolean): PumpEnactResult = this.also { it.isTempCancel = isTempCancel }
|
fun isTempCancel(isTempCancel: Boolean): PumpEnactResult = this.also { it.isTempCancel = isTempCancel }
|
||||||
fun bolusDelivered(bolusDelivered: Double): PumpEnactResult = this.also { it.bolusDelivered = bolusDelivered }
|
fun bolusDelivered(bolusDelivered: Double): PumpEnactResult = this.also { it.bolusDelivered = bolusDelivered }
|
||||||
fun carbsDelivered(carbsDelivered: Double): PumpEnactResult = this.also { it.carbsDelivered = carbsDelivered }
|
|
||||||
fun queued(queued: Boolean): PumpEnactResult = this.also { it.queued = queued }
|
fun queued(queued: Boolean): PumpEnactResult = this.also { it.queued = queued }
|
||||||
}
|
}
|
|
@ -179,7 +179,6 @@ open class VirtualPumpPlugin @Inject constructor(
|
||||||
val result = PumpEnactResult(injector)
|
val result = PumpEnactResult(injector)
|
||||||
.success(true)
|
.success(true)
|
||||||
.bolusDelivered(detailedBolusInfo.insulin)
|
.bolusDelivered(detailedBolusInfo.insulin)
|
||||||
.carbsDelivered(detailedBolusInfo.carbs)
|
|
||||||
.enacted(detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
|
.enacted(detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
|
||||||
.comment(rh.gs(info.nightscout.core.ui.R.string.virtualpump_resultok))
|
.comment(rh.gs(info.nightscout.core.ui.R.string.virtualpump_resultok))
|
||||||
val bolusingEvent = EventOverviewBolusProgress
|
val bolusingEvent = EventOverviewBolusProgress
|
||||||
|
|
|
@ -14,6 +14,5 @@ fun PumpEnactResult.log(): String {
|
||||||
" IsPercent: " + isPercent +
|
" IsPercent: " + isPercent +
|
||||||
" IsTempCancel: " + isTempCancel +
|
" IsTempCancel: " + isTempCancel +
|
||||||
" bolusDelivered: " + bolusDelivered +
|
" bolusDelivered: " + bolusDelivered +
|
||||||
" carbsDelivered: " + carbsDelivered +
|
|
||||||
" Queued: " + queued
|
" Queued: " + queued
|
||||||
}
|
}
|
|
@ -629,8 +629,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
|
||||||
return new PumpEnactResult(getInjector())
|
return new PumpEnactResult(getInjector())
|
||||||
.success(true)
|
.success(true)
|
||||||
.enacted(lastPumpBolus.amount > 0)
|
.enacted(lastPumpBolus.amount > 0)
|
||||||
.bolusDelivered(lastPumpBolus.amount)
|
.bolusDelivered(lastPumpBolus.amount);
|
||||||
.carbsDelivered(detailedBolusInfo.carbs);
|
|
||||||
} finally {
|
} finally {
|
||||||
pump.activity = null;
|
pump.activity = null;
|
||||||
rxBus.send(new EventComboPumpUpdateGUI());
|
rxBus.send(new EventComboPumpUpdateGUI());
|
||||||
|
|
|
@ -157,7 +157,7 @@ class DanaRKoreanPlugin @Inject constructor(
|
||||||
result
|
result
|
||||||
} else {
|
} else {
|
||||||
val result = PumpEnactResult(injector)
|
val result = PumpEnactResult(injector)
|
||||||
result.success(false).bolusDelivered(0.0).carbsDelivered(0.0).comment(info.nightscout.core.ui.R.string.invalid_input)
|
result.success(false).bolusDelivered(0.0).comment(info.nightscout.core.ui.R.string.invalid_input)
|
||||||
aapsLogger.error("deliverTreatment: Invalid input")
|
aapsLogger.error("deliverTreatment: Invalid input")
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,8 +197,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
|
||||||
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.getInsulin()) < pumpDescription.getBolusStep())
|
result.success(connectionOK && Math.abs(detailedBolusInfo.insulin - t.getInsulin()) < pumpDescription.getBolusStep())
|
||||||
.bolusDelivered(t.getInsulin())
|
.bolusDelivered(t.getInsulin());
|
||||||
.carbsDelivered(detailedBolusInfo.carbs);
|
|
||||||
if (!result.getSuccess())
|
if (!result.getSuccess())
|
||||||
result.comment(rh.gs(info.nightscout.pump.dana.R.string.boluserrorcode, detailedBolusInfo.insulin, t.getInsulin(),
|
result.comment(rh.gs(info.nightscout.pump.dana.R.string.boluserrorcode, detailedBolusInfo.insulin, t.getInsulin(),
|
||||||
danaPump.getBolusStartErrorCode()));
|
danaPump.getBolusStartErrorCode()));
|
||||||
|
@ -209,7 +208,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
PumpEnactResult result = new PumpEnactResult(getInjector());
|
PumpEnactResult result = new PumpEnactResult(getInjector());
|
||||||
result.success(false).bolusDelivered(0d).carbsDelivered(0d).comment(info.nightscout.core.ui.R.string.invalid_input);
|
result.success(false).bolusDelivered(0d).comment(info.nightscout.core.ui.R.string.invalid_input);
|
||||||
aapsLogger.error("deliverTreatment: Invalid input");
|
aapsLogger.error("deliverTreatment: Invalid input");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,8 +172,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
||||||
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.getInsulin()) < pumpDescription.getBolusStep())
|
result.success(connectionOK && Math.abs(detailedBolusInfo.insulin - t.getInsulin()) < pumpDescription.getBolusStep())
|
||||||
.bolusDelivered(t.getInsulin())
|
.bolusDelivered(t.getInsulin());
|
||||||
.carbsDelivered(detailedBolusInfo.carbs);
|
|
||||||
if (!result.getSuccess())
|
if (!result.getSuccess())
|
||||||
result.comment(rh.gs(info.nightscout.pump.dana.R.string.boluserrorcode, detailedBolusInfo.insulin, t.getInsulin(), danaPump.getBolusStartErrorCode()));
|
result.comment(rh.gs(info.nightscout.pump.dana.R.string.boluserrorcode, detailedBolusInfo.insulin, t.getInsulin(), danaPump.getBolusStartErrorCode()));
|
||||||
else
|
else
|
||||||
|
@ -199,7 +198,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
PumpEnactResult result = new PumpEnactResult(getInjector());
|
PumpEnactResult result = new PumpEnactResult(getInjector());
|
||||||
result.success(false).bolusDelivered(0d).carbsDelivered(0d).comment(info.nightscout.core.ui.R.string.invalid_input);
|
result.success(false).bolusDelivered(0d).comment(info.nightscout.core.ui.R.string.invalid_input);
|
||||||
aapsLogger.error("deliverTreatment: Invalid input");
|
aapsLogger.error("deliverTreatment: Invalid input");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -306,7 +306,6 @@ class DanaRSPlugin @Inject constructor(
|
||||||
val result = PumpEnactResult(injector)
|
val result = PumpEnactResult(injector)
|
||||||
result.success = connectionOK && abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.bolusStep
|
result.success = connectionOK && abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.bolusStep
|
||||||
result.bolusDelivered = t.insulin
|
result.bolusDelivered = t.insulin
|
||||||
result.carbsDelivered = detailedBolusInfo.carbs
|
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
var error = "" + danaPump.bolusStartErrorCode
|
var error = "" + danaPump.bolusStartErrorCode
|
||||||
when (danaPump.bolusStartErrorCode) {
|
when (danaPump.bolusStartErrorCode) {
|
||||||
|
@ -323,7 +322,6 @@ class DanaRSPlugin @Inject constructor(
|
||||||
val result = PumpEnactResult(injector)
|
val result = PumpEnactResult(injector)
|
||||||
result.success = false
|
result.success = false
|
||||||
result.bolusDelivered = 0.0
|
result.bolusDelivered = 0.0
|
||||||
result.carbsDelivered = 0.0
|
|
||||||
result.comment = rh.gs(info.nightscout.core.ui.R.string.invalid_input)
|
result.comment = rh.gs(info.nightscout.core.ui.R.string.invalid_input)
|
||||||
aapsLogger.error("deliverTreatment: Invalid input")
|
aapsLogger.error("deliverTreatment: Invalid input")
|
||||||
result
|
result
|
||||||
|
|
|
@ -278,7 +278,6 @@ class DiaconnG8Plugin @Inject constructor(
|
||||||
val result = PumpEnactResult(injector)
|
val result = PumpEnactResult(injector)
|
||||||
result.success = connectionOK
|
result.success = connectionOK
|
||||||
result.bolusDelivered = t.insulin
|
result.bolusDelivered = t.insulin
|
||||||
result.carbsDelivered = detailedBolusInfo.carbs
|
|
||||||
|
|
||||||
if (result.success) result.enacted = true
|
if (result.success) result.enacted = true
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
@ -290,7 +289,6 @@ class DiaconnG8Plugin @Inject constructor(
|
||||||
val result = PumpEnactResult(injector)
|
val result = PumpEnactResult(injector)
|
||||||
result.success = false
|
result.success = false
|
||||||
result.bolusDelivered = 0.0
|
result.bolusDelivered = 0.0
|
||||||
result.carbsDelivered = 0.0
|
|
||||||
result.comment = rh.gs(info.nightscout.core.ui.R.string.invalid_input)
|
result.comment = rh.gs(info.nightscout.core.ui.R.string.invalid_input)
|
||||||
aapsLogger.error("deliverTreatment: Invalid input")
|
aapsLogger.error("deliverTreatment: Invalid input")
|
||||||
result
|
result
|
||||||
|
|
|
@ -266,12 +266,8 @@ class EopatchPumpPlugin @Inject constructor(
|
||||||
|
|
||||||
override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult {
|
override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult {
|
||||||
|
|
||||||
if (detailedBolusInfo.insulin == 0.0 && detailedBolusInfo.carbs == 0.0) {
|
val askedInsulin = detailedBolusInfo.insulin
|
||||||
// neither carbs nor bolus requested
|
if (detailedBolusInfo.insulin > 0.0) {
|
||||||
aapsLogger.error("deliverTreatment: Invalid input: neither carbs nor insulin are set in treatment")
|
|
||||||
return PumpEnactResult(injector).success(false).enacted(false).bolusDelivered(0.0).carbsDelivered(0.0)
|
|
||||||
.comment(rh.gs(info.nightscout.core.ui.R.string.invalid_input))
|
|
||||||
} else if (detailedBolusInfo.insulin > 0.0) {
|
|
||||||
var isSuccess = true
|
var isSuccess = true
|
||||||
val result = BehaviorSubject.createDefault(true)
|
val result = BehaviorSubject.createDefault(true)
|
||||||
val disposable = result.hide()
|
val disposable = result.hide()
|
||||||
|
@ -315,17 +311,14 @@ class EopatchPumpPlugin @Inject constructor(
|
||||||
|
|
||||||
disposable.dispose()
|
disposable.dispose()
|
||||||
|
|
||||||
return if (isSuccess)
|
return if (isSuccess && askedInsulin == detailedBolusInfo.insulin)
|
||||||
PumpEnactResult(injector).success(true)/*.enacted(true)*/.carbsDelivered(detailedBolusInfo.carbs).bolusDelivered(detailedBolusInfo.insulin)
|
PumpEnactResult(injector).success(true).enacted(true).bolusDelivered(detailedBolusInfo.insulin)
|
||||||
else
|
else
|
||||||
PumpEnactResult(injector).success(false)/*.enacted(false)*/.carbsDelivered(0.0).bolusDelivered(detailedBolusInfo.insulin)
|
PumpEnactResult(injector).success(false)/*.enacted(false)*/.bolusDelivered(detailedBolusInfo.insulin)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// no bolus required, carb only treatment
|
// no bolus required
|
||||||
patchManager.addBolusToHistory(detailedBolusInfo)
|
return PumpEnactResult(injector).success(false).enacted(false).bolusDelivered(0.0).comment(rh.gs(info.nightscout.core.ui.R.string.error))
|
||||||
|
|
||||||
return PumpEnactResult(injector).success(true).enacted(true).bolusDelivered(0.0)
|
|
||||||
.carbsDelivered(detailedBolusInfo.carbs).comment(rh.gs(info.nightscout.core.ui.R.string.ok))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -664,10 +664,7 @@ class MedtronicPumpPlugin @Inject constructor(
|
||||||
val time = now + bolusTime * 1000
|
val time = now + bolusTime * 1000
|
||||||
busyTimestamps.add(time)
|
busyTimestamps.add(time)
|
||||||
setEnableCustomAction(MedtronicCustomActionType.ClearBolusBlock, true)
|
setEnableCustomAction(MedtronicCustomActionType.ClearBolusBlock, true)
|
||||||
PumpEnactResult(injector).success(true) //
|
PumpEnactResult(injector).success(true).enacted(true).bolusDelivered(detailedBolusInfo.insulin)
|
||||||
.enacted(true) //
|
|
||||||
.bolusDelivered(detailedBolusInfo.insulin) //
|
|
||||||
.carbsDelivered(detailedBolusInfo.carbs)
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
finishAction("Bolus")
|
finishAction("Bolus")
|
||||||
|
|
|
@ -661,7 +661,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
|
||||||
if (detailedBolusInfo.insulin == 0 && detailedBolusInfo.carbs == 0) {
|
if (detailedBolusInfo.insulin == 0 && detailedBolusInfo.carbs == 0) {
|
||||||
// neither carbs nor bolus requested
|
// neither carbs nor bolus requested
|
||||||
aapsLogger.error("deliverTreatment: Invalid input: neither carbs nor insulin are set in treatment");
|
aapsLogger.error("deliverTreatment: Invalid input: neither carbs nor insulin are set in treatment");
|
||||||
return new PumpEnactResult(getInjector()).success(false).enacted(false).bolusDelivered(0d).carbsDelivered(0d)
|
return new PumpEnactResult(getInjector()).success(false).enacted(false).bolusDelivered(0d)
|
||||||
.comment(info.nightscout.core.ui.R.string.invalid_input);
|
.comment(info.nightscout.core.ui.R.string.invalid_input);
|
||||||
} else if (detailedBolusInfo.insulin > 0) {
|
} else if (detailedBolusInfo.insulin > 0) {
|
||||||
// bolus needed, ask pump to deliver it
|
// bolus needed, ask pump to deliver it
|
||||||
|
@ -679,8 +679,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
|
||||||
"[date=%d, carbs=%.2f, pumpSerial=%s] - Result: %b",
|
"[date=%d, carbs=%.2f, pumpSerial=%s] - Result: %b",
|
||||||
detailedBolusInfo.timestamp, detailedBolusInfo.carbs, serialNumber(), result));
|
detailedBolusInfo.timestamp, detailedBolusInfo.carbs, serialNumber(), result));
|
||||||
|
|
||||||
return new PumpEnactResult(getInjector()).success(true).enacted(true).bolusDelivered(0d)
|
return new PumpEnactResult(getInjector()).success(true).enacted(true).bolusDelivered(0d);
|
||||||
.carbsDelivered(detailedBolusInfo.carbs);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1115,8 +1114,6 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
|
||||||
if (result.getSuccess()) {
|
if (result.getSuccess()) {
|
||||||
incrementStatistics(detailedBolusInfo.getBolusType() == DetailedBolusInfo.BolusType.SMB ? OmnipodErosStorageKeys.Statistics.SMB_BOLUSES_DELIVERED
|
incrementStatistics(detailedBolusInfo.getBolusType() == DetailedBolusInfo.BolusType.SMB ? OmnipodErosStorageKeys.Statistics.SMB_BOLUSES_DELIVERED
|
||||||
: OmnipodErosStorageKeys.Statistics.STANDARD_BOLUSES_DELIVERED);
|
: OmnipodErosStorageKeys.Statistics.STANDARD_BOLUSES_DELIVERED);
|
||||||
|
|
||||||
result.carbsDelivered(detailedBolusInfo.carbs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -446,7 +446,7 @@ public class AapsOmnipodErosManager {
|
||||||
|
|
||||||
sp.remove(OmnipodErosStorageKeys.Preferences.ACTIVE_BOLUS);
|
sp.remove(OmnipodErosStorageKeys.Preferences.ACTIVE_BOLUS);
|
||||||
|
|
||||||
return new PumpEnactResult(injector).success(true).enacted(true).carbsDelivered(detailedBolusInfo.carbs).bolusDelivered(detailedBolusInfo.insulin);
|
return new PumpEnactResult(injector).success(true).enacted(true).bolusDelivered(detailedBolusInfo.insulin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PumpEnactResult cancelBolus() {
|
public PumpEnactResult cancelBolus() {
|
||||||
|
|
|
@ -308,8 +308,7 @@ abstract class PumpPluginAbstract protected constructor(
|
||||||
if (detailedBolusInfo.insulin == 0.0 && detailedBolusInfo.carbs == 0.0) {
|
if (detailedBolusInfo.insulin == 0.0 && detailedBolusInfo.carbs == 0.0) {
|
||||||
// neither carbs nor bolus requested
|
// neither carbs nor bolus requested
|
||||||
aapsLogger.error("deliverTreatment: Invalid input")
|
aapsLogger.error("deliverTreatment: Invalid input")
|
||||||
PumpEnactResult(injector).success(false).enacted(false).bolusDelivered(0.0).carbsDelivered(0.0)
|
PumpEnactResult(injector).success(false).enacted(false).bolusDelivered(0.0).comment(info.nightscout.core.ui.R.string.invalid_input)
|
||||||
.comment(info.nightscout.core.ui.R.string.invalid_input)
|
|
||||||
} else if (detailedBolusInfo.insulin > 0) {
|
} else if (detailedBolusInfo.insulin > 0) {
|
||||||
// bolus needed, ask pump to deliver it
|
// bolus needed, ask pump to deliver it
|
||||||
deliverBolus(detailedBolusInfo)
|
deliverBolus(detailedBolusInfo)
|
||||||
|
@ -324,8 +323,7 @@ abstract class PumpPluginAbstract protected constructor(
|
||||||
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.")
|
||||||
PumpEnactResult(injector).success(true).enacted(true).bolusDelivered(0.0)
|
PumpEnactResult(injector).success(true).enacted(true).bolusDelivered(0.0).comment(R.string.common_resultok)
|
||||||
.carbsDelivered(detailedBolusInfo.carbs).comment(R.string.common_resultok)
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
triggerUIChange()
|
triggerUIChange()
|
||||||
|
|
|
@ -2,6 +2,7 @@ package info.nightscout.workflow.di
|
||||||
|
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.android.ContributesAndroidInjector
|
import dagger.android.ContributesAndroidInjector
|
||||||
|
import info.nightscout.workflow.DummyWorker
|
||||||
import info.nightscout.workflow.InvokeLoopWorker
|
import info.nightscout.workflow.InvokeLoopWorker
|
||||||
import info.nightscout.workflow.LoadBgDataWorker
|
import info.nightscout.workflow.LoadBgDataWorker
|
||||||
import info.nightscout.workflow.PrepareBasalDataWorker
|
import info.nightscout.workflow.PrepareBasalDataWorker
|
||||||
|
@ -33,4 +34,5 @@ abstract class WorkflowModule {
|
||||||
@ContributesAndroidInjector abstract fun prepareBucketedDataWorkerInjector(): PrepareBucketedDataWorker
|
@ContributesAndroidInjector abstract fun prepareBucketedDataWorkerInjector(): PrepareBucketedDataWorker
|
||||||
@ContributesAndroidInjector abstract fun loadBgDataWorkerInjector(): LoadBgDataWorker
|
@ContributesAndroidInjector abstract fun loadBgDataWorkerInjector(): LoadBgDataWorker
|
||||||
@ContributesAndroidInjector abstract fun invokeLoopWorkerInjector(): InvokeLoopWorker
|
@ContributesAndroidInjector abstract fun invokeLoopWorkerInjector(): InvokeLoopWorker
|
||||||
|
@ContributesAndroidInjector abstract fun dummyWorkerInjector(): DummyWorker
|
||||||
}
|
}
|
Loading…
Reference in a new issue