MDI pump driver
This commit is contained in:
parent
fdb252b62d
commit
29327aef01
|
@ -25,6 +25,7 @@ import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
|||
import info.nightscout.androidaps.plugins.DanaR.DanaRFragment;
|
||||
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanFragment;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopFragment;
|
||||
import info.nightscout.androidaps.plugins.MDI.MDIFragment;
|
||||
import info.nightscout.androidaps.plugins.NSProfile.NSProfileFragment;
|
||||
import info.nightscout.androidaps.plugins.Objectives.ObjectivesFragment;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAFragment;
|
||||
|
@ -75,6 +76,7 @@ public class MainApp extends Application {
|
|||
if (Config.DANAR) pluginsList.add(DanaRFragment.getPlugin());
|
||||
if (Config.DANARKOREAN) pluginsList.add(DanaRKoreanFragment.getPlugin());
|
||||
if (Config.CAREPORTALENABLED) pluginsList.add(CareportalFragment.getPlugin());
|
||||
pluginsList.add(MDIFragment.getPlugin());
|
||||
pluginsList.add(VirtualPumpFragment.getPlugin());
|
||||
if (Config.LOOPENABLED) pluginsList.add(LoopFragment.getPlugin());
|
||||
if (Config.OPENAPSMAENABLED) pluginsList.add(OpenAPSMAFragment.getPlugin());
|
||||
|
|
|
@ -5,6 +5,7 @@ package info.nightscout.androidaps.interfaces;
|
|||
*/
|
||||
|
||||
public class PumpDescription {
|
||||
public static final int NONE = 0;
|
||||
public static final int PERCENT = 1;
|
||||
public static final int ABSOLUTE = 2;
|
||||
public static final int EXTENDED = 4;
|
||||
|
|
|
@ -83,12 +83,12 @@ public class LoopPlugin implements PluginBase {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == LOOP && fragmentEnabled;
|
||||
return type == LOOP && fragmentEnabled && MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == LOOP && fragmentVisible;
|
||||
return type == LOOP && fragmentVisible && MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package info.nightscout.androidaps.plugins.MDI;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.FragmentBase;
|
||||
import info.nightscout.androidaps.plugins.VirtualPump.VirtualPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.VirtualPump.events.EventVirtualPumpUpdateGui;
|
||||
|
||||
public class MDIFragment extends Fragment implements FragmentBase {
|
||||
private static Logger log = LoggerFactory.getLogger(MDIFragment.class);
|
||||
|
||||
private static MDIPlugin mdiPlugin = new MDIPlugin();
|
||||
|
||||
public static MDIPlugin getPlugin() {
|
||||
return mdiPlugin;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,259 @@
|
|||
package info.nightscout.androidaps.plugins.MDI;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.BuildConfig;
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.db.TempBasal;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||
import info.nightscout.androidaps.plugins.VirtualPump.VirtualPumpFragment;
|
||||
import info.nightscout.androidaps.plugins.VirtualPump.events.EventVirtualPumpUpdateGui;
|
||||
import info.nightscout.client.data.NSProfile;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class MDIPlugin implements PluginBase, PumpInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(MDIPlugin.class);
|
||||
|
||||
boolean fragmentEnabled = false;
|
||||
boolean fragmentVisible = false;
|
||||
|
||||
PumpDescription pumpDescription = new PumpDescription();
|
||||
|
||||
public MDIPlugin() {
|
||||
pumpDescription.isBolusCapable = true;
|
||||
pumpDescription.bolusStep = 0.5d;
|
||||
|
||||
pumpDescription.isExtendedBolusCapable = false;
|
||||
pumpDescription.extendedBolusStep = 0d;
|
||||
|
||||
pumpDescription.isTempBasalCapable = false;
|
||||
pumpDescription.lowTempBasalStyle = PumpDescription.NONE;
|
||||
pumpDescription.highTempBasalStyle = PumpDescription.NONE;
|
||||
pumpDescription.maxHighTempPercent = 0;
|
||||
pumpDescription.maxHighTempAbsolute = 0;
|
||||
pumpDescription.lowTempPercentStep = 0;
|
||||
pumpDescription.lowTempAbsoluteStep = 0;
|
||||
pumpDescription.lowTempPercentDuration = 0;
|
||||
pumpDescription.lowTempAbsoluteDuration = 0;
|
||||
pumpDescription.highTempPercentStep = 0;
|
||||
pumpDescription.highTempAbsoluteStep = 0d;
|
||||
pumpDescription.highTempPercentDuration = 0;
|
||||
pumpDescription.highTempAbsoluteDuration = 0;
|
||||
|
||||
pumpDescription.isSetBasalProfileCapable = true;
|
||||
pumpDescription.basalStep = 0d;
|
||||
pumpDescription.basalMinimumRate = 0d;
|
||||
|
||||
pumpDescription.isRefillingCapable = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return MDIFragment.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.instance().getString(R.string.mdi);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == PUMP && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == PUMP) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == PUMP) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.PUMP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitialized() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTempBasalInProgress() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExtendedBoluslInProgress() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setNewBasalProfile(NSProfile profile) {
|
||||
// Do nothing here. we are using MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isThisProfileSet(NSProfile profile) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseBasalRate() {
|
||||
return 0d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTempBasalAbsoluteRate() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TempBasal getTempBasal() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TempBasal getExtendedBolus() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTempBasalRemainingMinutes() {
|
||||
return 0d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TempBasal getTempBasal(Date time) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult deliverTreatment(Double insulin, Integer carbs, Context context) {
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
result.success = true;
|
||||
result.bolusDelivered = insulin;
|
||||
result.carbsDelivered = carbs;
|
||||
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopBolusDelivering() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes) {
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
result.success = false;
|
||||
result.comment = MainApp.instance().getString(R.string.pumperror);
|
||||
if (Config.logPumpComm)
|
||||
log.debug("Setting temp basal absolute: " + result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) {
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
result.success = false;
|
||||
result.comment = MainApp.instance().getString(R.string.pumperror);
|
||||
if (Config.logPumpComm)
|
||||
log.debug("Settings temp basal percent: " + result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
result.success = false;
|
||||
result.comment = MainApp.instance().getString(R.string.pumperror);
|
||||
if (Config.logPumpComm)
|
||||
log.debug("Setting extended bolus: " + result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult cancelTempBasal() {
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
result.success = false;
|
||||
result.comment = MainApp.instance().getString(R.string.pumperror);
|
||||
if (Config.logPumpComm)
|
||||
log.debug("Cancel temp basal: " + result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult cancelExtendedBolus() {
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
result.success = false;
|
||||
result.comment = MainApp.instance().getString(R.string.pumperror);
|
||||
if (Config.logPumpComm)
|
||||
log.debug("Canceling extended basal: " + result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getJSONStatus() {
|
||||
JSONObject pump = new JSONObject();
|
||||
JSONObject status = new JSONObject();
|
||||
JSONObject extended = new JSONObject();
|
||||
try {
|
||||
status.put("status", "normal");
|
||||
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
|
||||
try {
|
||||
extended.put("ActiveProfile", MainApp.getConfigBuilder().getActiveProfile().getProfile().getActiveProfile());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
status.put("timestamp", DateUtil.toISOString(new Date()));
|
||||
|
||||
pump.put("status", status);
|
||||
pump.put("extended", extended);
|
||||
pump.put("clock", DateUtil.toISOString(new Date()));
|
||||
} catch (JSONException e) {
|
||||
}
|
||||
return pump;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String deviceID() {
|
||||
return "MDI";
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpDescription getPumpDescription() {
|
||||
return pumpDescription;
|
||||
}
|
||||
|
||||
}
|
|
@ -51,7 +51,7 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == CONSTRAINTS;
|
||||
return type == CONSTRAINTS && MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -58,12 +58,12 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == APS && fragmentEnabled;
|
||||
return type == APS && fragmentEnabled && MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == APS && fragmentVisible;
|
||||
return type == APS && fragmentVisible && MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -450,7 +450,7 @@ public class OverviewFragment extends Fragment {
|
|||
|
||||
// open loop mode
|
||||
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
|
||||
if (Config.APS) {
|
||||
if (Config.APS && MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable) {
|
||||
apsModeView.setVisibility(View.VISIBLE);
|
||||
apsModeView.setBackgroundResource(R.drawable.loopmodeborder);
|
||||
apsModeView.setTextColor(Color.BLACK);
|
||||
|
|
|
@ -66,12 +66,12 @@ public class TempBasalsPlugin implements PluginBase, TempBasalsInterface {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == TEMPBASAL && fragmentEnabled;
|
||||
return type == TEMPBASAL && fragmentEnabled && MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == TEMPBASAL && fragmentVisible;
|
||||
return type == TEMPBASAL && fragmentVisible && MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -373,4 +373,5 @@
|
|||
<string name="pumpNotInitializedProfileNotSet">Pumpa není inicializována, profil nenastaven!</string>
|
||||
<string name="wrongpumpdriverselected">Vybrán špatný ovladač pumpy</string>
|
||||
<string name="basalvaluebelowminimum">Hodnota bazálu pod minimem. Nenastaveno!</string>
|
||||
<string name="mdi">Pera</string>
|
||||
</resources>
|
||||
|
|
|
@ -386,4 +386,5 @@
|
|||
<string name="basalvaluebelowminimum">Basal value below minimum. Profile not set!</string>
|
||||
<string name="actualbg">BG:</string>
|
||||
<string name="lastbg">Last BG:</string>
|
||||
<string name="mdi">MDI</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue