Implement reading basal profile.
This commit is contained in:
parent
971a97a9e3
commit
75855f3f05
2 changed files with 45 additions and 30 deletions
|
@ -7,6 +7,7 @@ import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -230,8 +231,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isThisProfileSet(Profile profile) {
|
public boolean isThisProfileSet(Profile profile) {
|
||||||
return true;
|
return pump.basalProfile.equals(convertProfileToComboProfile(profile));
|
||||||
// return pump.basalProfile.equals(convertProfileToComboProfile(profile));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -284,18 +284,13 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// read basal profile into cache, update pump profile if needed
|
// read basal profile into cache, update pump profile if needed
|
||||||
/* not implemented by ruffiscripter
|
|
||||||
if (!pump.initialized) {
|
if (!pump.initialized) {
|
||||||
CommandResult readBasalResult = runCommand("Reading basal profile", 2, ruffyScripter::readBasalProfile);
|
CommandResult readBasalResult = runCommand("Reading basal profile", 2, ruffyScripter::readBasalProfile);
|
||||||
if (!readBasalResult.success) {
|
if (!readBasalResult.success) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
|
||||||
setNewBasalProfile(profile);
|
|
||||||
|
|
||||||
pump.basalProfile = readBasalResult.basalProfile;
|
pump.basalProfile = readBasalResult.basalProfile;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
if (!checkPumpHistory()) {
|
if (!checkPumpHistory()) {
|
||||||
return;
|
return;
|
||||||
|
@ -330,24 +325,8 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseBasalRate() {
|
public double getBaseBasalRate() {
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
int currentHour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
|
||||||
Double basal = profile.getBasal();
|
return pump.basalProfile.hourlyRates[currentHour];
|
||||||
log.trace("getBaseBasalrate returning " + basal);
|
|
||||||
return basal;
|
|
||||||
|
|
||||||
/* if (pump.basalProfile == null) {
|
|
||||||
// when to force refresh this?
|
|
||||||
CommandResult result = runCommand("Reading basal profile", new CommandExecution() {
|
|
||||||
@Override
|
|
||||||
public CommandResult execute() {
|
|
||||||
return ruffyScripter.readBasalProfile(1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
pump.basalProfile = result.basalProfile;
|
|
||||||
// error handling ...
|
|
||||||
}
|
|
||||||
return pump.basalProfile.hourlyRates[Calendar.getInstance().get(Calendar.HOUR_OF_DAY)];
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BolusProgressReporter nullBolusProgressReporter = (state, percent, delivered) -> {
|
private static BolusProgressReporter nullBolusProgressReporter = (state, percent, delivered) -> {
|
||||||
|
@ -964,6 +943,11 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
.tbrHistory(PumpHistoryRequest.FULL)
|
.tbrHistory(PumpHistoryRequest.FULL)
|
||||||
.pumpErrorHistory(PumpHistoryRequest.FULL)
|
.pumpErrorHistory(PumpHistoryRequest.FULL)
|
||||||
.tddHistory(PumpHistoryRequest.FULL));
|
.tddHistory(PumpHistoryRequest.FULL));
|
||||||
|
CommandResult commandResult = runCommand("Reading basal profile", 2,
|
||||||
|
ruffyScripter::readBasalProfile);
|
||||||
|
if (commandResult.success) {
|
||||||
|
pump.basalProfile = commandResult.basalProfile;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,14 +1,45 @@
|
||||||
package de.jotomo.ruffyscripter.commands;
|
package de.jotomo.ruffyscripter.commands;
|
||||||
|
|
||||||
|
import org.monkey.d.ruffy.ruffy.driver.display.MenuAttribute;
|
||||||
|
import org.monkey.d.ruffy.ruffy.driver.display.MenuType;
|
||||||
|
import org.monkey.d.ruffy.ruffy.driver.display.menu.MenuTime;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import de.jotomo.ruffy.spi.BasalProfile;
|
import de.jotomo.ruffy.spi.BasalProfile;
|
||||||
|
|
||||||
public class ReadBasalProfileCommand extends BaseCommand {
|
public class ReadBasalProfileCommand extends BaseCommand {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(ReadBasalProfileCommand.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
if (1==1) throw new RuntimeException("No implemented yet");
|
scripter.navigateToMenu(MenuType.BASAL_1_MENU);
|
||||||
// TODO
|
scripter.verifyMenuIsDisplayed(MenuType.BASAL_1_MENU);
|
||||||
result.basalProfile(new BasalProfile(new double[] {0.5d, 0.5d, 0.5d, 0.5d, 0.5d, 0.5d, 0.5d, 0.5d, 0.5d, 0.5d, 0.5d, 0.5d, 0.5d, 0.5d, 0.5d, 0.5d, 0.5d, 0.5d, 0.5d, 0.5d, 0.5d, 0.5d, 0.5d, 0.5d}));
|
scripter.pressCheckKey();
|
||||||
//scripter.returnToRootMenu();
|
|
||||||
result.success = true;
|
BasalProfile basalProfile = new BasalProfile();
|
||||||
|
|
||||||
|
// summary screen is shown; press menu to page through hours, wraps around to summary;
|
||||||
|
scripter.verifyMenuIsDisplayed(MenuType.BASAL_TOTAL);
|
||||||
|
for (int i = 0; i < 24; i++) {
|
||||||
|
scripter.pressMenuKey();
|
||||||
|
scripter.waitForScreenUpdate();
|
||||||
|
scripter.verifyMenuIsDisplayed(MenuType.BASAL_SET);
|
||||||
|
MenuTime startTime = (MenuTime) scripter.getCurrentMenu().getAttribute(MenuAttribute.BASAL_START);
|
||||||
|
if (i != startTime.getHour()) {
|
||||||
|
throw new CommandException("Attempting to read basal rate for hour " + i + ", but hour " + startTime.getHour() + " is displayed");
|
||||||
|
}
|
||||||
|
basalProfile.hourlyRates[i] = scripter.readBlinkingValue(Double.class, MenuAttribute.BASAL_RATE);
|
||||||
|
log.debug("Read basal profile, hour " + i + ": " + basalProfile.hourlyRates[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.debug("Basal profile read: " + Arrays.toString(basalProfile.hourlyRates));
|
||||||
|
|
||||||
|
scripter.returnToRootMenu();
|
||||||
|
scripter.verifyRootMenuIsDisplayed();
|
||||||
|
|
||||||
|
result.success(true).basalProfile(basalProfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue