Merge pull request #28 from jotomo/combo-scripter-v2

feb 7 V2
This commit is contained in:
Simon Pauwels 2018-02-07 23:17:58 +01:00 committed by GitHub
commit c57bb61d20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 9 deletions

View file

@ -264,7 +264,7 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
// last bolus // last bolus
Bolus bolus = plugin.getPump().lastBolus; Bolus bolus = plugin.getPump().lastBolus;
if (bolus != null && bolus.timestamp + 6 * 60 * 60 * 1000 >= System.currentTimeMillis()) { if (bolus != null) {
long agoMsc = System.currentTimeMillis() - bolus.timestamp; long agoMsc = System.currentTimeMillis() - bolus.timestamp;
double bolusMinAgo = agoMsc / 60d / 1000d; double bolusMinAgo = agoMsc / 60d / 1000d;
String unit = MainApp.gs(R.string.treatments_wizard_unit_label); String unit = MainApp.gs(R.string.treatments_wizard_unit_label);

View file

@ -785,16 +785,33 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
return OPERATION_NOT_SUPPORTED; return OPERATION_NOT_SUPPORTED;
} }
/** Cancel an active Temp Basal. Mostly sets a fake Temp Basal to avoid a TBR CANCELLED
* alert. This relies on TemporaryBasal objects to properly reflect the pumps state,
* which is ensured by {@link #checkAndResolveTbrMismatch(PumpState)}, which runs on each
* connect. When a hard cancel is requested, the pump is queried for it's TBR state to
* make absolutely sure no TBR is running (such a request is also made when resuming the
* loop, irregardless of whether a TBR is running or not).
*/
@Override @Override
public PumpEnactResult cancelTempBasal(boolean enforceNew) { public PumpEnactResult cancelTempBasal(boolean enforceNew) {
log.debug("cancelTempBasal called"); log.debug("cancelTempBasal called");
final TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()); final TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
if (enforceNew) { if (enforceNew) {
CommandResult stateResult = runCommand(MainApp.gs(R.string.combo_pump_action_refreshing), 2, ruffyScripter::readPumpState);
if (!stateResult.success) {
return new PumpEnactResult().success(false).enacted(false);
}
if (!stateResult.state.tbrActive) {
return new PumpEnactResult().success(true).enacted(false);
}
log.debug("cancelTempBasal: hard-cancelling TBR since force requested"); log.debug("cancelTempBasal: hard-cancelling TBR since force requested");
CommandResult commandResult = runCommand(MainApp.gs(R.string.combo_pump_action_cancelling_tbr), 2, ruffyScripter::cancelTbr); CommandResult cancelResult = runCommand(MainApp.gs(R.string.combo_pump_action_cancelling_tbr), 2, ruffyScripter::cancelTbr);
if (!commandResult.state.tbrActive) { if (!cancelResult.success) {
return new PumpEnactResult().success(false).enacted(false);
}
if (!cancelResult.state.tbrActive) {
TemporaryBasal tempBasal = new TemporaryBasal(); TemporaryBasal tempBasal = new TemporaryBasal();
tempBasal.date = commandResult.state.timestamp; tempBasal.date = cancelResult.state.timestamp;
tempBasal.durationInMinutes = 0; tempBasal.durationInMinutes = 0;
tempBasal.source = Source.USER; tempBasal.source = Source.USER;
MainApp.getConfigBuilder().addToHistoryTempBasal(tempBasal); MainApp.getConfigBuilder().addToHistoryTempBasal(tempBasal);

View file

@ -124,12 +124,12 @@ public class DateUtil {
public static String minAgo(long time) { public static String minAgo(long time) {
int mins = (int) ((System.currentTimeMillis() - time) / 1000 / 60); int mins = (int) ((System.currentTimeMillis() - time) / 1000 / 60);
return String.format(MainApp.sResources.getString(R.string.minago), mins); return MainApp.gs(R.string.minago, mins);
} }
public static String hourAgo(long time) { public static String hourAgo(long time) {
double hours = (System.currentTimeMillis() - time) / 1000d / 60 / 60; double hours = (System.currentTimeMillis() - time) / 1000d / 60 / 60;
return String.format(MainApp.sResources.getString(R.string.hoursago), hours); return MainApp.gs(R.string.hoursago, hours);
} }
private static LongSparseArray<String> timeStrings = new LongSparseArray<>(); private static LongSparseArray<String> timeStrings = new LongSparseArray<>();

View file

@ -722,7 +722,6 @@
<string name="combo_pump_action_bolusing">Bolus (%.1f IE) wird abgegeben</string> <string name="combo_pump_action_bolusing">Bolus (%.1f IE) wird abgegeben</string>
<string name="alert_dialog_storage_permission_text">Bitte starte dein Telefon neu oder starte AndroidAPS in den System-Einstellungen neu. Andernfalls wird AndroidAPS nicht protokolliert (wichtig zum Nachverfolgen und Verifizieren, dass der Algorithmus korrekt funktioniert)</string> <string name="alert_dialog_storage_permission_text">Bitte starte dein Telefon neu oder starte AndroidAPS in den System-Einstellungen neu. Andernfalls wird AndroidAPS nicht protokolliert (wichtig zum Nachverfolgen und Verifizieren, dass der Algorithmus korrekt funktioniert)</string>
<string name="pump_tempbasal_label">TBR</string> <string name="pump_tempbasal_label">TBR</string>
<string name="combo_last_bolus">%.1f %s (%s)</string>
<string name="bolus_frequency_exceeded">Ein gleich großer Bolus wurde in den letzten zwei Minuten angefordert. Dies ist nicht zulässig, um ungewollte Doppelboli zu verhindern und vor eventuellen Bugs zu schützen.</string> <string name="bolus_frequency_exceeded">Ein gleich großer Bolus wurde in den letzten zwei Minuten angefordert. Dies ist nicht zulässig, um ungewollte Doppelboli zu verhindern und vor eventuellen Bugs zu schützen.</string>
<string name="combo_activity_reading_pump_history">Historie wird gelesen</string> <string name="combo_activity_reading_pump_history">Historie wird gelesen</string>
<string name="combo_activity_setting_basal_profile">Basalratenprofil wird aktualisiert</string> <string name="combo_activity_setting_basal_profile">Basalratenprofil wird aktualisiert</string>

View file

@ -750,7 +750,6 @@
<string name="combo_pump_activity_label">Actividad</string> <string name="combo_pump_activity_label">Actividad</string>
<string name="combo_no_pump_connection" formatted="false">Ninguna coneccnion por %d min</string> <string name="combo_no_pump_connection" formatted="false">Ninguna coneccnion por %d min</string>
<string name="combo_tbr_remaining" formatted="false">%d%% (%d min restan)</string> <string name="combo_tbr_remaining" formatted="false">%d%% (%d min restan)</string>
<string name="combo_last_bolus" formatted="false">%.1f U (%s, %s)</string>
<string name="combo_pump_action_initializing">Iniciando</string> <string name="combo_pump_action_initializing">Iniciando</string>
<string name="combo_pump_state_disconnected">Desconectado</string> <string name="combo_pump_state_disconnected">Desconectado</string>
<string name="combo_pump_state_suspended_due_to_error">Apagado por error</string> <string name="combo_pump_state_suspended_due_to_error">Apagado por error</string>

View file

@ -738,7 +738,6 @@
<string name="combo_pump_state_label">Status</string> <string name="combo_pump_state_label">Status</string>
<string name="combo_no_pump_connection">Geen verbinding gedurende %d minuten</string> <string name="combo_no_pump_connection">Geen verbinding gedurende %d minuten</string>
<string name="combo_tbr_remaining">%d%% (%d min resterend)</string> <string name="combo_tbr_remaining">%d%% (%d min resterend)</string>
<string name="combo_last_bolus">%.1f E (%s, %s)</string>
<string name="combo_pump_state_initializing">Initialiseren</string> <string name="combo_pump_state_initializing">Initialiseren</string>
<string name="combo_pump_state_disconnected">Verbinding verbroken</string> <string name="combo_pump_state_disconnected">Verbinding verbroken</string>
<string name="combo_error_bolus_recovery_progress">Herstel van verbroken verbindng</string> <string name="combo_error_bolus_recovery_progress">Herstel van verbroken verbindng</string>