Update treatment history when setting/cancelling a TBR.
This commit is contained in:
parent
a27bb28e87
commit
e29ef5ffce
1 changed files with 42 additions and 31 deletions
|
@ -30,7 +30,10 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
|
import info.nightscout.androidaps.db.Source;
|
||||||
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
@ -287,7 +290,10 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
try {
|
try {
|
||||||
return ruffyScripter.runCommand(command);
|
return ruffyScripter.runCommand(command);
|
||||||
} finally {
|
} finally {
|
||||||
|
// MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||||
ruffyScripter.disconnect();
|
ruffyScripter.disconnect();
|
||||||
|
// MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED));
|
||||||
|
// MainApp.bus().post(new EventComboPumpUpdateGUI());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,10 +312,17 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) {
|
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) {
|
||||||
// TODO make each cmd return all the data the main screen displays and cache here ?
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.settingtempbasal)));
|
||||||
try {
|
CommandResult commandResult = runCommand(new SetTbrCommand(percent, durationInMinutes));
|
||||||
Command command = new SetTbrCommand(percent, durationInMinutes);
|
if (commandResult.enacted) {
|
||||||
CommandResult commandResult = ruffyScripter.runCommand(command);
|
TemporaryBasal tempStart = new TemporaryBasal(System.currentTimeMillis());
|
||||||
|
tempStart.durationInMinutes = durationInMinutes;
|
||||||
|
tempStart.percentRate = percent;
|
||||||
|
tempStart.isAbsolute = false;
|
||||||
|
tempStart.source = Source.USER;
|
||||||
|
ConfigBuilderPlugin treatmentsInterface = MainApp.getConfigBuilder();
|
||||||
|
treatmentsInterface.addToHistoryTempBasal(tempStart);
|
||||||
|
}
|
||||||
|
|
||||||
PumpEnactResult pumpEnactResult = new PumpEnactResult();
|
PumpEnactResult pumpEnactResult = new PumpEnactResult();
|
||||||
pumpEnactResult.success = commandResult.success;
|
pumpEnactResult.success = commandResult.success;
|
||||||
|
@ -321,23 +334,24 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
pumpEnactResult.percent = percent;
|
pumpEnactResult.percent = percent;
|
||||||
pumpEnactResult.duration = durationInMinutes;
|
pumpEnactResult.duration = durationInMinutes;
|
||||||
return pumpEnactResult;
|
return pumpEnactResult;
|
||||||
} finally {
|
|
||||||
ruffyScripter.disconnect();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
|
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
|
||||||
return OPERATION_NOT_SUPPORTED;
|
return OPERATION_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult cancelTempBasal() {
|
public PumpEnactResult cancelTempBasal() {
|
||||||
try {
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingtempbasal)));
|
||||||
Command command = new CancelTbrCommand();
|
CommandResult commandResult = runCommand(new CancelTbrCommand());
|
||||||
CommandResult commandResult = ruffyScripter.runCommand(command);
|
if(commandResult.enacted) {
|
||||||
|
TemporaryBasal tempStop = new TemporaryBasal(new Date().getTime());
|
||||||
|
tempStop.durationInMinutes = 0; // == ending temp basal
|
||||||
|
tempStop.source = Source.USER;
|
||||||
|
ConfigBuilderPlugin treatmentsInterface = MainApp.getConfigBuilder();
|
||||||
|
treatmentsInterface.addToHistoryTempBasal(tempStop);
|
||||||
|
}
|
||||||
|
|
||||||
PumpEnactResult pumpEnactResult = new PumpEnactResult();
|
PumpEnactResult pumpEnactResult = new PumpEnactResult();
|
||||||
pumpEnactResult.success = commandResult.success;
|
pumpEnactResult.success = commandResult.success;
|
||||||
|
@ -345,9 +359,6 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
pumpEnactResult.comment = commandResult.message;
|
pumpEnactResult.comment = commandResult.message;
|
||||||
pumpEnactResult.isTempCancel = true;
|
pumpEnactResult.isTempCancel = true;
|
||||||
return pumpEnactResult;
|
return pumpEnactResult;
|
||||||
} finally {
|
|
||||||
ruffyScripter.disconnect();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
Loading…
Reference in a new issue