- minor changes
This commit is contained in:
parent
02a8519f28
commit
f4648e44b2
|
@ -1,28 +1,30 @@
|
|||
package info.nightscout.androidaps.plugins.PumpCommon;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.data.ProfileStore;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.PumpCommon.data.PumpStatus;
|
||||
import info.nightscout.androidaps.plugins.PumpCommon.driver.PumpDriverInterface;
|
||||
import info.nightscout.androidaps.plugins.PumpMedtronic.MedtronicPumpPlugin;
|
||||
|
||||
/**
|
||||
* Created by andy on 23.04.18.
|
||||
*/
|
||||
|
||||
public abstract class PumpPluginAbstract implements PluginBase, PumpInterface {
|
||||
public abstract class PumpPluginAbstract implements PluginBase, PumpInterface, ConstraintsInterface, ProfileInterface {
|
||||
|
||||
protected boolean fragmentVisible = false;
|
||||
protected boolean fragmentEnabled = false;
|
||||
|
@ -34,11 +36,14 @@ public abstract class PumpPluginAbstract implements PluginBase, PumpInterface {
|
|||
|
||||
protected static PumpPluginAbstract plugin = null;
|
||||
protected PumpDriverInterface pumpDriver;
|
||||
protected PumpStatus pumpStatus;
|
||||
|
||||
|
||||
protected PumpPluginAbstract(PumpDriverInterface pumpDriverInterface)
|
||||
protected PumpPluginAbstract(PumpDriverInterface pumpDriverInterface, //
|
||||
String internalName)
|
||||
{
|
||||
this.pumpDriver = pumpDriverInterface;
|
||||
this.pumpStatus = this.pumpDriver.getPumpStatusData();
|
||||
}
|
||||
|
||||
|
||||
|
@ -95,7 +100,8 @@ public abstract class PumpPluginAbstract implements PluginBase, PumpInterface {
|
|||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == PUMP) this.fragmentVisible = fragmentVisible;
|
||||
if (type == PUMP)
|
||||
this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
protected abstract String getInternalName();
|
||||
|
@ -246,4 +252,79 @@ public abstract class PumpPluginAbstract implements PluginBase, PumpInterface {
|
|||
}
|
||||
|
||||
|
||||
// Constraints interface
|
||||
|
||||
@Override
|
||||
public boolean isLoopEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClosedModeEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutosensModeEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAMAModeEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSMBModeEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double applyBasalConstraints(Double absoluteRate) {
|
||||
this.pumpStatus.constraintBasalRateAbsolute = absoluteRate;
|
||||
return absoluteRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer applyBasalConstraints(Integer percentRate) {
|
||||
this.pumpStatus.constraintBasalRatePercent = percentRate;
|
||||
return percentRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double applyBolusConstraints(Double insulin) {
|
||||
this.pumpStatus.constraintBolus = insulin;
|
||||
return insulin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer applyCarbsConstraints(Integer carbs) {
|
||||
this.pumpStatus.constraintCarbs = carbs;
|
||||
return carbs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double applyMaxIOBConstraints(Double maxIob) {
|
||||
this.pumpStatus.constraintMaxIob = maxIob;
|
||||
return maxIob;
|
||||
}
|
||||
|
||||
// Profile interface
|
||||
|
||||
@Nullable
|
||||
public ProfileStore getProfile()
|
||||
{
|
||||
return this.pumpStatus.profileStore;
|
||||
}
|
||||
|
||||
public String getUnits()
|
||||
{
|
||||
return this.pumpStatus.units;
|
||||
}
|
||||
|
||||
public String getProfileName()
|
||||
{
|
||||
return this.pumpStatus.activeProfileName;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.PumpCommon.data;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.data.ProfileStore;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
|
||||
/**
|
||||
|
@ -13,12 +14,25 @@ public abstract class PumpStatus {
|
|||
public Date lastDataTime;
|
||||
public long lastConnection = 0L;
|
||||
public Date lastBolusTime;
|
||||
public String activeProfile = "0";
|
||||
public String activeProfileName = "0";
|
||||
public double reservoirRemainingUnits = 0d;
|
||||
public String reservoirFullUnits = "???";
|
||||
public double batteryRemaining = 0d;
|
||||
public String iob = "0";
|
||||
protected PumpDescription pumpDescription;
|
||||
public boolean validBasalRateProfileSelectedOnPump = true;
|
||||
|
||||
public ProfileStore profileStore;
|
||||
public String units; // Constants.MGDL or Constants.MMOL
|
||||
|
||||
public Double constraintBasalRateAbsolute;
|
||||
public Integer constraintBasalRatePercent;
|
||||
public Double constraintBolus;
|
||||
public Integer constraintCarbs;
|
||||
public Double constraintMaxIob;
|
||||
|
||||
|
||||
|
||||
|
||||
public PumpStatus(PumpDescription pumpDescription)
|
||||
{
|
||||
|
|
|
@ -35,7 +35,6 @@ import info.nightscout.androidaps.plugins.PumpDanaR.Dialogs.ProfileViewDialog;
|
|||
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRHistoryActivity;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRStatsActivity;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus;
|
||||
import info.nightscout.androidaps.plugins.PumpMedtronic.medtronic.MedtronicPumpStatus;
|
||||
import info.nightscout.androidaps.queue.events.EventQueueChanged;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
|
@ -224,7 +223,7 @@ public class MedtronicFragment extends SubscriberFragment {
|
|||
|
||||
//dailyUnitsView.setText(DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U");
|
||||
//SetWarnColor.setColor(dailyUnitsView, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75d, pump.maxDailyTotalUnits * 0.9d);
|
||||
basaBasalRateView.setText("(" + (pump.activeProfile) + ") " + DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) + " U/h");
|
||||
basaBasalRateView.setText("(" + (pump.activeProfileName) + ") " + DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) + " U/h");
|
||||
|
||||
if (ConfigBuilderPlugin.getActivePump().isFakingTempsByExtendedBoluses()) {
|
||||
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
|
||||
|
|
|
@ -29,19 +29,11 @@ import info.nightscout.utils.SP;
|
|||
|
||||
public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInterface {
|
||||
|
||||
//private static final String TAG = "MedtronicPumpPlugin";
|
||||
private static Logger LOG = LoggerFactory.getLogger(MedtronicPumpPlugin.class);
|
||||
|
||||
//private static final PumpEnactResult OPERATION_NOT_SUPPORTED = new PumpEnactResult()
|
||||
// .success(false).enacted(false).comment(MainApp.gs(R.string.pump_operation_not_supported_by_pump));
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MedtronicPumpPlugin.class);
|
||||
|
||||
private ServiceClientConnection serviceClientConnection;
|
||||
|
||||
|
||||
//private static MedtronicPumpPlugin plugin = null;
|
||||
//private MedtronicPumpStatus medtronicPumpStatus = MedtronicPumpStatus.getInstance();
|
||||
|
||||
|
||||
public static PumpPluginAbstract getPlugin() {
|
||||
|
||||
if (plugin == null)
|
||||
|
@ -49,14 +41,15 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
|||
return plugin;
|
||||
}
|
||||
|
||||
//
|
||||
// private Date lastDataTime;
|
||||
|
||||
|
||||
|
||||
|
||||
public MedtronicPumpPlugin()
|
||||
{
|
||||
super(new MedtronicPumpDriver());
|
||||
super(new MedtronicPumpDriver(), //
|
||||
"MedtronicPump"//
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
@ -177,4 +170,12 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
|||
public int getPreferencesId() {
|
||||
return R.xml.pref_medtronic;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isLoopEnabled() {
|
||||
// FIXME check if we need to override
|
||||
return getPumpStatusData().validBasalRateProfileSelectedOnPump;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.PumpMedtronic.medtronic;
|
||||
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpDriver;
|
||||
|
||||
|
@ -43,5 +44,44 @@ public class MedtronicPumpDriver extends VirtualPumpDriver /*implements PumpInte
|
|||
pumpDescription.storesCarbInfo = false;
|
||||
|
||||
this.pumpStatusData = new MedtronicPumpStatus(pumpDescription);
|
||||
|
||||
|
||||
// take care of validBasalRateProfileSelectedOnPump
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnecting() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(String reason) {
|
||||
// connection is established by each command specifically
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopConnecting() {
|
||||
// we're not doing that
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PumpEnactResult cancelTempBasal(boolean enforceNew)
|
||||
{
|
||||
|
||||
// FIXME
|
||||
// send Cancel Temp Basal
|
||||
return super.cancelTempBasal(enforceNew);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
package info.nightscout.androidaps.plugins.PumpMedtronic.medtronic;
|
||||
|
||||
import android.service.autofill.RegexValidator;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
|
@ -27,7 +23,7 @@ public class MedtronicPumpStatus extends PumpStatus {
|
|||
//public Date lastDataTime;
|
||||
//public long lastConnection = 0L;
|
||||
//public Date lastBolusTime;
|
||||
//public String activeProfile = "A";
|
||||
//public String activeProfileName = "A";
|
||||
//public double reservoirRemainingUnits = 50d;
|
||||
//public double batteryRemaining = 75d;
|
||||
//public String iob = "0";
|
||||
|
@ -51,7 +47,7 @@ public class MedtronicPumpStatus extends PumpStatus {
|
|||
|
||||
@Override
|
||||
public void initSettings() {
|
||||
this.activeProfile = "A";
|
||||
this.activeProfileName = "A";
|
||||
this.reservoirRemainingUnits = 75d;
|
||||
this.batteryRemaining = 75d;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue