Merge branch 'master' into insight-dev
# Conflicts: # app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java
This commit is contained in:
commit
05aa369bae
7 changed files with 113 additions and 43 deletions
|
@ -847,7 +847,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
accepted = true;
|
accepted = true;
|
||||||
if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) {
|
if (Math.abs(insulinAfterConstraints - wizard.calculatedTotalInsulin) >= 0.01 || finalCarbsAfterConstraints > 0) {
|
||||||
if (wizard.superBolus) {
|
if (wizard.superBolus) {
|
||||||
final LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
final LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
||||||
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class InsightAlertService extends Service implements InsightConnectionSer
|
||||||
public void onServiceConnected(ComponentName name, IBinder binder) {
|
public void onServiceConnected(ComponentName name, IBinder binder) {
|
||||||
connectionService = ((InsightConnectionService.LocalBinder) binder).getService();
|
connectionService = ((InsightConnectionService.LocalBinder) binder).getService();
|
||||||
connectionService.registerStateCallback(InsightAlertService.this);
|
connectionService.registerStateCallback(InsightAlertService.this);
|
||||||
stateChanged(connectionService.getState());
|
onStateChanged(connectionService.getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -114,7 +114,7 @@ public class InsightAlertService extends Service implements InsightConnectionSer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stateChanged(InsightState state) {
|
public void onStateChanged(InsightState state) {
|
||||||
if (state == InsightState.CONNECTED) {
|
if (state == InsightState.CONNECTED) {
|
||||||
thread = new Thread(this::queryActiveAlert);
|
thread = new Thread(this::queryActiveAlert);
|
||||||
thread.start();
|
thread.start();
|
||||||
|
|
|
@ -41,6 +41,7 @@ import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
|
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
|
||||||
|
@ -115,6 +116,7 @@ import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.Operating
|
||||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.PumpTime;
|
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.PumpTime;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.TotalDailyDose;
|
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.TotalDailyDose;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.exceptions.InsightException;
|
import info.nightscout.androidaps.plugins.PumpInsightLocal.exceptions.InsightException;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpInsightLocal.exceptions.app_layer_errors.AppLayerErrorException;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.exceptions.app_layer_errors.NoActiveTBRToCanceLException;
|
import info.nightscout.androidaps.plugins.PumpInsightLocal.exceptions.app_layer_errors.NoActiveTBRToCanceLException;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.utils.ExceptionTranslator;
|
import info.nightscout.androidaps.plugins.PumpInsightLocal.utils.ExceptionTranslator;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.utils.ParameterBlockUtil;
|
import info.nightscout.androidaps.plugins.PumpInsightLocal.utils.ParameterBlockUtil;
|
||||||
|
@ -153,7 +155,6 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
};
|
};
|
||||||
|
|
||||||
private final Object $bolusLock = new Object[0];
|
private final Object $bolusLock = new Object[0];
|
||||||
private boolean bolusInProgress;
|
|
||||||
private int bolusID = -1;
|
private int bolusID = -1;
|
||||||
private List<BasalProfileBlock> profileBlocks;
|
private List<BasalProfileBlock> profileBlocks;
|
||||||
private boolean limitsFetched;
|
private boolean limitsFetched;
|
||||||
|
@ -260,13 +261,15 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
if (connectionService == null || alertService == null) return false;
|
return connectionService != null
|
||||||
return connectionService.getState() == InsightState.CONNECTED;
|
&& alertService != null
|
||||||
|
&& connectionService.hasRequestedConnection(this)
|
||||||
|
&& connectionService.getState() == InsightState.CONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isConnecting() {
|
public boolean isConnecting() {
|
||||||
if (connectionService == null || alertService == null) return false;
|
if (connectionService == null || alertService == null || !connectionService.hasRequestedConnection(this)) return false;
|
||||||
InsightState state = connectionService.getState();
|
InsightState state = connectionService.getState();
|
||||||
return state == InsightState.CONNECTING
|
return state == InsightState.CONNECTING
|
||||||
|| state == InsightState.APP_CONNECT_MESSAGE
|
|| state == InsightState.APP_CONNECT_MESSAGE
|
||||||
|
@ -310,6 +313,8 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
fetchLimitations();
|
fetchLimitations();
|
||||||
updatePumpTimeIfNeeded();
|
updatePumpTimeIfNeeded();
|
||||||
readHistory();
|
readHistory();
|
||||||
|
} catch (AppLayerErrorException e) {
|
||||||
|
log.info("Exception while fetching status: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||||
} catch (InsightException e) {
|
} catch (InsightException e) {
|
||||||
log.info("Exception while fetching status: " + e.getClass().getCanonicalName());
|
log.info("Exception while fetching status: " + e.getClass().getCanonicalName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -450,6 +455,11 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
fetchStatus();
|
fetchStatus();
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
|
} catch (AppLayerErrorException e) {
|
||||||
|
log.info("Exception while setting profile: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||||
|
Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.gs(R.string.failedupdatebasalprofile), Notification.URGENT);
|
||||||
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
|
result.comment = ExceptionTranslator.getString(e);
|
||||||
} catch (InsightException e) {
|
} catch (InsightException e) {
|
||||||
log.info("Exception while setting profile: " + e.getClass().getCanonicalName());
|
log.info("Exception while setting profile: " + e.getClass().getCanonicalName());
|
||||||
Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.gs(R.string.failedupdatebasalprofile), Notification.URGENT);
|
Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.gs(R.string.failedupdatebasalprofile), Notification.URGENT);
|
||||||
|
@ -540,10 +550,14 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
detailedBolusInfo.pumpId = insightBolusID.id;
|
detailedBolusInfo.pumpId = insightBolusID.id;
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, true);
|
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, true);
|
||||||
while (true) {
|
while (true) {
|
||||||
List<ActiveBolus> activeBoluses = connectionService.requestMessage(new GetActiveBolusesMessage()).await().getActiveBoluses();
|
fetchStatus();
|
||||||
|
if (operatingMode != OperatingMode.STARTED) break;
|
||||||
ActiveBolus activeBolus = null;
|
ActiveBolus activeBolus = null;
|
||||||
for (ActiveBolus bolus : activeBoluses) {
|
for (ActiveBolus bolus : activeBoluses) {
|
||||||
if (bolus.getBolusID() == bolusID) activeBolus = bolus;
|
if (bolus.getBolusID() == bolusID) {
|
||||||
|
activeBolus = bolus;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (activeBolus != null) {
|
if (activeBolus != null) {
|
||||||
trials = -1;
|
trials = -1;
|
||||||
|
@ -552,14 +566,19 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
bolusingEvent.status = MainApp.gs(R.string.insight_delivered, activeBolus.getInitialAmount() - activeBolus.getRemainingAmount(), activeBolus.getInitialAmount());
|
bolusingEvent.status = MainApp.gs(R.string.insight_delivered, activeBolus.getInitialAmount() - activeBolus.getRemainingAmount(), activeBolus.getInitialAmount());
|
||||||
if (percentBefore != bolusingEvent.percent)
|
if (percentBefore != bolusingEvent.percent)
|
||||||
MainApp.bus().post(bolusingEvent);
|
MainApp.bus().post(bolusingEvent);
|
||||||
} else if (trials == -1 || trials++ >= 5) break;
|
} else if (trials == -1 || trials++ >= 5) {
|
||||||
|
bolusingEvent.status = MainApp.gs(R.string.insight_delivered, detailedBolusInfo.insulin, detailedBolusInfo.insulin);
|
||||||
|
bolusingEvent.percent = 100;
|
||||||
|
MainApp.bus().post(bolusingEvent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
}
|
}
|
||||||
bolusingEvent.status = MainApp.gs(R.string.insight_delivered, detailedBolusInfo.insulin, detailedBolusInfo.insulin);
|
|
||||||
bolusingEvent.percent = 100;
|
|
||||||
MainApp.bus().post(bolusingEvent);
|
|
||||||
readHistory();
|
readHistory();
|
||||||
fetchStatus();
|
fetchStatus();
|
||||||
|
} catch (AppLayerErrorException e) {
|
||||||
|
log.info("Exception while delivering bolus: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||||
|
result.comment = ExceptionTranslator.getString(e);
|
||||||
} catch (InsightException e) {
|
} catch (InsightException e) {
|
||||||
log.info("Exception while delivering bolus: " + e.getClass().getCanonicalName());
|
log.info("Exception while delivering bolus: " + e.getClass().getCanonicalName());
|
||||||
result.comment = ExceptionTranslator.getString(e);
|
result.comment = ExceptionTranslator.getString(e);
|
||||||
|
@ -585,6 +604,8 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
cancelBolusMessage.setBolusID(bolusID);
|
cancelBolusMessage.setBolusID(bolusID);
|
||||||
connectionService.requestMessage(cancelBolusMessage).await();
|
connectionService.requestMessage(cancelBolusMessage).await();
|
||||||
confirmAlert(AlertType.WARNING_38);
|
confirmAlert(AlertType.WARNING_38);
|
||||||
|
} catch (AppLayerErrorException e) {
|
||||||
|
log.info("Exception while canceling bolus: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||||
} catch (InsightException e) {
|
} catch (InsightException e) {
|
||||||
log.info("Exception while canceling bolus: " + e.getClass().getCanonicalName());
|
log.info("Exception while canceling bolus: " + e.getClass().getCanonicalName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -633,6 +654,8 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
try {
|
try {
|
||||||
fetchStatus();
|
fetchStatus();
|
||||||
readHistory();
|
readHistory();
|
||||||
|
} catch (AppLayerErrorException e) {
|
||||||
|
log.info("Exception after setting TBR: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||||
} catch (InsightException e) {
|
} catch (InsightException e) {
|
||||||
log.info("Exception after setting TBR: " + e.getClass().getCanonicalName());
|
log.info("Exception after setting TBR: " + e.getClass().getCanonicalName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -667,6 +690,9 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
result.comment = MainApp.gs(R.string.virtualpump_resultok);
|
result.comment = MainApp.gs(R.string.virtualpump_resultok);
|
||||||
readHistory();
|
readHistory();
|
||||||
fetchStatus();
|
fetchStatus();
|
||||||
|
} catch (AppLayerErrorException e) {
|
||||||
|
log.info("Exception while setting TBR: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||||
|
result.comment = ExceptionTranslator.getString(e);
|
||||||
} catch (InsightException e) {
|
} catch (InsightException e) {
|
||||||
log.info("Exception while setting TBR: " + e.getClass().getCanonicalName());
|
log.info("Exception while setting TBR: " + e.getClass().getCanonicalName());
|
||||||
result.comment = ExceptionTranslator.getString(e);
|
result.comment = ExceptionTranslator.getString(e);
|
||||||
|
@ -683,6 +709,8 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
try {
|
try {
|
||||||
fetchStatus();
|
fetchStatus();
|
||||||
readHistory();
|
readHistory();
|
||||||
|
} catch (AppLayerErrorException e) {
|
||||||
|
log.info("Exception after delivering extended bolus: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||||
} catch (InsightException e) {
|
} catch (InsightException e) {
|
||||||
log.info("Exception after delivering extended bolus: " + e.getClass().getCanonicalName());
|
log.info("Exception after delivering extended bolus: " + e.getClass().getCanonicalName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -715,6 +743,9 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
result.comment = MainApp.gs(R.string.virtualpump_resultok);
|
result.comment = MainApp.gs(R.string.virtualpump_resultok);
|
||||||
|
} catch (AppLayerErrorException e) {
|
||||||
|
log.info("Exception while delivering extended bolus: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||||
|
result.comment = ExceptionTranslator.getString(e);
|
||||||
} catch (InsightException e) {
|
} catch (InsightException e) {
|
||||||
log.info("Exception while delivering extended bolus: " + e.getClass().getCanonicalName());
|
log.info("Exception while delivering extended bolus: " + e.getClass().getCanonicalName());
|
||||||
result.comment = ExceptionTranslator.getString(e);
|
result.comment = ExceptionTranslator.getString(e);
|
||||||
|
@ -737,6 +768,8 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
try {
|
try {
|
||||||
fetchStatus();
|
fetchStatus();
|
||||||
readHistory();
|
readHistory();
|
||||||
|
} catch (AppLayerErrorException e) {
|
||||||
|
log.info("Exception after canceling TBR: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||||
} catch (InsightException e) {
|
} catch (InsightException e) {
|
||||||
log.info("Exception after canceling TBR: " + e.getClass().getCanonicalName());
|
log.info("Exception after canceling TBR: " + e.getClass().getCanonicalName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -759,6 +792,9 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
} catch (NoActiveTBRToCanceLException e) {
|
} catch (NoActiveTBRToCanceLException e) {
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.comment = MainApp.gs(R.string.virtualpump_resultok);
|
result.comment = MainApp.gs(R.string.virtualpump_resultok);
|
||||||
|
} catch (AppLayerErrorException e) {
|
||||||
|
log.info("Exception while canceling TBR: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||||
|
result.comment = ExceptionTranslator.getString(e);
|
||||||
} catch (InsightException e) {
|
} catch (InsightException e) {
|
||||||
log.info("Exception while canceling TBR: " + e.getClass().getCanonicalName());
|
log.info("Exception while canceling TBR: " + e.getClass().getCanonicalName());
|
||||||
result.comment = ExceptionTranslator.getString(e);
|
result.comment = ExceptionTranslator.getString(e);
|
||||||
|
@ -775,10 +811,12 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
try {
|
try {
|
||||||
fetchStatus();
|
fetchStatus();
|
||||||
readHistory();
|
readHistory();
|
||||||
|
} catch (AppLayerErrorException e) {
|
||||||
|
log.info("Exception after canceling extended bolus: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||||
} catch (InsightException e) {
|
} catch (InsightException e) {
|
||||||
log.info("Exception after canceling bolus: " + e.getClass().getCanonicalName());
|
log.info("Exception after canceling extended bolus: " + e.getClass().getCanonicalName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Exception after canceling bolus", e);
|
log.error("Exception after canceling extended bolus", e);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -817,11 +855,14 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
}
|
}
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.comment = MainApp.gs(R.string.virtualpump_resultok);
|
result.comment = MainApp.gs(R.string.virtualpump_resultok);
|
||||||
|
} catch (AppLayerErrorException e) {
|
||||||
|
log.info("Exception while canceling extended bolus: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||||
|
result.comment = ExceptionTranslator.getString(e);
|
||||||
} catch (InsightException e) {
|
} catch (InsightException e) {
|
||||||
log.info("Exception while canceling bolus: " + e.getClass().getCanonicalName());
|
log.info("Exception while canceling extended bolus: " + e.getClass().getCanonicalName());
|
||||||
result.comment = ExceptionTranslator.getString(e);
|
result.comment = ExceptionTranslator.getString(e);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Exception while canceling bolus", e);
|
log.error("Exception while canceling extended bolus", e);
|
||||||
result.comment = ExceptionTranslator.getString(e);
|
result.comment = ExceptionTranslator.getString(e);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -840,6 +881,8 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
} else break;
|
} else break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (AppLayerErrorException e) {
|
||||||
|
log.info("Exception while confirming alert: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||||
} catch (InsightException e) {
|
} catch (InsightException e) {
|
||||||
log.info("Exception while confirming alert: " + e.getClass().getCanonicalName());
|
log.info("Exception while confirming alert: " + e.getClass().getCanonicalName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -911,6 +954,9 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
fetchStatus();
|
fetchStatus();
|
||||||
readHistory();
|
readHistory();
|
||||||
|
} catch (AppLayerErrorException e) {
|
||||||
|
log.info("Exception while stopping pump: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||||
|
result.comment = ExceptionTranslator.getString(e);
|
||||||
} catch (InsightException e) {
|
} catch (InsightException e) {
|
||||||
log.info("Exception while stopping pump: " + e.getClass().getCanonicalName());
|
log.info("Exception while stopping pump: " + e.getClass().getCanonicalName());
|
||||||
result.comment = ExceptionTranslator.getString(e);
|
result.comment = ExceptionTranslator.getString(e);
|
||||||
|
@ -931,8 +977,12 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
fetchStatus();
|
fetchStatus();
|
||||||
readHistory();
|
readHistory();
|
||||||
|
} catch (AppLayerErrorException e) {
|
||||||
|
log.info("Exception while starting pump: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||||
|
result.comment = ExceptionTranslator.getString(e);
|
||||||
} catch (InsightException e) {
|
} catch (InsightException e) {
|
||||||
log.info("Exception while starting pump: " + e.getClass().getCanonicalName());
|
log.info("Exception while starting pump: " + e.getClass().getCanonicalName());
|
||||||
|
result.comment = ExceptionTranslator.getString(e);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Exception while starting pump", e);
|
log.error("Exception while starting pump", e);
|
||||||
result.comment = ExceptionTranslator.getString(e);
|
result.comment = ExceptionTranslator.getString(e);
|
||||||
|
@ -948,6 +998,10 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
ParameterBlockUtil.writeConfigurationBlock(connectionService, tbrOverNotificationBlock);
|
ParameterBlockUtil.writeConfigurationBlock(connectionService, tbrOverNotificationBlock);
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
|
} catch (AppLayerErrorException e) {
|
||||||
|
tbrOverNotificationBlock.setEnabled(valueBefore);
|
||||||
|
log.info("Exception while updating TBR notification block: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||||
|
result.comment = ExceptionTranslator.getString(e);
|
||||||
} catch (InsightException e) {
|
} catch (InsightException e) {
|
||||||
tbrOverNotificationBlock.setEnabled(valueBefore);
|
tbrOverNotificationBlock.setEnabled(valueBefore);
|
||||||
log.info("Exception while updating TBR notification block: " + e.getClass().getSimpleName());
|
log.info("Exception while updating TBR notification block: " + e.getClass().getSimpleName());
|
||||||
|
@ -1018,11 +1072,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
startMessage.setDirection(HistoryReadingDirection.BACKWARD);
|
startMessage.setDirection(HistoryReadingDirection.BACKWARD);
|
||||||
startMessage.setOffset(0xFFFFFFFF);
|
startMessage.setOffset(0xFFFFFFFF);
|
||||||
connectionService.requestMessage(startMessage).await();
|
connectionService.requestMessage(startMessage).await();
|
||||||
for (int i = 0; i < 50; i++) {
|
historyEvents = connectionService.requestMessage(new ReadHistoryEventsMessage()).await().getHistoryEvents();
|
||||||
List<HistoryEvent> newEvents = connectionService.requestMessage(new ReadHistoryEventsMessage()).await().getHistoryEvents();
|
|
||||||
if (newEvents.size() == 0) break;
|
|
||||||
historyEvents.addAll(newEvents);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
StartReadingHistoryMessage startMessage = new StartReadingHistoryMessage();
|
StartReadingHistoryMessage startMessage = new StartReadingHistoryMessage();
|
||||||
startMessage.setDirection(HistoryReadingDirection.FORWARD);
|
startMessage.setDirection(HistoryReadingDirection.FORWARD);
|
||||||
|
@ -1034,17 +1084,29 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
historyEvents.addAll(newEvents);
|
historyEvents.addAll(newEvents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
processHistoryEvents(pumpSerial, historyEvents);
|
Collections.sort(historyEvents);
|
||||||
|
Collections.reverse(historyEvents);
|
||||||
|
if (historyOffset != null) processHistoryEvents(pumpSerial, historyEvents);
|
||||||
|
if (historyEvents.size() > 0) {
|
||||||
|
historyOffset = new InsightHistoryOffset();
|
||||||
|
historyOffset.pumpSerial = pumpSerial;
|
||||||
|
historyOffset.offset = historyEvents.get(0).getEventPosition();
|
||||||
|
MainApp.getDbHelper().createOrUpdate(historyOffset);
|
||||||
|
}
|
||||||
|
} catch (AppLayerErrorException e) {
|
||||||
|
log.info("Exception while reading history: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||||
} catch (InsightException e) {
|
} catch (InsightException e) {
|
||||||
log.info("Error while reading history: " + e.getClass().getSimpleName());
|
log.info("Exception while reading history: " + e.getClass().getSimpleName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error while reading history", e);
|
log.error("Exception while reading history", e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
connectionService.requestMessage(new StopReadingHistoryMessage()).await();
|
connectionService.requestMessage(new StopReadingHistoryMessage()).await();
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (AppLayerErrorException e) {
|
||||||
|
log.info("Exception while reading history: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||||
} catch (InsightException e) {
|
} catch (InsightException e) {
|
||||||
log.info("Exception while reading history: " + e.getClass().getSimpleName());
|
log.info("Exception while reading history: " + e.getClass().getSimpleName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -1054,8 +1116,6 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processHistoryEvents(String serial, List<HistoryEvent> historyEvents) {
|
private void processHistoryEvents(String serial, List<HistoryEvent> historyEvents) {
|
||||||
Collections.sort(historyEvents);
|
|
||||||
Collections.reverse(historyEvents);
|
|
||||||
List<TemporaryBasal> temporaryBasals = new ArrayList<>();
|
List<TemporaryBasal> temporaryBasals = new ArrayList<>();
|
||||||
List<InsightPumpID> pumpStartedEvents = new ArrayList<>();
|
List<InsightPumpID> pumpStartedEvents = new ArrayList<>();
|
||||||
for (HistoryEvent historyEvent : historyEvents)
|
for (HistoryEvent historyEvent : historyEvents)
|
||||||
|
@ -1078,12 +1138,6 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
Collections.sort(temporaryBasals, (o1, o2) -> (int) (o1.date - o2.date));
|
Collections.sort(temporaryBasals, (o1, o2) -> (int) (o1.date - o2.date));
|
||||||
for (TemporaryBasal temporaryBasal : temporaryBasals)
|
for (TemporaryBasal temporaryBasal : temporaryBasals)
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal);
|
||||||
if (historyEvents.size() > 0) {
|
|
||||||
InsightHistoryOffset historyOffset = new InsightHistoryOffset();
|
|
||||||
historyOffset.pumpSerial = serial;
|
|
||||||
historyOffset.offset = historyEvents.get(0).getEventPosition();
|
|
||||||
MainApp.getDbHelper().createOrUpdate(historyOffset);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean processHistoryEvent(String serial, List<TemporaryBasal> temporaryBasals, List<InsightPumpID> pumpStartedEvents, HistoryEvent event) {
|
private boolean processHistoryEvent(String serial, List<TemporaryBasal> temporaryBasals, List<InsightPumpID> pumpStartedEvents, HistoryEvent event) {
|
||||||
|
@ -1471,7 +1525,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stateChanged(InsightState state) {
|
public void onStateChanged(InsightState state) {
|
||||||
if (state == InsightState.CONNECTED) statusLoaded = false;
|
if (state == InsightState.CONNECTED) statusLoaded = false;
|
||||||
else if (state == InsightState.NOT_PAIRED) {
|
else if (state == InsightState.NOT_PAIRED) {
|
||||||
connectionService.withdrawConnectionRequest(this);
|
connectionService.withdrawConnectionRequest(this);
|
||||||
|
@ -1485,7 +1539,13 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
activeTBR = null;
|
activeTBR = null;
|
||||||
activeBoluses = null;
|
activeBoluses = null;
|
||||||
tbrOverNotificationBlock = null;
|
tbrOverNotificationBlock = null;
|
||||||
|
new Handler(Looper.getMainLooper()).post(() -> MainApp.bus().post(new EventRefreshOverview("LocalInsightPlugin::onStateChanged")));
|
||||||
}
|
}
|
||||||
new Handler(Looper.getMainLooper()).post(() -> MainApp.bus().post(new EventLocalInsightUpdateGUI()));
|
new Handler(Looper.getMainLooper()).post(() -> MainApp.bus().post(new EventLocalInsightUpdateGUI()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPumpPaired() {
|
||||||
|
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("Pump paired", null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -56,7 +55,7 @@ public class InsightPairingActivity extends AppCompatActivity implements Insight
|
||||||
service.requestConnection(InsightPairingActivity.this);
|
service.requestConnection(InsightPairingActivity.this);
|
||||||
service.registerStateCallback(InsightPairingActivity.this);
|
service.registerStateCallback(InsightPairingActivity.this);
|
||||||
service.registerExceptionCallback(InsightPairingActivity.this);
|
service.registerExceptionCallback(InsightPairingActivity.this);
|
||||||
stateChanged(service.getState());
|
onStateChanged(service.getState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +115,7 @@ public class InsightPairingActivity extends AppCompatActivity implements Insight
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stateChanged(InsightState state) {
|
public void onStateChanged(InsightState state) {
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case NOT_PAIRED:
|
case NOT_PAIRED:
|
||||||
|
|
|
@ -20,7 +20,6 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.BolusProgressReporter;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.AppLayerMessage;
|
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.AppLayerMessage;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.ReadParameterBlockMessage;
|
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.ReadParameterBlockMessage;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.configuration.CloseConfigurationWriteSessionMessage;
|
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.configuration.CloseConfigurationWriteSessionMessage;
|
||||||
|
@ -245,7 +244,7 @@ public class InsightConnectionService extends Service implements ConnectionEstab
|
||||||
wakeLock.release();
|
wakeLock.release();
|
||||||
else if (!wakeLock.isHeld()) wakeLock.acquire();
|
else if (!wakeLock.isHeld()) wakeLock.acquire();
|
||||||
this.state = state;
|
this.state = state;
|
||||||
for (StateCallback stateCallback : stateCallbacks) stateCallback.stateChanged(state);
|
for (StateCallback stateCallback : stateCallbacks) stateCallback.onStateChanged(state);
|
||||||
log.info("Insight state changed: " + state.name());
|
log.info("Insight state changed: " + state.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,6 +277,10 @@ public class InsightConnectionService extends Service implements ConnectionEstab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized boolean hasRequestedConnection(Object lock) {
|
||||||
|
return connectionRequests.contains(lock);
|
||||||
|
}
|
||||||
|
|
||||||
private void cleanup() {
|
private void cleanup() {
|
||||||
messageQueue.completeActiveRequest(new ConnectionLostException());
|
messageQueue.completeActiveRequest(new ConnectionLostException());
|
||||||
messageQueue.completePendingRequests(new ConnectionLostException());
|
messageQueue.completePendingRequests(new ConnectionLostException());
|
||||||
|
@ -704,6 +707,7 @@ public class InsightConnectionService extends Service implements ConnectionEstab
|
||||||
pairingDataStorage.setPaired(true);
|
pairingDataStorage.setPaired(true);
|
||||||
log.info("Pairing completed YEE-HAW ♪ ┏(・o・)┛ ♪ ┗( ・o・)┓ ♪");
|
log.info("Pairing completed YEE-HAW ♪ ┏(・o・)┛ ♪ ┗( ・o・)┓ ♪");
|
||||||
setState(InsightState.CONNECTED);
|
setState(InsightState.CONNECTED);
|
||||||
|
for (StateCallback stateCallback : stateCallbacks) stateCallback.onPumpPaired();
|
||||||
}
|
}
|
||||||
} else processGenericAppLayerMessage(message);
|
} else processGenericAppLayerMessage(message);
|
||||||
}
|
}
|
||||||
|
@ -771,7 +775,10 @@ public class InsightConnectionService extends Service implements ConnectionEstab
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface StateCallback {
|
public interface StateCallback {
|
||||||
void stateChanged(InsightState state);
|
void onStateChanged(InsightState state);
|
||||||
|
default void onPumpPaired() {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ExceptionCallback {
|
public interface ExceptionCallback {
|
||||||
|
|
|
@ -14,4 +14,8 @@ public abstract class AppLayerErrorException extends AppLayerException {
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return "Error code: " + errorCode;
|
return "Error code: " + errorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getErrorCode() {
|
||||||
|
return errorCode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -886,7 +886,7 @@
|
||||||
<string name="combo_error_bolus_verification_failed">Delivering the bolus and verifying the pump\'s history failed, please check the pump. If a bolus was delivered, it will be added to treatments during the next connection to the pump.</string>
|
<string name="combo_error_bolus_verification_failed">Delivering the bolus and verifying the pump\'s history failed, please check the pump. If a bolus was delivered, it will be added to treatments during the next connection to the pump.</string>
|
||||||
<string name="combo_reservoir_level_insufficient_for_bolus">Not enough insulin for bolus left in reservoir</string>
|
<string name="combo_reservoir_level_insufficient_for_bolus">Not enough insulin for bolus left in reservoir</string>
|
||||||
<string name="extendedbolusdeliveryerror">Extended bolus delivery error</string>
|
<string name="extendedbolusdeliveryerror">Extended bolus delivery error</string>
|
||||||
<string name="insightpump_shortname">Insight</string>
|
<string name="insightpump_shortname">Sight</string>
|
||||||
<string name="insightpump">Insight Pump</string>
|
<string name="insightpump">Insight Pump</string>
|
||||||
<string name="status_no_colon">Status</string>
|
<string name="status_no_colon">Status</string>
|
||||||
<string name="changed">Changed</string>
|
<string name="changed">Changed</string>
|
||||||
|
@ -1281,8 +1281,8 @@
|
||||||
<string name="extended_bolus">Extended bolus</string>
|
<string name="extended_bolus">Extended bolus</string>
|
||||||
<string name="multiwave_bolus">Multiwave bolus</string>
|
<string name="multiwave_bolus">Multiwave bolus</string>
|
||||||
<string name="eb_formatter">%1$.2f / %2$.2f U for %3$d min</string>
|
<string name="eb_formatter">%1$.2f / %2$.2f U for %3$d min</string>
|
||||||
<string name="enable_tbr_over_notification">Enable TBR over notification</string>
|
<string name="enable_tbr_over_notification">Enable notification of TBR end\n(pump setting)</string>
|
||||||
<string name="disable_tbr_over_notification">Disable TBR over notification</string>
|
<string name="disable_tbr_over_notification">Disable notification of TBR end\n(pump setting)</string>
|
||||||
<string name="refresh">Refresh</string>
|
<string name="refresh">Refresh</string>
|
||||||
<string name="description_pump_insight_local">Pump integration for Accu-Chek Insight pumps</string>
|
<string name="description_pump_insight_local">Pump integration for Accu-Chek Insight pumps</string>
|
||||||
<string name="not_inserted">Not inserted</string>
|
<string name="not_inserted">Not inserted</string>
|
||||||
|
|
Loading…
Reference in a new issue