Avoid race condition checking for an active TBR.

This commit is contained in:
Johannes Mockenhaupt 2018-01-10 10:48:44 +01:00
parent bdd1a85d26
commit 06d949cd82
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
3 changed files with 8 additions and 7 deletions

View file

@ -139,8 +139,8 @@ public class PersistentNotificationPlugin implements PluginBase {
}
}
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
if (activeTemp != null) {
line1 += " " + activeTemp.toStringShort();
}

View file

@ -403,8 +403,10 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
@Override
public double getTempBasalRemainingMinutesFromHistory() {
if (isTempBasalInProgress())
return getTempBasalFromHistory(System.currentTimeMillis()).getPlannedRemainingMinutes();
TemporaryBasal activeTemp = getTempBasalFromHistory(System.currentTimeMillis());
if (activeTemp != null) {
return activeTemp.getPlannedRemainingMinutes();
}
return 0;
}

View file

@ -182,10 +182,9 @@ public class StatuslinePlugin implements PluginBase {
//Temp basal
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
if (treatmentsInterface.isTempBasalInProgress()) {
TemporaryBasal activeTemp = treatmentsInterface.getTempBasalFromHistory(System.currentTimeMillis());
TemporaryBasal activeTemp = treatmentsInterface.getTempBasalFromHistory(System.currentTimeMillis());
if (activeTemp != null) {
status += activeTemp.toStringShort();
}
//IOB