allow automated actions only whem pump is initialized

This commit is contained in:
Milos Kozak 2016-11-10 23:32:58 +01:00
parent 86a3df1996
commit e8d169f078
6 changed files with 34 additions and 4 deletions

View file

@ -16,6 +16,8 @@ import info.nightscout.client.data.NSProfile;
*/ */
public interface PumpInterface { public interface PumpInterface {
boolean isInitialized();
boolean isTempBasalInProgress(); boolean isTempBasalInProgress();
boolean isExtendedBoluslInProgress(); boolean isExtendedBoluslInProgress();

View file

@ -294,10 +294,15 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
} }
/* /*
* Pump interface * Pump interface
* *
* Config builder return itself as a pump and check constraints before it passes command to pump driver * Config builder return itself as a pump and check constraints before it passes command to pump driver
*/ */
@Override
public boolean isInitialized() {
return activePump.isInitialized();
}
@Override @Override
public boolean isTempBasalInProgress() { public boolean isTempBasalInProgress() {
return activePump.isTempBasalInProgress(); return activePump.isTempBasalInProgress();
@ -527,6 +532,13 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
request.rate = applyBasalConstraints(request.rate); request.rate = applyBasalConstraints(request.rate);
PumpEnactResult result; PumpEnactResult result;
if (!isInitialized()) {
result = new PumpEnactResult();
result.comment = MainApp.sResources.getString(R.string.pumpNotInitialized);
result.enacted = false;
result.success = false;
}
if (Config.logCongigBuilderActions) if (Config.logCongigBuilderActions)
log.debug("applyAPSRequest: " + request.toString()); log.debug("applyAPSRequest: " + request.toString());
if ((request.rate == 0 && request.duration == 0) || Math.abs(request.rate - getBaseBasalRate()) < 0.05) { if ((request.rate == 0 && request.duration == 0) || Math.abs(request.rate - getBaseBasalRate()) < 0.05) {

View file

@ -150,6 +150,11 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
this.fragmentPumpVisible = fragmentVisible; this.fragmentPumpVisible = fragmentVisible;
} }
@Override
public boolean isInitialized() {
return getDanaRPump().lastConnection.getTime() > 0;
}
// Pump interface // Pump interface
@Override @Override
public boolean isTempBasalInProgress() { public boolean isTempBasalInProgress() {

View file

@ -94,6 +94,11 @@ public class MM640gPlugin implements PluginBase, PumpInterface, BgSourceInterfac
* Pump Interface * Pump Interface
*/ */
@Override
public boolean isInitialized() {
return false;
}
@Override @Override
public boolean isTempBasalInProgress() { public boolean isTempBasalInProgress() {
return false; return false;

View file

@ -77,6 +77,11 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
return PluginBase.PUMP; return PluginBase.PUMP;
} }
@Override
public boolean isInitialized() {
return true;
}
@Override @Override
public boolean isTempBasalInProgress() { public boolean isTempBasalInProgress() {
return getTempBasal() != null; return getTempBasal() != null;

View file

@ -339,4 +339,5 @@
<string name="ns_upload_only">NS upload only (disabled sync)</string> <string name="ns_upload_only">NS upload only (disabled sync)</string>
<string name="ns_upload_only_summary">NS upload only. Not effective on SGV unless a local source like xDrip is selected. Not effective on Profiles while NS-Profiles is used.</string> <string name="ns_upload_only_summary">NS upload only. Not effective on SGV unless a local source like xDrip is selected. Not effective on Profiles while NS-Profiles is used.</string>
<string name="ns_upload_only_enabled">Please deactivate "NS upload only" to use this feature.</string> <string name="ns_upload_only_enabled">Please deactivate "NS upload only" to use this feature.</string>
<string name="pumpNotInitialized">Pump not initialized!</string>
</resources> </resources>