RuffyScripter: clean up answers.

(cherry picked from commit 0c30e1b)
This commit is contained in:
Johannes Mockenhaupt 2018-01-31 01:34:58 +01:00
parent 6108e9f17a
commit 4defd40023
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -165,8 +165,9 @@ public class RuffyScripter implements RuffyCommands {
if (!boundSucceeded) { if (!boundSucceeded) {
log.error("No connection to ruffy. Pump control unavailable."); log.error("No connection to ruffy. Pump control unavailable.");
} else { } else {
Answers.getInstance().logCustom(new CustomEvent("RuffyScripterInit") Answers.getInstance().logCustom(new CustomEvent("ComboScripterInit")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)); .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION));
} }
} }
@ -218,10 +219,14 @@ public class RuffyScripter implements RuffyCommands {
@Override @Override
public CommandResult readQuickInfo() { public CommandResult readQuickInfo() {
if (readQuickInfo) { if (readQuickInfo) {
Answers.getInstance().logCustom(new CustomEvent("ComboReadQuickInfoCmd")); Answers.getInstance().logCustom(new CustomEvent("ComboReadQuickInfoCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new ReadQuickInfoCommand()); return runCommand(new ReadQuickInfoCommand());
} }
Answers.getInstance().logCustom(new CustomEvent("ComboReadHistoryCmd")); Answers.getInstance().logCustom(new CustomEvent("ComboReadHistoryCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new ReadHistoryCommand(new PumpHistoryRequest().bolusHistory(PumpHistoryRequest.LAST))); return runCommand(new ReadHistoryCommand(new PumpHistoryRequest().bolusHistory(PumpHistoryRequest.LAST)));
} }
@ -421,6 +426,8 @@ public class RuffyScripter implements RuffyCommands {
} }
log.debug("Recovery from connection loss " + (connected ? "succeeded" : "failed")); log.debug("Recovery from connection loss " + (connected ? "succeeded" : "failed"));
Answers.getInstance().logCustom(new CustomEvent("ComboRecoveryFromConnectionLoss") Answers.getInstance().logCustom(new CustomEvent("ComboRecoveryFromConnectionLoss")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("activeCommand", "" + activeCmd) .putCustomAttribute("activeCommand", "" + activeCmd)
.putCustomAttribute("success", connected ? "true" : "else")); .putCustomAttribute("success", connected ? "true" : "else"));
return connected; return connected;
@ -434,6 +441,8 @@ public class RuffyScripter implements RuffyCommands {
Menu menu = this.currentMenu; Menu menu = this.currentMenu;
if (menu == null) { if (menu == null) {
Answers.getInstance().logCustom(new CustomEvent("ComboRecoveryFromCommandFailure") Answers.getInstance().logCustom(new CustomEvent("ComboRecoveryFromCommandFailure")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("activeCommand", "" + activeCmd) .putCustomAttribute("activeCommand", "" + activeCmd)
.putCustomAttribute("success", "false")); .putCustomAttribute("success", "false"));
return new PumpState(); return new PumpState();
@ -449,11 +458,16 @@ public class RuffyScripter implements RuffyCommands {
} }
try { try {
PumpState pumpState = readPumpStateInternal(); PumpState pumpState = readPumpStateInternal();
Answers.getInstance().logCustom(new CustomEvent("ComboRecoveryFromCommandFailureSucceded") Answers.getInstance().logCustom(new CustomEvent("ComboRecoveryFromCommandFailure")
.putCustomAttribute("activeCommand", "" + activeCmd)); .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("activeCommand", "" + activeCmd)
.putCustomAttribute("success", "true"));
return pumpState; return pumpState;
} catch (Exception e) { } catch (Exception e) {
Answers.getInstance().logCustom(new CustomEvent("ComboRecoveryFromCommandFailure") Answers.getInstance().logCustom(new CustomEvent("ComboRecoveryFromCommandFailure")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("activeCommand", "" + activeCmd) .putCustomAttribute("activeCommand", "" + activeCmd)
.putCustomAttribute("success", "false")); .putCustomAttribute("success", "false"));
log.debug("Reading pump state during recovery failed", e); log.debug("Reading pump state during recovery failed", e);
@ -478,6 +492,8 @@ public class RuffyScripter implements RuffyCommands {
while (initialUpdateTime == menuLastUpdated) { while (initialUpdateTime == menuLastUpdated) {
if (System.currentTimeMillis() > timeoutExpired) { if (System.currentTimeMillis() > timeoutExpired) {
Answers.getInstance().logCustom(new CustomEvent("ComboConnectTimeout") Answers.getInstance().logCustom(new CustomEvent("ComboConnectTimeout")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("activeCommand", "" + activeCmd) .putCustomAttribute("activeCommand", "" + activeCmd)
.putCustomAttribute("previousCommand", previousCommand)); .putCustomAttribute("previousCommand", previousCommand));
throw new CommandException("Timeout connecting to pump"); throw new CommandException("Timeout connecting to pump");
@ -786,14 +802,18 @@ public class RuffyScripter implements RuffyCommands {
@Override @Override
public CommandResult deliverBolus(double amount, BolusProgressReporter bolusProgressReporter) { public CommandResult deliverBolus(double amount, BolusProgressReporter bolusProgressReporter) {
Answers.getInstance().logCustom(new CustomEvent("ComboBolusCmd")); Answers.getInstance().logCustom(new CustomEvent("ComboBolusCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new BolusCommand(amount, bolusProgressReporter)); return runCommand(new BolusCommand(amount, bolusProgressReporter));
} }
@Override @Override
public void cancelBolus() { public void cancelBolus() {
if (activeCmd instanceof BolusCommand) { if (activeCmd instanceof BolusCommand) {
Answers.getInstance().logCustom(new CustomEvent("ComboBolusCmdCancel")); Answers.getInstance().logCustom(new CustomEvent("ComboBolusCmdCancel")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION));
((BolusCommand) activeCmd).requestCancellation(); ((BolusCommand) activeCmd).requestCancellation();
} else { } else {
log.error("cancelBolus called, but active command is not a bolus:" + activeCmd); log.error("cancelBolus called, but active command is not a bolus:" + activeCmd);
@ -802,37 +822,49 @@ public class RuffyScripter implements RuffyCommands {
@Override @Override
public CommandResult setTbr(int percent, int duration) { public CommandResult setTbr(int percent, int duration) {
Answers.getInstance().logCustom(new CustomEvent("ComboSetTbrCmd")); Answers.getInstance().logCustom(new CustomEvent("ComboSetTbrCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new SetTbrCommand(percent, duration)); return runCommand(new SetTbrCommand(percent, duration));
} }
@Override @Override
public CommandResult cancelTbr() { public CommandResult cancelTbr() {
Answers.getInstance().logCustom(new CustomEvent("ComboCancelTbrCmd")); Answers.getInstance().logCustom(new CustomEvent("ComboCancelTbrCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new CancelTbrCommand()); return runCommand(new CancelTbrCommand());
} }
@Override @Override
public CommandResult confirmAlert(int warningCode) { public CommandResult confirmAlert(int warningCode) {
Answers.getInstance().logCustom(new CustomEvent("ComboConfirmAlertCmd")); Answers.getInstance().logCustom(new CustomEvent("ComboConfirmAlertCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new ConfirmAlertCommand(warningCode)); return runCommand(new ConfirmAlertCommand(warningCode));
} }
@Override @Override
public CommandResult readHistory(PumpHistoryRequest request) { public CommandResult readHistory(PumpHistoryRequest request) {
Answers.getInstance().logCustom(new CustomEvent("ComboReadHistoryCmd")); Answers.getInstance().logCustom(new CustomEvent("ComboReadHistoryCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new ReadHistoryCommand(request)); return runCommand(new ReadHistoryCommand(request));
} }
@Override @Override
public CommandResult readBasalProfile() { public CommandResult readBasalProfile() {
Answers.getInstance().logCustom(new CustomEvent("ComboReadBasalProfileCmd")); Answers.getInstance().logCustom(new CustomEvent("ComboReadBasalProfileCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new ReadBasalProfileCommand()); return runCommand(new ReadBasalProfileCommand());
} }
@Override @Override
public CommandResult setBasalProfile(BasalProfile basalProfile) { public CommandResult setBasalProfile(BasalProfile basalProfile) {
Answers.getInstance().logCustom(new CustomEvent("ComboSetBasalProfileCmd")); Answers.getInstance().logCustom(new CustomEvent("ComboSetBasalProfileCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new SetBasalProfileCommand(basalProfile)); return runCommand(new SetBasalProfileCommand(basalProfile));
} }