Avoid race condition using active extended bolus.
(cherry picked from commit 5b7c0cc)
This commit is contained in:
parent
1471d2bcd5
commit
f888e0d7ab
|
@ -137,11 +137,11 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
|||
extendedBolus.setVisibility(View.GONE);
|
||||
extendedBolusCancel.setVisibility(View.GONE);
|
||||
} else {
|
||||
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
|
||||
ExtendedBolus activeExtendedBolus = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||
if (activeExtendedBolus != null) {
|
||||
extendedBolus.setVisibility(View.GONE);
|
||||
extendedBolusCancel.setVisibility(View.VISIBLE);
|
||||
ExtendedBolus running = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||
extendedBolusCancel.setText(MainApp.instance().getString(R.string.cancel) + " " + running.toString());
|
||||
extendedBolusCancel.setText(MainApp.instance().getString(R.string.cancel) + " " + activeExtendedBolus.toString());
|
||||
} else {
|
||||
extendedBolus.setVisibility(View.VISIBLE);
|
||||
extendedBolusCancel.setVisibility(View.GONE);
|
||||
|
@ -153,10 +153,10 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
|||
tempBasal.setVisibility(View.GONE);
|
||||
tempBasalCancel.setVisibility(View.GONE);
|
||||
} else {
|
||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
||||
final TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
||||
if (activeTemp != null) {
|
||||
tempBasal.setVisibility(View.GONE);
|
||||
tempBasalCancel.setVisibility(View.VISIBLE);
|
||||
final TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
||||
tempBasalCancel.setText(MainApp.instance().getString(R.string.cancel) + " " + activeTemp.toStringShort());
|
||||
} else {
|
||||
tempBasal.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -538,11 +538,13 @@ public abstract class AbstractDanaRPlugin implements PluginBase, PumpInterface,
|
|||
if (pump.lastBolusTime.getTime() != 0) {
|
||||
ret += "LastBolus: " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.lastBolusTime) + "\n";
|
||||
}
|
||||
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
|
||||
ret += "Temp: " + MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull() + "\n";
|
||||
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
|
||||
if (activeTemp != null) {
|
||||
ret += "Temp: " + activeTemp.toStringFull() + "\n";
|
||||
}
|
||||
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
|
||||
ret += "Extended: " + MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis()).toString() + "\n";
|
||||
ExtendedBolus activeExtendedBolus = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||
if (activeExtendedBolus != null) {
|
||||
ret += "Extended: " + activeExtendedBolus.toString() + "\n";
|
||||
}
|
||||
if (!veryShort) {
|
||||
ret += "TDD: " + DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U\n";
|
||||
|
|
|
@ -29,6 +29,7 @@ import butterknife.OnClick;
|
|||
import butterknife.Unbinder;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||
|
@ -216,8 +217,9 @@ public class DanaRFragment extends SubscriberFragment {
|
|||
tempBasalView.setText("");
|
||||
}
|
||||
}
|
||||
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
|
||||
extendedBolusView.setText(MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis()).toString());
|
||||
ExtendedBolus activeExtendedBolus = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||
if (activeExtendedBolus != null) {
|
||||
extendedBolusView.setText(activeExtendedBolus.toString());
|
||||
} else {
|
||||
extendedBolusView.setText("");
|
||||
}
|
||||
|
|
|
@ -315,8 +315,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
|||
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress())
|
||||
return cancelRealTempBasal();
|
||||
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
|
||||
PumpEnactResult cancelEx = cancelExtendedBolus();
|
||||
return cancelEx;
|
||||
return cancelExtendedBolus();
|
||||
}
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
result.success = true;
|
||||
|
|
|
@ -69,8 +69,8 @@ public class MsgStatusBolusExtended extends MessageBase {
|
|||
DanaRPump pump = DanaRPump.getInstance();
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
if (treatmentsInterface.isInHistoryExtendedBoluslInProgress()) {
|
||||
ExtendedBolus extendedBolus = treatmentsInterface.getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||
ExtendedBolus extendedBolus = treatmentsInterface.getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||
if (extendedBolus != null) {
|
||||
if (pump.isExtendedInProgress) {
|
||||
if (extendedBolus.absoluteRate() != pump.extendedBolusAbsoluteRate) {
|
||||
// Close current extended
|
||||
|
|
|
@ -316,8 +316,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
|||
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress())
|
||||
return cancelRealTempBasal();
|
||||
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
|
||||
PumpEnactResult cancelEx = cancelExtendedBolus();
|
||||
return cancelEx;
|
||||
return cancelExtendedBolus();
|
||||
}
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
result.success = true;
|
||||
|
|
|
@ -820,11 +820,13 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
|
|||
if (pump.lastBolusTime.getTime() != 0) {
|
||||
ret += "LastBolus: " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.lastBolusTime) + "\n";
|
||||
}
|
||||
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
|
||||
ret += "Temp: " + MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull() + "\n";
|
||||
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
|
||||
if (activeTemp != null) {
|
||||
ret += "Temp: " + activeTemp.toStringFull() + "\n";
|
||||
}
|
||||
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
|
||||
ret += "Extended: " + MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis()).toString() + "\n";
|
||||
ExtendedBolus activeExtendedBolus = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||
if (activeExtendedBolus != null) {
|
||||
ret += "Extended: " + activeExtendedBolus.toString() + "\n";
|
||||
}
|
||||
if (!veryShort) {
|
||||
ret += "TDD: " + DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U\n";
|
||||
|
|
|
@ -18,6 +18,8 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
|
||||
|
||||
|
@ -81,13 +83,15 @@ public class VirtualPumpFragment extends SubscriberFragment {
|
|||
public void run() {
|
||||
VirtualPumpPlugin virtualPump = VirtualPumpPlugin.getPlugin();
|
||||
basaBasalRateView.setText(virtualPump.getBaseBasalRate() + "U");
|
||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
||||
tempBasalView.setText(MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
|
||||
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
||||
if (activeTemp != null) {
|
||||
tempBasalView.setText(activeTemp.toStringFull());
|
||||
} else {
|
||||
tempBasalView.setText("");
|
||||
}
|
||||
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
|
||||
extendedBolusView.setText(MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis()).toString());
|
||||
ExtendedBolus activeExtendedBolus = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||
if (activeExtendedBolus != null) {
|
||||
extendedBolusView.setText(activeExtendedBolus.toString());
|
||||
} else {
|
||||
extendedBolusView.setText("");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue