Added options Max Bolus and Max Basal
Little bit of refactoring in Medtronic code
This commit is contained in:
parent
c03b4f6780
commit
2cc4fe4450
9 changed files with 206 additions and 155 deletions
|
@ -28,12 +28,13 @@ import info.nightscout.androidaps.plugins.PumpCommon.driver.PumpDriverInterface;
|
||||||
* Created by andy on 23.04.18.
|
* Created by andy on 23.04.18.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public abstract class PumpPluginAbstract extends PluginBase implements PumpInterface, ConstraintsInterface, ProfileInterface {
|
public abstract class PumpPluginAbstract extends PluginBase implements PumpInterface, ConstraintsInterface {
|
||||||
|
|
||||||
protected boolean fragmentVisible = false;
|
// , ProfileInterface
|
||||||
protected boolean fragmentEnabled = false;
|
//protected boolean fragmentVisible = false;
|
||||||
|
//protected boolean fragmentEnabled = false;
|
||||||
protected boolean pumpServiceRunning = false;
|
protected boolean pumpServiceRunning = false;
|
||||||
private static final String TAG = "PumpPluginAbstract";
|
//private static final String TAG = "PumpPluginAbstract";
|
||||||
//protected PumpStatus pumpStatus;
|
//protected PumpStatus pumpStatus;
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,11 +76,7 @@ public abstract class PumpPluginAbstract extends PluginBase implements PumpInter
|
||||||
// return true;
|
// return true;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean hasFragment() {
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// @Override
|
// @Override
|
||||||
|
@ -88,25 +85,6 @@ public abstract class PumpPluginAbstract extends PluginBase implements PumpInter
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
|
||||||
// if (type == PUMP) {
|
|
||||||
// this.fragmentEnabled = fragmentEnabled;
|
|
||||||
//
|
|
||||||
// if (fragmentEnabled) {
|
|
||||||
// if (!pumpServiceRunning)
|
|
||||||
// startPumpService();
|
|
||||||
// else
|
|
||||||
// Log.d(TAG, "Can't start, Pump service (" + getInternalName() + "is already running.");
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// if (pumpServiceRunning)
|
|
||||||
// stopPumpService();
|
|
||||||
// else
|
|
||||||
// Log.d(TAG, "Can't stop, Pump service (" + getInternalName() + "is already stopped.");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
|
@ -204,17 +182,15 @@ public abstract class PumpPluginAbstract extends PluginBase implements PumpInter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, boolean enforceNew){
|
|
||||||
//return pumpDriver.setTempBasalAbsolute(absoluteRate, durationInMinutes, enforceNew);
|
@Override
|
||||||
// FIXME
|
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
||||||
return null;
|
return pumpDriver.setTempBasalAbsolute(absoluteRate, durationInMinutes, profile, enforceNew);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew){
|
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
||||||
//return pumpDriver.setTempBasalPercent(percent, durationInMinutes, enforceNew);
|
return pumpDriver.setTempBasalPercent(percent, durationInMinutes, profile, enforceNew);
|
||||||
// FIXME
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -342,4 +318,10 @@ public abstract class PumpPluginAbstract extends PluginBase implements PumpInter
|
||||||
return this.pumpStatus.activeProfileName;
|
return this.pumpStatus.activeProfileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PumpEnactResult loadTDDs() {
|
||||||
|
return this.pumpDriver.loadTDDs();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,6 @@ public abstract class PumpStatus {
|
||||||
public abstract String getErrorInfo();
|
public abstract String getErrorInfo();
|
||||||
|
|
||||||
|
|
||||||
|
public abstract void refreshConfiguration();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpMedtronic;
|
package info.nightscout.androidaps.plugins.PumpMedtronic;
|
||||||
|
|
||||||
import com.gxwtech.roundtrip2.ServiceClientConnection;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -13,17 +11,13 @@ import info.nightscout.androidaps.BuildConfig;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
|
||||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.PumpPluginAbstract;
|
import info.nightscout.androidaps.plugins.PumpCommon.PumpPluginAbstract;
|
||||||
import info.nightscout.androidaps.plugins.PumpMedtronic.medtronic.MedtronicPumpDriver;
|
import info.nightscout.androidaps.plugins.PumpMedtronic.medtronic.MedtronicPumpDriver;
|
||||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpDriver;
|
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.SP;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by andy on 23.04.18.
|
* Created by andy on 23.04.18.
|
||||||
|
@ -33,7 +27,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(MedtronicPumpPlugin.class);
|
private static final Logger LOG = LoggerFactory.getLogger(MedtronicPumpPlugin.class);
|
||||||
|
|
||||||
private ServiceClientConnection serviceClientConnection;
|
//private ServiceClientConnection serviceClientConnection;
|
||||||
|
|
||||||
|
|
||||||
public static PumpPluginAbstract getPlugin() {
|
public static PumpPluginAbstract getPlugin() {
|
||||||
|
@ -44,11 +38,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private MedtronicPumpPlugin() {
|
||||||
|
|
||||||
|
|
||||||
public MedtronicPumpPlugin()
|
|
||||||
{
|
|
||||||
super(new MedtronicPumpDriver(), //
|
super(new MedtronicPumpDriver(), //
|
||||||
"MedtronicPump", //
|
"MedtronicPump", //
|
||||||
MedtronicFragment.class.getName(), //
|
MedtronicFragment.class.getName(), //
|
||||||
|
@ -58,36 +48,25 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getInternalName() {
|
protected String getInternalName() {
|
||||||
return "MedtronicPump";
|
return "MedtronicPump";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void startPumpService() {
|
protected void startPumpService() {
|
||||||
|
|
||||||
//serviceClientConnection = new ServiceClientConnection();
|
//serviceClientConnection = new ServiceClientConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void stopPumpService() {
|
protected void stopPumpService() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject getJSONStatus(Profile profile, String profileName) {
|
public JSONObject getJSONStatus(Profile profile, String profileName) {
|
||||||
//if (!SP.getBoolean("virtualpump_uploadstatus", false)) {
|
//if (!SP.getBoolean("virtualpump_uploadstatus", false)) {
|
||||||
|
@ -139,33 +118,16 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//@Override
|
||||||
@Override
|
//public String shortStatus(boolean veryShort) {
|
||||||
public String shortStatus(boolean veryShort) {
|
// return "Medtronic Pump";
|
||||||
return "Medtronic Pump";
|
//}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFakingTempsByExtendedBoluses() {
|
public boolean isFakingTempsByExtendedBoluses() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public PumpEnactResult loadTDDs() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public boolean isEnabled(int type) {
|
|
||||||
// // TODO might need tweaking
|
|
||||||
// if (type == PluginBase.PUMP)
|
|
||||||
// return fragmentEnabled;
|
|
||||||
// else if (type == PluginBase.CONSTRAINTS)
|
|
||||||
// return fragmentEnabled;
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPreferencesId() {
|
public int getPreferencesId() {
|
||||||
|
@ -173,10 +135,4 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public boolean isLoopEnabled() {
|
|
||||||
// // FIXME check if we need to override
|
|
||||||
// return getPumpStatusData().validBasalRateProfileSelectedOnPump;
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,21 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpMedtronic.medtronic;
|
package info.nightscout.androidaps.plugins.PumpMedtronic.medtronic;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.Config;
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
|
import info.nightscout.androidaps.db.Source;
|
||||||
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpCommon.utils.PumpUtil;
|
||||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpDriver;
|
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpDriver;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by andy on 4/28/18.
|
* Created by andy on 4/28/18.
|
||||||
|
@ -10,45 +23,29 @@ import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpDriver;
|
||||||
|
|
||||||
public class MedtronicPumpDriver extends VirtualPumpDriver /*implements PumpInterface*/ {
|
public class MedtronicPumpDriver extends VirtualPumpDriver /*implements PumpInterface*/ {
|
||||||
|
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(MedtronicPumpDriver.class);
|
||||||
|
MedtronicPumpStatus pumpStatusLocal;
|
||||||
|
|
||||||
public MedtronicPumpDriver()
|
public MedtronicPumpDriver()
|
||||||
{
|
{
|
||||||
// bolus
|
pumpStatusLocal = new MedtronicPumpStatus(pumpDescription);
|
||||||
|
pumpStatusLocal.verifyConfiguration();
|
||||||
|
|
||||||
|
this.pumpStatusData = pumpStatusLocal;
|
||||||
|
|
||||||
|
if (pumpStatusLocal.pumpType!=null)
|
||||||
|
PumpUtil.setPumpDescription(pumpDescription, pumpStatusLocal.pumpType);
|
||||||
|
|
||||||
|
if (pumpStatusLocal.maxBasal!=null)
|
||||||
|
pumpDescription.maxTempAbsolute = (pumpStatusLocal.maxBasal!=null) ? pumpStatusLocal.maxBasal : 35.0d;
|
||||||
|
|
||||||
|
// needs to be changed in configuration, after all functionalities are done
|
||||||
pumpDescription.isBolusCapable = true;
|
pumpDescription.isBolusCapable = true;
|
||||||
pumpDescription.bolusStep = 0.1d; // this needs to be reconfigurable
|
|
||||||
|
|
||||||
// TBR
|
|
||||||
pumpDescription.isTempBasalCapable = true;
|
pumpDescription.isTempBasalCapable = true;
|
||||||
pumpDescription.tempBasalStyle = PumpDescription.ABSOLUTE;
|
|
||||||
pumpDescription.maxTempAbsolute = 35.0d;
|
|
||||||
//pumpDescription.maxTempPercent = 200;
|
|
||||||
//pumpDescription.tempPercentStep = 1;
|
|
||||||
pumpDescription.tempDurationStep = 30;
|
|
||||||
pumpDescription.tempMaxDuration = 24 * 60;
|
|
||||||
|
|
||||||
// extended bolus
|
|
||||||
pumpDescription.isExtendedBolusCapable = false;
|
pumpDescription.isExtendedBolusCapable = false;
|
||||||
pumpDescription.extendedBolusStep = 0.1d; // 0 - 25
|
|
||||||
pumpDescription.extendedBolusDurationStep = 30;
|
|
||||||
pumpDescription.extendedBolusMaxDuration = 8 * 60;
|
|
||||||
|
|
||||||
// set basal profile
|
|
||||||
pumpDescription.isSetBasalProfileCapable = true;
|
pumpDescription.isSetBasalProfileCapable = true;
|
||||||
pumpDescription.basalStep = 0.05d;
|
|
||||||
pumpDescription.basalMinimumRate = 0.05d;
|
|
||||||
|
|
||||||
// ?
|
|
||||||
pumpDescription.isRefillingCapable = false;
|
pumpDescription.isRefillingCapable = false;
|
||||||
|
|
||||||
// ?
|
|
||||||
pumpDescription.storesCarbInfo = false;
|
pumpDescription.storesCarbInfo = false;
|
||||||
|
|
||||||
this.pumpStatusData = new MedtronicPumpStatus(pumpDescription);
|
|
||||||
|
|
||||||
|
|
||||||
// take care of validBasalRateProfileSelectedOnPump
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,6 +79,35 @@ public class MedtronicPumpDriver extends VirtualPumpDriver /*implements PumpInte
|
||||||
return super.cancelTempBasal(enforceNew);
|
return super.cancelTempBasal(enforceNew);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
||||||
|
|
||||||
|
TemporaryBasal tempBasal = new TemporaryBasal()
|
||||||
|
.date(System.currentTimeMillis())
|
||||||
|
.absolute(absoluteRate)
|
||||||
|
.duration(durationInMinutes)
|
||||||
|
.source(Source.USER);
|
||||||
|
|
||||||
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
|
result.success = true;
|
||||||
|
result.enacted = true;
|
||||||
|
result.isTempCancel = false;
|
||||||
|
result.absolute = absoluteRate;
|
||||||
|
result.duration = durationInMinutes;
|
||||||
|
result.comment = MainApp.gs(R.string.virtualpump_resultok);
|
||||||
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempBasal);
|
||||||
|
if (Config.logPumpComm)
|
||||||
|
LOG.debug("Setting temp basal absolute: " + result);
|
||||||
|
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
||||||
|
pumpStatusData.setLastDataTimeToNow();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,14 @@ package info.nightscout.androidaps.plugins.PumpMedtronic.medtronic;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.data.PumpStatus;
|
import info.nightscout.androidaps.plugins.PumpCommon.data.PumpStatus;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.PumpMedtronic.medtronic.defs.MedtronicPumpType;
|
import info.nightscout.androidaps.plugins.PumpMedtronic.medtronic.defs.MedtronicPumpType;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
|
@ -30,13 +34,18 @@ public class MedtronicPumpStatus extends PumpStatus {
|
||||||
|
|
||||||
public String errorDescription = null;
|
public String errorDescription = null;
|
||||||
public String serialNumber;
|
public String serialNumber;
|
||||||
public MedtronicPumpType pumpType = null;
|
public PumpType pumpType = null;
|
||||||
public String pumpFrequency = null;
|
public String pumpFrequency = null;
|
||||||
public String rileyLinkAddress = null;
|
public String rileyLinkAddress = null;
|
||||||
|
public Integer maxBolus;
|
||||||
|
public Integer maxBasal;
|
||||||
|
private String[] frequencies;
|
||||||
|
private boolean isFrequencyUS = false;
|
||||||
|
|
||||||
String regexMac = "([\\da-fA-F]{1,2}(?:\\:|$)){6}";
|
String regexMac = "([\\da-fA-F]{1,2}(?:\\:|$)){6}";
|
||||||
String regexSN = "[0-9]{6}";
|
String regexSN = "[0-9]{6}";
|
||||||
|
|
||||||
|
private Map<String,PumpType> medtronicPumpMap = null;
|
||||||
|
|
||||||
|
|
||||||
public MedtronicPumpStatus(PumpDescription pumpDescription)
|
public MedtronicPumpStatus(PumpDescription pumpDescription)
|
||||||
|
@ -47,53 +56,86 @@ public class MedtronicPumpStatus extends PumpStatus {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initSettings() {
|
public void initSettings() {
|
||||||
this.activeProfileName = "A";
|
|
||||||
|
this.activeProfileName = "STD";
|
||||||
this.reservoirRemainingUnits = 75d;
|
this.reservoirRemainingUnits = 75d;
|
||||||
this.batteryRemaining = 75d;
|
this.batteryRemaining = 75d;
|
||||||
|
|
||||||
|
if (this.medtronicPumpMap==null)
|
||||||
|
createMedtronicPumpMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createMedtronicPumpMap() {
|
||||||
|
|
||||||
//
|
medtronicPumpMap = new HashMap<>();
|
||||||
// //public static MedtronicPumpStatus getInstance()
|
medtronicPumpMap.put("512", PumpType.Minimed_512_712);
|
||||||
// {
|
medtronicPumpMap.put("712", PumpType.Minimed_512_712);
|
||||||
// return medtronicPumpStatus;
|
medtronicPumpMap.put("515", PumpType.Minimed_515_715);
|
||||||
// }
|
medtronicPumpMap.put("715", PumpType.Minimed_515_715);
|
||||||
|
|
||||||
|
medtronicPumpMap.put("522", PumpType.Minimed_522_722);
|
||||||
|
medtronicPumpMap.put("722", PumpType.Minimed_522_722);
|
||||||
|
medtronicPumpMap.put("523", PumpType.Minimed_523_723);
|
||||||
|
medtronicPumpMap.put("723", PumpType.Minimed_523_723);
|
||||||
|
medtronicPumpMap.put("554", PumpType.Minimed_554_754_Veo);
|
||||||
|
medtronicPumpMap.put("754", PumpType.Minimed_554_754_Veo);
|
||||||
|
|
||||||
|
frequencies = new String[2];
|
||||||
|
frequencies[0] = MainApp.gs(R.string.medtronic_pump_frequency_us);
|
||||||
|
frequencies[1] = MainApp.gs(R.string.medtronic_pump_frequency_worldwide);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void verifyConfiguration()
|
public void verifyConfiguration()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
if (this.medtronicPumpMap==null)
|
||||||
|
createMedtronicPumpMap();
|
||||||
|
|
||||||
|
|
||||||
this.errorDescription = null;
|
this.errorDescription = null;
|
||||||
|
this.serialNumber = null;
|
||||||
|
this.pumpType = null;
|
||||||
|
this.pumpFrequency = null;
|
||||||
|
this.rileyLinkAddress = null;
|
||||||
|
this.maxBolus = null;
|
||||||
|
this.maxBasal = null;
|
||||||
|
|
||||||
|
|
||||||
String serialNr = SP.getString("pref_medtronic_serial", null);
|
String serialNr = SP.getString("pref_medtronic_serial", null);
|
||||||
|
|
||||||
if (serialNr == null) {
|
if (serialNr == null) {
|
||||||
this.errorDescription = MainApp.sResources.getString(R.string.medtronic_error_serial_not_set);
|
this.errorDescription = MainApp.gs(R.string.medtronic_error_serial_not_set);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (!serialNr.matches(regexSN)) {
|
if (!serialNr.matches(regexSN)) {
|
||||||
this.errorDescription = MainApp.sResources.getString(R.string.medtronic_error_serial_invalid);
|
this.errorDescription = MainApp.gs(R.string.medtronic_error_serial_invalid);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
serialNumber = serialNr;
|
this.serialNumber = serialNr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String pumpType = SP.getString("pref_medtronic_pump_type", null);
|
String pumpType = SP.getString("pref_medtronic_pump_type", null);
|
||||||
|
|
||||||
if (pumpType == null) {
|
if (pumpType == null) {
|
||||||
this.errorDescription = MainApp.sResources.getString(R.string.medtronic_error_pump_type_not_set);
|
this.errorDescription = MainApp.gs(R.string.medtronic_error_pump_type_not_set);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
String pumpTypePart = pumpType.substring(0, 3);
|
String pumpTypePart = pumpType.substring(0, 3);
|
||||||
|
|
||||||
if (!pumpTypePart.matches("[0-9]{3}")) {
|
if (!pumpTypePart.matches("[0-9]{3}")) {
|
||||||
this.errorDescription = MainApp.sResources.getString(R.string.medtronic_error_pump_type_invalid);
|
this.errorDescription = MainApp.gs(R.string.medtronic_error_pump_type_invalid);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
this.pumpType = MedtronicPumpType.getByCode(pumpTypePart);
|
this.pumpType = medtronicPumpMap.get(pumpTypePart);
|
||||||
setDescriptionFromPumpType();
|
|
||||||
|
if (pumpTypePart.startsWith("7"))
|
||||||
|
this.reservoirFullUnits = "300";
|
||||||
|
else
|
||||||
|
this.reservoirFullUnits = "180";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,14 +143,15 @@ public class MedtronicPumpStatus extends PumpStatus {
|
||||||
String pumpFrequency = SP.getString("pref_medtronic_frequency", null);
|
String pumpFrequency = SP.getString("pref_medtronic_frequency", null);
|
||||||
|
|
||||||
if (pumpFrequency == null) {
|
if (pumpFrequency == null) {
|
||||||
this.errorDescription = MainApp.sResources.getString(R.string.medtronic_error_pump_frequency_not_set);
|
this.errorDescription = MainApp.gs(R.string.medtronic_error_pump_frequency_not_set);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (!pumpFrequency.equals("US") && !pumpFrequency.equals("EU")) {
|
if (!pumpFrequency.equals(frequencies[0]) && !pumpFrequency.equals(frequencies[1])) {
|
||||||
this.errorDescription = MainApp.sResources.getString(R.string.medtronic_error_pump_frequency_invalid);
|
this.errorDescription = MainApp.gs(R.string.medtronic_error_pump_frequency_invalid);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
this.pumpFrequency = pumpFrequency;
|
this.pumpFrequency = pumpFrequency;
|
||||||
|
this.isFrequencyUS = pumpFrequency.equals(frequencies[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,15 +159,35 @@ public class MedtronicPumpStatus extends PumpStatus {
|
||||||
String rileyLinkAddress = SP.getString("pref_medtronic_rileylink_mac", null);
|
String rileyLinkAddress = SP.getString("pref_medtronic_rileylink_mac", null);
|
||||||
|
|
||||||
if (rileyLinkAddress == null) {
|
if (rileyLinkAddress == null) {
|
||||||
this.errorDescription = MainApp.sResources.getString(R.string.medtronic_error_rileylink_address_invalid);
|
this.errorDescription = MainApp.gs(R.string.medtronic_error_rileylink_address_invalid);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (!rileyLinkAddress.matches(regexMac)) {
|
if (!rileyLinkAddress.matches(regexMac)) {
|
||||||
this.errorDescription = MainApp.sResources.getString(R.string.medtronic_error_rileylink_address_invalid);
|
this.errorDescription = MainApp.gs(R.string.medtronic_error_rileylink_address_invalid);
|
||||||
} else {
|
} else {
|
||||||
this.rileyLinkAddress = rileyLinkAddress;
|
this.rileyLinkAddress = rileyLinkAddress;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String value = SP.getString("pref_medtronic_max_bolus", "25");
|
||||||
|
|
||||||
|
maxBolus = Integer.parseInt(value);
|
||||||
|
|
||||||
|
if (maxBolus> 25)
|
||||||
|
{
|
||||||
|
SP.putString("pref_medtronic_max_bolus", "25");
|
||||||
|
}
|
||||||
|
|
||||||
|
value = SP.getString("pref_medtronic_max_basal", "35");
|
||||||
|
|
||||||
|
maxBasal = Integer.parseInt(value);
|
||||||
|
|
||||||
|
if (maxBasal> 35)
|
||||||
|
{
|
||||||
|
SP.putString("pref_medtronic_max_basal", "35");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -133,13 +196,6 @@ public class MedtronicPumpStatus extends PumpStatus {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDescriptionFromPumpType() {
|
|
||||||
if (this.pumpType==MedtronicPumpType.Unknown)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this.reservoirFullUnits = "" + this.pumpType.getReservoir();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getErrorInfo()
|
public String getErrorInfo()
|
||||||
{
|
{
|
||||||
|
@ -149,4 +205,10 @@ public class MedtronicPumpStatus extends PumpStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refreshConfiguration() {
|
||||||
|
verifyConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,4 +22,9 @@ public class VirtualPumpStatus extends PumpStatus {
|
||||||
public String getErrorInfo() {
|
public String getErrorInfo() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refreshConfiguration() {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,8 +148,8 @@
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="medtronicPumpFreqArray">
|
<string-array name="medtronicPumpFreqArray">
|
||||||
<item>US</item>
|
<item>@string/medtronic_pump_frequency_us</item>
|
||||||
<item>EU</item>
|
<item>@string/medtronic_pump_frequency_worldwide</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1062,6 +1062,8 @@
|
||||||
<string name="medtronic_serial_number">Pump Serial Number</string>
|
<string name="medtronic_serial_number">Pump Serial Number</string>
|
||||||
<string name="medtronic_pump_type">Pump Type</string>
|
<string name="medtronic_pump_type">Pump Type</string>
|
||||||
<string name="medtronic_pump_frequency">Pump Frequency</string>
|
<string name="medtronic_pump_frequency">Pump Frequency</string>
|
||||||
|
<string name="medtronic_pump_max_bolus">Max Bolus on Pump</string>
|
||||||
|
<string name="medtronic_pump_max_basal">Max Basal on Pump</string>
|
||||||
<string name="medtronic_rileylink_mac_address">RileyLink MAC Address</string>
|
<string name="medtronic_rileylink_mac_address">RileyLink MAC Address</string>
|
||||||
<string name="medtronic_errors">Errors</string>
|
<string name="medtronic_errors">Errors</string>
|
||||||
<string name="medtronic_error_serial_not_set">Serial # not set.</string>
|
<string name="medtronic_error_serial_not_set">Serial # not set.</string>
|
||||||
|
@ -1071,6 +1073,8 @@
|
||||||
<string name="medtronic_error_pump_frequency_not_set">Pump Frequency not set.</string>
|
<string name="medtronic_error_pump_frequency_not_set">Pump Frequency not set.</string>
|
||||||
<string name="medtronic_error_pump_frequency_invalid">Pump Frequency unsupported.</string>
|
<string name="medtronic_error_pump_frequency_invalid">Pump Frequency unsupported.</string>
|
||||||
<string name="medtronic_error_rileylink_address_invalid">RileyLink Address invalid.</string>
|
<string name="medtronic_error_rileylink_address_invalid">RileyLink Address invalid.</string>
|
||||||
|
<string name="medtronic_pump_frequency_us">US (916 MHz)</string>
|
||||||
|
<string name="medtronic_pump_frequency_worldwide">Worldwide (868 Mhz)</string>
|
||||||
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -4,13 +4,6 @@
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="@string/medtronic_name">
|
android:title="@string/medtronic_name">
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:enabled="false"
|
|
||||||
android:key="blescannner"
|
|
||||||
android:title="RileyLink Configuration (maybe)">
|
|
||||||
<intent android:action="info.nightscout.androidaps.plugins.PumpDanaRS.activities.BLEScanActivity" />
|
|
||||||
</Preference>
|
|
||||||
|
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:defaultValue="000000"
|
android:defaultValue="000000"
|
||||||
|
@ -35,6 +28,29 @@
|
||||||
android:selectable="true"
|
android:selectable="true"
|
||||||
android:title="@string/medtronic_pump_frequency" />
|
android:title="@string/medtronic_pump_frequency" />
|
||||||
|
|
||||||
|
<EditTextPreference
|
||||||
|
android:defaultValue="35"
|
||||||
|
android:key="pref_medtronic_max_basal"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:inputType="number"
|
||||||
|
android:title="@string/medtronic_pump_max_basal" />
|
||||||
|
|
||||||
|
<EditTextPreference
|
||||||
|
android:defaultValue="25"
|
||||||
|
android:key="pref_medtronic_max_bolus"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:inputType="number"
|
||||||
|
android:title="@string/medtronic_pump_max_bolus" />
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:enabled="false"
|
||||||
|
android:key="rileylink_scanner"
|
||||||
|
android:title="RileyLink Configuration">
|
||||||
|
<intent android:action="info.nightscout.androidaps.plugins.PumpDanaRS.activities.BLEScanActivity" />
|
||||||
|
</Preference>
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:defaultValue="xx:xx:xx:xx:xx:xx"
|
android:defaultValue="xx:xx:xx:xx:xx:xx"
|
||||||
android:editable="false"
|
android:editable="false"
|
||||||
|
|
Loading…
Reference in a new issue