move applyAPSResult out of pump interface
This commit is contained in:
parent
56225f1851
commit
c16ad7e37d
|
@ -33,7 +33,6 @@ public interface PumpInterface {
|
||||||
PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes);
|
PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes);
|
||||||
PumpEnactResult cancelTempBasal();
|
PumpEnactResult cancelTempBasal();
|
||||||
PumpEnactResult cancelExtendedBolus();
|
PumpEnactResult cancelExtendedBolus();
|
||||||
PumpEnactResult applyAPSRequest(APSResult request);
|
|
||||||
|
|
||||||
// Status to be passed to NS
|
// Status to be passed to NS
|
||||||
JSONObject getJSONStatus();
|
JSONObject getJSONStatus();
|
||||||
|
|
|
@ -144,6 +144,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
||||||
}
|
}
|
||||||
|
|
||||||
void setViews() {
|
void setViews() {
|
||||||
|
// TODO: hide empty categories
|
||||||
bgsourceDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.BGSOURCE));
|
bgsourceDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.BGSOURCE));
|
||||||
bgsourceListView.setAdapter(bgsourceDataAdapter);
|
bgsourceListView.setAdapter(bgsourceDataAdapter);
|
||||||
setListViewHeightBasedOnChildren(bgsourceListView);
|
setListViewHeightBasedOnChildren(bgsourceListView);
|
||||||
|
@ -365,7 +366,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public PumpEnactResult applyAPSRequest(APSResult request) {
|
public PumpEnactResult applyAPSRequest(APSResult request) {
|
||||||
request.rate = applyBasalConstraints(request.rate);
|
request.rate = applyBasalConstraints(request.rate);
|
||||||
PumpEnactResult result = null;
|
PumpEnactResult result = null;
|
||||||
|
|
|
@ -39,6 +39,7 @@ import info.nightscout.androidaps.interfaces.APSInterface;
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
||||||
|
|
||||||
public class LoopFragment extends Fragment implements View.OnClickListener, PluginBase {
|
public class LoopFragment extends Fragment implements View.OnClickListener, PluginBase {
|
||||||
private static Logger log = LoggerFactory.getLogger(LoopFragment.class);
|
private static Logger log = LoggerFactory.getLogger(LoopFragment.class);
|
||||||
|
@ -226,10 +227,10 @@ public class LoopFragment extends Fragment implements View.OnClickListener, Plug
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PumpInterface pumpInterface = MainApp.getConfigBuilder().getActivePump();
|
ConfigBuilderFragment configBuilder = MainApp.getConfigBuilder();
|
||||||
APSResult result = null;
|
APSResult result = null;
|
||||||
|
|
||||||
if (constraintsInterface == null || pumpInterface == null || !isEnabled())
|
if (constraintsInterface == null || configBuilder == null || !isEnabled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
APSInterface usedAPS = null;
|
APSInterface usedAPS = null;
|
||||||
|
@ -274,7 +275,7 @@ public class LoopFragment extends Fragment implements View.OnClickListener, Plug
|
||||||
|
|
||||||
if (constraintsInterface.isClosedModeEnabled()) {
|
if (constraintsInterface.isClosedModeEnabled()) {
|
||||||
if (result.changeRequested) {
|
if (result.changeRequested) {
|
||||||
PumpEnactResult applyResult = pumpInterface.applyAPSRequest(resultAfterConstraints);
|
PumpEnactResult applyResult = configBuilder.applyAPSRequest(resultAfterConstraints);
|
||||||
if (applyResult.enacted) {
|
if (applyResult.enacted) {
|
||||||
lastRun.setByPump = applyResult;
|
lastRun.setByPump = applyResult;
|
||||||
lastRun.lastEnact = lastRun.lastAPSRun;
|
lastRun.lastEnact = lastRun.lastAPSRun;
|
||||||
|
|
|
@ -240,7 +240,7 @@ public class OverviewFragment extends Fragment implements PluginBase {
|
||||||
builder.setMessage(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed);
|
builder.setMessage(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed);
|
||||||
builder.setPositiveButton(getContext().getString(R.string.ok), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(getContext().getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
PumpEnactResult applyResult = MainApp.getConfigBuilder().getActivePump().applyAPSRequest(finalLastRun.constraintsProcessed);
|
PumpEnactResult applyResult = MainApp.getConfigBuilder().applyAPSRequest(finalLastRun.constraintsProcessed);
|
||||||
if (applyResult.enacted) {
|
if (applyResult.enacted) {
|
||||||
finalLastRun.setByPump = applyResult;
|
finalLastRun.setByPump = applyResult;
|
||||||
finalLastRun.lastEnact = new Date();
|
finalLastRun.lastEnact = new Date();
|
||||||
|
|
|
@ -51,6 +51,8 @@ public class VirtualPumpFragment extends Fragment implements PluginBase, PumpInt
|
||||||
boolean fragmentVisible = true;
|
boolean fragmentVisible = true;
|
||||||
boolean visibleNow = false;
|
boolean visibleNow = false;
|
||||||
|
|
||||||
|
// TODO: upload pump status without Loop plugin too
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return MainApp.instance().getString(R.string.virtualpump);
|
return MainApp.instance().getString(R.string.virtualpump);
|
||||||
|
@ -342,12 +344,6 @@ public class VirtualPumpFragment extends Fragment implements PluginBase, PumpInt
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public PumpEnactResult applyAPSRequest(APSResult request) {
|
|
||||||
// This should be implemented only on ConfigBuilder
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject getJSONStatus() {
|
public JSONObject getJSONStatus() {
|
||||||
JSONObject pump = new JSONObject();
|
JSONObject pump = new JSONObject();
|
||||||
|
|
Loading…
Reference in a new issue