Merge pull request #1111 from jotomo/combo-setup-notification
Combo setup notification
This commit is contained in:
commit
df021a2dd2
5 changed files with 24 additions and 14 deletions
|
@ -354,6 +354,11 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
||||||
|
|
||||||
// trigger a connect, which will update state and check history
|
// trigger a connect, which will update state and check history
|
||||||
CommandResult stateResult = runCommand(null, 1, ruffyScripter::readPumpState);
|
CommandResult stateResult = runCommand(null, 1, ruffyScripter::readPumpState);
|
||||||
|
if (stateResult.invalidSetup) {
|
||||||
|
MainApp.bus().post(new EventNewNotification(
|
||||||
|
new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_invalid_setup), Notification.URGENT)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!stateResult.success) {
|
if (!stateResult.success) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,11 @@ import android.support.annotation.Nullable;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Bolus;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistory;
|
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistory;
|
||||||
|
|
||||||
public class CommandResult {
|
public class CommandResult {
|
||||||
|
/** True if a condition indicating a broken pump setup/configuration is detected */
|
||||||
|
public boolean invalidSetup;
|
||||||
/** Whether the command was executed successfully. */
|
/** Whether the command was executed successfully. */
|
||||||
public boolean success;
|
public boolean success;
|
||||||
/** State of the pump *after* command execution. */
|
/** State of the pump *after* command execution. */
|
||||||
|
|
|
@ -281,10 +281,10 @@ public class RuffyScripter implements RuffyCommands {
|
||||||
log.debug("Executing " + cmd + " took " + (cmdEndTime - cmdStartTime) + "ms");
|
log.debug("Executing " + cmd + " took " + (cmdEndTime - cmdStartTime) + "ms");
|
||||||
} catch (CommandException e) {
|
} catch (CommandException e) {
|
||||||
log.error("CommandException running command", e);
|
log.error("CommandException running command", e);
|
||||||
activeCmd.getResult().success = false;
|
cmd.getResult().success = false;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Unexpected exception running cmd", e);
|
log.error("Unexpected exception running cmd", e);
|
||||||
activeCmd.getResult().success = false;
|
cmd.getResult().success = false;
|
||||||
}
|
}
|
||||||
}, cmd.getClass().getSimpleName());
|
}, cmd.getClass().getSimpleName());
|
||||||
long executionStart = System.currentTimeMillis();
|
long executionStart = System.currentTimeMillis();
|
||||||
|
@ -328,6 +328,7 @@ public class RuffyScripter implements RuffyCommands {
|
||||||
if (unparsableMenuEncountered) {
|
if (unparsableMenuEncountered) {
|
||||||
log.error("UnparsableMenuEncountered flagged, aborting command");
|
log.error("UnparsableMenuEncountered flagged, aborting command");
|
||||||
cmdThread.interrupt();
|
cmdThread.interrupt();
|
||||||
|
activeCmd.getResult().invalidSetup = true;
|
||||||
activeCmd.getResult().success = false;
|
activeCmd.getResult().success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ public class ReadQuickInfoCommand extends BaseCommand {
|
||||||
// read bolus records
|
// read bolus records
|
||||||
int totalRecords = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.TOTAL_RECORD);
|
int totalRecords = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.TOTAL_RECORD);
|
||||||
int record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
|
int record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
|
||||||
|
if (record > 0) {
|
||||||
while (true) {
|
while (true) {
|
||||||
bolusHistory.add(readBolusRecord());
|
bolusHistory.add(readBolusRecord());
|
||||||
if (bolusHistory.size() == numberOfBolusRecordsToRetrieve || record == totalRecords) {
|
if (bolusHistory.size() == numberOfBolusRecordsToRetrieve || record == totalRecords) {
|
||||||
|
@ -51,6 +52,7 @@ public class ReadQuickInfoCommand extends BaseCommand {
|
||||||
}
|
}
|
||||||
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
|
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
if (!result.history.bolusHistory.isEmpty()) {
|
if (!result.history.bolusHistory.isEmpty()) {
|
||||||
log.debug("Read bolus history (" + result.history.bolusHistory.size() + "):");
|
log.debug("Read bolus history (" + result.history.bolusHistory.size() + "):");
|
||||||
|
|
|
@ -1162,6 +1162,7 @@
|
||||||
<string name="nth_objective">%1$d. Objective</string>
|
<string name="nth_objective">%1$d. Objective</string>
|
||||||
<string name="poctech">Poctech</string>
|
<string name="poctech">Poctech</string>
|
||||||
<string name="description_source_poctech">Receive BG values from Poctech app</string>
|
<string name="description_source_poctech">Receive BG values from Poctech app</string>
|
||||||
|
<string name="combo_invalid_setup">Invalid pump setup, check the docs and verify that the Quick Info menu is named "QUICK INFO" using the 360 configuration software.</string>
|
||||||
|
|
||||||
<plurals name="objective_days">
|
<plurals name="objective_days">
|
||||||
<item quantity="one">%d day</item>
|
<item quantity="one">%d day</item>
|
||||||
|
|
Loading…
Reference in a new issue