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 @Override
public double getTempBasalAbsoluteRate() { public double getTempBasalAbsoluteRate() {
if (isRealTempBasalInProgress()) { TempBasal tb = getRealTempBasal();
if (getRealTempBasal().isAbsolute) { if (tb != null) {
return getRealTempBasal().absolute; if (tb.isAbsolute) {
return tb.absolute;
} else { } else {
Double baseRate = getBaseBasalRate(); Double baseRate = getBaseBasalRate();
Double tempRate = baseRate * (getRealTempBasal().percent / 100d); Double tempRate = baseRate * (tb.percent / 100d);
return tempRate; return tempRate;
} }
} }
if (isExtendedBoluslInProgress() && useExtendedBoluses) { TempBasal eb = getExtendedBolus();
return getBaseBasalRate() + getExtendedBolus().absolute; if (eb != null && useExtendedBoluses) {
return getBaseBasalRate() + eb.absolute;
} }
return 0; return 0;
} }

View file

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