nsclient always use virtual pump, more sync fixes

This commit is contained in:
Milos Kozak 2017-06-07 18:10:07 +02:00
parent fec56e7c23
commit e5a326c377
9 changed files with 26 additions and 11 deletions

View file

@ -48,6 +48,7 @@ import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Fragment;
import info.nightscout.androidaps.plugins.PumpDanaRv2.services.DanaRv2ExecutionService;
import info.nightscout.androidaps.plugins.PumpMDI.MDIFragment;
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpFragment;
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorFragment;
import info.nightscout.androidaps.plugins.SourceGlimp.SourceGlimpFragment;
import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gFragment;
@ -102,7 +103,7 @@ public class MainApp extends Application {
if (Config.DANARv2) pluginsList.add(DanaRv2Fragment.getPlugin());
pluginsList.add(CareportalFragment.getPlugin());
if (Config.MDI) pluginsList.add(MDIFragment.getPlugin());
if (Config.VIRTUALPUMP) pluginsList.add(VirtualPumpFragment.getPlugin());
if (Config.VIRTUALPUMP) pluginsList.add(VirtualPumpPlugin.getInstance());
if (Config.LOOPENABLED) pluginsList.add(LoopFragment.getPlugin());
if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSMAFragment.getPlugin());
if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSAMAFragment.getPlugin());

View file

@ -48,6 +48,7 @@ import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
import info.nightscout.utils.NSUpload;
/**
@ -275,7 +276,9 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
// PluginBase.PUMP
pluginsInCategory = MainApp.getSpecificPluginsList(PluginBase.PUMP);
activePump = (PumpInterface) getTheOneEnabledInArray(pluginsInCategory, PluginBase.PUMP);
if (Config.logConfigBuilder && activePump != null)
if (activePump == null)
activePump = VirtualPumpPlugin.getInstance(); // for NSClient build
if (Config.logConfigBuilder)
log.debug("Selected pump interface: " + ((PluginBase) activePump).getName());
for (PluginBase p : pluginsInCategory) {
if (!p.getName().equals(((PluginBase) activePump).getName())) {

View file

@ -27,6 +27,7 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.utils.PlusMinusEditText;
import info.nightscout.utils.SafeParse;
@ -112,6 +113,7 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
detailedBolusInfo.insulin = finalInsulinAfterConstraints;
detailedBolusInfo.carbs = finalCarbsAfterConstraints;
detailedBolusInfo.context = context;
detailedBolusInfo.source = Source.USER;
PumpEnactResult result = pump.deliverTreatment(detailedBolusInfo);
if (!result.success) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);

View file

@ -48,6 +48,7 @@ import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
@ -333,6 +334,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
detailedBolusInfo.glucoseType = "Manual";
detailedBolusInfo.carbTime = carbTime;
detailedBolusInfo.boluscalc = boluscalcJSON;
detailedBolusInfo.source = Source.USER;
result = pump.deliverTreatment(detailedBolusInfo);
if (!result.success) {
OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.treatmentdeliveryerror), result.comment, null);

View file

@ -73,6 +73,7 @@ import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.db.ExtendedBolus;
import info.nightscout.androidaps.db.ProfileSwitch;
import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.db.Treatment;
@ -698,6 +699,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
detailedBolusInfo.carbs = finalCarbsAfterConstraints;
detailedBolusInfo.context = context;
detailedBolusInfo.boluscalc = boluscalcJSON;
detailedBolusInfo.source = Source.USER;
PumpEnactResult result = pump.deliverTreatment(detailedBolusInfo);
if (!result.success) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());

View file

@ -25,12 +25,6 @@ import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpd
public class VirtualPumpFragment extends Fragment {
private static Logger log = LoggerFactory.getLogger(VirtualPumpFragment.class);
private static VirtualPumpPlugin virtualPumpPlugin = new VirtualPumpPlugin();
public static VirtualPumpPlugin getPlugin() {
return virtualPumpPlugin;
}
TextView basaBasalRateView;
TextView tempBasalView;
TextView extendedBolusView;
@ -93,7 +87,7 @@ public class VirtualPumpFragment extends Fragment {
@Override
public void run() {
basaBasalRateView.setText(virtualPumpPlugin.getBaseBasalRate() + "U");
basaBasalRateView.setText(VirtualPumpPlugin.getInstance().getBaseBasalRate() + "U");
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
tempBasalView.setText(MainApp.getConfigBuilder().getTempBasalFromHistory(new Date().getTime()).toString());
} else {
@ -104,8 +98,8 @@ public class VirtualPumpFragment extends Fragment {
} else {
extendedBolusView.setText("");
}
batteryView.setText(VirtualPumpPlugin.batteryPercent + "%");
reservoirView.setText(VirtualPumpPlugin.reservoirInUnits + "U");
batteryView.setText(VirtualPumpPlugin.getInstance().batteryPercent + "%");
reservoirView.setText(VirtualPumpPlugin.getInstance().reservoirInUnits + "U");
}
});
}

View file

@ -46,6 +46,13 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
PumpDescription pumpDescription = new PumpDescription();
static VirtualPumpPlugin instance = null;
public static VirtualPumpPlugin getInstance() {
if (instance == null)
instance = new VirtualPumpPlugin();
return instance;
}
public VirtualPumpPlugin() {
pumpDescription.isBolusCapable = true;
pumpDescription.bolusStep = 0.1d;

View file

@ -27,6 +27,7 @@ import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.interfaces.PluginBase;
@ -465,6 +466,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
danaRPlugin = (DanaRPlugin) MainApp.getSpecificPlugin(DanaRPlugin.class);
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
detailedBolusInfo.insulin = bolusWaitingForConfirmation.bolusRequested;
detailedBolusInfo.source = Source.USER;
PumpEnactResult result = pumpInterface.deliverTreatment(detailedBolusInfo);
if (result.success) {
reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_bolusdelivered), result.bolusDelivered);

View file

@ -16,6 +16,7 @@ import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.interfaces.APSInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
@ -390,6 +391,7 @@ public class ActionStringHandler {
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
detailedBolusInfo.insulin = amount;
detailedBolusInfo.carbs = carbs;
detailedBolusInfo.source = Source.USER;
PumpEnactResult result = MainApp.getConfigBuilder().deliverTreatment(detailedBolusInfo);
if (!result.success) {
sendError(MainApp.sResources.getString(R.string.treatmentdeliveryerror) +