PumpDescription -> kt

This commit is contained in:
Milos Kozak 2021-03-07 15:19:51 +01:00
parent 54ad6caf83
commit 563bee2faf
28 changed files with 248 additions and 326 deletions

View file

@ -343,15 +343,15 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
boolean detailed = sp.getBoolean(R.string.key_wear_detailed_delta, false);
if (units.equals(Constants.MGDL)) {
if (detailed) {
deltastring += DecimalFormatter.to1Decimal(Math.abs(deltaMGDL));
deltastring += DecimalFormatter.INSTANCE.to1Decimal(Math.abs(deltaMGDL));
} else {
deltastring += DecimalFormatter.to0Decimal(Math.abs(deltaMGDL));
deltastring += DecimalFormatter.INSTANCE.to0Decimal(Math.abs(deltaMGDL));
}
} else {
if (detailed) {
deltastring += DecimalFormatter.to2Decimal(Math.abs(deltaMMOL));
deltastring += DecimalFormatter.INSTANCE.to2Decimal(Math.abs(deltaMMOL));
} else {
deltastring += DecimalFormatter.to1Decimal(Math.abs(deltaMMOL));
deltastring += DecimalFormatter.INSTANCE.to1Decimal(Math.abs(deltaMMOL));
}
}
return deltastring;
@ -689,14 +689,14 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
treatmentsPlugin.updateTotalIOBTempBasals();
IobTotal basalIob = treatmentsPlugin.getLastCalculationTempBasals().round();
iobSum = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob);
iobDetail = "(" + DecimalFormatter.to2Decimal(bolusIob.iob) + "|" + DecimalFormatter.to2Decimal(basalIob.basaliob) + ")";
iobSum = DecimalFormatter.INSTANCE.to2Decimal(bolusIob.iob + basalIob.basaliob);
iobDetail = "(" + DecimalFormatter.INSTANCE.to2Decimal(bolusIob.iob) + "|" + DecimalFormatter.INSTANCE.to2Decimal(basalIob.basaliob) + ")";
cobString = iobCobCalculatorPlugin.getCobInfo(false, "WatcherUpdaterService").generateCOBString();
currentBasal = generateBasalString();
//bgi
double bgi = -(bolusIob.activity + basalIob.activity) * 5 * Profile.fromMgdlToUnits(profile.getIsfMgdl(), profileFunction.getUnits());
bgiString = "" + ((bgi >= 0) ? "+" : "") + DecimalFormatter.to1Decimal(bgi);
bgiString = "" + ((bgi >= 0) ? "+" : "") + DecimalFormatter.INSTANCE.to1Decimal(bgi);
status = generateStatusString(profile, currentBasal, iobSum, iobDetail, bgiString);
}
@ -804,7 +804,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
if (sp.getBoolean(R.string.key_danar_visualizeextendedaspercentage, false)) {
basalStringResult = "100%";
} else {
basalStringResult = DecimalFormatter.to2Decimal(profile.getBasal()) + "U/h";
basalStringResult = DecimalFormatter.INSTANCE.to2Decimal(profile.getBasal()) + "U/h";
}
}
return basalStringResult;

View file

@ -12,7 +12,7 @@ class TabPageAdapter(private val activity: AppCompatActivity) : FragmentStateAda
override fun getItemCount(): Int = visibleFragmentList.size
override fun createFragment(position: Int): Fragment =
activity.supportFragmentManager.fragmentFactory.instantiate(ClassLoader.getSystemClassLoader(), visibleFragmentList[position].pluginDescription.fragmentClass)
activity.supportFragmentManager.fragmentFactory.instantiate(ClassLoader.getSystemClassLoader(), visibleFragmentList[position].pluginDescription.fragmentClass ?: Fragment::class.java.name)
fun getPluginAt(position: Int): PluginBase = visibleFragmentList[position]

View file

@ -745,9 +745,9 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
int adjustedPercent = percent;
if (adjustedPercent > pumpDescription.maxTempPercent) {
getAapsLogger().debug(LTag.PUMP, "Reducing requested TBR to the maximum support by the pump: " + percent + " -> " + pumpDescription.maxTempPercent);
adjustedPercent = pumpDescription.maxTempPercent;
if (adjustedPercent > pumpDescription.getMaxTempPercent()) {
getAapsLogger().debug(LTag.PUMP, "Reducing requested TBR to the maximum support by the pump: " + percent + " -> " + pumpDescription.getMaxTempPercent());
adjustedPercent = pumpDescription.getMaxTempPercent();
}
if (adjustedPercent % 10 != 0) {

View file

@ -245,7 +245,7 @@ public class Profile {
if (isValid) {
// Check for hours alignment
PumpInterface pump = activePlugin.getActivePump();
if (!pump.getPumpDescription().is30minBasalRatesCapable) {
if (!pump.getPumpDescription().is30minBasalRatesCapable()) {
for (int index = 0; index < basal_v.size(); index++) {
long secondsFromMidnight = basal_v.keyAt(index);
if (notify && secondsFromMidnight % 3600 != 0) {
@ -260,12 +260,12 @@ public class Profile {
// Check for minimal basal value
PumpDescription description = pump.getPumpDescription();
for (int i = 0; i < basal_v.size(); i++) {
if (basal_v.valueAt(i) < description.basalMinimumRate) {
basal_v.setValueAt(i, description.basalMinimumRate);
if (basal_v.valueAt(i) < description.getBasalMinimumRate()) {
basal_v.setValueAt(i, description.getBasalMinimumRate());
if (notify)
sendBelowMinimumNotification(from);
} else if (basal_v.valueAt(i) > description.basalMaximumRate) {
basal_v.setValueAt(i, description.basalMaximumRate);
} else if (basal_v.valueAt(i) > description.getBasalMaximumRate()) {
basal_v.setValueAt(i, description.getBasalMaximumRate());
if (notify)
sendAboveMaximumNotification(from);
}
@ -666,14 +666,14 @@ public class Profile {
}
public static String toUnitsString(double valueInMgdl, double valueInMmol, String units) {
if (units.equals(Constants.MGDL)) return DecimalFormatter.to0Decimal(valueInMgdl);
else return DecimalFormatter.to1Decimal(valueInMmol);
if (units.equals(Constants.MGDL)) return DecimalFormatter.INSTANCE.to0Decimal(valueInMgdl);
else return DecimalFormatter.INSTANCE.to1Decimal(valueInMmol);
}
public static String toSignedUnitsString(double valueInMgdl, double valueInMmol, String units) {
if (units.equals(Constants.MGDL))
return (valueInMgdl > 0 ? "+" : "") + DecimalFormatter.to0Decimal(valueInMgdl);
else return (valueInMmol > 0 ? "+" : "") + DecimalFormatter.to1Decimal(valueInMmol);
return (valueInMgdl > 0 ? "+" : "") + DecimalFormatter.INSTANCE.to0Decimal(valueInMgdl);
else return (valueInMmol > 0 ? "+" : "") + DecimalFormatter.INSTANCE.to1Decimal(valueInMmol);
}
public static double toCurrentUnits(ProfileFunction profileFunction, double anyBg) {

View file

@ -330,23 +330,23 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
}
public String toString() {
return "E " + DecimalFormatter.to2Decimal(absoluteRate()) + "U/h @" +
return "E " + DecimalFormatter.INSTANCE.to2Decimal(absoluteRate()) + "U/h @" +
dateUtil.timeString(date) +
" " + getRealDuration() + "/" + durationInMinutes + "min";
}
public String toStringShort() {
return "E " + DecimalFormatter.to2Decimal(absoluteRate()) + "U/h ";
return "E " + DecimalFormatter.INSTANCE.to2Decimal(absoluteRate()) + "U/h ";
}
public String toStringMedium() {
return DecimalFormatter.to2Decimal(absoluteRate()) + "U/h "
return DecimalFormatter.INSTANCE.to2Decimal(absoluteRate()) + "U/h "
+ getRealDuration() + "/" + durationInMinutes + "'";
}
public String toStringTotal() {
return DecimalFormatter.to2Decimal(insulin) + "U ( " +
DecimalFormatter.to2Decimal(absoluteRate()) + " U/h )";
return DecimalFormatter.INSTANCE.to2Decimal(insulin) + "U ( " +
DecimalFormatter.INSTANCE.to2Decimal(absoluteRate()) + " U/h )";
}
// -------- DataPointWithLabelInterface --------

View file

@ -130,7 +130,7 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
public String getCustomizedName() {
String name = profileName;
if (Constants.LOCAL_PROFILE.equals(name)) {
name = DecimalFormatter.to2Decimal(getProfileObject().percentageBasalSum()) + "U ";
name = DecimalFormatter.INSTANCE.to2Decimal(getProfileObject().percentageBasalSum()) + "U ";
}
if (isCPP) {
name += "(" + percentage + "%";

View file

@ -431,11 +431,11 @@ public class TemporaryBasal implements Interval, DbObjectBase {
return "null";
Double currentBasalRate = profile.getBasal();
double rate = currentBasalRate + netExtendedRate;
return getCalcuatedPercentageIfNeeded() + DecimalFormatter.to2Decimal(rate) + "U/h (" + DecimalFormatter.to2Decimal(netExtendedRate) + "E) @" +
return getCalcuatedPercentageIfNeeded() + DecimalFormatter.INSTANCE.to2Decimal(rate) + "U/h (" + DecimalFormatter.INSTANCE.to2Decimal(netExtendedRate) + "E) @" +
dateUtil.timeString(date) +
" " + getRealDuration() + "/" + durationInMinutes + "'";
} else if (isAbsolute) {
return DecimalFormatter.to2Decimal(absoluteRate) + "U/h @" +
return DecimalFormatter.INSTANCE.to2Decimal(absoluteRate) + "U/h @" +
dateUtil.timeString(date) +
" " + getRealDuration() + "/" + durationInMinutes + "'";
} else { // percent
@ -468,7 +468,7 @@ public class TemporaryBasal implements Interval, DbObjectBase {
}
}
}
return DecimalFormatter.to2Decimal(rate) + "U/h";
return DecimalFormatter.INSTANCE.to2Decimal(rate) + "U/h";
} else { // percent
return percentRate + "%";
}
@ -515,7 +515,7 @@ public class TemporaryBasal implements Interval, DbObjectBase {
} else {
rate = absoluteRate;
}
return DecimalFormatter.to2Decimal(rate) + "U/h";
return DecimalFormatter.INSTANCE.to2Decimal(rate) + "U/h";
} else { // percent
return percentRate + "%";
}

View file

@ -243,7 +243,7 @@ public class Treatment implements DataPointWithLabelInterface, DbObjectBase {
@Override
public String getLabel() {
String label = "";
if (insulin > 0) label += DecimalFormatter.toPumpSupportedBolus(insulin, activePlugin.getActivePump(), resourceHelper);
if (insulin > 0) label += DecimalFormatter.INSTANCE.toPumpSupportedBolus(insulin, activePlugin.getActivePump(), resourceHelper);
if (carbs > 0)
label += "~" + resourceHelper.gs(R.string.format_carbs, (int) carbs);
return label;

View file

@ -1,152 +0,0 @@
package info.nightscout.androidaps.interfaces;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpCapability;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpTempBasalType;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
/**
* Created by mike on 08.12.2016.
*/
public class PumpDescription {
public PumpType pumpType = PumpType.GenericAAPS;
public PumpDescription() {
resetSettings();
}
public PumpDescription(PumpType pumpType) {
this();
setPumpDescription(pumpType);
}
public static final int NONE = 0;
public static final int PERCENT = 0x01;
public static final int ABSOLUTE = 0x02;
public boolean isBolusCapable;
public double bolusStep;
public boolean isExtendedBolusCapable;
public double extendedBolusStep;
public double extendedBolusDurationStep;
public double extendedBolusMaxDuration;
public boolean isTempBasalCapable;
public int tempBasalStyle;
public int maxTempPercent;
public int tempPercentStep;
public double maxTempAbsolute;
public double tempAbsoluteStep;
public int tempDurationStep;
public boolean tempDurationStep15mAllowed;
public boolean tempDurationStep30mAllowed;
public int tempMaxDuration;
public boolean isSetBasalProfileCapable;
public double basalStep;
public double basalMinimumRate;
public double basalMaximumRate;
public boolean isRefillingCapable;
public boolean isBatteryReplaceable;
public boolean storesCarbInfo;
public boolean is30minBasalRatesCapable;
public boolean supportsTDDs;
public boolean needsManualTDDLoad;
public boolean hasCustomUnreachableAlertCheck;
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;
tempDurationStep15mAllowed = false;
tempDurationStep30mAllowed = false;
isSetBasalProfileCapable = true;
basalStep = 0.01d;
basalMinimumRate = 0.04d;
basalMaximumRate = 25d;
is30minBasalRatesCapable = false;
isRefillingCapable = true;
isBatteryReplaceable = true;
storesCarbInfo = true;
supportsTDDs = false;
needsManualTDDLoad = true;
hasCustomUnreachableAlertCheck = false;
}
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);
isBatteryReplaceable = pumpCapability.hasCapability(PumpCapability.ReplaceBattery);
storesCarbInfo = pumpCapability.hasCapability(PumpCapability.StoreCarbInfo);
supportsTDDs = pumpCapability.hasCapability(PumpCapability.TDD);
needsManualTDDLoad = pumpCapability.hasCapability(PumpCapability.ManualTDDLoad);
is30minBasalRatesCapable = pumpCapability.hasCapability(PumpCapability.BasalRate30min);
hasCustomUnreachableAlertCheck = pumpType.getHasCustomUnreachableAlertCheck();
}
}

View file

@ -0,0 +1,120 @@
package info.nightscout.androidaps.interfaces
import info.nightscout.androidaps.plugins.pump.common.defs.PumpCapability
import info.nightscout.androidaps.plugins.pump.common.defs.PumpTempBasalType
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
class PumpDescription() {
constructor(pumpType: PumpType) : this() {
setPumpDescription(pumpType)
}
var pumpType = PumpType.GenericAAPS
var isBolusCapable = false
var bolusStep = 0.0
var isExtendedBolusCapable = false
var extendedBolusStep = 0.0
var extendedBolusDurationStep = 0.0
var extendedBolusMaxDuration = 0.0
var isTempBasalCapable = false
var tempBasalStyle = 0
var maxTempPercent = 0
var tempPercentStep = 0
var maxTempAbsolute = 0.0
var tempAbsoluteStep = 0.0
var tempDurationStep = 0
var tempDurationStep15mAllowed = false
var tempDurationStep30mAllowed = false
var tempMaxDuration = 0
var isSetBasalProfileCapable = false
var basalStep = 0.0
var basalMinimumRate = 0.0
var basalMaximumRate = 0.0
var isRefillingCapable = false
var isBatteryReplaceable = false
var storesCarbInfo = false
var is30minBasalRatesCapable = false
var supportsTDDs = false
var needsManualTDDLoad = false
var hasCustomUnreachableAlertCheck = false
fun resetSettings() {
isBolusCapable = true
bolusStep = 0.1
isExtendedBolusCapable = true
extendedBolusStep = 0.1
extendedBolusDurationStep = 30.0
extendedBolusMaxDuration = (12 * 60).toDouble()
isTempBasalCapable = true
tempBasalStyle = PERCENT
maxTempPercent = 200
tempPercentStep = 10
maxTempAbsolute = 10.0
tempAbsoluteStep = 0.05
tempDurationStep = 60
tempMaxDuration = 12 * 60
tempDurationStep15mAllowed = false
tempDurationStep30mAllowed = false
isSetBasalProfileCapable = true
basalStep = 0.01
basalMinimumRate = 0.04
basalMaximumRate = 25.0
is30minBasalRatesCapable = false
isRefillingCapable = true
isBatteryReplaceable = true
storesCarbInfo = true
supportsTDDs = false
needsManualTDDLoad = true
hasCustomUnreachableAlertCheck = false
}
fun setPumpDescription(pumpType: PumpType) {
resetSettings()
this.pumpType = pumpType
val pumpCapability = pumpType.pumpCapability
isBolusCapable = pumpCapability.hasCapability(PumpCapability.Bolus)
bolusStep = pumpType.bolusSize
isExtendedBolusCapable = pumpCapability.hasCapability(PumpCapability.ExtendedBolus)
extendedBolusStep = pumpType.extendedBolusSettings.step
extendedBolusDurationStep = pumpType.extendedBolusSettings.durationStep.toDouble()
extendedBolusMaxDuration = pumpType.extendedBolusSettings.maxDuration.toDouble()
isTempBasalCapable = pumpCapability.hasCapability(PumpCapability.TempBasal)
if (pumpType.pumpTempBasalType == PumpTempBasalType.Percent) {
tempBasalStyle = PERCENT
maxTempPercent = pumpType.tbrSettings.maxDose.toInt()
tempPercentStep = pumpType.tbrSettings.step.toInt()
} else {
tempBasalStyle = ABSOLUTE
maxTempAbsolute = pumpType.tbrSettings.maxDose
tempAbsoluteStep = pumpType.tbrSettings.step
}
tempDurationStep = pumpType.tbrSettings.durationStep
tempMaxDuration = pumpType.tbrSettings.maxDuration
tempDurationStep15mAllowed = pumpType.specialBasalDurations
.hasCapability(PumpCapability.BasalRate_Duration15minAllowed)
tempDurationStep30mAllowed = pumpType.specialBasalDurations
.hasCapability(PumpCapability.BasalRate_Duration30minAllowed)
isSetBasalProfileCapable = pumpCapability.hasCapability(PumpCapability.BasalProfileSet)
basalStep = pumpType.baseBasalStep
basalMinimumRate = pumpType.baseBasalMinValue
isRefillingCapable = pumpCapability.hasCapability(PumpCapability.Refill)
isBatteryReplaceable = pumpCapability.hasCapability(PumpCapability.ReplaceBattery)
storesCarbInfo = pumpCapability.hasCapability(PumpCapability.StoreCarbInfo)
supportsTDDs = pumpCapability.hasCapability(PumpCapability.TDD)
needsManualTDDLoad = pumpCapability.hasCapability(PumpCapability.ManualTDDLoad)
is30minBasalRatesCapable = pumpCapability.hasCapability(PumpCapability.BasalRate30min)
hasCustomUnreachableAlertCheck = pumpType.hasCustomUnreachableAlertCheck
}
companion object {
const val NONE = 0
const val PERCENT = 0x01
const val ABSOLUTE = 0x02
}
init {
resetSettings()
}
}

View file

@ -375,7 +375,7 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
ret += "LastConn: " + agoMin + " min ago\n";
}
if (getPumpStatusData().lastBolusTime != null && getPumpStatusData().lastBolusTime.getTime() != 0) {
ret += "LastBolus: " + DecimalFormatter.to2Decimal(getPumpStatusData().lastBolusAmount) + "U @" + //
ret += "LastBolus: " + DecimalFormatter.INSTANCE.to2Decimal(getPumpStatusData().lastBolusAmount) + "U @" + //
android.text.format.DateFormat.format("HH:mm", getPumpStatusData().lastBolusTime) + "\n";
}
TemporaryBasal activeTemp = activePlugin.getActiveTreatments().getRealTempBasalFromHistory(System.currentTimeMillis());
@ -392,7 +392,7 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
// + pumpStatus.maxDailyTotalUnits + " U\n";
// }
ret += "IOB: " + getPumpStatusData().iob + "U\n";
ret += "Reserv: " + DecimalFormatter.to0Decimal(getPumpStatusData().reservoirRemainingUnits) + "U\n";
ret += "Reserv: " + DecimalFormatter.INSTANCE.to0Decimal(getPumpStatusData().reservoirRemainingUnits) + "U\n";
ret += "Batt: " + getPumpStatusData().batteryRemaining + "\n";
return ret;
}

View file

@ -1,67 +0,0 @@
package info.nightscout.androidaps.utils;
import java.text.DecimalFormat;
import info.nightscout.androidaps.core.R;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
/**
* Created by mike on 11.07.2016.
*/
public class DecimalFormatter {
private static final DecimalFormat format0dec = new DecimalFormat("0");
private static final DecimalFormat format1dec = new DecimalFormat("0.0");
private static final DecimalFormat format2dec = new DecimalFormat("0.00");
private static final DecimalFormat format3dec = new DecimalFormat("0.000");
public static String to0Decimal(double value) {
return format0dec.format(value);
}
public static String to0Decimal(double value, String unit) {
return format0dec.format(value) + unit;
}
public static String to1Decimal(double value) {
return format1dec.format(value);
}
public static String to1Decimal(double value, String unit) {
return format1dec.format(value) + unit;
}
public static String to2Decimal(double value) {
return format2dec.format(value);
}
public static String to2Decimal(double value, String unit) {
return format2dec.format(value) + unit;
}
public static String to3Decimal(double value) {
return format3dec.format(value);
}
public static String to3Decimal(double value, String unit) {
return format3dec.format(value) + unit;
}
public static String toPumpSupportedBolus(double value, PumpInterface pump) {
return pump.getPumpDescription().bolusStep <= 0.051
? to2Decimal(value)
: to1Decimal(value);
}
public static String toPumpSupportedBolus(double value, PumpInterface pump, ResourceHelper resourceHelper) {
return pump.getPumpDescription().bolusStep <= 0.051
? resourceHelper.gs(R.string.formatinsulinunits, value)
: resourceHelper.gs(R.string.formatinsulinunits1, value);
}
public static DecimalFormat pumpSupportedBolusFormat(PumpInterface pump) {
return pump.getPumpDescription().bolusStep <= 0.051
? new DecimalFormat("0.00")
: new DecimalFormat("0.0");
}
}

View file

@ -0,0 +1,26 @@
package info.nightscout.androidaps.utils
import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.interfaces.PumpInterface
import info.nightscout.androidaps.utils.resources.ResourceHelper
import java.text.DecimalFormat
object DecimalFormatter {
private val format0dec = DecimalFormat("0")
private val format1dec = DecimalFormat("0.0")
private val format2dec = DecimalFormat("0.00")
private val format3dec = DecimalFormat("0.000")
fun to0Decimal(value: Double): String = format0dec.format(value)
fun to0Decimal(value: Double, unit: String): String = format0dec.format(value) + unit
fun to1Decimal(value: Double): String = format1dec.format(value)
fun to1Decimal(value: Double, unit: String): String = format1dec.format(value) + unit
fun to2Decimal(value: Double): String = format2dec.format(value)
fun to2Decimal(value: Double, unit: String): String = format2dec.format(value) + unit
fun to3Decimal(value: Double): String = format3dec.format(value)
fun to3Decimal(value: Double, unit: String): String = format3dec.format(value) + unit
fun toPumpSupportedBolus(value: Double, pump: PumpInterface): String = if (pump.pumpDescription.bolusStep <= 0.051) to2Decimal(value) else to1Decimal(value)
fun toPumpSupportedBolus(value: Double, pump: PumpInterface, resourceHelper: ResourceHelper): String = if (pump.pumpDescription.bolusStep <= 0.051) resourceHelper.gs(R.string.formatinsulinunits, value) else resourceHelper.gs(R.string.formatinsulinunits1, value)
fun pumpSupportedBolusFormat(pump: PumpInterface): DecimalFormat = if (pump.pumpDescription.bolusStep <= 0.051) DecimalFormat("0.00") else DecimalFormat("0.0")
}

View file

@ -169,7 +169,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, detailedBolusInfo.carbTime, t);
PumpEnactResult result = new PumpEnactResult(getInjector());
result.success(connectionOK && Math.abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.bolusStep)
result.success(connectionOK && Math.abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.getBolusStep())
.bolusDelivered(t.insulin)
.carbsDelivered(detailedBolusInfo.carbs);
if (!result.getSuccess())
@ -229,8 +229,8 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
if (absoluteRate < 0.10d) percentRate = 0;
if (percentRate < 100) percentRate = Round.ceilTo((double) percentRate, 10d).intValue();
else percentRate = Round.floorTo((double) percentRate, 10d).intValue();
if (percentRate > getPumpDescription().maxTempPercent) {
percentRate = getPumpDescription().maxTempPercent;
if (percentRate > getPumpDescription().getMaxTempPercent()) {
percentRate = getPumpDescription().getMaxTempPercent();
}
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Calculated percent rate: " + percentRate);
@ -276,17 +276,17 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
// Calculate # of halfHours from minutes
int durationInHalfHours = Math.max(durationInMinutes / 30, 1);
// We keep current basal running so need to sub current basal
Double extendedRateToSet = absoluteRate - getBaseBasalRate();
double extendedRateToSet = absoluteRate - getBaseBasalRate();
extendedRateToSet = constraintChecker.applyBasalConstraints(new Constraint<>(extendedRateToSet), profile).value();
// needs to be rounded to 0.1
extendedRateToSet = Round.roundTo(extendedRateToSet, pumpDescription.extendedBolusStep * 2); // *2 because of half hours
extendedRateToSet = Round.roundTo(extendedRateToSet, pumpDescription.getExtendedBolusStep() * 2); // *2 because of half hours
// What is current rate of extended bolusing in u/h?
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Extended bolus in progress: " + (activeExtended != null) + " rate: " + danaPump.getExtendedBolusAbsoluteRate() + "U/h duration remaining: " + danaPump.getExtendedBolusRemainingMinutes() + "min");
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Rate to set: " + extendedRateToSet + "U/h");
// Compare with extended rate in progress
if (activeExtended != null && Math.abs(danaPump.getExtendedBolusAbsoluteRate() - extendedRateToSet) < getPumpDescription().extendedBolusStep) {
if (activeExtended != null && Math.abs(danaPump.getExtendedBolusAbsoluteRate() - extendedRateToSet) < getPumpDescription().getExtendedBolusStep()) {
// correct extended already set
result.success(true).absolute(danaPump.getExtendedBolusAbsoluteRate()).enacted(false).duration(danaPump.getExtendedBolusRemainingMinutes()).isPercent(false).isTempCancel(false);
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Correct extended already set");

View file

@ -151,7 +151,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
danaPump.setLastConnection(now);
Profile profile = profileFunction.getProfile();
if (profile != null && Math.abs(danaPump.getCurrentBasal() - profile.getBasal()) >= danaRKoreanPlugin.getPumpDescription().basalStep) {
if (profile != null && Math.abs(danaPump.getCurrentBasal() - profile.getBasal()) >= danaRKoreanPlugin.getPumpDescription().getBasalStep()) {
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpsettings)));
mSerialIOThread.sendMessage(new MsgSettingBasal(injector));
if (!danaRKoreanPlugin.isThisProfileSet(profile) && !commandQueue.isRunning(Command.CommandType.BASAL_PROFILE)) {

View file

@ -188,7 +188,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
if (detailedBolusInfo.insulin > 0 || carbs > 0)
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) carbs, DateUtil.now() + T.mins(carbTime).msecs(), t);
PumpEnactResult result = new PumpEnactResult(getInjector());
result.success(connectionOK && Math.abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.bolusStep)
result.success(connectionOK && Math.abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.getBolusStep())
.bolusDelivered(t.insulin)
.carbsDelivered(detailedBolusInfo.carbs);
if (!result.getSuccess())
@ -218,11 +218,6 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
// This is called from APS
@NonNull @Override
public PumpEnactResult setTempBasalAbsolute(double absoluteRate, int durationInMinutes, @NonNull Profile profile, boolean enforceNew) {
// Recheck pump status if older than 30 min
//This should not be needed while using queue because connection should be done before calling this
//if (pump.lastConnection.getTime() + 30 * 60 * 1000L < System.currentTimeMillis()) {
// connect("setTempBasalAbsolute old data");
//}
PumpEnactResult result = new PumpEnactResult(getInjector());
@ -294,8 +289,8 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
aapsLogger.error("setTempBasalPercent: Invalid input");
return result;
}
if (percent > getPumpDescription().maxTempPercent)
percent = getPumpDescription().maxTempPercent;
if (percent > getPumpDescription().getMaxTempPercent())
percent = getPumpDescription().getMaxTempPercent();
long now = System.currentTimeMillis();
TemporaryBasal activeTemp = activePlugin.getActiveTreatments().getRealTempBasalFromHistory(now);
if (activeTemp != null && activeTemp.percentRate == percent && activeTemp.getPlannedRemainingMinutes() > 4 && !enforceNew) {

View file

@ -180,7 +180,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
Profile profile = profileFunction.getProfile();
PumpInterface pump = activePlugin.getActivePump();
if (profile != null && Math.abs(danaPump.getCurrentBasal() - profile.getBasal()) >= pump.getPumpDescription().basalStep) {
if (profile != null && Math.abs(danaPump.getCurrentBasal() - profile.getBasal()) >= pump.getPumpDescription().getBasalStep()) {
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpsettings)));
mSerialIOThread.sendMessage(new MsgSettingBasal(injector));
if (!pump.isThisProfileSet(profile) && !commandQueue.isRunning(Command.CommandType.BASAL_PROFILE)) {

View file

@ -176,7 +176,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
for (int h = 0; h < basalValues; h++) {
Double pumpValue = danaPump.getPumpProfiles()[danaPump.getActiveProfile()][h];
Double profileValue = profile.getBasalTimeFromMidnight(h * basalIncrement);
if (Math.abs(pumpValue - profileValue) > getPumpDescription().basalStep) {
if (Math.abs(pumpValue - profileValue) > getPumpDescription().getBasalStep()) {
getAapsLogger().debug(LTag.PUMP, "Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue);
return false;
}
@ -223,8 +223,8 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
getAapsLogger().error("setTempBasalPercent: Invalid input");
return result;
}
if (percent > getPumpDescription().maxTempPercent)
percent = getPumpDescription().maxTempPercent;
if (percent > getPumpDescription().getMaxTempPercent())
percent = getPumpDescription().getMaxTempPercent();
long now = System.currentTimeMillis();
TemporaryBasal activeTemp = activePlugin.getActiveTreatments().getRealTempBasalFromHistory(now);
if (activeTemp != null && activeTemp.percentRate == percent && activeTemp.getPlannedRemainingMinutes() > 4 && !enforceNew) {
@ -260,11 +260,11 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
insulin = constraintChecker.applyExtendedBolusConstraints(new Constraint<>(insulin)).value();
// needs to be rounded
int durationInHalfHours = Math.max(durationInMinutes / 30, 1);
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep);
insulin = Round.roundTo(insulin, getPumpDescription().getExtendedBolusStep());
PumpEnactResult result = new PumpEnactResult(getInjector());
ExtendedBolus runningEB = activePlugin.getActiveTreatments().getExtendedBolusFromHistory(System.currentTimeMillis());
if (runningEB != null && Math.abs(runningEB.insulin - insulin) < getPumpDescription().extendedBolusStep) {
if (runningEB != null && Math.abs(runningEB.insulin - insulin) < getPumpDescription().getExtendedBolusStep()) {
result.enacted(false)
.success(true)
.comment(R.string.ok)
@ -276,7 +276,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
return result;
}
boolean connectionOK = sExecutionService.extendedBolus(insulin, durationInHalfHours);
if (connectionOK && pump.isExtendedInProgress() && Math.abs(pump.getExtendedBolusAmount() - insulin) < getPumpDescription().extendedBolusStep) {
if (connectionOK && pump.isExtendedInProgress() && Math.abs(pump.getExtendedBolusAmount() - insulin) < getPumpDescription().getExtendedBolusStep()) {
result.enacted(true)
.success(true)
.comment(R.string.ok)
@ -316,8 +316,8 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
public void connect(@NonNull String from) {
if (sExecutionService != null) {
sExecutionService.connect();
pumpDescription.basalStep = danaPump.getBasalStep();
pumpDescription.bolusStep = danaPump.getBolusStep();
pumpDescription.setBasalStep(danaPump.getBasalStep());
pumpDescription.setBolusStep(danaPump.getBolusStep());
}
}
@ -345,19 +345,19 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
public void getPumpStatus(@NonNull String reason) {
if (sExecutionService != null) {
sExecutionService.getPumpStatus();
pumpDescription.basalStep = danaPump.getBasalStep();
pumpDescription.bolusStep = danaPump.getBolusStep();
pumpDescription.setBasalStep(danaPump.getBasalStep());
pumpDescription.setBolusStep(danaPump.getBolusStep());
}
}
@NonNull @Override
public JSONObject getJSONStatus(@NonNull Profile profile, @NonNull String profilename, @NonNull String version) {
public JSONObject getJSONStatus(@NonNull Profile profile, @NonNull String profileName, @NonNull String version) {
DanaPump pump = danaPump;
long now = System.currentTimeMillis();
if (pump.getLastConnection() + 60 * 60 * 1000L < System.currentTimeMillis()) {
return new JSONObject();
}
JSONObject pumpjson = new JSONObject();
JSONObject pumpJson = new JSONObject();
JSONObject battery = new JSONObject();
JSONObject status = new JSONObject();
JSONObject extended = new JSONObject();
@ -384,19 +384,19 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
}
extended.put("BaseBasalRate", getBaseBasalRate());
try {
extended.put("ActiveProfile", profilename);
extended.put("ActiveProfile", profileName);
} catch (Exception ignored) {
}
pumpjson.put("battery", battery);
pumpjson.put("status", status);
pumpjson.put("extended", extended);
pumpjson.put("reservoir", (int) pump.getReservoirRemainingUnits());
pumpjson.put("clock", DateUtil.toISOString(new Date()));
pumpJson.put("battery", battery);
pumpJson.put("status", status);
pumpJson.put("extended", extended);
pumpJson.put("reservoir", (int) pump.getReservoirRemainingUnits());
pumpJson.put("clock", DateUtil.toISOString(new Date()));
} catch (JSONException e) {
getAapsLogger().error("Unhandled exception", e);
}
return pumpjson;
return pumpJson;
}
@NonNull @Override
@ -436,7 +436,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
@NonNull @Override
public Constraint<Integer> applyBasalPercentConstraints(Constraint<Integer> percentRate, @NonNull Profile profile) {
percentRate.setIfGreater(getAapsLogger(), 0, String.format(getResourceHelper().gs(R.string.limitingpercentrate), 0, getResourceHelper().gs(R.string.itmustbepositivevalue)), this);
percentRate.setIfSmaller(getAapsLogger(), getPumpDescription().maxTempPercent, String.format(getResourceHelper().gs(R.string.limitingpercentrate), getPumpDescription().maxTempPercent, getResourceHelper().gs(R.string.pumplimit)), this);
percentRate.setIfSmaller(getAapsLogger(), getPumpDescription().getMaxTempPercent(), String.format(getResourceHelper().gs(R.string.limitingpercentrate), getPumpDescription().getMaxTempPercent(), getResourceHelper().gs(R.string.pumplimit)), this);
return percentRate;
}
@ -467,7 +467,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
ret += "LastConn: " + agoMin + " min ago\n";
}
if (pump.getLastBolusTime() != 0) {
ret += "LastBolus: " + DecimalFormatter.to2Decimal(pump.getLastBolusAmount()) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.getLastBolusTime()) + "\n";
ret += "LastBolus: " + DecimalFormatter.INSTANCE.to2Decimal(pump.getLastBolusAmount()) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.getLastBolusTime()) + "\n";
}
TemporaryBasal activeTemp = activePlugin.getActiveTreatments().getRealTempBasalFromHistory(System.currentTimeMillis());
if (activeTemp != null) {
@ -478,9 +478,9 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
ret += "Extended: " + activeExtendedBolus.toString() + "\n";
}
if (!veryShort) {
ret += "TDD: " + DecimalFormatter.to0Decimal(pump.getDailyTotalUnits()) + " / " + pump.getMaxDailyTotalUnits() + " U\n";
ret += "TDD: " + DecimalFormatter.INSTANCE.to0Decimal(pump.getDailyTotalUnits()) + " / " + pump.getMaxDailyTotalUnits() + " U\n";
}
ret += "Reserv: " + DecimalFormatter.to0Decimal(pump.getReservoirRemainingUnits()) + "U\n";
ret += "Reserv: " + DecimalFormatter.INSTANCE.to0Decimal(pump.getReservoirRemainingUnits()) + "U\n";
ret += "Batt: " + pump.getBatteryRemaining() + "\n";
return ret;
}

View file

@ -167,7 +167,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, detailedBolusInfo.carbTime, t);
PumpEnactResult result = new PumpEnactResult(getInjector());
result.success(connectionOK && Math.abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.bolusStep)
result.success(connectionOK && Math.abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.getBolusStep())
.bolusDelivered(t.insulin)
.carbsDelivered(detailedBolusInfo.carbs);
if (!result.getSuccess())
@ -227,8 +227,8 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
if (absoluteRate < 0.10d) percentRate = 0;
if (percentRate < 100) percentRate = Round.ceilTo((double) percentRate, 10d).intValue();
else percentRate = Round.floorTo((double) percentRate, 10d).intValue();
if (percentRate > getPumpDescription().maxTempPercent) {
percentRate = getPumpDescription().maxTempPercent;
if (percentRate > getPumpDescription().getMaxTempPercent()) {
percentRate = getPumpDescription().getMaxTempPercent();
}
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Calculated percent rate: " + percentRate);
@ -274,17 +274,17 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
// Calculate # of halfHours from minutes
int durationInHalfHours = Math.max(durationInMinutes / 30, 1);
// We keep current basal running so need to sub current basal
Double extendedRateToSet = absoluteRate - getBaseBasalRate();
double extendedRateToSet = absoluteRate - getBaseBasalRate();
extendedRateToSet = constraintChecker.applyBasalConstraints(new Constraint<>(extendedRateToSet), profile).value();
// needs to be rounded to 0.1
extendedRateToSet = Round.roundTo(extendedRateToSet, pumpDescription.extendedBolusStep * 2); // *2 because of half hours
extendedRateToSet = Round.roundTo(extendedRateToSet, pumpDescription.getExtendedBolusStep() * 2); // *2 because of half hours
// What is current rate of extended bolusing in u/h?
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Extended bolus in progress: " + (activeExtended != null) + " rate: " + danaPump.getExtendedBolusAbsoluteRate() + "U/h duration remaining: " + danaPump.getExtendedBolusRemainingMinutes() + "min");
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Rate to set: " + extendedRateToSet + "U/h");
// Compare with extended rate in progress
if (activeExtended != null && Math.abs(danaPump.getExtendedBolusAbsoluteRate() - extendedRateToSet) < getPumpDescription().extendedBolusStep) {
if (activeExtended != null && Math.abs(danaPump.getExtendedBolusAbsoluteRate() - extendedRateToSet) < getPumpDescription().getExtendedBolusStep()) {
// correct extended already set
result.success(true).absolute(danaPump.getExtendedBolusAbsoluteRate()).enacted(false).duration(danaPump.getExtendedBolusRemainingMinutes()).isPercent(false).isTempCancel(false);
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Correct extended already set");

View file

@ -161,7 +161,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
danaPump.setLastConnection(now);
Profile profile = profileFunction.getProfile();
if (profile != null && Math.abs(danaPump.getCurrentBasal() - profile.getBasal()) >= danaRPlugin.getPumpDescription().basalStep) {
if (profile != null && Math.abs(danaPump.getCurrentBasal() - profile.getBasal()) >= danaRPlugin.getPumpDescription().getBasalStep()) {
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpsettings)));
mSerialIOThread.sendMessage(new MsgSettingBasal(injector));
if (!danaRPlugin.isThisProfileSet(profile) && !commandQueue.isRunning(Command.CommandType.BASAL_PROFILE)) {
@ -185,7 +185,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumptime)));
mSerialIOThread.sendMessage(new MsgSettingPumpTime(injector));
if (danaPump.getPumpTime() == 0) {
// initial handshake was not successfull
// initial handshake was not successful
// deinitialize pump
danaPump.reset();
rxBus.send(new EventDanaRNewStatus());

View file

@ -279,7 +279,7 @@ public class LocalInsightFragment extends DaggerFragment implements View.OnClick
if (cartridgeStatus == null) return;
String status;
if (cartridgeStatus.isInserted())
status = DecimalFormatter.to2Decimal(localInsightPlugin.getCartridgeStatus().getRemainingAmount()) + "U";
status = DecimalFormatter.INSTANCE.to2Decimal(localInsightPlugin.getCartridgeStatus().getRemainingAmount()) + "U";
else status = resourceHelper.gs(R.string.not_inserted);
statusItems.add(getStatusItem(resourceHelper.gs(R.string.reservoir_label), status));
}
@ -287,16 +287,16 @@ public class LocalInsightFragment extends DaggerFragment implements View.OnClick
private void getTDDItems(List<View> statusItems) {
if (localInsightPlugin.getTotalDailyDose() == null) return;
TotalDailyDose tdd = localInsightPlugin.getTotalDailyDose();
statusItems.add(getStatusItem(resourceHelper.gs(R.string.tdd_bolus), DecimalFormatter.to2Decimal(tdd.getBolus())));
statusItems.add(getStatusItem(resourceHelper.gs(R.string.tdd_basal), DecimalFormatter.to2Decimal(tdd.getBasal())));
statusItems.add(getStatusItem(resourceHelper.gs(R.string.tdd_total), DecimalFormatter.to2Decimal(tdd.getBolusAndBasal())));
statusItems.add(getStatusItem(resourceHelper.gs(R.string.tdd_bolus), DecimalFormatter.INSTANCE.to2Decimal(tdd.getBolus())));
statusItems.add(getStatusItem(resourceHelper.gs(R.string.tdd_basal), DecimalFormatter.INSTANCE.to2Decimal(tdd.getBasal())));
statusItems.add(getStatusItem(resourceHelper.gs(R.string.tdd_total), DecimalFormatter.INSTANCE.to2Decimal(tdd.getBolusAndBasal())));
}
private void getBaseBasalRateItem(List<View> statusItems) {
if (localInsightPlugin.getActiveBasalRate() == null) return;
ActiveBasalRate activeBasalRate = localInsightPlugin.getActiveBasalRate();
statusItems.add(getStatusItem(resourceHelper.gs(R.string.basebasalrate_label),
DecimalFormatter.to2Decimal(activeBasalRate.getActiveBasalRate()) + " U/h (" + activeBasalRate.getActiveBasalProfileName() + ")"));
DecimalFormatter.INSTANCE.to2Decimal(activeBasalRate.getActiveBasalRate()) + " U/h (" + activeBasalRate.getActiveBasalProfileName() + ")"));
}
private void getTBRItem(List<View> statusItems) {

View file

@ -477,8 +477,8 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
maximumBasalAmount = ParameterBlockUtil.readParameterBlock(connectionService, Service.CONFIGURATION, MaxBasalAmountBlock.class).getAmountLimitation();
minimumBolusAmount = ParameterBlockUtil.readParameterBlock(connectionService, Service.CONFIGURATION, FactoryMinBolusAmountBlock.class).getAmountLimitation();
minimumBasalAmount = ParameterBlockUtil.readParameterBlock(connectionService, Service.CONFIGURATION, FactoryMinBasalAmountBlock.class).getAmountLimitation();
this.pumpDescription.basalMaximumRate = maximumBasalAmount;
this.pumpDescription.basalMinimumRate = minimumBasalAmount;
this.pumpDescription.setBasalMaximumRate(maximumBasalAmount);
this.pumpDescription.setBasalMinimumRate(minimumBasalAmount);
limitsFetched = true;
}
@ -1610,7 +1610,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
@NonNull @Override
public Constraint<Integer> applyBasalPercentConstraints(Constraint<Integer> percentRate, @NonNull Profile profile) {
percentRate.setIfGreater(getAapsLogger(), 0, String.format(resourceHelper.gs(R.string.limitingpercentrate), 0, resourceHelper.gs(R.string.itmustbepositivevalue)), this);
percentRate.setIfSmaller(getAapsLogger(), getPumpDescription().maxTempPercent, String.format(resourceHelper.gs(R.string.limitingpercentrate), getPumpDescription().maxTempPercent, resourceHelper.gs(R.string.pumplimit)), this);
percentRate.setIfSmaller(getAapsLogger(), getPumpDescription().getMaxTempPercent(), String.format(resourceHelper.gs(R.string.limitingpercentrate), getPumpDescription().getMaxTempPercent(), resourceHelper.gs(R.string.pumplimit)), this);
return percentRate;
}

View file

@ -226,7 +226,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
aapsLogger.debug(LTag.PUMP, "initPumpStatusData: " + this.medtronicPumpStatus);
// this is only thing that can change, by being configured
pumpDescription.maxTempAbsolute = (medtronicPumpStatus.maxBasal != null) ? medtronicPumpStatus.maxBasal : 35.0d;
pumpDescription.setMaxTempAbsolute((medtronicPumpStatus.maxBasal != null) ? medtronicPumpStatus.maxBasal : 35.0d);
// set first Medtronic Pump Start
if (!sp.contains(MedtronicConst.Statistics.FirstPumpStart)) {
@ -681,7 +681,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
for (Profile.ProfileValue basalValue : profile.getBasalValues()) {
double basalValueValue = pumpDescription.pumpType.determineCorrectBasalSize(basalValue.value);
double basalValueValue = pumpDescription.getPumpType().determineCorrectBasalSize(basalValue.value);
int hour = basalValue.timeAsSeconds / (60 * 60);
@ -1073,7 +1073,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
return setTempBasalAbsolute(0.0d, durationInMinutes, profile, enforceNew);
} else {
double absoluteValue = profile.getBasal() * (percent / 100.0d);
absoluteValue = pumpDescription.pumpType.determineCorrectBasalSize(absoluteValue);
absoluteValue = pumpDescription.getPumpType().determineCorrectBasalSize(absoluteValue);
aapsLogger.warn(LTag.PUMP, "setTempBasalPercent [MedtronicPumpPlugin] - You are trying to use setTempBasalPercent with percent other then 0% (" + percent + "). This will start setTempBasalAbsolute, with calculated value (" + absoluteValue + "). Result might not be 100% correct.");
return setTempBasalAbsolute(absoluteValue, durationInMinutes, profile, enforceNew);
}
@ -1110,7 +1110,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
if (this.medtronicPumpStatus.basalProfileStatus != BasalProfileStatus.NotInitialized
&& medtronicHistoryData.hasBasalProfileChanged()) {
medtronicHistoryData.processLastBasalProfileChange(pumpDescription.pumpType, medtronicPumpStatus);
medtronicHistoryData.processLastBasalProfileChange(pumpDescription.getPumpType(), medtronicPumpStatus);
}
PumpDriverState previousState = this.pumpState;
@ -1409,12 +1409,12 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
@NonNull @Override
public ManufacturerType manufacturer() {
return pumpDescription.pumpType.getManufacturer();
return pumpDescription.getPumpType().getManufacturer();
}
@NonNull @Override
public PumpType model() {
return pumpDescription.pumpType;
return pumpDescription.getPumpType();
}
@NonNull @Override
@ -1503,7 +1503,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
for (int i = 0; i < 24; i++) {
double rate = profile.getBasalTimeFromMidnight(i * 60 * 60);
double v = pumpDescription.pumpType.determineCorrectBasalSize(rate);
double v = pumpDescription.getPumpType().determineCorrectBasalSize(rate);
BasalProfileEntry basalEntry = new BasalProfileEntry(v, i, 0);
basalProfile.addEntry(basalEntry);

View file

@ -176,7 +176,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
} else {
// radioResponse.rssi;
Object dataResponse = medtronicConverter.convertResponse(medtronicPumpPlugin.getPumpDescription().pumpType, MedtronicCommandType.PumpModel,
Object dataResponse = medtronicConverter.convertResponse(medtronicPumpPlugin.getPumpDescription().getPumpType(), MedtronicCommandType.PumpModel,
pumpResponse.getRawContent());
MedtronicDeviceType pumpModel = (MedtronicDeviceType) dataResponse;
@ -574,7 +574,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
if (check == null) {
Object dataResponse = medtronicConverter.convertResponse(medtronicPumpPlugin.getPumpDescription().pumpType, commandType, response.getRawContent());
Object dataResponse = medtronicConverter.convertResponse(medtronicPumpPlugin.getPumpDescription().getPumpType(), commandType, response.getRawContent());
if (dataResponse != null) {
this.errorMessage = null;
@ -711,7 +711,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
errorMessage = check;
}
BasalProfile basalProfile = (BasalProfile) medtronicConverter.convertResponse(medtronicPumpPlugin.getPumpDescription().pumpType, commandType, data);
BasalProfile basalProfile = (BasalProfile) medtronicConverter.convertResponse(medtronicPumpPlugin.getPumpDescription().getPumpType(), commandType, data);
if (basalProfile != null) {
aapsLogger.debug(LTag.PUMPCOMM, "Converted response for {} is {}.", commandType.name(), basalProfile);

View file

@ -68,7 +68,7 @@ public class MedtronicUIPostprocessor {
if (response) {
BasalProfile basalProfile = (BasalProfile) uiTask.getParameter(0);
medtronicPumpStatus.basalsByHour = basalProfile.getProfilesByHour(medtronicPumpPlugin.getPumpDescription().pumpType);
medtronicPumpStatus.basalsByHour = basalProfile.getProfilesByHour(medtronicPumpPlugin.getPumpDescription().getPumpType());
}
}
break;
@ -77,7 +77,7 @@ public class MedtronicUIPostprocessor {
BasalProfile basalProfile = (BasalProfile) uiTask.returnData;
try {
Double[] profilesByHour = basalProfile.getProfilesByHour(medtronicPumpPlugin.getPumpDescription().pumpType);
Double[] profilesByHour = basalProfile.getProfilesByHour(medtronicPumpPlugin.getPumpDescription().getPumpType());
if (profilesByHour != null) {
medtronicPumpStatus.basalsByHour = profilesByHour;

View file

@ -156,11 +156,11 @@ public class OmnipodDashPumpPlugin extends PumpPluginBase implements PumpInterfa
}
@NotNull @Override public ManufacturerType manufacturer() {
return getPumpDescription().pumpType.getManufacturer();
return getPumpDescription().getPumpType().getManufacturer();
}
@NotNull @Override public PumpType model() {
return getPumpDescription().pumpType;
return getPumpDescription().getPumpType();
}
@NotNull @Override public String serialNumber() {

View file

@ -801,7 +801,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements PumpInterfa
ret += resourceHelper.gs(R.string.omnipod_common_short_status_last_connection, agoMin) + "\n";
}
if (podStateManager.getLastBolusStartTime() != null) {
ret += resourceHelper.gs(R.string.omnipod_common_short_status_last_bolus, DecimalFormatter.to2Decimal(podStateManager.getLastBolusAmount()),
ret += resourceHelper.gs(R.string.omnipod_common_short_status_last_bolus, DecimalFormatter.INSTANCE.to2Decimal(podStateManager.getLastBolusAmount()),
android.text.format.DateFormat.format("HH:mm", podStateManager.getLastBolusStartTime().toDate())) + "\n";
}
TemporaryBasal activeTemp = activePlugin.getActiveTreatments().getRealTempBasalFromHistory(System.currentTimeMillis());
@ -813,7 +813,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements PumpInterfa
if (activeExtendedBolus != null) {
ret += resourceHelper.gs(R.string.omnipod_common_short_status_extended_bolus, activeExtendedBolus.toString()) + "\n";
}
ret += resourceHelper.gs(R.string.omnipod_common_short_status_reservoir, (getReservoirLevel() > OmnipodConstants.MAX_RESERVOIR_READING ? "50+" : DecimalFormatter.to0Decimal(getReservoirLevel()))) + "\n";
ret += resourceHelper.gs(R.string.omnipod_common_short_status_reservoir, (getReservoirLevel() > OmnipodConstants.MAX_RESERVOIR_READING ? "50+" : DecimalFormatter.INSTANCE.to0Decimal(getReservoirLevel()))) + "\n";
if (isUseRileyLinkBatteryLevel()) {
ret += resourceHelper.gs(R.string.omnipod_eros_short_status_riley_link_battery, getBatteryLevel()) + "\n";
}
@ -1032,7 +1032,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements PumpInterfa
return setTempBasalAbsolute(0.0d, durationInMinutes, profile, enforceNew);
} else {
double absoluteValue = profile.getBasal() * (percent / 100.0d);
absoluteValue = pumpDescription.pumpType.determineCorrectBasalSize(absoluteValue);
absoluteValue = pumpDescription.getPumpType().determineCorrectBasalSize(absoluteValue);
aapsLogger.warn(LTag.PUMP, "setTempBasalPercent [OmnipodPumpPlugin] - You are trying to use setTempBasalPercent with percent other then 0% (" + percent + "). This will start setTempBasalAbsolute, with calculated value (" + absoluteValue + "). Result might not be 100% correct.");
return setTempBasalAbsolute(absoluteValue, durationInMinutes, profile, enforceNew);
}

View file

@ -116,7 +116,7 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
this.deviceType.setText(targetDevice.getResourceId());
if (targetDevice == RileyLinkTargetDevice.MedtronicPump) {
this.connectedDeviceDetails.setVisibility(View.VISIBLE);
this.configuredDeviceModel.setText(activePlugin.getActivePump().getPumpDescription().pumpType.getDescription());
this.configuredDeviceModel.setText(activePlugin.getActivePump().getPumpDescription().getPumpType().getDescription());
this.connectedDeviceModel.setText(rileyLinkPumpInfo.getConnectedDeviceModel());
} else {
this.connectedDeviceDetails.setVisibility(View.GONE);