Implement getBatteryLevel() in PumpInterface and for all pump plugins

This commit is contained in:
Nico Schmitz 2018-06-13 00:28:17 +02:00
parent f28fca668f
commit a7aa4c2b5a
7 changed files with 29 additions and 0 deletions

View file

@ -35,6 +35,8 @@ public interface PumpInterface {
double getReservoirLevel();
int getBatteryLevel(); // in percent as integer
PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo);
void stopBolusDelivering();
PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew);

View file

@ -428,6 +428,18 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
return pump.reservoirLevel;
}
@Override
public int getBatteryLevel() {
switch (pump.state.batteryState) {
case PumpState.EMPTY:
return 0;
case PumpState.LOW:
return 25;
default:
return 100;
}
}
private static BolusProgressReporter bolusProgressReporter = (state, percent, delivered) -> {
EventOverviewBolusProgress event = EventOverviewBolusProgress.getInstance();
switch (state) {

View file

@ -153,6 +153,9 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
@Override
public double getReservoirLevel() { return pump.reservoirRemainingUnits; }
@Override
public int getBatteryLevel() { return pump.batteryRemaining; }
@Override
public void stopBolusDelivering() {
if (sExecutionService == null) {

View file

@ -357,6 +357,9 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
return pump.reservoirRemainingUnits;
}
@Override
public int getBatteryLevel() { return pump.batteryRemaining; }
@Override
public synchronized PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
detailedBolusInfo.insulin = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(detailedBolusInfo.insulin)).value();

View file

@ -388,6 +388,9 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
@Override
public double getReservoirLevel() { return reservoirInUnits; }
@Override
public int getBatteryLevel() { return batteryPercent; }
public String getBaseBasalRateString() {
final DecimalFormat df = new DecimalFormat("#.##");
return df.format(basalRate);

View file

@ -132,6 +132,9 @@ public class MDIPlugin extends PluginBase implements PumpInterface {
@Override
public double getReservoirLevel() { return -1; }
@Override
public int getBatteryLevel() { return -1; }
@Override
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
PumpEnactResult result = new PumpEnactResult();

View file

@ -200,6 +200,9 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
@Override
public double getReservoirLevel() { return reservoirInUnits; }
@Override
public int getBatteryLevel() { return batteryPercent; }
@Override
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
PumpEnactResult result = new PumpEnactResult();