Merge pull request #1370 from jotomo/upstream-combo-fabric-removal
Upstream combo fabric removal
This commit is contained in:
commit
bb18fad654
|
@ -7,8 +7,6 @@ import android.support.annotation.Nullable;
|
|||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
||||
import com.crashlytics.android.answers.CustomEvent;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -66,7 +64,6 @@ import info.nightscout.androidaps.plugins.PumpCommon.utils.PumpUtil;
|
|||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
|
@ -329,7 +326,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
|||
return basalProfile;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public long lastDataTime() {
|
||||
return pump.lastSuccessfulCmdTime;
|
||||
|
@ -556,10 +552,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
|||
}
|
||||
if (waitLoops > 0) {
|
||||
long waitDuration = (System.currentTimeMillis() - waitStartTime) / 1000;
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusTimestampWait")
|
||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||
.putCustomAttribute("version", BuildConfig.VERSION)
|
||||
.putCustomAttribute("waitTimeSecs", String.valueOf(waitDuration)));
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Waited " + waitDuration + "s for pump to switch to a fresh minute before bolusing");
|
||||
}
|
||||
|
@ -681,11 +673,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
|||
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_error_updating_treatment_record), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
}
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusToDbError")
|
||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||
.putCustomAttribute("version", BuildConfig.VERSION)
|
||||
.putCustomAttribute("bolus", String.valueOf(lastPumpBolus.amount))
|
||||
.putCustomAttribute("issue", "record with same timestamp existed and was overridden"));
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -693,11 +680,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
|||
if (dbi.isSMB) {
|
||||
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_error_updating_treatment_record), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusToDbError")
|
||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||
.putCustomAttribute("version", BuildConfig.VERSION)
|
||||
.putCustomAttribute("bolus", String.valueOf(lastPumpBolus.amount))
|
||||
.putCustomAttribute("issue", "adding record caused exception"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1111,10 +1093,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
|||
if (aapsTbr == null && state.tbrActive && state.tbrRemainingDuration > 2) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Creating temp basal from pump TBR");
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch")
|
||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||
.putCustomAttribute("version", BuildConfig.VERSION)
|
||||
.putCustomAttribute("type", "new TBR on pump"));
|
||||
TemporaryBasal newTempBasal = new TemporaryBasal()
|
||||
.date(now)
|
||||
.percent(state.tbrPercent)
|
||||
|
@ -1124,10 +1102,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
|||
} else if (aapsTbr != null && aapsTbr.getPlannedRemainingMinutes() > 2 && !state.tbrActive) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Ending AAPS-TBR since pump has no TBR active");
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch")
|
||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||
.putCustomAttribute("version", BuildConfig.VERSION)
|
||||
.putCustomAttribute("type", "TBR cancelled on pump"));
|
||||
TemporaryBasal tempStop = new TemporaryBasal()
|
||||
.date(now)
|
||||
.duration(0)
|
||||
|
@ -1138,10 +1112,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
|||
Math.abs(aapsTbr.getPlannedRemainingMinutes() - state.tbrRemainingDuration) > 2)) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("AAPSs and pump-TBR differ; ending AAPS-TBR and creating new TBR based on pump TBR");
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch")
|
||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||
.putCustomAttribute("version", BuildConfig.VERSION)
|
||||
.putCustomAttribute("type", "TBR on pump differs from AAPS TBR"));
|
||||
TemporaryBasal tempStop = new TemporaryBasal()
|
||||
.date(now - 1000)
|
||||
.duration(0)
|
||||
|
@ -1262,19 +1232,13 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
|||
if (bolusSet.size() != historyResult.history.bolusHistory.size()) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Bolus with same amount within the same minute imported. Only one will make it to the DB.");
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusToDbError")
|
||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||
.putCustomAttribute("version", BuildConfig.VERSION)
|
||||
.putCustomAttribute("bolus", "")
|
||||
.putCustomAttribute("issue", "multiple pump history records with the same time and amount"));
|
||||
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.
|
||||
combo_error_multiple_boluses_with_identical_timestamp), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
}
|
||||
|
||||
pumpHistoryChanged = updateDbFromPumpHistory(historyResult.history);
|
||||
if (pumpHistoryChanged) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
if (L.isEnabled(L.PUMP) && pumpHistoryChanged) {
|
||||
log.debug("Setting 'pumpHistoryChanged' true");
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ import android.os.SystemClock;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.crashlytics.android.answers.CustomEvent;
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
import org.monkey.d.ruffy.ruffy.driver.IRTHandler;
|
||||
|
@ -39,8 +38,6 @@ import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.ReadH
|
|||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.ReadPumpStateCommand;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.SetBasalProfileCommand;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.SetTbrCommand;
|
||||
import info.nightscout.androidaps.BuildConfig;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
|
||||
/**
|
||||
* Provides scripting 'runtime' and operations. consider moving operations into a separate
|
||||
|
@ -57,8 +54,6 @@ public class RuffyScripter implements RuffyCommands {
|
|||
private volatile long menuLastUpdated = 0;
|
||||
private volatile boolean unparsableMenuEncountered;
|
||||
|
||||
|
||||
private String previousCommand = "<none>";
|
||||
private volatile Command activeCmd = null;
|
||||
|
||||
private boolean started = false;
|
||||
|
@ -67,51 +62,43 @@ public class RuffyScripter implements RuffyCommands {
|
|||
|
||||
private IRTHandler mHandler = new IRTHandler.Stub() {
|
||||
@Override
|
||||
public void log(String message) throws RemoteException {
|
||||
public void log(String message) {
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("Ruffy says: " + message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fail(String message) throws RemoteException {
|
||||
public void fail(String message) {
|
||||
log.warn("Ruffy warns: " + message);
|
||||
if (message.startsWith("no connection possible"))
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRuffyWarning").putCustomAttribute("message", "no connection possible"));
|
||||
else if (message.startsWith("Error sending keep alive while rtModeRunning is still true"))
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRuffyWarning").putCustomAttribute("message", "Error sending keep alive while rtModeRunning is still true"));
|
||||
else if (message.startsWith("Error sending keep alive. rtModeRunning is false, so this is most likely a race condition during disconnect"))
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRuffyWarning").putCustomAttribute("message", "Error sending keep alive. rtModeRunning is false, so this is most likely a race condition during disconnect"));
|
||||
else
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRuffyWarning").putCustomAttribute("message", message.substring(0, 98)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestBluetooth() throws RemoteException {
|
||||
public void requestBluetooth() {
|
||||
log.trace("Ruffy invoked requestBluetooth callback");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rtStopped() throws RemoteException {
|
||||
public void rtStopped() {
|
||||
log.debug("rtStopped callback invoked");
|
||||
currentMenu = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rtStarted() throws RemoteException {
|
||||
public void rtStarted() {
|
||||
log.debug("rtStarted callback invoked");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rtClearDisplay() throws RemoteException {
|
||||
public void rtClearDisplay() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rtUpdateDisplay(byte[] quarter, int which) throws RemoteException {
|
||||
public void rtUpdateDisplay(byte[] quarter, int which) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rtDisplayHandleMenu(Menu menu) throws RemoteException {
|
||||
public void rtDisplayHandleMenu(Menu menu) {
|
||||
// method is called every ~500ms
|
||||
log.debug("rtDisplayHandleMenu: " + menu);
|
||||
|
||||
|
@ -124,7 +111,7 @@ public class RuffyScripter implements RuffyCommands {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void rtDisplayHandleNoMenu() throws RemoteException {
|
||||
public void rtDisplayHandleNoMenu() {
|
||||
log.warn("rtDisplayHandleNoMenu callback invoked");
|
||||
unparsableMenuEncountered = true;
|
||||
}
|
||||
|
@ -173,10 +160,6 @@ public class RuffyScripter implements RuffyCommands {
|
|||
|
||||
if (!boundSucceeded) {
|
||||
log.error("No connection to ruffy. Pump control unavailable.");
|
||||
} else {
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboScripterInit")
|
||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||
.putCustomAttribute("version", BuildConfig.VERSION));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -227,9 +210,6 @@ public class RuffyScripter implements RuffyCommands {
|
|||
|
||||
@Override
|
||||
public CommandResult readQuickInfo(int numberOfBolusRecordsToRetrieve) {
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboReadQuickInfoCmd")
|
||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||
.putCustomAttribute("version", BuildConfig.VERSION));
|
||||
return runCommand(new ReadQuickInfoCommand(numberOfBolusRecordsToRetrieve));
|
||||
}
|
||||
|
||||
|
@ -366,7 +346,6 @@ public class RuffyScripter implements RuffyCommands {
|
|||
// ignore
|
||||
}
|
||||
}
|
||||
previousCommand = "" + activeCmd;
|
||||
activeCmd = null;
|
||||
}
|
||||
}
|
||||
|
@ -435,11 +414,6 @@ public class RuffyScripter implements RuffyCommands {
|
|||
}
|
||||
}
|
||||
log.debug("Recovery from connection loss " + (connected ? "succeeded" : "failed"));
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRecoveryFromConnectionLoss")
|
||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||
.putCustomAttribute("version", BuildConfig.VERSION)
|
||||
.putCustomAttribute("activeCommand", "" + (activeCmd != null ? activeCmd.getClass().getSimpleName() : ""))
|
||||
.putCustomAttribute("success", connected ? "true" : "else"));
|
||||
return connected;
|
||||
}
|
||||
|
||||
|
@ -450,12 +424,6 @@ public class RuffyScripter implements RuffyCommands {
|
|||
private PumpState recoverFromCommandFailure() {
|
||||
Menu menu = this.currentMenu;
|
||||
if (menu == null) {
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRecoveryFromCommandFailure")
|
||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||
.putCustomAttribute("version", BuildConfig.VERSION)
|
||||
.putCustomAttribute("activeCommand", "" + (activeCmd != null ? activeCmd.getClass().getSimpleName() : ""))
|
||||
.putCustomAttribute("exit", "1")
|
||||
.putCustomAttribute("success", "false"));
|
||||
return new PumpState();
|
||||
}
|
||||
MenuType type = menu.getType();
|
||||
|
@ -469,21 +437,8 @@ public class RuffyScripter implements RuffyCommands {
|
|||
}
|
||||
try {
|
||||
PumpState pumpState = readPumpStateInternal();
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRecoveryFromCommandFailure")
|
||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||
.putCustomAttribute("version", BuildConfig.VERSION)
|
||||
.putCustomAttribute("activeCommand", "" + (activeCmd != null ? activeCmd.getClass().getSimpleName() : ""))
|
||||
.putCustomAttribute("exit", "2")
|
||||
.putCustomAttribute("success", "true"));
|
||||
return pumpState;
|
||||
} catch (Exception e) {
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRecoveryFromCommandFailure")
|
||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||
.putCustomAttribute("version", BuildConfig.VERSION)
|
||||
.putCustomAttribute("exit", "3")
|
||||
.putCustomAttribute("activeCommand", "" + (activeCmd != null ? activeCmd.getClass().getSimpleName() : ""))
|
||||
.putCustomAttribute("success", "false"));
|
||||
|
||||
log.debug("Reading pump state during recovery failed", e);
|
||||
return new PumpState();
|
||||
}
|
||||
|
@ -505,11 +460,6 @@ public class RuffyScripter implements RuffyCommands {
|
|||
long initialUpdateTime = menuLastUpdated;
|
||||
while (initialUpdateTime == menuLastUpdated) {
|
||||
if (System.currentTimeMillis() > timeoutExpired) {
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboConnectTimeout")
|
||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||
.putCustomAttribute("version", BuildConfig.VERSION)
|
||||
.putCustomAttribute("activeCommand", "" + (activeCmd != null ? activeCmd.getClass().getSimpleName() : ""))
|
||||
.putCustomAttribute("previousCommand", previousCommand));
|
||||
throw new CommandException("Timeout connecting to pump");
|
||||
}
|
||||
SystemClock.sleep(50);
|
||||
|
@ -818,18 +768,12 @@ public class RuffyScripter implements RuffyCommands {
|
|||
|
||||
@Override
|
||||
public CommandResult deliverBolus(double amount, BolusProgressReporter bolusProgressReporter) {
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusCmd")
|
||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||
.putCustomAttribute("version", BuildConfig.VERSION));
|
||||
return runCommand(new BolusCommand(amount, bolusProgressReporter));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelBolus() {
|
||||
if (activeCmd instanceof BolusCommand) {
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusCmdCancel")
|
||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||
.putCustomAttribute("version", BuildConfig.VERSION));
|
||||
((BolusCommand) activeCmd).requestCancellation();
|
||||
} else {
|
||||
log.error("cancelBolus called, but active command is not a bolus:" + activeCmd);
|
||||
|
@ -838,49 +782,31 @@ public class RuffyScripter implements RuffyCommands {
|
|||
|
||||
@Override
|
||||
public CommandResult setTbr(int percent, int duration) {
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboSetTbrCmd")
|
||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||
.putCustomAttribute("version", BuildConfig.VERSION));
|
||||
return runCommand(new SetTbrCommand(percent, duration));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult cancelTbr() {
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboCancelTbrCmd")
|
||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||
.putCustomAttribute("version", BuildConfig.VERSION));
|
||||
return runCommand(new CancelTbrCommand());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult confirmAlert(int warningCode) {
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboConfirmAlertCmd")
|
||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||
.putCustomAttribute("version", BuildConfig.VERSION));
|
||||
return runCommand(new ConfirmAlertCommand(warningCode));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult readHistory(PumpHistoryRequest request) {
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboReadHistoryCmd")
|
||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||
.putCustomAttribute("version", BuildConfig.VERSION));
|
||||
return runCommand(new ReadHistoryCommand(request));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult readBasalProfile() {
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboReadBasalProfileCmd")
|
||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||
.putCustomAttribute("version", BuildConfig.VERSION));
|
||||
return runCommand(new ReadBasalProfileCommand());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult setBasalProfile(BasalProfile basalProfile) {
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboSetBasalProfileCmd")
|
||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||
.putCustomAttribute("version", BuildConfig.VERSION));
|
||||
return runCommand(new SetBasalProfileCommand(basalProfile));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue