PumpUtil cleanup
This commit is contained in:
parent
e2182528fd
commit
316f001cbc
11 changed files with 177 additions and 195 deletions
|
@ -200,7 +200,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
VirtualPumpPlugin.setFakingStatus(true);
|
VirtualPumpPlugin.getPlugin().setFakingStatus(true);
|
||||||
scheduleBgChange(null); // trigger refresh
|
scheduleBgChange(null); // trigger refresh
|
||||||
scheduleTemporaryBasalChange();
|
scheduleTemporaryBasalChange();
|
||||||
scheduleExtendedBolusChange();
|
scheduleExtendedBolusChange();
|
||||||
|
@ -236,7 +236,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
VirtualPumpPlugin.setFakingStatus(false);
|
VirtualPumpPlugin.getPlugin().setFakingStatus(false);
|
||||||
scheduleTemporaryBasalChange();
|
scheduleTemporaryBasalChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -967,8 +967,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
extendedBolus.durationInMinutes = trJson.getInt("duration");
|
extendedBolus.durationInMinutes = trJson.getInt("duration");
|
||||||
extendedBolus.insulin = trJson.getDouble("originalExtendedAmount");
|
extendedBolus.insulin = trJson.getDouble("originalExtendedAmount");
|
||||||
extendedBolus._id = trJson.getString("_id");
|
extendedBolus._id = trJson.getString("_id");
|
||||||
if (!VirtualPumpPlugin.getFakingStatus()) {
|
if (!VirtualPumpPlugin.getPlugin().getFakingStatus()) {
|
||||||
VirtualPumpPlugin.setFakingStatus(true);
|
VirtualPumpPlugin.getPlugin().setFakingStatus(true);
|
||||||
updateEarliestDataChange(0);
|
updateEarliestDataChange(0);
|
||||||
scheduleTemporaryBasalChange();
|
scheduleTemporaryBasalChange();
|
||||||
}
|
}
|
||||||
|
@ -981,8 +981,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
extendedBolus.durationInMinutes = 0;
|
extendedBolus.durationInMinutes = 0;
|
||||||
extendedBolus.insulin = 0;
|
extendedBolus.insulin = 0;
|
||||||
extendedBolus._id = trJson.getString("_id");
|
extendedBolus._id = trJson.getString("_id");
|
||||||
if (!VirtualPumpPlugin.getFakingStatus()) {
|
if (!VirtualPumpPlugin.getPlugin().getFakingStatus()) {
|
||||||
VirtualPumpPlugin.setFakingStatus(true);
|
VirtualPumpPlugin.getPlugin().setFakingStatus(true);
|
||||||
updateEarliestDataChange(0);
|
updateEarliestDataChange(0);
|
||||||
scheduleTemporaryBasalChange();
|
scheduleTemporaryBasalChange();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,54 +1,62 @@
|
||||||
package info.nightscout.androidaps.interfaces;
|
package info.nightscout.androidaps.interfaces;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpCapability;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpTempBasalType;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 08.12.2016.
|
* Created by mike on 08.12.2016.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class PumpDescription {
|
public class PumpDescription {
|
||||||
|
PumpType pumpType = PumpType.GenericAAPS;
|
||||||
|
|
||||||
|
public PumpDescription () {
|
||||||
|
resetSettings();
|
||||||
|
}
|
||||||
|
|
||||||
public static final int NONE = 0;
|
public static final int NONE = 0;
|
||||||
public static final int PERCENT = 0x01;
|
public static final int PERCENT = 0x01;
|
||||||
public static final int ABSOLUTE = 0x02;
|
public static final int ABSOLUTE = 0x02;
|
||||||
|
|
||||||
public boolean isBolusCapable = true;
|
public boolean isBolusCapable;
|
||||||
public double bolusStep = 0.1d;
|
public double bolusStep;
|
||||||
|
|
||||||
public boolean isExtendedBolusCapable = true;
|
public boolean isExtendedBolusCapable;
|
||||||
public double extendedBolusStep = 0.1d;
|
public double extendedBolusStep;
|
||||||
public double extendedBolusDurationStep = 30;
|
public double extendedBolusDurationStep;
|
||||||
public double extendedBolusMaxDuration = 12 * 60;
|
public double extendedBolusMaxDuration;
|
||||||
|
|
||||||
public boolean isTempBasalCapable = true;
|
public boolean isTempBasalCapable;
|
||||||
public int tempBasalStyle = PERCENT;
|
public int tempBasalStyle;
|
||||||
|
|
||||||
public int maxTempPercent = 200;
|
public int maxTempPercent;
|
||||||
public int tempPercentStep = 10;
|
public int tempPercentStep;
|
||||||
|
|
||||||
public double maxTempAbsolute = 10;
|
public double maxTempAbsolute;
|
||||||
public double tempAbsoluteStep = 0.05d;
|
public double tempAbsoluteStep;
|
||||||
|
|
||||||
public int tempDurationStep = 60;
|
public int tempDurationStep;
|
||||||
public boolean tempDurationStep15mAllowed = false;
|
public boolean tempDurationStep15mAllowed;
|
||||||
public boolean tempDurationStep30mAllowed = false;
|
public boolean tempDurationStep30mAllowed;
|
||||||
public int tempMaxDuration = 12 * 60;
|
public int tempMaxDuration;
|
||||||
|
|
||||||
|
public boolean isSetBasalProfileCapable;
|
||||||
|
public double basalStep;
|
||||||
|
public double basalMinimumRate;
|
||||||
|
public double basalMaximumRate;
|
||||||
|
|
||||||
|
public boolean isRefillingCapable;
|
||||||
|
|
||||||
|
public boolean storesCarbInfo;
|
||||||
|
|
||||||
|
public boolean is30minBasalRatesCapable;
|
||||||
|
|
||||||
|
public boolean supportsTDDs;
|
||||||
|
public boolean needsManualTDDLoad;
|
||||||
|
|
||||||
|
|
||||||
public boolean isSetBasalProfileCapable = true;
|
public void resetSettings() {
|
||||||
public double basalStep = 0.01d;
|
|
||||||
public double basalMinimumRate = 0.04d;
|
|
||||||
public double basalMaximumRate = 25d;
|
|
||||||
|
|
||||||
public boolean isRefillingCapable = false;
|
|
||||||
|
|
||||||
public boolean storesCarbInfo = true;
|
|
||||||
|
|
||||||
public boolean is30minBasalRatesCapable = false;
|
|
||||||
|
|
||||||
public boolean supportsTDDs = false;
|
|
||||||
public boolean needsManualTDDLoad = true;
|
|
||||||
|
|
||||||
|
|
||||||
public void resetSettings()
|
|
||||||
{
|
|
||||||
isBolusCapable = true;
|
isBolusCapable = true;
|
||||||
bolusStep = 0.1d;
|
bolusStep = 0.1d;
|
||||||
|
|
||||||
|
@ -71,6 +79,7 @@ public class PumpDescription {
|
||||||
isSetBasalProfileCapable = true;
|
isSetBasalProfileCapable = true;
|
||||||
basalStep = 0.01d;
|
basalStep = 0.01d;
|
||||||
basalMinimumRate = 0.04d;
|
basalMinimumRate = 0.04d;
|
||||||
|
basalMaximumRate = 25d;
|
||||||
is30minBasalRatesCapable = false;
|
is30minBasalRatesCapable = false;
|
||||||
|
|
||||||
isRefillingCapable = false;
|
isRefillingCapable = false;
|
||||||
|
@ -78,6 +87,53 @@ public class PumpDescription {
|
||||||
|
|
||||||
supportsTDDs = false;
|
supportsTDDs = false;
|
||||||
needsManualTDDLoad = true;
|
needsManualTDDLoad = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPumpDescription(PumpType pumpType) {
|
||||||
|
resetSettings();
|
||||||
|
this.pumpType = pumpType;
|
||||||
|
|
||||||
|
PumpCapability pumpCapability = pumpType.getPumpCapability();
|
||||||
|
|
||||||
|
isBolusCapable = pumpCapability.hasCapability(PumpCapability.Bolus);
|
||||||
|
bolusStep = pumpType.getBolusSize();
|
||||||
|
|
||||||
|
isExtendedBolusCapable = pumpCapability.hasCapability(PumpCapability.ExtendedBolus);
|
||||||
|
extendedBolusStep = pumpType.getExtendedBolusSettings().getStep();
|
||||||
|
extendedBolusDurationStep = pumpType.getExtendedBolusSettings().getDurationStep();
|
||||||
|
extendedBolusMaxDuration = pumpType.getExtendedBolusSettings().getMaxDuration();
|
||||||
|
|
||||||
|
isTempBasalCapable = pumpCapability.hasCapability(PumpCapability.TempBasal);
|
||||||
|
|
||||||
|
if (pumpType.getPumpTempBasalType() == PumpTempBasalType.Percent) {
|
||||||
|
tempBasalStyle = PERCENT;
|
||||||
|
maxTempPercent = pumpType.getTbrSettings().getMaxDose().intValue();
|
||||||
|
tempPercentStep = (int) pumpType.getTbrSettings().getStep();
|
||||||
|
} else {
|
||||||
|
tempBasalStyle = ABSOLUTE;
|
||||||
|
maxTempAbsolute = pumpType.getTbrSettings().getMaxDose();
|
||||||
|
tempAbsoluteStep = pumpType.getTbrSettings().getStep();
|
||||||
|
}
|
||||||
|
|
||||||
|
tempDurationStep = pumpType.getTbrSettings().getDurationStep();
|
||||||
|
tempMaxDuration = pumpType.getTbrSettings().getMaxDuration();
|
||||||
|
|
||||||
|
tempDurationStep15mAllowed = pumpType.getSpecialBasalDurations()
|
||||||
|
.hasCapability(PumpCapability.BasalRate_Duration15minAllowed);
|
||||||
|
tempDurationStep30mAllowed = pumpType.getSpecialBasalDurations()
|
||||||
|
.hasCapability(PumpCapability.BasalRate_Duration30minAllowed);
|
||||||
|
|
||||||
|
isSetBasalProfileCapable = pumpCapability.hasCapability(PumpCapability.BasalProfileSet);
|
||||||
|
basalStep = pumpType.getBaseBasalStep();
|
||||||
|
basalMinimumRate = pumpType.getBaseBasalMinValue();
|
||||||
|
|
||||||
|
isRefillingCapable = pumpCapability.hasCapability(PumpCapability.Refill);
|
||||||
|
storesCarbInfo = pumpCapability.hasCapability(PumpCapability.StoreCarbInfo);
|
||||||
|
|
||||||
|
supportsTDDs = pumpCapability.hasCapability(PumpCapability.TDD);
|
||||||
|
needsManualTDDLoad = pumpCapability.hasCapability(PumpCapability.ManualTDDLoad);
|
||||||
|
|
||||||
|
is30minBasalRatesCapable = pumpCapability.hasCapability(PumpCapability.BasalRate30min);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,6 @@ import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHi
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistoryRequest;
|
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistoryRequest;
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Tdd;
|
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Tdd;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.utils.PumpUtil;
|
|
||||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
@ -136,7 +135,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
||||||
.description(R.string.description_pump_combo)
|
.description(R.string.description_pump_combo)
|
||||||
);
|
);
|
||||||
ruffyScripter = new RuffyScripter(MainApp.instance().getApplicationContext());
|
ruffyScripter = new RuffyScripter(MainApp.instance().getApplicationContext());
|
||||||
PumpUtil.setPumpDescription(pumpDescription, PumpType.AccuChekCombo);
|
pumpDescription.setPumpDescription(PumpType.AccuChekCombo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ComboPump getPump() {
|
public ComboPump getPump() {
|
||||||
|
|
|
@ -326,4 +326,68 @@ public enum PumpType {
|
||||||
PumpCapability.BasalRate_Duration15and30minNotAllowed : specialBasalDurations;
|
PumpCapability.BasalRate_Duration15and30minNotAllowed : specialBasalDurations;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double determineCorrectBolusSize(double bolusAmount) {
|
||||||
|
if (bolusAmount == 0.0d) {
|
||||||
|
return bolusAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
double bolusStepSize;
|
||||||
|
|
||||||
|
if (getSpecialBolusSize() == null) {
|
||||||
|
bolusStepSize = getBolusSize();
|
||||||
|
} else {
|
||||||
|
DoseStepSize specialBolusSize = getSpecialBolusSize();
|
||||||
|
|
||||||
|
bolusStepSize = specialBolusSize.getStepSizeForAmount((float)bolusAmount);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Math.round(bolusAmount / bolusStepSize) * bolusStepSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public double determineCorrectExtendedBolusSize(double bolusAmount) {
|
||||||
|
if (bolusAmount == 0.0d) {
|
||||||
|
return bolusAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
double bolusStepSize;
|
||||||
|
|
||||||
|
if (getExtendedBolusSettings() == null) { // this should be never null
|
||||||
|
return 0.0d;
|
||||||
|
}
|
||||||
|
|
||||||
|
DoseSettings extendedBolusSettings = getExtendedBolusSettings();
|
||||||
|
|
||||||
|
bolusStepSize = extendedBolusSettings.getStep();
|
||||||
|
|
||||||
|
if (bolusAmount > extendedBolusSettings.getMaxDose()) {
|
||||||
|
bolusAmount = extendedBolusSettings.getMaxDose();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Math.round(bolusAmount / bolusStepSize) * bolusStepSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public double determineCorrectBasalSize(double basalAmount) {
|
||||||
|
if (basalAmount == 0.0d) {
|
||||||
|
return basalAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
double basalStepSize;
|
||||||
|
|
||||||
|
if (getBaseBasalSpecialSteps() == null) {
|
||||||
|
basalStepSize = getBaseBasalStep();
|
||||||
|
} else {
|
||||||
|
DoseStepSize specialBolusSize = getBaseBasalSpecialSteps();
|
||||||
|
|
||||||
|
basalStepSize = specialBolusSize.getStepSizeForAmount((float) basalAmount);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (basalAmount > getTbrSettings().getMaxDose())
|
||||||
|
basalAmount = getTbrSettings().getMaxDose().doubleValue();
|
||||||
|
|
||||||
|
return Math.round(basalAmount / basalStepSize) * basalStepSize;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,130 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpCommon.utils;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.data.DoseSettings;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.DoseStepSize;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpCapability;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpTempBasalType;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by andy on 02/05/2018.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class PumpUtil {
|
|
||||||
|
|
||||||
public static double determineCorrectBolusSize(double bolusAmount, PumpType pumpType) {
|
|
||||||
if (bolusAmount == 0.0d || pumpType == null) {
|
|
||||||
return bolusAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
double bolusStepSize;
|
|
||||||
|
|
||||||
if (pumpType.getSpecialBolusSize() == null) {
|
|
||||||
bolusStepSize = pumpType.getBolusSize();
|
|
||||||
} else {
|
|
||||||
DoseStepSize specialBolusSize = pumpType.getSpecialBolusSize();
|
|
||||||
|
|
||||||
bolusStepSize = specialBolusSize.getStepSizeForAmount((float)bolusAmount);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Math.round(bolusAmount / bolusStepSize) * bolusStepSize;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static double determineCorrectExtendedBolusSize(double bolusAmount, PumpType pumpType) {
|
|
||||||
if (bolusAmount == 0.0d || pumpType == null) {
|
|
||||||
return bolusAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
double bolusStepSize;
|
|
||||||
|
|
||||||
if (pumpType.getExtendedBolusSettings() == null) { // this should be never null
|
|
||||||
return 0.0d;
|
|
||||||
}
|
|
||||||
|
|
||||||
DoseSettings extendedBolusSettings = pumpType.getExtendedBolusSettings();
|
|
||||||
|
|
||||||
bolusStepSize = extendedBolusSettings.getStep();
|
|
||||||
|
|
||||||
if (bolusAmount > extendedBolusSettings.getMaxDose()) {
|
|
||||||
bolusAmount = extendedBolusSettings.getMaxDose();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Math.round(bolusAmount / bolusStepSize) * bolusStepSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static double determineCorrectBasalSize(Double basalAmount, PumpType pumpType) {
|
|
||||||
if (basalAmount == null || basalAmount == 0.0d || pumpType == null) {
|
|
||||||
return basalAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
double basalStepSize;
|
|
||||||
|
|
||||||
if (pumpType.getBaseBasalSpecialSteps() == null) {
|
|
||||||
basalStepSize = pumpType.getBaseBasalStep();
|
|
||||||
} else {
|
|
||||||
DoseStepSize specialBolusSize = pumpType.getBaseBasalSpecialSteps();
|
|
||||||
|
|
||||||
basalStepSize = specialBolusSize.getStepSizeForAmount(basalAmount.floatValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (basalAmount > pumpType.getTbrSettings().getMaxDose())
|
|
||||||
basalAmount = pumpType.getTbrSettings().getMaxDose().doubleValue();
|
|
||||||
|
|
||||||
return Math.round(basalAmount / basalStepSize) * basalStepSize;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void setPumpDescription(PumpDescription pumpDescription, PumpType pumpType) {
|
|
||||||
// reset
|
|
||||||
pumpDescription.resetSettings();
|
|
||||||
|
|
||||||
PumpCapability pumpCapability = pumpType.getPumpCapability();
|
|
||||||
|
|
||||||
pumpDescription.isBolusCapable = pumpCapability.hasCapability(PumpCapability.Bolus);
|
|
||||||
pumpDescription.bolusStep = pumpType.getBolusSize();
|
|
||||||
|
|
||||||
pumpDescription.isExtendedBolusCapable = pumpCapability.hasCapability(PumpCapability.ExtendedBolus);
|
|
||||||
pumpDescription.extendedBolusStep = pumpType.getExtendedBolusSettings().getStep();
|
|
||||||
pumpDescription.extendedBolusDurationStep = pumpType.getExtendedBolusSettings().getDurationStep();
|
|
||||||
pumpDescription.extendedBolusMaxDuration = pumpType.getExtendedBolusSettings().getMaxDuration();
|
|
||||||
|
|
||||||
pumpDescription.isTempBasalCapable = pumpCapability.hasCapability(PumpCapability.TempBasal);
|
|
||||||
|
|
||||||
if (pumpType.getPumpTempBasalType() == PumpTempBasalType.Percent) {
|
|
||||||
pumpDescription.tempBasalStyle = PumpDescription.PERCENT;
|
|
||||||
pumpDescription.maxTempPercent = pumpType.getTbrSettings().getMaxDose().intValue();
|
|
||||||
pumpDescription.tempPercentStep = (int)pumpType.getTbrSettings().getStep();
|
|
||||||
} else {
|
|
||||||
pumpDescription.tempBasalStyle = PumpDescription.ABSOLUTE;
|
|
||||||
pumpDescription.maxTempAbsolute = pumpType.getTbrSettings().getMaxDose();
|
|
||||||
pumpDescription.tempAbsoluteStep = pumpType.getTbrSettings().getStep();
|
|
||||||
}
|
|
||||||
|
|
||||||
pumpDescription.tempDurationStep = pumpType.getTbrSettings().getDurationStep();
|
|
||||||
pumpDescription.tempMaxDuration = pumpType.getTbrSettings().getMaxDuration();
|
|
||||||
|
|
||||||
pumpDescription.tempDurationStep15mAllowed = pumpType.getSpecialBasalDurations()
|
|
||||||
.hasCapability(PumpCapability.BasalRate_Duration15minAllowed);
|
|
||||||
pumpDescription.tempDurationStep30mAllowed = pumpType.getSpecialBasalDurations()
|
|
||||||
.hasCapability(PumpCapability.BasalRate_Duration30minAllowed);
|
|
||||||
|
|
||||||
pumpDescription.isSetBasalProfileCapable = pumpCapability.hasCapability(PumpCapability.BasalProfileSet);
|
|
||||||
pumpDescription.basalStep = pumpType.getBaseBasalStep();
|
|
||||||
pumpDescription.basalMinimumRate = pumpType.getBaseBasalMinValue();
|
|
||||||
|
|
||||||
pumpDescription.isRefillingCapable = pumpCapability.hasCapability(PumpCapability.Refill);
|
|
||||||
pumpDescription.storesCarbInfo = pumpCapability.hasCapability(PumpCapability.StoreCarbInfo);
|
|
||||||
|
|
||||||
pumpDescription.supportsTDDs = pumpCapability.hasCapability(PumpCapability.TDD);
|
|
||||||
pumpDescription.needsManualTDDLoad = pumpCapability.hasCapability(PumpCapability.ManualTDDLoad);
|
|
||||||
|
|
||||||
pumpDescription.is30minBasalRatesCapable = pumpCapability.hasCapability(PumpCapability.BasalRate30min);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -24,7 +24,6 @@ import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.utils.PumpUtil;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStartWithSpeed;
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStartWithSpeed;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.services.DanaRExecutionService;
|
import info.nightscout.androidaps.plugins.PumpDanaR.services.DanaRExecutionService;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
|
@ -48,7 +47,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
||||||
public DanaRPlugin() {
|
public DanaRPlugin() {
|
||||||
super();
|
super();
|
||||||
useExtendedBoluses = SP.getBoolean(R.string.key_danar_useextended, false);
|
useExtendedBoluses = SP.getBoolean(R.string.key_danar_useextended, false);
|
||||||
PumpUtil.setPumpDescription(pumpDescription, PumpType.getByDescription("DanaR"));
|
pumpDescription.setPumpDescription(PumpType.DanaR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -24,7 +24,6 @@ import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.utils.PumpUtil;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
|
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStart;
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStart;
|
||||||
|
@ -51,7 +50,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
||||||
pluginDescription.description(R.string.description_pump_dana_r_korean);
|
pluginDescription.description(R.string.description_pump_dana_r_korean);
|
||||||
|
|
||||||
useExtendedBoluses = SP.getBoolean(R.string.key_danar_useextended, false);
|
useExtendedBoluses = SP.getBoolean(R.string.key_danar_useextended, false);
|
||||||
PumpUtil.setPumpDescription(pumpDescription, PumpType.DanaRKorean);
|
pumpDescription.setPumpDescription(PumpType.DanaRKorean);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -44,7 +44,6 @@ import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
|
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.utils.PumpUtil;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRFragment;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRFragment;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
|
||||||
|
@ -90,7 +89,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
.description(R.string.description_pump_dana_rs)
|
.description(R.string.description_pump_dana_rs)
|
||||||
);
|
);
|
||||||
|
|
||||||
PumpUtil.setPumpDescription(pumpDescription, PumpType.DanaRS);
|
pumpDescription.setPumpDescription(PumpType.DanaRS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -22,7 +22,6 @@ import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.utils.PumpUtil;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
|
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStartWithSpeed;
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStartWithSpeed;
|
||||||
|
@ -51,7 +50,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
|
||||||
pluginDescription.description(R.string.description_pump_dana_r_v2);
|
pluginDescription.description(R.string.description_pump_dana_r_v2);
|
||||||
|
|
||||||
useExtendedBoluses = false;
|
useExtendedBoluses = false;
|
||||||
PumpUtil.setPumpDescription(pumpDescription, PumpType.DanaRv2);
|
pumpDescription.setPumpDescription(PumpType.DanaRv2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -39,7 +39,6 @@ import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.utils.PumpUtil;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpInsight.connector.CancelBolusSilentlyTaskRunner;
|
import info.nightscout.androidaps.plugins.PumpInsight.connector.CancelBolusSilentlyTaskRunner;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsight.connector.CancelTBRSilentlyTaskRunner;
|
import info.nightscout.androidaps.plugins.PumpInsight.connector.CancelTBRSilentlyTaskRunner;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsight.connector.Connector;
|
import info.nightscout.androidaps.plugins.PumpInsight.connector.Connector;
|
||||||
|
@ -122,7 +121,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
||||||
.description(R.string.description_pump_insight)
|
.description(R.string.description_pump_insight)
|
||||||
);
|
);
|
||||||
log("InsightPlugin instantiated");
|
log("InsightPlugin instantiated");
|
||||||
PumpUtil.setPumpDescription(pumpDescription, PumpType.AccuChekInsight);
|
pumpDescription.setPumpDescription(PumpType.AccuChekInsight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.utils.PumpUtil;
|
|
||||||
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.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
@ -47,7 +46,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(VirtualPumpPlugin.class);
|
private static Logger log = LoggerFactory.getLogger(VirtualPumpPlugin.class);
|
||||||
private static VirtualPumpPlugin plugin = null;
|
private static VirtualPumpPlugin plugin = null;
|
||||||
private static boolean fromNSAreCommingFakedExtendedBoluses = false;
|
private static boolean fromNSAreCommingFakedExtendedBoluses = false;
|
||||||
PumpType pumpType = null;
|
private PumpType pumpType = null;
|
||||||
private long lastDataTime = 0;
|
private long lastDataTime = 0;
|
||||||
private PumpDescription pumpDescription = new PumpDescription();
|
private PumpDescription pumpDescription = new PumpDescription();
|
||||||
|
|
||||||
|
@ -92,21 +91,21 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VirtualPumpPlugin getPlugin() {
|
public static VirtualPumpPlugin getPlugin() {
|
||||||
loadFakingStatus();
|
|
||||||
if (plugin == null)
|
if (plugin == null)
|
||||||
plugin = new VirtualPumpPlugin();
|
plugin = new VirtualPumpPlugin();
|
||||||
|
plugin.loadFakingStatus();
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadFakingStatus() {
|
private void loadFakingStatus() {
|
||||||
fromNSAreCommingFakedExtendedBoluses = SP.getBoolean(R.string.key_fromNSAreCommingFakedExtendedBoluses, false);
|
fromNSAreCommingFakedExtendedBoluses = SP.getBoolean(R.string.key_fromNSAreCommingFakedExtendedBoluses, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getFakingStatus() {
|
public boolean getFakingStatus() {
|
||||||
return fromNSAreCommingFakedExtendedBoluses;
|
return fromNSAreCommingFakedExtendedBoluses;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setFakingStatus(boolean newStatus) {
|
public void setFakingStatus(boolean newStatus) {
|
||||||
fromNSAreCommingFakedExtendedBoluses = newStatus;
|
fromNSAreCommingFakedExtendedBoluses = newStatus;
|
||||||
SP.putBoolean(R.string.key_fromNSAreCommingFakedExtendedBoluses, fromNSAreCommingFakedExtendedBoluses);
|
SP.putBoolean(R.string.key_fromNSAreCommingFakedExtendedBoluses, fromNSAreCommingFakedExtendedBoluses);
|
||||||
}
|
}
|
||||||
|
@ -137,8 +136,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult loadTDDs() {
|
public PumpEnactResult loadTDDs() {
|
||||||
//no result, could read DB in the future?
|
//no result, could read DB in the future?
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
return new PumpEnactResult();
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -229,7 +227,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
||||||
|
|
||||||
detailedBolusInfo.insulin = PumpUtil.determineCorrectBolusSize(detailedBolusInfo.insulin, this.pumpType);
|
detailedBolusInfo.insulin = pumpType.determineCorrectBolusSize(detailedBolusInfo.insulin);
|
||||||
|
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
result.success = true;
|
result.success = true;
|
||||||
|
@ -269,7 +267,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
||||||
|
|
||||||
absoluteRate = PumpUtil.determineCorrectBasalSize(absoluteRate, this.pumpType);
|
absoluteRate = pumpType.determineCorrectBasalSize(absoluteRate);
|
||||||
|
|
||||||
TemporaryBasal tempBasal = new TemporaryBasal()
|
TemporaryBasal tempBasal = new TemporaryBasal()
|
||||||
.date(System.currentTimeMillis())
|
.date(System.currentTimeMillis())
|
||||||
|
@ -325,7 +323,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
if (!result.success)
|
if (!result.success)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
insulin = PumpUtil.determineCorrectExtendedBolusSize(insulin, this.pumpType);
|
insulin = pumpType.determineCorrectExtendedBolusSize(insulin);
|
||||||
|
|
||||||
ExtendedBolus extendedBolus = new ExtendedBolus();
|
ExtendedBolus extendedBolus = new ExtendedBolus();
|
||||||
extendedBolus.date = System.currentTimeMillis();
|
extendedBolus.date = System.currentTimeMillis();
|
||||||
|
@ -400,7 +398,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
|
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
|
||||||
try {
|
try {
|
||||||
extended.put("ActiveProfile", profileName);
|
extended.put("ActiveProfile", profileName);
|
||||||
} catch (Exception e) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
TemporaryBasal tb = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
|
TemporaryBasal tb = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
|
||||||
if (tb != null) {
|
if (tb != null) {
|
||||||
|
@ -461,7 +459,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
if (L.isEnabled(L.PUMP))
|
if (L.isEnabled(L.PUMP))
|
||||||
log.debug("New pump configuration found ({}), changing from previous ({})", pumpTypeNew, pumpType);
|
log.debug("New pump configuration found ({}), changing from previous ({})", pumpTypeNew, pumpType);
|
||||||
|
|
||||||
PumpUtil.setPumpDescription(pumpDescription, pumpTypeNew);
|
pumpDescription.setPumpDescription(pumpTypeNew);
|
||||||
|
|
||||||
this.pumpType = pumpTypeNew;
|
this.pumpType = pumpTypeNew;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue