fix maxdailybasal calculation

This commit is contained in:
Milos Kozak 2017-06-11 14:29:02 +02:00
parent 39224f421a
commit bf953f1240
4 changed files with 10 additions and 11 deletions

View file

@ -112,7 +112,7 @@ public class Profile {
public String log() {
String ret = "\n";
for (Integer hour = 0; hour < 24; hour++) {
double value = getBasal(hour * 60 * 60);
double value = getBasal((Integer) (hour * 60 * 60));
ret += "NS basal value for " + hour + ":00 is " + value + "\n";
}
ret += "NS units: " + getUnits();
@ -285,7 +285,7 @@ public class Profile {
public double getMaxDailyBasal() {
Double max = 0d;
for (Integer hour = 0; hour < 24; hour++) {
double value = getBasal(hour * 60 * 60);
double value = getBasal((Integer)(hour * 60 * 60));
if (value > max) max = value;
}
return max;

View file

@ -438,7 +438,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
Double extendedRateToSet = absoluteRate - getBaseBasalRate();
extendedRateToSet = configBuilderPlugin.applyBasalConstraints(extendedRateToSet);
// needs to be rounded to 0.1
extendedRateToSet = Round.roundTo(extendedRateToSet, pumpDescription.extendedBolusStep);
extendedRateToSet = Round.roundTo(extendedRateToSet, pumpDescription.extendedBolusStep * 2); // *2 because of halfhours
// What is current rate of extended bolusing in u/h?
if (Config.logPumpActions) {
@ -534,7 +534,8 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
insulin = configBuilderPlugin.applyBolusConstraints(insulin);
// needs to be rounded
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep);
int durationInHalfHours = Math.max(durationInMinutes / 30, 1);
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep * (1 + durationInHalfHours % 1));
PumpEnactResult result = new PumpEnactResult();
if (pump.isExtendedInProgress && Math.abs(pump.extendedBolusAmount - insulin) < getPumpDescription().extendedBolusStep) {
@ -549,7 +550,6 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
log.debug("setExtendedBolus: Correct extended bolus already set. Current: " + pump.extendedBolusAmount + " Asked: " + insulin);
return result;
}
int durationInHalfHours = Math.max(durationInMinutes / 30, 1);
boolean connectionOK = sExecutionService.extendedBolus(insulin, durationInHalfHours);
if (connectionOK && pump.isExtendedInProgress && Math.abs(pump.extendedBolusAmount - insulin) < getPumpDescription().extendedBolusStep) {
result.enacted = true;

View file

@ -442,7 +442,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
Double extendedRateToSet = absoluteRate - getBaseBasalRate();
extendedRateToSet = configBuilderPlugin.applyBasalConstraints(extendedRateToSet);
// needs to be rounded to 0.1
extendedRateToSet = Round.roundTo(extendedRateToSet, pumpDescription.extendedBolusStep);
extendedRateToSet = Round.roundTo(extendedRateToSet, pumpDescription.extendedBolusStep * 2); // *2 because of 30 min
// What is current rate of extended bolusing in u/h?
if (Config.logPumpActions) {
@ -538,7 +538,8 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
insulin = configBuilderPlugin.applyBolusConstraints(insulin);
// needs to be rounded
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep);
int durationInHalfHours = Math.max(durationInMinutes / 30, 1);
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep * (1 + durationInHalfHours % 1));
PumpEnactResult result = new PumpEnactResult();
if (pump.isExtendedInProgress && Math.abs(pump.extendedBolusAmount - insulin) < getPumpDescription().extendedBolusStep) {
@ -553,7 +554,6 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
log.debug("setExtendedBolus: Correct extended bolus already set. Current: " + pump.extendedBolusAmount + " Asked: " + insulin);
return result;
}
int durationInHalfHours = Math.max(durationInMinutes / 30, 1);
boolean connectionOK = sExecutionService.extendedBolus(insulin, durationInHalfHours);
if (connectionOK && pump.isExtendedInProgress && Math.abs(pump.extendedBolusAmount - insulin) < getPumpDescription().extendedBolusStep) {
result.enacted = true;

View file

@ -467,8 +467,8 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, ConstraintsInte
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
insulin = configBuilderPlugin.applyBolusConstraints(insulin);
// needs to be rounded
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep);
int durationInHalfHours = Math.max(durationInMinutes / 30, 1);
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep * (1 + durationInHalfHours % 1));
PumpEnactResult result = new PumpEnactResult();
if (pump.isExtendedInProgress && Math.abs(pump.extendedBolusAmount - insulin) < getPumpDescription().extendedBolusStep) {
result.enacted = false;
@ -482,7 +482,6 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, ConstraintsInte
log.debug("setExtendedBolus: Correct extended bolus already set. Current: " + pump.extendedBolusAmount + " Asked: " + insulin);
return result;
}
int durationInHalfHours = Math.max(durationInMinutes / 30, 1);
boolean connectionOK = sExecutionService.extendedBolus(insulin, durationInHalfHours);
if (connectionOK && pump.isExtendedInProgress && Math.abs(pump.extendedBolusAmount - insulin) < getPumpDescription().extendedBolusStep) {
result.enacted = true;