fix nullpointerexception in reading temp basal status

This commit is contained in:
Milos Kozak 2017-02-09 16:43:27 +01:00
parent a39416d876
commit 806cc4a3a7
2 changed files with 16 additions and 12 deletions

View file

@ -292,17 +292,19 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
@Override
public double getTempBasalAbsoluteRate() {
if (isRealTempBasalInProgress()) {
if (getRealTempBasal().isAbsolute) {
return getRealTempBasal().absolute;
TempBasal tb = getRealTempBasal();
if (tb != null) {
if (tb.isAbsolute) {
return tb.absolute;
} else {
Double baseRate = getBaseBasalRate();
Double tempRate = baseRate * (getRealTempBasal().percent / 100d);
Double tempRate = baseRate * (tb.percent / 100d);
return tempRate;
}
}
if (isExtendedBoluslInProgress() && useExtendedBoluses) {
return getBaseBasalRate() + getExtendedBolus().absolute;
TempBasal eb = getExtendedBolus();
if (eb != null && useExtendedBoluses) {
return getBaseBasalRate() + eb.absolute;
}
return 0;
}

View file

@ -292,17 +292,19 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
@Override
public double getTempBasalAbsoluteRate() {
if (isRealTempBasalInProgress()) {
if (getRealTempBasal().isAbsolute) {
return getRealTempBasal().absolute;
TempBasal tb = getRealTempBasal();
if (tb != null) {
if (tb.isAbsolute) {
return tb.absolute;
} else {
Double baseRate = getBaseBasalRate();
Double tempRate = baseRate * (getRealTempBasal().percent / 100d);
Double tempRate = baseRate * (tb.percent / 100d);
return tempRate;
}
}
if (isExtendedBoluslInProgress() && useExtendedBoluses) {
return getBaseBasalRate() + getExtendedBolus().absolute;
TempBasal eb = getExtendedBolus();
if (eb != null && useExtendedBoluses) {
return getBaseBasalRate() + eb.absolute;
}
return 0;
}