Merge branch 're-add-pump-time-check' into combo-scripter-v2
* re-add-pump-time-check: Shorten/make clearer message on pump clock being off. Pump time warning: urgency level based on how much the time is off. Check pump time not last connection time Re-add warning if pump time is off (needed for basal rates). RuffyScripter: read/infer pump time from menu.
This commit is contained in:
commit
279d322c53
3 changed files with 32 additions and 4 deletions
|
@ -46,7 +46,6 @@ import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProg
|
|||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.events.EventComboPumpUpdateGUI;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static de.jotomo.ruffy.spi.BolusProgressReporter.State.FINISHED;
|
||||
|
||||
|
@ -703,10 +702,25 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
}
|
||||
|
||||
checkAndResolveTbrMismatch(preCheckResult.state);
|
||||
checkPumpTime(preCheckResult.state);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Check pump time (on the main menu) and raise notification if time is off.
|
||||
* (setting clock is not supported by ruffy) */
|
||||
private void checkPumpTime(PumpState state) {
|
||||
if (state.pumpTime == 0) {
|
||||
// time couldn't be read (e.g. a warning is displayed on the menu , hiding the time field)
|
||||
} else if (Math.abs(state.pumpTime - System.currentTimeMillis()) >= 10 * 60 * 1000) {
|
||||
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.sResources.getString(R.string.combo_notification_check_time_date), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
} else if (Math.abs(state.pumpTime - System.currentTimeMillis()) >= 3 * 60 * 1000) {
|
||||
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.sResources.getString(R.string.combo_notification_check_time_date), Notification.NORMAL);
|
||||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyAboutPumpWarning(WarningOrErrorCode activeAlert) {
|
||||
if (activeAlert.warningCode == null ||
|
||||
(!activeAlert.warningCode.equals(PumpWarningCodes.CARTRIDGE_LOW)
|
||||
|
@ -797,7 +811,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
|
||||
/**
|
||||
* Reads the pump's history and updates the DB accordingly.
|
||||
*
|
||||
* <p>
|
||||
* Only ever called by #readAllPumpData which is triggered by the user via the combo fragment
|
||||
* which warns the user against doing this.
|
||||
*/
|
||||
|
|
|
@ -2,8 +2,11 @@ package de.jotomo.ruffy.spi;
|
|||
|
||||
/** State displayed on the main screen of the pump. */
|
||||
public class PumpState {
|
||||
/** Time the state was captured. This is NOT the pump's time! */
|
||||
/** Time the state was captured. */
|
||||
public long timestamp;
|
||||
/** Pump time. Note that this is derived from the time displayed on the main menu and assumes
|
||||
* the date is set correctly */
|
||||
public long pumpTime;
|
||||
public String menu = null;
|
||||
public boolean suspended;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.monkey.d.ruffy.ruffy.driver.display.menu.MenuTime;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -509,12 +510,22 @@ public class RuffyScripter implements RuffyCommands {
|
|||
}
|
||||
state.batteryState = ((int) menu.getAttribute(MenuAttribute.BATTERY_STATE));
|
||||
state.insulinState = ((int) menu.getAttribute(MenuAttribute.INSULIN_STATE));
|
||||
MenuTime time = (MenuTime) menu.getAttribute(MenuAttribute.TIME);
|
||||
Date date = new Date();
|
||||
date.setHours(time.getHour());
|
||||
date.setMinutes(time.getMinute());
|
||||
state.pumpTime = date.getTime();
|
||||
} else if (menuType == MenuType.WARNING_OR_ERROR) {
|
||||
state.activeAlert = readWarningOrErrorCode();
|
||||
} else if (menuType == MenuType.STOP) {
|
||||
state.suspended = true;
|
||||
state.batteryState = ((int) menu.getAttribute(MenuAttribute.BATTERY_STATE));
|
||||
state.insulinState = ((int) menu.getAttribute(MenuAttribute.INSULIN_STATE));
|
||||
MenuTime time = (MenuTime) menu.getAttribute(MenuAttribute.TIME);
|
||||
Date date = new Date();
|
||||
date.setHours(time.getHour());
|
||||
date.setMinutes(time.getMinute());
|
||||
state.pumpTime = date.getTime();
|
||||
}
|
||||
|
||||
return state;
|
||||
|
|
Loading…
Reference in a new issue