Cleanups and strings.

This commit is contained in:
Johannes Mockenhaupt 2018-01-31 00:12:04 +01:00
parent 34db941c29
commit e790c87940
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
2 changed files with 44 additions and 24 deletions

View file

@ -1021,30 +1021,46 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
return pumpBolus.timestamp + (Math.min((int) (pumpBolus.amount - 0.1) * 10 * 1000, 59 * 1000));
}
// TODO queue
void readTddData() {
readHistory(new PumpHistoryRequest().tddHistory(PumpHistoryRequest.FULL));
// TODO use queue once ready
void readTddData(Callback post) {
// ConfigBuilderPlugin.getCommandQueue().custom(new Callback() {
// @Override
// public void run() {
readHistory(new PumpHistoryRequest().tddHistory(PumpHistoryRequest.FULL));
// }
// }, post);
post.run();
ruffyScripter.disconnect();
}
// TODO queue
void readAlertData() {
readHistory(new PumpHistoryRequest().pumpErrorHistory(PumpHistoryRequest.FULL));
// TODO use queue once ready
void readAlertData(Callback post) {
// ConfigBuilderPlugin.getCommandQueue().custom(new Callback() {
// @Override
// public void run() {
readHistory(new PumpHistoryRequest().pumpErrorHistory(PumpHistoryRequest.FULL));
// }
// }, post);
post.run();
ruffyScripter.disconnect();
}
// TODO queue
void readAllPumpData() {
readHistory(new PumpHistoryRequest()
.bolusHistory(PumpHistoryRequest.FULL)
// .tbrHistory(PumpHistoryRequest.FULL)
.pumpErrorHistory(PumpHistoryRequest.FULL)
.tddHistory(PumpHistoryRequest.FULL)
);
CommandResult readBasalResult = runCommand(MainApp.gs(R.string.combo_actvity_reading_basal_profile), 2, ruffyScripter::readBasalProfile);
if (readBasalResult.success) {
pump.basalProfile = readBasalResult.basalProfile;
}
// TODO use queue once ready
void readAllPumpData(Callback post) {
// ConfigBuilderPlugin.getCommandQueue().custom(new Callback() {
// @Override
// public void run() {
readHistory(new PumpHistoryRequest()
.bolusHistory(PumpHistoryRequest.FULL)
.pumpErrorHistory(PumpHistoryRequest.FULL)
.tddHistory(PumpHistoryRequest.FULL));
CommandResult readBasalResult = runCommand(MainApp.gs(R.string.combo_actvity_reading_basal_profile), 2, ruffyScripter::readBasalProfile);
if (readBasalResult.success) {
pump.basalProfile = readBasalResult.basalProfile;
}
// }
// }, post);
post.run();
ruffyScripter.disconnect();
}
@ -1061,13 +1077,14 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
return null;
}
// TODO maybe optimize for the default case where no new records exists by checking quick info;
// and only read My Data history when quick info shows a new record
// OPTIMIZE this reads the entire history on start, so this could be optimized by persisting
// `timestampOfLastKnownPumpBolusRecord`, though this should be thought through, to make sure
// all scenarios are covered
CommandResult historyResult = runCommand(MainApp.gs(R.string.combo_activity_reading_pump_history), 3, () ->
ruffyScripter.readHistory(new PumpHistoryRequest()
.bolusHistory(timestampOfLastKnownPumpBolusRecord)));
if (!historyResult.success) {
return;
return historyResult;
}
pumpHistoryChanged = updateDbFromPumpHistory(historyResult.history);
@ -1076,8 +1093,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
timestampOfLastKnownPumpBolusRecord = historyResult.history.bolusHistory.get(0).timestamp;
}
long end = System.currentTimeMillis();
log.debug("History check took: " + ((end - start) / 1000) + "s");
return null;
}
@Override

View file

@ -854,7 +854,7 @@
<string name="combo_notification_check_time_date">Pump clock update needed</string>
<string name="combo_history">History</string>
<string name="combo_warning">Warning</string>
<string name="combo_read_full_history_info">Long press this button to force a full read of history and basal profile from the pump. This is generally not needed, but can be useful if the pump\'s date and time was significantly off or the basal profile was changed on the pump (which should never be done under normal circumstances).</string>
<string name="combo_read_full_history_info">Long press this button to force a full read of history and basal profile from the pump. This is generally not needed, but can be useful if the pump\'s date and time changed significantly or the pump was replaced.</string>
<string name="combo_read_full_history_warning">This will read the full history and state of the pump. Everything in \"My Data\" and the basal rate. Boluses and TBRs will be added to Treatments if they don\'t already exist. This can cause entries to be duplicated because the pump\'s time is imprecise. Using this when normally looping with the pump is highly discouraged and reserved for special circumstances. If you still want to do this, long press this button again.\n\nWARNING: this can trigger a bug which causes the pump to reject all connection attempts and requires pressing a button on the pump to recover and should therefore be avoided.</string>
<string name="combo_read_full_history_confirmation">Are you really sure you want to read all pump data and take the consequences of this action?</string>
<string name="combo_pump_tbr_cancelled_warrning">TBR CANCELLED warning was confirmed</string>
@ -870,5 +870,9 @@
<string name="combo_bolus_rejected_due_to_pump_history_change">The pump history has changed after the bolus calculation was performed. The bolus was not delivered. Please recalculate if a bolus is still needed. If the same bolus amount is required, please wait a minute since boluses with the same amount are blocked when requested with less than tow minutes between them for safety (regardless of whether they were administered or not).</string>
<string name="combo_error_updating_treatment_record">Bolus successfully delivered, but adding the treatment entry failed. This can happen if two small boluses of the same size are administered within the last two minutes. Please check the pump history and treatment entries and use the Careportal to add missing entries. Make sure not to add any entries for the exact same minute and same amount.</string>
<string name="combo_high_temp_rejected_due_to_pump_history_changes">Rejecting high temp since calculation didn\'t consider recently changed pump history</string>
<string name="combo_activity_checking_pump_state">Refreshing pump state</string>
<string name="combo_warning_pump_basal_rate_changed">The basal rate on the pump has changed and will be updated soon</string>
<string name="combo_error_failure_reading_changed_basal_rate">Basal rate changed on pump, but reading it failed</string>
<string name="combo_activity_checking_for_history_changes">Checking for history changes</string>
</resources>