Initial commit after dev was merged into here
This commit is contained in:
parent
421946269a
commit
af56304669
|
@ -162,6 +162,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
||||||
addPreferencesFromResourceIfEnabled(DanaRSPlugin.getPlugin(), PluginType.PUMP);
|
addPreferencesFromResourceIfEnabled(DanaRSPlugin.getPlugin(), PluginType.PUMP);
|
||||||
addPreferencesFromResourceIfEnabled(InsightPlugin.getPlugin(), PluginType.PUMP);
|
addPreferencesFromResourceIfEnabled(InsightPlugin.getPlugin(), PluginType.PUMP);
|
||||||
addPreferencesFromResourceIfEnabled(ComboPlugin.getPlugin(), PluginType.PUMP);
|
addPreferencesFromResourceIfEnabled(ComboPlugin.getPlugin(), PluginType.PUMP);
|
||||||
|
addPreferencesFromResourceIfEnabled(MedtronicPumpPlugin.getPlugin(), PluginType.PUMP);
|
||||||
|
|
||||||
if (DanaRPlugin.getPlugin().isEnabled(PluginType.PROFILE)
|
if (DanaRPlugin.getPlugin().isEnabled(PluginType.PROFILE)
|
||||||
|| DanaRKoreanPlugin.getPlugin().isEnabled(PluginType.PROFILE)
|
|| DanaRKoreanPlugin.getPlugin().isEnabled(PluginType.PROFILE)
|
||||||
|
@ -175,7 +176,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
||||||
addPreferencesFromResourceIfEnabled(VirtualPumpPlugin.getPlugin(), PluginType.PUMP);
|
addPreferencesFromResourceIfEnabled(VirtualPumpPlugin.getPlugin(), PluginType.PUMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
addPreferencesFromResourceIfEnabled(MedtronicPumpPlugin.getPlugin(), PluginBase.PUMP);
|
|
||||||
|
|
||||||
addPreferencesFromResourceIfEnabled(InsulinOrefFreePeakPlugin.getPlugin(), PluginType.INSULIN);
|
addPreferencesFromResourceIfEnabled(InsulinOrefFreePeakPlugin.getPlugin(), PluginType.INSULIN);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
package info.nightscout.androidaps.interfaces;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 08.12.2016.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class PumpDescription {
|
||||||
|
public static final int NONE = 0;
|
||||||
|
public static final int PERCENT = 0x01;
|
||||||
|
public static final int ABSOLUTE = 0x02;
|
||||||
|
|
||||||
|
public boolean isBolusCapable = true;
|
||||||
|
public double bolusStep = 0.1d;
|
||||||
|
|
||||||
|
public boolean isExtendedBolusCapable = true;
|
||||||
|
public double extendedBolusStep = 0.1d;
|
||||||
|
public double extendedBolusDurationStep = 30;
|
||||||
|
public double extendedBolusMaxDuration = 12 * 60;
|
||||||
|
|
||||||
|
public boolean isTempBasalCapable = true;
|
||||||
|
public int tempBasalStyle = PERCENT;
|
||||||
|
|
||||||
|
public int maxTempPercent = 200;
|
||||||
|
public int tempPercentStep = 10;
|
||||||
|
|
||||||
|
public double maxTempAbsolute = 10;
|
||||||
|
public double tempAbsoluteStep = 0.05d;
|
||||||
|
|
||||||
|
public int tempDurationStep = 60;
|
||||||
|
public boolean tempDurationStep15mAllowed = false;
|
||||||
|
public boolean tempDurationStep30mAllowed = false;
|
||||||
|
public int tempMaxDuration = 12 * 60;
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isSetBasalProfileCapable = true;
|
||||||
|
public double basalStep = 0.01d;
|
||||||
|
public double basalMinimumRate = 0.04d;
|
||||||
|
|
||||||
|
public boolean isRefillingCapable = false;
|
||||||
|
|
||||||
|
public boolean storesCarbInfo = true;
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
|
||||||
|
public void resetSettings()
|
||||||
|
{
|
||||||
|
isBolusCapable = true;
|
||||||
|
bolusStep = 0.1d;
|
||||||
|
|
||||||
|
isExtendedBolusCapable = true;
|
||||||
|
extendedBolusStep = 0.1d;
|
||||||
|
extendedBolusDurationStep = 30;
|
||||||
|
extendedBolusMaxDuration = 12 * 60;
|
||||||
|
|
||||||
|
isTempBasalCapable = true;
|
||||||
|
tempBasalStyle = PERCENT;
|
||||||
|
|
||||||
|
maxTempPercent = 200;
|
||||||
|
tempPercentStep = 10;
|
||||||
|
|
||||||
|
maxTempAbsolute = 10;
|
||||||
|
tempAbsoluteStep = 0.05d;
|
||||||
|
|
||||||
|
tempDurationStep = 60;
|
||||||
|
tempMaxDuration = 12 * 60;
|
||||||
|
|
||||||
|
|
||||||
|
isSetBasalProfileCapable = true;
|
||||||
|
basalStep = 0.01d;
|
||||||
|
basalMinimumRate = 0.04d;
|
||||||
|
|
||||||
|
isRefillingCapable = false;
|
||||||
|
|
||||||
|
storesCarbInfo = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
=======
|
||||||
|
public boolean is30minBasalRatesCapable = false;
|
||||||
|
|
||||||
|
public boolean supportsTDDs = false;
|
||||||
|
public boolean needsManualTDDLoad = true;
|
||||||
|
>>>>>>> dev
|
||||||
|
}
|
|
@ -8,15 +8,19 @@ import org.json.JSONObject;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.ProfileStore;
|
import info.nightscout.androidaps.data.ProfileStore;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
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.PluginDescription;
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpCombo.ComboFragment;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.data.PumpStatus;
|
import info.nightscout.androidaps.plugins.PumpCommon.data.PumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.driver.PumpDriverInterface;
|
import info.nightscout.androidaps.plugins.PumpCommon.driver.PumpDriverInterface;
|
||||||
|
|
||||||
|
@ -24,7 +28,7 @@ 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 implements PluginBase, PumpInterface, ConstraintsInterface, ProfileInterface {
|
public abstract class PumpPluginAbstract extends PluginBase implements PumpInterface, ConstraintsInterface, ProfileInterface {
|
||||||
|
|
||||||
protected boolean fragmentVisible = false;
|
protected boolean fragmentVisible = false;
|
||||||
protected boolean fragmentEnabled = false;
|
protected boolean fragmentEnabled = false;
|
||||||
|
@ -40,69 +44,76 @@ public abstract class PumpPluginAbstract implements PluginBase, PumpInterface, C
|
||||||
|
|
||||||
|
|
||||||
protected PumpPluginAbstract(PumpDriverInterface pumpDriverInterface, //
|
protected PumpPluginAbstract(PumpDriverInterface pumpDriverInterface, //
|
||||||
String internalName)
|
String internalName, //
|
||||||
|
String fragmentClassName, //
|
||||||
|
int pluginName, //
|
||||||
|
int pluginShortName)
|
||||||
{
|
{
|
||||||
|
super(new PluginDescription()
|
||||||
|
.mainType(PluginType.PUMP)
|
||||||
|
.fragmentClass(fragmentClassName)
|
||||||
|
.pluginName(pluginName)
|
||||||
|
.shortName(pluginShortName)
|
||||||
|
);
|
||||||
|
|
||||||
this.pumpDriver = pumpDriverInterface;
|
this.pumpDriver = pumpDriverInterface;
|
||||||
this.pumpStatus = this.pumpDriver.getPumpStatusData();
|
this.pumpStatus = this.pumpDriver.getPumpStatusData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getType() {
|
|
||||||
return PluginBase.PUMP;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isVisibleInTabs(int type) {
|
// @Override
|
||||||
return type == PUMP && fragmentVisible;
|
// public boolean isVisibleInTabs(int type) {
|
||||||
}
|
// return type == PUMP && fragmentVisible;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public boolean canBeHidden(int type) {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public boolean hasFragment() {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public boolean showInList(int type) {
|
||||||
|
// return type == PUMP;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public boolean canBeHidden(int type) {
|
// public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||||
return true;
|
// 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
|
||||||
public boolean hasFragment() {
|
// public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||||
return true;
|
// if (type == PUMP)
|
||||||
}
|
// this.fragmentVisible = fragmentVisible;
|
||||||
|
// }
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean showInList(int type) {
|
|
||||||
return type == PUMP;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@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
|
|
||||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
|
||||||
if (type == PUMP)
|
|
||||||
this.fragmentVisible = fragmentVisible;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract String getInternalName();
|
protected abstract String getInternalName();
|
||||||
|
|
||||||
|
@ -194,12 +205,16 @@ public abstract class PumpPluginAbstract implements PluginBase, PumpInterface, C
|
||||||
|
|
||||||
|
|
||||||
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, boolean enforceNew){
|
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, boolean enforceNew){
|
||||||
return pumpDriver.setTempBasalAbsolute(absoluteRate, durationInMinutes, enforceNew);
|
//return pumpDriver.setTempBasalAbsolute(absoluteRate, durationInMinutes, enforceNew);
|
||||||
|
// FIXME
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew){
|
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew){
|
||||||
return pumpDriver.setTempBasalPercent(percent, durationInMinutes, enforceNew);
|
//return pumpDriver.setTempBasalPercent(percent, durationInMinutes, enforceNew);
|
||||||
|
// FIXME
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -222,8 +237,8 @@ public abstract class PumpPluginAbstract implements PluginBase, PumpInterface, C
|
||||||
// Status to be passed to NS
|
// Status to be passed to NS
|
||||||
|
|
||||||
|
|
||||||
public JSONObject getJSONStatus(){
|
public JSONObject getJSONStatus(Profile profile, String profileName){
|
||||||
return pumpDriver.getJSONStatus();
|
return pumpDriver.getJSONStatus( profile, profileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -254,60 +269,60 @@ public abstract class PumpPluginAbstract implements PluginBase, PumpInterface, C
|
||||||
|
|
||||||
// Constraints interface
|
// Constraints interface
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public boolean isLoopEnabled() {
|
// public boolean isLoopEnabled() {
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public boolean isClosedModeEnabled() {
|
// public boolean isClosedModeEnabled() {
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public boolean isAutosensModeEnabled() {
|
// public boolean isAutosensModeEnabled() {
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public boolean isAMAModeEnabled() {
|
// public boolean isAMAModeEnabled() {
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public boolean isSMBModeEnabled() {
|
// public boolean isSMBModeEnabled() {
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public Double applyBasalConstraints(Double absoluteRate) {
|
// public Double applyBasalConstraints(Double absoluteRate) {
|
||||||
this.pumpStatus.constraintBasalRateAbsolute = absoluteRate;
|
// this.pumpStatus.constraintBasalRateAbsolute = absoluteRate;
|
||||||
return absoluteRate;
|
// return absoluteRate;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public Integer applyBasalConstraints(Integer percentRate) {
|
// public Integer applyBasalConstraints(Integer percentRate) {
|
||||||
this.pumpStatus.constraintBasalRatePercent = percentRate;
|
// this.pumpStatus.constraintBasalRatePercent = percentRate;
|
||||||
return percentRate;
|
// return percentRate;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public Double applyBolusConstraints(Double insulin) {
|
// public Double applyBolusConstraints(Double insulin) {
|
||||||
this.pumpStatus.constraintBolus = insulin;
|
// this.pumpStatus.constraintBolus = insulin;
|
||||||
return insulin;
|
// return insulin;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public Integer applyCarbsConstraints(Integer carbs) {
|
// public Integer applyCarbsConstraints(Integer carbs) {
|
||||||
this.pumpStatus.constraintCarbs = carbs;
|
// this.pumpStatus.constraintCarbs = carbs;
|
||||||
return carbs;
|
// return carbs;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public Double applyMaxIOBConstraints(Double maxIob) {
|
// public Double applyMaxIOBConstraints(Double maxIob) {
|
||||||
this.pumpStatus.constraintMaxIob = maxIob;
|
// this.pumpStatus.constraintMaxIob = maxIob;
|
||||||
return maxIob;
|
// return maxIob;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Profile interface
|
// Profile interface
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,8 @@ public class PumpUtil {
|
||||||
|
|
||||||
pumpDescription.isRefillingCapable = pumpCapability.hasCapability(PumpCapability.Refill);
|
pumpDescription.isRefillingCapable = pumpCapability.hasCapability(PumpCapability.Refill);
|
||||||
pumpDescription.storesCarbInfo = pumpCapability.hasCapability(PumpCapability.StoreCarbInfo);
|
pumpDescription.storesCarbInfo = pumpCapability.hasCapability(PumpCapability.StoreCarbInfo);
|
||||||
|
|
||||||
|
setPumpDescription(pumpDescription, PumpType.AccuChekCombo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,9 @@ import info.nightscout.androidaps.plugins.PumpCommon.data.PumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.Dialogs.ProfileViewDialog;
|
import info.nightscout.androidaps.plugins.PumpDanaR.Dialogs.ProfileViewDialog;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRHistoryActivity;
|
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.PumpDanaR.events.EventDanaRNewStatus;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.queue.events.EventQueueChanged;
|
import info.nightscout.androidaps.queue.events.EventQueueChanged;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
@ -133,10 +134,10 @@ public class MedtronicFragment extends SubscriberFragment {
|
||||||
profileViewDialog.show(manager, "ProfileViewDialog");
|
profileViewDialog.show(manager, "ProfileViewDialog");
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.medtronic_stats)
|
//@OnClick(R.id.medtronic_stats)
|
||||||
void onStatsClick() {
|
//void onStatsClick() {
|
||||||
startActivity(new Intent(getContext(), DanaRStatsActivity.class));
|
// startActivity(new Intent(getContext(), DanaRStatsActivity.class));
|
||||||
}
|
//}
|
||||||
|
|
||||||
@OnClick(R.id.medtronic_btconnection)
|
@OnClick(R.id.medtronic_btconnection)
|
||||||
void onBtConnectionClick() {
|
void onBtConnectionClick() {
|
||||||
|
@ -226,20 +227,24 @@ public class MedtronicFragment extends SubscriberFragment {
|
||||||
basaBasalRateView.setText("(" + (pump.activeProfileName) + ") " + DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) + " U/h");
|
basaBasalRateView.setText("(" + (pump.activeProfileName) + ") " + DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) + " U/h");
|
||||||
|
|
||||||
if (ConfigBuilderPlugin.getActivePump().isFakingTempsByExtendedBoluses()) {
|
if (ConfigBuilderPlugin.getActivePump().isFakingTempsByExtendedBoluses()) {
|
||||||
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
|
if (TreatmentsPlugin.getPlugin().isInHistoryRealTempBasalInProgress()) {
|
||||||
tempBasalView.setText(MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
|
tempBasalView.setText(TreatmentsPlugin.getPlugin().getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
|
||||||
} else {
|
} else {
|
||||||
tempBasalView.setText("");
|
tempBasalView.setText("");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// v2 plugin
|
// v2 plugin
|
||||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
|
||||||
tempBasalView.setText(MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
|
tempBasalView.setText(TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
|
||||||
} else {
|
} else {
|
||||||
tempBasalView.setText("");
|
tempBasalView.setText("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
reservoirView.setText(DecimalFormatter.to0Decimal(pump.reservoirRemainingUnits) + " / " + pump.reservoirFullUnits + " U");
|
reservoirView.setText(DecimalFormatter.to0Decimal(pump.reservoirRemainingUnits) + " / " + pump.reservoirFullUnits + " U");
|
||||||
SetWarnColor.setColorInverse(reservoirView, pump.reservoirRemainingUnits, 50d, 20d);
|
SetWarnColor.setColorInverse(reservoirView, pump.reservoirRemainingUnits, 50d, 20d);
|
||||||
batteryView.setText("{fa-battery-" + (pump.batteryRemaining / 25) + "}");
|
batteryView.setText("{fa-battery-" + (pump.batteryRemaining / 25) + "}");
|
||||||
|
|
|
@ -12,6 +12,7 @@ import java.util.Date;
|
||||||
import info.nightscout.androidaps.BuildConfig;
|
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.PumpEnactResult;
|
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;
|
||||||
|
@ -20,6 +21,7 @@ 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.PumpVirtual.VirtualPumpDriver;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
|
@ -48,7 +50,10 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
public MedtronicPumpPlugin()
|
public MedtronicPumpPlugin()
|
||||||
{
|
{
|
||||||
super(new MedtronicPumpDriver(), //
|
super(new MedtronicPumpDriver(), //
|
||||||
"MedtronicPump"//
|
"MedtronicPump", //
|
||||||
|
MedtronicFragment.class.getName(), //
|
||||||
|
R.string.medtronic_name, //
|
||||||
|
R.string.medtronic_name_short //
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,14 +78,18 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject getJSONStatus() {
|
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject getJSONStatus(Profile profile, String profileName) {
|
||||||
//if (!SP.getBoolean("virtualpump_uploadstatus", false)) {
|
//if (!SP.getBoolean("virtualpump_uploadstatus", false)) {
|
||||||
// return null;
|
// return null;
|
||||||
//}
|
//}
|
||||||
|
@ -96,18 +105,21 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
extended.put("ActiveProfile", MainApp.getConfigBuilder().getProfileName());
|
extended.put("ActiveProfile", MainApp.getConfigBuilder().getProfileName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
TemporaryBasal tb = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
|
||||||
|
TemporaryBasal tb = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (tb != null) {
|
if (tb != null) {
|
||||||
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(System.currentTimeMillis()));
|
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(System.currentTimeMillis(), profile));
|
||||||
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date));
|
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date));
|
||||||
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
|
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
|
||||||
}
|
}
|
||||||
ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
|
||||||
|
ExtendedBolus eb = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||||
if (eb != null) {
|
if (eb != null) {
|
||||||
extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate());
|
extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate());
|
||||||
extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date));
|
extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date));
|
||||||
extended.put("ExtendedBolusRemaining", eb.getPlannedRemainingMinutes());
|
extended.put("ExtendedBolusRemaining", eb.getPlannedRemainingMinutes());
|
||||||
}
|
}
|
||||||
|
|
||||||
status.put("timestamp", DateUtil.toISOString(new Date()));
|
status.put("timestamp", DateUtil.toISOString(new Date()));
|
||||||
|
|
||||||
pump.put("battery", battery);
|
pump.put("battery", battery);
|
||||||
|
@ -138,32 +150,21 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFragmentClass()
|
public PumpEnactResult loadTDDs() {
|
||||||
{
|
return null;
|
||||||
return MedtronicFragment.class.getName();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "Medtronic";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public String getNameShort() {
|
// public boolean isEnabled(int type) {
|
||||||
return "MEDT";
|
// // TODO might need tweaking
|
||||||
}
|
// if (type == PluginBase.PUMP)
|
||||||
|
// return fragmentEnabled;
|
||||||
@Override
|
// else if (type == PluginBase.CONSTRAINTS)
|
||||||
public boolean isEnabled(int type) {
|
// return fragmentEnabled;
|
||||||
// TODO might need tweaking
|
// return false;
|
||||||
if (type == PluginBase.PUMP)
|
// }
|
||||||
return fragmentEnabled;
|
|
||||||
else if (type == PluginBase.CONSTRAINTS)
|
|
||||||
return fragmentEnabled;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -172,10 +173,10 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public boolean isLoopEnabled() {
|
// public boolean isLoopEnabled() {
|
||||||
// FIXME check if we need to override
|
// // FIXME check if we need to override
|
||||||
return getPumpStatusData().validBasalRateProfileSelectedOnPump;
|
// return getPumpStatusData().validBasalRateProfileSelectedOnPump;
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.driver.PumpDriverAbstract;
|
import info.nightscout.androidaps.plugins.PumpCommon.driver.PumpDriverAbstract;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.driver.PumpDriverInterface;
|
import info.nightscout.androidaps.plugins.PumpCommon.driver.PumpDriverInterface;
|
||||||
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
|
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.NSUpload;
|
import info.nightscout.utils.NSUpload;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
@ -110,6 +111,8 @@ public class VirtualPumpDriver extends PumpDriverAbstract {
|
||||||
return (Config.NSCLIENT || Config.G5UPLOADER) && fromNSAreCommingFakedExtendedBoluses;
|
return (Config.NSCLIENT || Config.G5UPLOADER) && fromNSAreCommingFakedExtendedBoluses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInitialized() {
|
public boolean isInitialized() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -180,11 +183,12 @@ public class VirtualPumpDriver extends PumpDriverAbstract {
|
||||||
public double getBaseBasalRate() {
|
public double getBaseBasalRate() {
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
if (profile != null)
|
if (profile != null)
|
||||||
return profile.getBasal() != null ? profile.getBasal() : 0d;
|
return profile.getBasal();
|
||||||
else
|
else
|
||||||
return 0d;
|
return 0d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
|
@ -192,21 +196,21 @@ public class VirtualPumpDriver extends PumpDriverAbstract {
|
||||||
result.bolusDelivered = detailedBolusInfo.insulin;
|
result.bolusDelivered = detailedBolusInfo.insulin;
|
||||||
result.carbsDelivered = detailedBolusInfo.carbs;
|
result.carbsDelivered = detailedBolusInfo.carbs;
|
||||||
result.enacted = result.bolusDelivered > 0 || result.carbsDelivered > 0;
|
result.enacted = result.bolusDelivered > 0 || result.carbsDelivered > 0;
|
||||||
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
|
result.comment = MainApp.gs(R.string.virtualpump_resultok);
|
||||||
|
|
||||||
Double delivering = 0d;
|
Double delivering = 0d;
|
||||||
|
|
||||||
while (delivering < detailedBolusInfo.insulin) {
|
while (delivering < detailedBolusInfo.insulin) {
|
||||||
SystemClock.sleep(200);
|
SystemClock.sleep(200);
|
||||||
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
|
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
|
||||||
bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.bolusdelivering), delivering);
|
bolusingEvent.status = String.format(MainApp.gs(R.string.bolusdelivering), delivering);
|
||||||
bolusingEvent.percent = Math.min((int) (delivering / detailedBolusInfo.insulin * 100), 100);
|
bolusingEvent.percent = Math.min((int) (delivering / detailedBolusInfo.insulin * 100), 100);
|
||||||
MainApp.bus().post(bolusingEvent);
|
MainApp.bus().post(bolusingEvent);
|
||||||
delivering += 0.1d;
|
delivering += 0.1d;
|
||||||
}
|
}
|
||||||
SystemClock.sleep(200);
|
SystemClock.sleep(200);
|
||||||
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
|
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
|
||||||
bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.bolusdelivered), detailedBolusInfo.insulin);
|
bolusingEvent.status = String.format(MainApp.gs(R.string.bolusdelivered), detailedBolusInfo.insulin);
|
||||||
bolusingEvent.percent = 100;
|
bolusingEvent.percent = 100;
|
||||||
MainApp.bus().post(bolusingEvent);
|
MainApp.bus().post(bolusingEvent);
|
||||||
SystemClock.sleep(1000);
|
SystemClock.sleep(1000);
|
||||||
|
@ -214,32 +218,34 @@ public class VirtualPumpDriver extends PumpDriverAbstract {
|
||||||
LOG.debug("Delivering treatment insulin: " + detailedBolusInfo.insulin + "U carbs: " + detailedBolusInfo.carbs + "g " + result);
|
LOG.debug("Delivering treatment insulin: " + detailedBolusInfo.insulin + "U carbs: " + detailedBolusInfo.carbs + "g " + result);
|
||||||
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
||||||
pumpStatusData.setLastDataTimeToNow();
|
pumpStatusData.setLastDataTimeToNow();
|
||||||
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopBolusDelivering() {
|
public void stopBolusDelivering() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, boolean enforceNew) {
|
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
||||||
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
|
TemporaryBasal tempBasal = new TemporaryBasal()
|
||||||
TemporaryBasal tempBasal = new TemporaryBasal();
|
.date(System.currentTimeMillis())
|
||||||
tempBasal.date = System.currentTimeMillis();
|
.absolute(absoluteRate)
|
||||||
tempBasal.isAbsolute = true;
|
.duration(durationInMinutes)
|
||||||
tempBasal.absoluteRate = absoluteRate;
|
.source(Source.USER);
|
||||||
tempBasal.durationInMinutes = durationInMinutes;
|
|
||||||
tempBasal.source = Source.USER;
|
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
result.isTempCancel = false;
|
result.isTempCancel = false;
|
||||||
result.absolute = absoluteRate;
|
result.absolute = absoluteRate;
|
||||||
result.duration = durationInMinutes;
|
result.duration = durationInMinutes;
|
||||||
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
|
result.comment = MainApp.gs(R.string.virtualpump_resultok);
|
||||||
treatmentsInterface.addToHistoryTempBasal(tempBasal);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempBasal);
|
||||||
if (Config.logPumpComm)
|
if (Config.logPumpComm)
|
||||||
LOG.debug("Setting temp basal absolute: " + result);
|
LOG.debug("Setting temp basal absolute: " + result);
|
||||||
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
||||||
|
@ -247,40 +253,39 @@ public class VirtualPumpDriver extends PumpDriverAbstract {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew) {
|
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
||||||
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
|
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
|
||||||
result = cancelTempBasal(false);
|
result = cancelTempBasal(false);
|
||||||
if (!result.success)
|
if (!result.success)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
TemporaryBasal tempBasal = new TemporaryBasal();
|
TemporaryBasal tempBasal = new TemporaryBasal()
|
||||||
tempBasal.date = System.currentTimeMillis();
|
.date(System.currentTimeMillis())
|
||||||
tempBasal.isAbsolute = false;
|
.percent(percent)
|
||||||
tempBasal.percentRate = percent;
|
.duration(durationInMinutes)
|
||||||
tempBasal.durationInMinutes = durationInMinutes;
|
.source(Source.USER);
|
||||||
tempBasal.source = Source.USER;
|
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
result.percent = percent;
|
result.percent = percent;
|
||||||
result.isPercent = true;
|
result.isPercent = true;
|
||||||
result.isTempCancel = false;
|
result.isTempCancel = false;
|
||||||
result.duration = durationInMinutes;
|
result.duration = durationInMinutes;
|
||||||
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
|
result.comment = MainApp.gs(R.string.virtualpump_resultok);
|
||||||
treatmentsInterface.addToHistoryTempBasal(tempBasal);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempBasal);
|
||||||
if (Config.logPumpComm)
|
if (Config.logPumpComm)
|
||||||
LOG.debug("Settings temp basal percent: " + result);
|
LOG.debug("Settings temp basal percent: " + result);
|
||||||
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
||||||
pumpStatusData.setLastDataTimeToNow();
|
pumpStatusData.setLastDataTimeToNow();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
|
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
|
||||||
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
|
|
||||||
PumpEnactResult result = cancelExtendedBolus();
|
PumpEnactResult result = cancelExtendedBolus();
|
||||||
if (!result.success)
|
if (!result.success)
|
||||||
return result;
|
return result;
|
||||||
|
@ -294,61 +299,63 @@ public class VirtualPumpDriver extends PumpDriverAbstract {
|
||||||
result.bolusDelivered = insulin;
|
result.bolusDelivered = insulin;
|
||||||
result.isTempCancel = false;
|
result.isTempCancel = false;
|
||||||
result.duration = durationInMinutes;
|
result.duration = durationInMinutes;
|
||||||
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
|
result.comment = MainApp.gs(R.string.virtualpump_resultok);
|
||||||
treatmentsInterface.addToHistoryExtendedBolus(extendedBolus);
|
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
|
||||||
if (Config.logPumpComm)
|
if (Config.logPumpComm)
|
||||||
LOG.debug("Setting extended bolus: " + result);
|
LOG.debug("Setting extended bolus: " + result);
|
||||||
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
||||||
pumpStatusData.setLastDataTimeToNow();
|
pumpStatusData.setLastDataTimeToNow();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult cancelTempBasal(boolean force) {
|
public PumpEnactResult cancelTempBasal(boolean force) {
|
||||||
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
|
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.isTempCancel = true;
|
result.isTempCancel = true;
|
||||||
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
|
result.comment = MainApp.gs(R.string.virtualpump_resultok);
|
||||||
if (treatmentsInterface.isTempBasalInProgress()) {
|
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
TemporaryBasal tempStop = new TemporaryBasal(System.currentTimeMillis());
|
TemporaryBasal tempStop = new TemporaryBasal().date(System.currentTimeMillis()).source(Source.USER);
|
||||||
tempStop.source = Source.USER;
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempStop);
|
||||||
treatmentsInterface.addToHistoryTempBasal(tempStop);
|
|
||||||
//tempBasal = null;
|
//tempBasal = null;
|
||||||
if (Config.logPumpComm)
|
if (Config.logPumpComm)
|
||||||
LOG.debug("Canceling temp basal: " + result);
|
LOG.debug("Canceling temp basal: " + result);
|
||||||
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
||||||
}
|
}
|
||||||
pumpStatusData.setLastDataTimeToNow();
|
pumpStatusData.setLastDataTimeToNow();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult cancelExtendedBolus() {
|
public PumpEnactResult cancelExtendedBolus() {
|
||||||
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
|
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
if (treatmentsInterface.isInHistoryExtendedBoluslInProgress()) {
|
if (TreatmentsPlugin.getPlugin().isInHistoryExtendedBoluslInProgress()) {
|
||||||
ExtendedBolus exStop = new ExtendedBolus(System.currentTimeMillis());
|
ExtendedBolus exStop = new ExtendedBolus(System.currentTimeMillis());
|
||||||
exStop.source = Source.USER;
|
exStop.source = Source.USER;
|
||||||
treatmentsInterface.addToHistoryExtendedBolus(exStop);
|
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(exStop);
|
||||||
}
|
}
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
result.isTempCancel = true;
|
result.isTempCancel = true;
|
||||||
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
|
result.comment = MainApp.gs(R.string.virtualpump_resultok);
|
||||||
if (Config.logPumpComm)
|
if (Config.logPumpComm)
|
||||||
LOG.debug("Canceling extended basal: " + result);
|
LOG.debug("Canceling extended basal: " + result);
|
||||||
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
||||||
pumpStatusData.setLastDataTimeToNow();
|
pumpStatusData.setLastDataTimeToNow();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject getJSONStatus() {
|
public JSONObject getJSONStatus(Profile profile, String profileName) {
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
if (!SP.getBoolean("virtualpump_uploadstatus", false)) {
|
if (!SP.getBoolean("virtualpump_uploadstatus", false)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -361,28 +368,28 @@ public class VirtualPumpDriver extends PumpDriverAbstract {
|
||||||
status.put("status", "normal");
|
status.put("status", "normal");
|
||||||
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
|
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
|
||||||
try {
|
try {
|
||||||
extended.put("ActiveProfile", MainApp.getConfigBuilder().getProfileName());
|
extended.put("ActiveProfile", profileName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
TemporaryBasal tb = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal tb = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
|
||||||
if (tb != null) {
|
if (tb != null) {
|
||||||
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(System.currentTimeMillis()));
|
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile));
|
||||||
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date));
|
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date));
|
||||||
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
|
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
|
||||||
}
|
}
|
||||||
ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
ExtendedBolus eb = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(now);
|
||||||
if (eb != null) {
|
if (eb != null) {
|
||||||
extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate());
|
extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate());
|
||||||
extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date));
|
extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date));
|
||||||
extended.put("ExtendedBolusRemaining", eb.getPlannedRemainingMinutes());
|
extended.put("ExtendedBolusRemaining", eb.getPlannedRemainingMinutes());
|
||||||
}
|
}
|
||||||
status.put("timestamp", DateUtil.toISOString(new Date()));
|
status.put("timestamp", DateUtil.toISOString(now));
|
||||||
|
|
||||||
pump.put("battery", battery);
|
pump.put("battery", battery);
|
||||||
pump.put("status", status);
|
pump.put("status", status);
|
||||||
pump.put("extended", extended);
|
pump.put("extended", extended);
|
||||||
pump.put("reservoir", pumpStatusData.reservoirRemainingUnits);
|
pump.put("reservoir", pumpStatusData.reservoirRemainingUnits);
|
||||||
pump.put("clock", DateUtil.toISOString(new Date()));
|
pump.put("clock", DateUtil.toISOString(now));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
LOG.error("Unhandled exception", e);
|
LOG.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
@ -390,5 +397,11 @@ public class VirtualPumpDriver extends PumpDriverAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PumpEnactResult loadTDDs() {
|
||||||
|
//no result, could read DB in the future?
|
||||||
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import com.squareup.otto.Subscribe;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
|
|
|
@ -131,7 +131,7 @@
|
||||||
<item>Tandem t:slim X2</item>
|
<item>Tandem t:slim X2</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="medtronicPumpTypeArray">
|
<string-array name="medtronicPumpTypeArray">
|
||||||
<item>Other (unsupported)</item>
|
<item>Other (unsupported)</item>
|
||||||
<item>512</item>
|
<item>512</item>
|
||||||
<item>712</item>
|
<item>712</item>
|
||||||
|
|
|
@ -1036,12 +1036,19 @@
|
||||||
<string name="value_unavailable_short">n/a</string>
|
<string name="value_unavailable_short">n/a</string>
|
||||||
<string name="ns_autobackfill_title">Autobackfill BG</string>
|
<string name="ns_autobackfill_title">Autobackfill BG</string>
|
||||||
|
|
||||||
|
<string name="virtualpump_type">Virtual Pump Type</string>
|
||||||
|
<string name="virtualpump_definition">Pump Definition</string>
|
||||||
|
<string name="virtualpump_pump_def">Bolus: Step=%s\nExtended Bolus: [Step=%s, Duration=%smin-%sh]\nBasal: Step=%s\nTBR: %s (by %s), Duration=%smin-%sh\nEXTENDED_NOTE</string>
|
||||||
|
<string name="virtualpump_pump_def_extended_note">* Ranged basal/bolus values are not supported by Virtual Pump.</string>
|
||||||
|
|
||||||
|
|
||||||
<!-- Pump Abstract -->
|
<!-- Pump Abstract -->
|
||||||
<string name="pump_operation_not_supported_by_pump">Operation not supported by pump.</string>
|
<string name="pump_operation_not_supported_by_pump">Operation not supported by pump.</string>
|
||||||
<string name="pump_operation_not_yet_supported_by_pump">Operation not YET supported by pump.</string>
|
<string name="pump_operation_not_yet_supported_by_pump">Operation not YET supported by pump.</string>
|
||||||
|
|
||||||
<!-- Medtronic -->
|
<!-- Medtronic -->
|
||||||
<string name="medtronic_name" translatable="false">Medtronic</string>
|
<string name="medtronic_name" translatable="false">Medtronic</string>
|
||||||
|
<string name="medtronic_name_short" translatable="false">MT</string>
|
||||||
<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>
|
||||||
|
@ -1054,4 +1061,5 @@
|
||||||
<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>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue