Cleanup.
This commit is contained in:
parent
5dcf214d08
commit
4a1970926c
2 changed files with 53 additions and 51 deletions
|
@ -106,7 +106,7 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
builder.setMessage(R.string.combo_read_full_history_confirmation);
|
builder.setMessage(R.string.combo_read_full_history_confirmation);
|
||||||
builder.setPositiveButton(R.string.ok, (dialog, which) ->
|
builder.setPositiveButton(R.string.ok, (dialog, which) ->
|
||||||
new Thread(() -> ComboPlugin.getPlugin().readAllPumpData()).start());
|
new Thread(() -> ComboPlugin.getPlugin().readAllPumpData()).start());
|
||||||
builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null);
|
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
||||||
builder.show();
|
builder.show();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
lastConnectionView.setText(R.string.combo_pump_connected_now);
|
lastConnectionView.setText(R.string.combo_pump_connected_now);
|
||||||
lastConnectionView.setTextColor(Color.WHITE);
|
lastConnectionView.setTextColor(Color.WHITE);
|
||||||
} else if (plugin.getPump().lastSuccessfulCmdTime + 30 * 60 * 1000 < System.currentTimeMillis()) {
|
} else if (plugin.getPump().lastSuccessfulCmdTime + 30 * 60 * 1000 < System.currentTimeMillis()) {
|
||||||
lastConnectionView.setText(MainApp.sResources.getString(R.string.combo_no_pump_connection, min));
|
lastConnectionView.setText(MainApp.gs(R.string.combo_no_pump_connection, min));
|
||||||
lastConnectionView.setTextColor(Color.RED);
|
lastConnectionView.setTextColor(Color.RED);
|
||||||
} else {
|
} else {
|
||||||
lastConnectionView.setText(minAgo);
|
lastConnectionView.setText(minAgo);
|
||||||
|
@ -199,7 +199,7 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
}
|
}
|
||||||
|
|
||||||
// base basal rate
|
// base basal rate
|
||||||
baseBasalRate.setText(MainApp.sResources.getString(R.string.pump_basebasalrate, plugin.getBaseBasalRate()));
|
baseBasalRate.setText(MainApp.gs(R.string.pump_basebasalrate, plugin.getBaseBasalRate()));
|
||||||
|
|
||||||
// TBR
|
// TBR
|
||||||
String tbrStr = "";
|
String tbrStr = "";
|
||||||
|
@ -207,7 +207,7 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
long minSinceRead = (System.currentTimeMillis() - plugin.getPump().state.timestamp) / 1000 / 60;
|
long minSinceRead = (System.currentTimeMillis() - plugin.getPump().state.timestamp) / 1000 / 60;
|
||||||
long remaining = ps.tbrRemainingDuration - minSinceRead;
|
long remaining = ps.tbrRemainingDuration - minSinceRead;
|
||||||
if (remaining >= 0) {
|
if (remaining >= 0) {
|
||||||
tbrStr = MainApp.sResources.getString(R.string.combo_tbr_remaining, ps.tbrPercent, remaining);
|
tbrStr = MainApp.gs(R.string.combo_tbr_remaining, ps.tbrPercent, remaining);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tempBasalText.setText(tbrStr);
|
tempBasalText.setText(tbrStr);
|
||||||
|
|
|
@ -126,12 +126,12 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return MainApp.instance().getString(R.string.combopump);
|
return MainApp.gs(R.string.combopump);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNameShort() {
|
public String getNameShort() {
|
||||||
String name = MainApp.sResources.getString(R.string.combopump_shortname);
|
String name = MainApp.gs(R.string.combopump_shortname);
|
||||||
if (!name.trim().isEmpty()) {
|
if (!name.trim().isEmpty()) {
|
||||||
//only if translation exists
|
//only if translation exists
|
||||||
return name;
|
return name;
|
||||||
|
@ -143,18 +143,18 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
String getStateSummary() {
|
String getStateSummary() {
|
||||||
PumpState ps = pump.state;
|
PumpState ps = pump.state;
|
||||||
if (!validBasalRateProfileSelectedOnPump) {
|
if (!validBasalRateProfileSelectedOnPump) {
|
||||||
return MainApp.sResources.getString(R.string.loopdisabled);
|
return MainApp.gs(R.string.loopdisabled);
|
||||||
} else if (ps.activeAlert != null) {
|
} else if (ps.activeAlert != null) {
|
||||||
return ps.activeAlert.errorCode != null
|
return ps.activeAlert.errorCode != null
|
||||||
? "E" + ps.activeAlert.errorCode + ": " + ps.activeAlert.message
|
? "E" + ps.activeAlert.errorCode + ": " + ps.activeAlert.message
|
||||||
: "W" + ps.activeAlert.warningCode + ": " + ps.activeAlert.message;
|
: "W" + ps.activeAlert.warningCode + ": " + ps.activeAlert.message;
|
||||||
} else if (ps.menu == null)
|
} else if (ps.menu == null)
|
||||||
return MainApp.sResources.getString(R.string.combo_pump_state_disconnected);
|
return MainApp.gs(R.string.combo_pump_state_disconnected);
|
||||||
else if (ps.suspended && (ps.batteryState == PumpState.EMPTY || ps.insulinState == PumpState.EMPTY))
|
else if (ps.suspended && (ps.batteryState == PumpState.EMPTY || ps.insulinState == PumpState.EMPTY))
|
||||||
return MainApp.sResources.getString(R.string.combo_pump_state_suspended_due_to_error);
|
return MainApp.gs(R.string.combo_pump_state_suspended_due_to_error);
|
||||||
else if (ps.suspended)
|
else if (ps.suspended)
|
||||||
return MainApp.sResources.getString(R.string.combo_pump_state_suspended_by_user);
|
return MainApp.gs(R.string.combo_pump_state_suspended_by_user);
|
||||||
return MainApp.sResources.getString(R.string.combo_pump_state_running);
|
return MainApp.gs(R.string.combo_pump_state_running);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -231,7 +231,14 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connect(String reason) {
|
public void connect(String reason) {
|
||||||
// ruffyscripter establishes a connection as needed
|
// ruffyscripter establishes a connection as needed.
|
||||||
|
// ComboPlugin.runCommand performs on connect checks if needed, thus needs info on
|
||||||
|
// whether a connection is there.
|
||||||
|
// More importantly, RuffyScripter needs control over connection to be able to recover
|
||||||
|
// from a failure and deal with alarms on pump.
|
||||||
|
// Yes, this could also be done by keeping a flag 'inCmd' in RuffyScripter, which kicks
|
||||||
|
// off recovery unless set to false again after command completion and have connect
|
||||||
|
// checks be called in ComboPlugin.connect(); ... and have that cause other issues
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -251,9 +258,9 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
// note that this should not happen anymore since the queue is present, which
|
// note that this should not happen anymore since the queue is present, which
|
||||||
// issues a READSTATE when starting to issue commands which initializes the pump
|
// issues a READSTATE when starting to issue commands which initializes the pump
|
||||||
log.error("setNewBasalProfile not initialized");
|
log.error("setNewBasalProfile not initialized");
|
||||||
Notification notification = new Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, MainApp.sResources.getString(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT);
|
Notification notification = new Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, MainApp.gs(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT);
|
||||||
MainApp.bus().post(new EventNewNotification(notification));
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
return new PumpEnactResult().success(false).enacted(false).comment(MainApp.sResources.getString(R.string.pumpNotInitializedProfileNotSet));
|
return new PumpEnactResult().success(false).enacted(false).comment(MainApp.gs(R.string.pumpNotInitializedProfileNotSet));
|
||||||
}
|
}
|
||||||
|
|
||||||
BasalProfile requestedBasalProfile = convertProfileToComboProfile(profile);
|
BasalProfile requestedBasalProfile = convertProfileToComboProfile(profile);
|
||||||
|
@ -266,29 +273,24 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
|
|
||||||
CommandResult stateResult = runCommand(null, 1, ruffyScripter::readPumpState);
|
CommandResult stateResult = runCommand(null, 1, ruffyScripter::readPumpState);
|
||||||
if (stateResult.state.unsafeUsageDetected == PumpState.UNSUPPORTED_BASAL_RATE_PROFILE) {
|
if (stateResult.state.unsafeUsageDetected == PumpState.UNSUPPORTED_BASAL_RATE_PROFILE) {
|
||||||
return new PumpEnactResult().success(false).enacted(false).comment(MainApp.sResources.getString(R.string.combo_force_disabled_notification));
|
return new PumpEnactResult().success(false).enacted(false).comment(MainApp.gs(R.string.combo_force_disabled_notification));
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult setResult = runCommand(MainApp.sResources.getString(R.string.combo_activity_setting_basal_profile), 2,
|
CommandResult setResult = runCommand(MainApp.gs(R.string.combo_activity_setting_basal_profile), 2,
|
||||||
() -> ruffyScripter.setBasalProfile(requestedBasalProfile));
|
() -> ruffyScripter.setBasalProfile(requestedBasalProfile));
|
||||||
if (!setResult.success) {
|
if (!setResult.success) {
|
||||||
Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.sResources.getString(R.string.failedupdatebasalprofile), Notification.URGENT);
|
Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.gs(R.string.failedupdatebasalprofile), Notification.URGENT);
|
||||||
MainApp.bus().post(new EventNewNotification(notification));
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
return new PumpEnactResult().success(false).enacted(false).comment(MainApp.sResources.getString(R.string.failedupdatebasalprofile));
|
return new PumpEnactResult().success(false).enacted(false).comment(MainApp.gs(R.string.failedupdatebasalprofile));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* don't re-read basal profile to not trigger pump bug; setBasalProfile command checks the total at the end, which must suffice
|
|
||||||
CommandResult readResult = runCommand(MainApp.sResources.getString(R.string.combo_activity_setting_basal_profile), 2,
|
|
||||||
ruffyScripter::readBasalProfile);
|
|
||||||
*/
|
|
||||||
|
|
||||||
pump.basalProfile = requestedBasalProfile;
|
pump.basalProfile = requestedBasalProfile;
|
||||||
|
|
||||||
//dismiss previously "FAILED" overview notifications
|
//dismiss previously "FAILED" overview notifications
|
||||||
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
|
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
|
||||||
MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
|
MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
|
||||||
//issue success notification
|
//issue success notification
|
||||||
Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60);
|
Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60);
|
||||||
MainApp.bus().post(new EventNewNotification(notification));
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
return new PumpEnactResult().success(true).enacted(true);
|
return new PumpEnactResult().success(true).enacted(true);
|
||||||
}
|
}
|
||||||
|
@ -342,7 +344,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
if (!pump.initialized) {
|
if (!pump.initialized) {
|
||||||
initializePump();
|
initializePump();
|
||||||
} else {
|
} else {
|
||||||
runCommand(MainApp.sResources.getString(R.string.combo_pump_action_refreshing), 1, ruffyScripter::readPumpState);
|
runCommand(MainApp.gs(R.string.combo_pump_action_refreshing), 1, ruffyScripter::readPumpState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,14 +361,14 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult stateResult = runCommand(MainApp.sResources.getString(R.string.combo_pump_action_initializing),1, ruffyScripter::readPumpState);
|
CommandResult stateResult = runCommand(MainApp.gs(R.string.combo_pump_action_initializing),1, ruffyScripter::readPumpState);
|
||||||
if (!stateResult.success) {
|
if (!stateResult.success) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stateResult.state.unsafeUsageDetected == PumpState.UNSUPPORTED_BASAL_RATE_PROFILE) {
|
if (stateResult.state.unsafeUsageDetected == PumpState.UNSUPPORTED_BASAL_RATE_PROFILE) {
|
||||||
Notification n = new Notification(Notification.COMBO_PUMP_ALARM,
|
Notification n = new Notification(Notification.COMBO_PUMP_ALARM,
|
||||||
MainApp.sResources.getString(R.string.combo_force_disabled_notification),
|
MainApp.gs(R.string.combo_force_disabled_notification),
|
||||||
Notification.URGENT);
|
Notification.URGENT);
|
||||||
n.soundId = R.raw.alarm;
|
n.soundId = R.raw.alarm;
|
||||||
MainApp.bus().post(new EventNewNotification(n));
|
MainApp.bus().post(new EventNewNotification(n));
|
||||||
|
@ -383,7 +385,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
pump.initialized = true;
|
pump.initialized = true;
|
||||||
MainApp.bus().post(new EventInitializationChanged());
|
MainApp.bus().post(new EventInitializationChanged());
|
||||||
|
|
||||||
// ComboFragment updates state fully only after the pump has initialized, so run this manually here
|
// ComboFragment updates state fully only after the pump has initialized, so read full state here
|
||||||
updateLocalData(readBasalResult);
|
updateLocalData(readBasalResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,22 +409,22 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
EventOverviewBolusProgress event = EventOverviewBolusProgress.getInstance();
|
EventOverviewBolusProgress event = EventOverviewBolusProgress.getInstance();
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case PROGRAMMING:
|
case PROGRAMMING:
|
||||||
event.status = MainApp.sResources.getString(R.string.combo_programming_bolus);
|
event.status = MainApp.gs(R.string.combo_programming_bolus);
|
||||||
break;
|
break;
|
||||||
case DELIVERING:
|
case DELIVERING:
|
||||||
event.status = String.format(MainApp.sResources.getString(R.string.bolusdelivering), delivered);
|
event.status = MainApp.gs(R.string.bolusdelivering, delivered);
|
||||||
break;
|
break;
|
||||||
case DELIVERED:
|
case DELIVERED:
|
||||||
event.status = String.format(MainApp.sResources.getString(R.string.bolusdelivered), delivered);
|
event.status = MainApp.gs(R.string.bolusdelivered, delivered);
|
||||||
break;
|
break;
|
||||||
case STOPPING:
|
case STOPPING:
|
||||||
event.status = MainApp.sResources.getString(R.string.bolusstopping);
|
event.status = MainApp.gs(R.string.bolusstopping);
|
||||||
break;
|
break;
|
||||||
case STOPPED:
|
case STOPPED:
|
||||||
event.status = MainApp.sResources.getString(R.string.bolusstopped);
|
event.status = MainApp.gs(R.string.bolusstopped);
|
||||||
break;
|
break;
|
||||||
case RECOVERING:
|
case RECOVERING:
|
||||||
event.status = MainApp.sResources.getString(R.string.combo_error_bolus_recovery_progress);
|
event.status = MainApp.gs(R.string.combo_error_bolus_recovery_progress);
|
||||||
}
|
}
|
||||||
event.percent = percent;
|
event.percent = percent;
|
||||||
MainApp.bus().post(event);
|
MainApp.bus().post(event);
|
||||||
|
@ -468,7 +470,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
&& lastRequestedBolus.timestamp + 60 * 1000 > System.currentTimeMillis()) {
|
&& lastRequestedBolus.timestamp + 60 * 1000 > System.currentTimeMillis()) {
|
||||||
log.error("Bolus delivery failure at stage 0", new Exception());
|
log.error("Bolus delivery failure at stage 0", new Exception());
|
||||||
return new PumpEnactResult().success(false).enacted(false)
|
return new PumpEnactResult().success(false).enacted(false)
|
||||||
.comment(MainApp.sResources.getString(R.string.bolus_frequency_exceeded));
|
.comment(MainApp.gs(R.string.bolus_frequency_exceeded));
|
||||||
}
|
}
|
||||||
lastRequestedBolus = new Bolus(System.currentTimeMillis(), detailedBolusInfo.insulin, true);
|
lastRequestedBolus = new Bolus(System.currentTimeMillis(), detailedBolusInfo.insulin, true);
|
||||||
|
|
||||||
|
@ -476,11 +478,11 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
long pumpTimeWhenBolusWasRequested = stateResult .state.pumpTime;
|
long pumpTimeWhenBolusWasRequested = stateResult .state.pumpTime;
|
||||||
if (!stateResult.success || pumpTimeWhenBolusWasRequested == 0) {
|
if (!stateResult.success || pumpTimeWhenBolusWasRequested == 0) {
|
||||||
return new PumpEnactResult().success(false).enacted(false)
|
return new PumpEnactResult().success(false).enacted(false)
|
||||||
.comment(MainApp.sResources.getString(R.string.combo_error_no_bolus_delivered));
|
.comment(MainApp.gs(R.string.combo_error_no_bolus_delivered));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
pump.activity = MainApp.sResources.getString(R.string.combo_pump_action_bolusing, detailedBolusInfo.insulin);
|
pump.activity = MainApp.gs(R.string.combo_pump_action_bolusing, detailedBolusInfo.insulin);
|
||||||
MainApp.bus().post(new EventComboPumpUpdateGUI());
|
MainApp.bus().post(new EventComboPumpUpdateGUI());
|
||||||
|
|
||||||
if (cancelBolus) {
|
if (cancelBolus) {
|
||||||
|
@ -539,7 +541,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
// this happens when the cartridge runs empty during delivery, the pump will be in an error
|
// this happens when the cartridge runs empty during delivery, the pump will be in an error
|
||||||
// state with multiple alarms ringing and no chance of reading history
|
// state with multiple alarms ringing and no chance of reading history
|
||||||
return new PumpEnactResult().success(false).enacted(false)
|
return new PumpEnactResult().success(false).enacted(false)
|
||||||
.comment(MainApp.sResources.getString(R.string.combo_error_bolus_verification_failed));
|
.comment(MainApp.gs(R.string.combo_error_bolus_verification_failed));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Bolus> bolusHistory = readLastBolusResult.history.bolusHistory;
|
List<Bolus> bolusHistory = readLastBolusResult.history.bolusHistory;
|
||||||
|
@ -553,7 +555,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
|| !lastBolus.isValid) { // ext/multiwave bolus
|
|| !lastBolus.isValid) { // ext/multiwave bolus
|
||||||
log.debug("No bolus was delivered");
|
log.debug("No bolus was delivered");
|
||||||
return new PumpEnactResult().success(false).enacted(false)
|
return new PumpEnactResult().success(false).enacted(false)
|
||||||
.comment(MainApp.sResources.getString(R.string.combo_error_no_bolus_delivered));
|
.comment(MainApp.gs(R.string.combo_error_no_bolus_delivered));
|
||||||
} else if (Math.abs(lastBolus.amount - detailedBolusInfo.insulin) > 0.01) { // bolus only partially delivered
|
} else if (Math.abs(lastBolus.amount - detailedBolusInfo.insulin) > 0.01) { // bolus only partially delivered
|
||||||
double requestedBolus = detailedBolusInfo.insulin;
|
double requestedBolus = detailedBolusInfo.insulin;
|
||||||
|
|
||||||
|
@ -563,7 +565,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
log.debug(String.format(Locale.getDefault(), "Added partial bolus of %.2f to treatments (requested: %.2f)", lastBolus.amount, requestedBolus));
|
log.debug(String.format(Locale.getDefault(), "Added partial bolus of %.2f to treatments (requested: %.2f)", lastBolus.amount, requestedBolus));
|
||||||
|
|
||||||
return new PumpEnactResult().success(false).enacted(true)
|
return new PumpEnactResult().success(false).enacted(true)
|
||||||
.comment(MainApp.sResources.getString(R.string.combo_error_partial_bolus_delivered,
|
.comment(MainApp.gs(R.string.combo_error_partial_bolus_delivered,
|
||||||
lastBolus.amount, requestedBolus));
|
lastBolus.amount, requestedBolus));
|
||||||
} else {
|
} else {
|
||||||
// bolus was correctly and fully delivered
|
// bolus was correctly and fully delivered
|
||||||
|
@ -635,7 +637,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
}
|
}
|
||||||
|
|
||||||
int finalAdjustedPercent = adjustedPercent;
|
int finalAdjustedPercent = adjustedPercent;
|
||||||
CommandResult commandResult = runCommand(MainApp.sResources.getString(R.string.combo_pump_action_setting_tbr, percent, durationInMinutes),
|
CommandResult commandResult = runCommand(MainApp.gs(R.string.combo_pump_action_setting_tbr, percent, durationInMinutes),
|
||||||
3, () -> ruffyScripter.setTbr(finalAdjustedPercent, durationInMinutes));
|
3, () -> ruffyScripter.setTbr(finalAdjustedPercent, durationInMinutes));
|
||||||
if (!commandResult.success) {
|
if (!commandResult.success) {
|
||||||
return new PumpEnactResult().success(false).enacted(false);
|
return new PumpEnactResult().success(false).enacted(false);
|
||||||
|
@ -670,7 +672,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
final TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
final TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (userRequested) {
|
if (userRequested) {
|
||||||
log.debug("cancelTempBasal: hard-cancelling TBR since user requested");
|
log.debug("cancelTempBasal: hard-cancelling TBR since user requested");
|
||||||
CommandResult commandResult = runCommand(MainApp.sResources.getString(R.string.combo_pump_action_cancelling_tbr), 2, ruffyScripter::cancelTbr);
|
CommandResult commandResult = runCommand(MainApp.gs(R.string.combo_pump_action_cancelling_tbr), 2, ruffyScripter::cancelTbr);
|
||||||
if (!commandResult.state.tbrActive) {
|
if (!commandResult.state.tbrActive) {
|
||||||
TemporaryBasal tempBasal = new TemporaryBasal();
|
TemporaryBasal tempBasal = new TemporaryBasal();
|
||||||
tempBasal.date = commandResult.state.timestamp;
|
tempBasal.date = commandResult.state.timestamp;
|
||||||
|
@ -744,7 +746,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
if (validBasalRateProfileSelectedOnPump && commandResult.state.unsafeUsageDetected == PumpState.UNSUPPORTED_BASAL_RATE_PROFILE) {
|
if (validBasalRateProfileSelectedOnPump && commandResult.state.unsafeUsageDetected == PumpState.UNSUPPORTED_BASAL_RATE_PROFILE) {
|
||||||
validBasalRateProfileSelectedOnPump = false;
|
validBasalRateProfileSelectedOnPump = false;
|
||||||
Notification n = new Notification(Notification.COMBO_PUMP_ALARM,
|
Notification n = new Notification(Notification.COMBO_PUMP_ALARM,
|
||||||
MainApp.sResources.getString(R.string.combo_force_disabled_notification),
|
MainApp.gs(R.string.combo_force_disabled_notification),
|
||||||
Notification.URGENT);
|
Notification.URGENT);
|
||||||
n.soundId = R.raw.alarm;
|
n.soundId = R.raw.alarm;
|
||||||
MainApp.bus().post(new EventNewNotification(n));
|
MainApp.bus().post(new EventNewNotification(n));
|
||||||
|
@ -791,7 +793,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
notification.date = new Date();
|
notification.date = new Date();
|
||||||
notification.id = Notification.COMBO_PUMP_ALARM;
|
notification.id = Notification.COMBO_PUMP_ALARM;
|
||||||
notification.level = Notification.URGENT;
|
notification.level = Notification.URGENT;
|
||||||
notification.text = MainApp.sResources.getString(R.string.combo_is_in_error_state, activeAlert.errorCode, activeAlert.message);
|
notification.text = MainApp.gs(R.string.combo_is_in_error_state, activeAlert.errorCode, activeAlert.message);
|
||||||
MainApp.bus().post(new EventNewNotification(notification));
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
return preCheckResult.success(false);
|
return preCheckResult.success(false);
|
||||||
}
|
}
|
||||||
|
@ -810,11 +812,11 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
// time couldn't be read (e.g. a warning is displayed on the menu , hiding the time field)
|
// 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) {
|
} else if (Math.abs(state.pumpTime - System.currentTimeMillis()) >= 10 * 60 * 1000) {
|
||||||
log.debug("Pump clock needs update, pump time: " + state.pumpTime + " (" + new Date(state.pumpTime) + ")");
|
log.debug("Pump clock needs update, pump time: " + state.pumpTime + " (" + new Date(state.pumpTime) + ")");
|
||||||
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.sResources.getString(R.string.combo_notification_check_time_date), Notification.URGENT);
|
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_notification_check_time_date), Notification.URGENT);
|
||||||
MainApp.bus().post(new EventNewNotification(notification));
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
} else if (Math.abs(state.pumpTime - System.currentTimeMillis()) >= 3 * 60 * 1000) {
|
} else if (Math.abs(state.pumpTime - System.currentTimeMillis()) >= 3 * 60 * 1000) {
|
||||||
log.debug("Pump clock needs update, pump time: " + state.pumpTime + " (" + new Date(state.pumpTime) + ")");
|
log.debug("Pump clock needs update, pump time: " + state.pumpTime + " (" + new Date(state.pumpTime) + ")");
|
||||||
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.sResources.getString(R.string.combo_notification_check_time_date), Notification.NORMAL);
|
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_notification_check_time_date), Notification.NORMAL);
|
||||||
MainApp.bus().post(new EventNewNotification(notification));
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -831,11 +833,11 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
notification.id = Notification.COMBO_PUMP_ALARM;
|
notification.id = Notification.COMBO_PUMP_ALARM;
|
||||||
notification.level = Notification.NORMAL;
|
notification.level = Notification.NORMAL;
|
||||||
if (activeAlert.warningCode == PumpWarningCodes.CARTRIDGE_LOW) {
|
if (activeAlert.warningCode == PumpWarningCodes.CARTRIDGE_LOW) {
|
||||||
notification.text = MainApp.sResources.getString(R.string.combo_pump_cartridge_low_warrning);
|
notification.text = MainApp.gs(R.string.combo_pump_cartridge_low_warrning);
|
||||||
} else if (activeAlert.warningCode == PumpWarningCodes.BATTERY_LOW) {
|
} else if (activeAlert.warningCode == PumpWarningCodes.BATTERY_LOW) {
|
||||||
notification.text = MainApp.sResources.getString(R.string.combo_pump_battery_low_warrning);
|
notification.text = MainApp.gs(R.string.combo_pump_battery_low_warrning);
|
||||||
} else if (activeAlert.warningCode == PumpWarningCodes.TBR_CANCELLED) {
|
} else if (activeAlert.warningCode == PumpWarningCodes.TBR_CANCELLED) {
|
||||||
notification.text = MainApp.sResources.getString(R.string.combo_pump_tbr_cancelled_warrning);
|
notification.text = MainApp.gs(R.string.combo_pump_tbr_cancelled_warrning);
|
||||||
}
|
}
|
||||||
MainApp.bus().post(new EventNewNotification(notification));
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
}
|
}
|
||||||
|
@ -859,7 +861,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
lowSuspendOnlyLoopEnforcedUntil = lastViolation + 6 * 60 * 60 * 1000;
|
lowSuspendOnlyLoopEnforcedUntil = lastViolation + 6 * 60 * 60 * 1000;
|
||||||
if (lowSuspendOnlyLoopEnforcedUntil > System.currentTimeMillis() && violationWarningRaisedForBolusAt != lowSuspendOnlyLoopEnforcedUntil) {
|
if (lowSuspendOnlyLoopEnforcedUntil > System.currentTimeMillis() && violationWarningRaisedForBolusAt != lowSuspendOnlyLoopEnforcedUntil) {
|
||||||
Notification n = new Notification(Notification.COMBO_PUMP_ALARM,
|
Notification n = new Notification(Notification.COMBO_PUMP_ALARM,
|
||||||
MainApp.sResources.getString(R.string.combo_low_suspend_forced_notification),
|
MainApp.gs(R.string.combo_low_suspend_forced_notification),
|
||||||
Notification.URGENT);
|
Notification.URGENT);
|
||||||
n.soundId = R.raw.alarm;
|
n.soundId = R.raw.alarm;
|
||||||
MainApp.bus().post(new EventNewNotification(n));
|
MainApp.bus().post(new EventNewNotification(n));
|
||||||
|
@ -919,7 +921,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
* which warns the user against doing this.
|
* which warns the user against doing this.
|
||||||
*/
|
*/
|
||||||
private boolean readHistory(final PumpHistoryRequest request) {
|
private boolean readHistory(final PumpHistoryRequest request) {
|
||||||
CommandResult historyResult = runCommand(MainApp.sResources.getString(R.string.combo_activity_reading_pump_history), 3, () -> ruffyScripter.readHistory(request));
|
CommandResult historyResult = runCommand(MainApp.gs(R.string.combo_activity_reading_pump_history), 3, () -> ruffyScripter.readHistory(request));
|
||||||
if (!historyResult.success) {
|
if (!historyResult.success) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue