- fixes for Bolus problems

This commit is contained in:
Andy Rozman 2019-04-12 21:20:09 +01:00
parent ad17c66b1b
commit c7f6eb79f0
7 changed files with 210 additions and 355 deletions

View file

@ -65,7 +65,7 @@ android {
multiDexEnabled true
versionCode 1500
// dev_version: 2.2.3-dev
version "medtronic-0.9.2-SNAPSHOT"
version "medtronic-0.9.3-SNAPSHOT"
buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'

View file

@ -19,17 +19,14 @@ import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.plugins.general.careportal.CareportalPlugin;
import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin;
import info.nightscout.androidaps.plugins.insulin.InsulinOrefFreePeakPlugin;
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin;
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin;
import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin;
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin;
import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin;
import info.nightscout.androidaps.plugins.general.careportal.CareportalPlugin;
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin;
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin;
import info.nightscout.androidaps.plugins.general.wear.WearPlugin;
import info.nightscout.androidaps.plugins.general.xdripStatusline.StatuslinePlugin;
import info.nightscout.androidaps.plugins.insulin.InsulinOrefFreePeakPlugin;
import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin;
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin;
@ -42,16 +39,17 @@ import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin;
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref0Plugin;
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin;
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin;
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin;
import info.nightscout.androidaps.plugins.source.SourceDexcomG5Plugin;
import info.nightscout.androidaps.plugins.general.wear.WearPlugin;
import info.nightscout.androidaps.plugins.general.xdripStatusline.StatuslinePlugin;
import info.nightscout.androidaps.utils.LocaleHelper;
import info.nightscout.androidaps.utils.OKDialog;
import info.nightscout.androidaps.utils.SP;
public class PreferencesActivity extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
MyPreferenceFragment myPreferenceFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -63,7 +61,6 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
MainApp.bus().post(new EventPreferenceChange(key));
@ -71,21 +68,18 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
String lang = sharedPreferences.getString("language", "en");
LocaleHelper.setLocale(getApplicationContext(), lang);
MainApp.bus().post(new EventRefreshGui(true));
// recreate() does not update language so better close settings
//recreate() does not update language so better close settings
finish();
}
if (key.equals("short_tabtitles")) {
MainApp.bus().post(new EventRefreshGui());
}
if (key.equals(MainApp.gs(R.string.key_openapsama_useautosens))
&& SP.getBoolean(R.string.key_openapsama_useautosens, false)) {
OKDialog.show(this, MainApp.gs(R.string.configbuilder_sensitivity),
MainApp.gs(R.string.sensitivity_warning), null);
if (key.equals(MainApp.gs(R.string.key_openapsama_useautosens)) && SP.getBoolean(R.string.key_openapsama_useautosens, false)) {
OKDialog.show(this, MainApp.gs(R.string.configbuilder_sensitivity), MainApp.gs(R.string.sensitivity_warning), null);
}
updatePrefSummary(myPreferenceFragment.getPreference(key));
}
private static void updatePrefSummary(Preference pref) {
if (pref instanceof ListPreference) {
ListPreference listPref = (ListPreference) pref;
@ -100,14 +94,12 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
} else if (editTextPref.getText() != null) {
((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage());
pref.setSummary(editTextPref.getText());
} else if (pref.getKey().contains("smscommunicator_allowednumbers")
&& TextUtils.isEmpty(editTextPref.getText().trim())) {
} else if (pref.getKey().contains("smscommunicator_allowednumbers") && TextUtils.isEmpty(editTextPref.getText().trim())) {
pref.setSummary(MainApp.gs(R.string.smscommunicator_allowednumbers_summary));
}
}
}
public static void initSummary(Preference p) {
if (p instanceof PreferenceGroup) {
PreferenceGroup pGrp = (PreferenceGroup) p;
@ -120,23 +112,19 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
}
public static class MyPreferenceFragment extends PreferenceFragment {
private Integer id;
@Override
public void setArguments(Bundle args) {
super.setArguments(args);
id = args.getInt("id");
}
void addPreferencesFromResourceIfEnabled(PluginBase p, PluginType type) {
if (p.isEnabled(type) && p.getPreferencesId() != -1)
addPreferencesFromResource(p.getPreferencesId());
}
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -168,8 +156,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
}
addPreferencesFromResourceIfEnabled(SensitivityAAPSPlugin.getPlugin(), PluginType.SENSITIVITY);
addPreferencesFromResourceIfEnabled(SensitivityWeightedAveragePlugin.getPlugin(),
PluginType.SENSITIVITY);
addPreferencesFromResourceIfEnabled(SensitivityWeightedAveragePlugin.getPlugin(), PluginType.SENSITIVITY);
addPreferencesFromResourceIfEnabled(SensitivityOref0Plugin.getPlugin(), PluginType.SENSITIVITY);
addPreferencesFromResourceIfEnabled(SensitivityOref1Plugin.getPlugin(), PluginType.SENSITIVITY);
@ -207,16 +194,12 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
}
if (Config.NSCLIENT) {
PreferenceScreen scrnAdvancedSettings = (PreferenceScreen) findPreference(getString(R.string.key_advancedsettings));
PreferenceScreen scrnAdvancedSettings = (PreferenceScreen)findPreference(getString(R.string.key_advancedsettings));
if (scrnAdvancedSettings != null) {
scrnAdvancedSettings
.removePreference(getPreference(getString(R.string.key_statuslights_res_warning)));
scrnAdvancedSettings
.removePreference(getPreference(getString(R.string.key_statuslights_res_critical)));
scrnAdvancedSettings
.removePreference(getPreference(getString(R.string.key_statuslights_bat_warning)));
scrnAdvancedSettings
.removePreference(getPreference(getString(R.string.key_statuslights_bat_critical)));
scrnAdvancedSettings.removePreference(getPreference(getString(R.string.key_statuslights_res_warning)));
scrnAdvancedSettings.removePreference(getPreference(getString(R.string.key_statuslights_res_critical)));
scrnAdvancedSettings.removePreference(getPreference(getString(R.string.key_statuslights_bat_warning)));
scrnAdvancedSettings.removePreference(getPreference(getString(R.string.key_statuslights_bat_critical)));
scrnAdvancedSettings.removePreference(getPreference(getString(R.string.key_show_statuslights)));
}
}
@ -224,14 +207,12 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
initSummary(getPreferenceScreen());
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt("id", id);
}
public Preference getPreference(String key) {
return findPreference(key);
}

View file

@ -1,12 +1,12 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
import info.nightscout.androidaps.plugins.pump.common.utils.HexDump;
@ -23,7 +23,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
/**
* This file was taken from GGC - GNU Gluco Control and modified/extended for AAPS.
*
* <p>
* Author: Andy {andy.rozman@gmail.com}
*/
@ -94,17 +94,17 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
}
List<Byte> listRawData = new ArrayList<Byte>();
listRawData.add((byte)opCode);
listRawData.add((byte) opCode);
if (entryType == PumpHistoryEntryType.UnabsorbedInsulin) {
int elements = dataClear.get(counter);
listRawData.add((byte)elements);
listRawData.add((byte) elements);
counter++;
int els = getUnsignedInt(elements);
for (int k = 0; k < (els - 2); k++) {
listRawData.add((byte)dataClear.get(counter));
listRawData.add((byte) dataClear.get(counter));
counter++;
}
@ -117,8 +117,8 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
listRawData.add(dataClear.get(counter));
counter++;
} catch (Exception ex) {
LOG.error("OpCode: " + HexDump.getCorrectHexValue((byte)opCode) + ", Invalid package: "
+ HexDump.toHexStringDisplayable(listRawData));
LOG.error("OpCode: " + HexDump.getCorrectHexValue((byte) opCode) + ", Invalid package: "
+ HexDump.toHexStringDisplayable(listRawData));
// throw ex;
incompletePacket = true;
break;
@ -205,7 +205,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
case ChangeBasalPattern:
return RecordDecodeStatus.OK; // Not supported at the moment
// AAPS Implementation - Ignored entries
// AAPS Implementation - Ignored entries
case CalBGForPH:
case ChangeRemoteId:
case ClearAlarm:
@ -255,9 +255,9 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
case ReadOtherDevicesStatus:
return RecordDecodeStatus.OK;
// case ChangeWatchdogMarriageProfile:
// case DeleteOtherDeviceID:
// case ChangeCaptureEventEnable:
// case ChangeWatchdogMarriageProfile:
// case DeleteOtherDeviceID:
// case ChangeCaptureEventEnable:
case Sensor54:
case Sensor55:
case Sensor51:
@ -287,7 +287,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
LOG.debug(" -- ignored Pump Entry: " + entry);
return RecordDecodeStatus.Ignored;
// **** Implemented records ****
// **** Implemented records ****
case DailyTotals522:
case DailyTotals523:
@ -357,11 +357,11 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
case UnknownBasePacket:
return RecordDecodeStatus.Error;
// case Andy0d:
// case Andy0d:
// case Andy58:
// case Andy58:
// case Andy90:
// case Andy90:
default: {
LOG.debug("Not supported: " + entry.getEntryType());
@ -483,8 +483,8 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
// FIXME 554 ?
private void decodeEndResultTotals(PumpHistoryEntry entry) {
float totals = bitUtils.toInt((int)entry.getHead()[0], (int)entry.getHead()[1], (int)entry.getHead()[2],
(int)entry.getHead()[3], ByteUtil.BitConversion.BIG_ENDIAN) * 0.025f;
float totals = bitUtils.toInt((int) entry.getHead()[0], (int) entry.getHead()[1], (int) entry.getHead()[2],
(int) entry.getHead()[3], ByteUtil.BitConversion.BIG_ENDIAN) * 0.025f;
entry.addDecodedData("Totals", totals);
entry.setDisplayableValue(getFormattedValue(totals, 3));
@ -508,13 +508,13 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
int index = body[2];
if (MedtronicDeviceType.isSameDevice(MedtronicUtil.getMedtronicPumpModel(),
MedtronicDeviceType.Medtronic_523andHigher)) {
MedtronicDeviceType.Medtronic_523andHigher)) {
rate = body[1] * 0.025f;
}
if (rate == null) {
LOG.warn("Basal Profile Start (ERROR): offset={}, rate={}, index={}, body_raw={}", offset, rate, index,
body);
body);
return RecordDecodeStatus.Error;
} else {
// writeData(PumpBaseType.Basal, PumpBasalType.ValueChange, getFormattedFloat(rate, 3),
@ -535,7 +535,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
float bolus_strokes = 10.0f;
if (MedtronicDeviceType.isSameDevice(MedtronicUtil.getMedtronicPumpModel(),
MedtronicDeviceType.Medtronic_523andHigher)) {
MedtronicDeviceType.Medtronic_523andHigher)) {
// https://github.com/ps2/minimed_rf/blob/master/lib/minimed_rf/log_entries/bolus_wizard.rb#L102
bolus_strokes = 40.0f;
@ -546,19 +546,19 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
// carb_ratio (?) = (((self.body[2] & 0x07) << 8) + self.body[3]) /
// 10.0s
dto.insulinSensitivity = new Float(body[4]);
dto.bgTargetLow = (int)body[5];
dto.bgTargetHigh = (int)body[14];
dto.bgTargetLow = (int) body[5];
dto.bgTargetHigh = (int) body[14];
dto.correctionEstimate = (((body[9] & 0x38) << 5) + body[6]) / bolus_strokes;
dto.foodEstimate = ((body[7] << 8) + body[8]) / bolus_strokes;
dto.unabsorbedInsulin = ((body[10] << 8) + body[11]) / bolus_strokes;
dto.bolusTotal = ((body[12] << 8) + body[13]) / bolus_strokes;
} else {
dto.bloodGlucose = (((body[1] & 0x0F) << 8) | entry.getHead()[0]);
dto.carbs = (int)body[0];
dto.carbs = (int) body[0];
dto.carbRatio = Float.valueOf(body[2]);
dto.insulinSensitivity = new Float(body[3]);
dto.bgTargetLow = (int)body[4];
dto.bgTargetHigh = (int)body[12];
dto.bgTargetLow = (int) body[4];
dto.bgTargetHigh = (int) body[12];
dto.bolusTotal = body[11] / 10.0f;
dto.foodEstimate = body[6] / 10.0f;
dto.unabsorbedInsulin = body[9] / 10.0f;
@ -598,7 +598,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
entry.addDecodedData("FixedAmount", fixed);
entry.setDisplayableValue("Amount=" + getFormattedValue(amount, 2) + ", Fixed Amount="
+ getFormattedValue(fixed, 2));
+ getFormattedValue(fixed, 2));
// amount = (double) (asUINT8(data[4]) << 2) / 40.0;
// programmedAmount = (double) (asUINT8(data[2]) << 2) / 40.0;
@ -630,19 +630,19 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
byte[] data = entry.getHead();
if (MedtronicDeviceType.isSameDevice(MedtronicUtil.getMedtronicPumpModel(),
MedtronicDeviceType.Medtronic_523andHigher)) {
bolus.setRequestedAmount(ByteUtil.toInt(data[0], data[1]) / 40.0f);
bolus.setDeliveredAmount(ByteUtil.toInt(data[2], data[3]) / 40.0f);
bolus.setInsulinOnBoard(ByteUtil.toInt(data[4], data[5]) / 40.0f);
MedtronicDeviceType.Medtronic_523andHigher)) {
bolus.setRequestedAmount(ByteUtil.toInt(data[0], data[1]) / 40.0d);
bolus.setDeliveredAmount(ByteUtil.toInt(data[2], data[3]) / 40.0d);
bolus.setInsulinOnBoard(ByteUtil.toInt(data[4], data[5]) / 40.0d);
bolus.setDuration(data[6] * 30);
} else {
bolus.setRequestedAmount(ByteUtil.asUINT8(data[0]) / 10.0f);
bolus.setDeliveredAmount(ByteUtil.asUINT8(data[1]) / 10.0f);
bolus.setRequestedAmount(ByteUtil.asUINT8(data[0]) / 10.0d);
bolus.setDeliveredAmount(ByteUtil.asUINT8(data[1]) / 10.0d);
bolus.setDuration(ByteUtil.asUINT8(data[2]) * 30);
}
bolus.setBolusType((bolus.getDuration() != null && (bolus.getDuration() > 0)) ? PumpBolusType.Extended
: PumpBolusType.Normal);
: PumpBolusType.Normal);
bolus.setAtechDateTime(entry.atechDateTime);
// String dateTime = entry.DT;
@ -699,7 +699,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
}
TempBasalPair tbr = new TempBasalPair(tbrRate.getHead()[0], tbrDuration.getHead()[0], (ByteUtil.asUINT8(tbrRate
.getDatetime()[4]) >> 3) == 0);
.getDatetime()[4]) >> 3) == 0);
// System.out.println("TBR: amount=" + tbr.getInsulinRate() + ", duration=" + tbr.getDurationMinutes()
// // + " min. Packed: " + tbr.getValue()
@ -729,7 +729,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
int dayOfMonth = dt[3] & 0x1F;
int year = fix2DigitYear(dt[4] & 0x3F); // Assuming this is correct, need to verify. Otherwise this will be
// a problem in 2016.
// a problem in 2016.
entry.setAtechDateTime(DateTimeUtil.toATechDate(year, month, dayOfMonth, hour, minutes, seconds));
@ -757,7 +757,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
if (dayOfMonth == 32) {
// FIXME remove
LOG.debug("Entry: Day 32 {} = [{}] {}", entry.getEntryType().name(),
ByteUtil.getHex(entry.getRawData()), entry);
ByteUtil.getHex(entry.getRawData()), entry);
}
if (entry.getEntryType() == PumpHistoryEntryType.EndResultTotals) {

View file

@ -605,8 +605,6 @@ public class MedtronicHistoryData {
switch (bolusDTO.getBolusType()) {
case Normal: {
// DetailedBolusInfo normalBolus = new DetailedBolusInfo();
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
detailedBolusInfo.date = tryToGetByLocalTime(bolus.atechDateTime);
@ -618,10 +616,6 @@ public class MedtronicHistoryData {
bolus.setLinkedObject(detailedBolusInfo);
// bolus.setLinkedObject(normalBolus);
// TreatmentsPlugin.getPlugin().addToHistoryTreatment(normalBolus, false);
if (L.isEnabled(L.PUMPCOMM))
LOG.debug("addBolus - [date={},pumpId={}, insulin={}, newRecord={}]", detailedBolusInfo.date,
detailedBolusInfo.pumpId, detailedBolusInfo.insulin, newRecord);
@ -652,23 +646,6 @@ public class MedtronicHistoryData {
} else {
boolean old = false;
// if (old) {
// treatment.insulin = bolusDTO.getDeliveredAmount();
// treatment.pumpId = bolus.getPumpId();
// treatment.source = Source.PUMP;
//
// bolus.setLinkedObject(treatment);
//
// TreatmentsPlugin.getPlugin().getService().createOrUpdate(treatment);
//
// LOG.debug("editBolus - [date={},pumpId={}, insulin={}]", treatment.date, treatment.pumpId,
// treatment.insulin);
//
// MainApp.bus().post(new EventTreatmentChange(treatment));
// } else {
DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(treatment.date);
if (detailedBolusInfo == null) {
detailedBolusInfo = new DetailedBolusInfo();
@ -678,6 +655,7 @@ public class MedtronicHistoryData {
detailedBolusInfo.source = Source.PUMP;
detailedBolusInfo.pumpId = bolus.getPumpId();
detailedBolusInfo.insulin = bolusDTO.getDeliveredAmount();
detailedBolusInfo.carbs = treatment.carbs;
boolean newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);

View file

@ -29,16 +29,16 @@ import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpBolusType;
public class BolusDTO extends PumpTimeStampedRecord {
@Expose
private Float requestedAmount;
private Double requestedAmount;
@Expose
private Float deliveredAmount;
private Double deliveredAmount;
@Expose
private Float immediateAmount; // when Multiwave this is used
private Double immediateAmount; // when Multiwave this is used
@Expose
private Integer duration;
@Expose
private PumpBolusType bolusType;
private Float insulinOnBoard;
private Double insulinOnBoard;
public BolusDTO() {
@ -46,22 +46,22 @@ public class BolusDTO extends PumpTimeStampedRecord {
}
public Float getRequestedAmount() {
public Double getRequestedAmount() {
return requestedAmount;
}
public void setRequestedAmount(Float requestedAmount) {
public void setRequestedAmount(Double requestedAmount) {
this.requestedAmount = requestedAmount;
}
public Float getDeliveredAmount() {
public Double getDeliveredAmount() {
return deliveredAmount;
}
public void setDeliveredAmount(Float deliveredAmount) {
public void setDeliveredAmount(Double deliveredAmount) {
this.deliveredAmount = deliveredAmount;
}
@ -86,12 +86,12 @@ public class BolusDTO extends PumpTimeStampedRecord {
}
public Float getInsulinOnBoard() {
public Double getInsulinOnBoard() {
return insulinOnBoard;
}
public void setInsulinOnBoard(Float insulinOnBoard) {
public void setInsulinOnBoard(Double insulinOnBoard) {
this.insulinOnBoard = insulinOnBoard;
}
@ -112,10 +112,10 @@ public class BolusDTO extends PumpTimeStampedRecord {
return getFormattedDecimal(this.deliveredAmount);
} else if (bolusType == PumpBolusType.Extended) {
return String.format("AMOUNT_SQUARE=%s;DURATION=%s", getFormattedDecimal(this.deliveredAmount),
getDurationString());
getDurationString());
} else {
return String.format("AMOUNT=%s;AMOUNT_SQUARE=%s;DURATION=%s", getFormattedDecimal(this.immediateAmount),
getFormattedDecimal(this.deliveredAmount), getDurationString());
getFormattedDecimal(this.deliveredAmount), getDurationString());
}
}
@ -131,12 +131,12 @@ public class BolusDTO extends PumpTimeStampedRecord {
}
public Float getImmediateAmount() {
public Double getImmediateAmount() {
return immediateAmount;
}
public void setImmediateAmount(Float immediateAmount) {
public void setImmediateAmount(Double immediateAmount) {
this.immediateAmount = immediateAmount;
}

View file

@ -108,9 +108,9 @@ public class Treatment implements DataPointWithLabelInterface {
public boolean isDataChanging(Treatment other) {
if (date != other.date)
return true;
if (insulin != other.insulin)
if (!isSame(insulin, other.insulin))
return true;
if (carbs != other.carbs)
if (!isSame(carbs, other.carbs))
return true;
return false;
}
@ -118,9 +118,9 @@ public class Treatment implements DataPointWithLabelInterface {
public boolean isEqual(Treatment other) {
if (date != other.date)
return false;
if (insulin != other.insulin)
if (!isSame(insulin, other.insulin))
return false;
if (carbs != other.carbs)
if (!isSame(carbs, other.carbs))
return false;
if (mealBolus != other.mealBolus)
return false;
@ -136,9 +136,9 @@ public class Treatment implements DataPointWithLabelInterface {
public boolean isEqualWithoutPumpId(Treatment other) {
if (date != other.date)
return false;
if (insulin != other.insulin)
if (!isSame(insulin, other.insulin))
return false;
if (carbs != other.carbs)
if (!isSame(carbs, other.carbs))
return false;
if (mealBolus != other.mealBolus)
return false;
@ -149,6 +149,11 @@ public class Treatment implements DataPointWithLabelInterface {
return true;
}
public boolean isSame(Double d1, Double d2) {
double diff = d1 - d2;
return (Math.abs(diff) <= 0.000001);
}
@Nullable
public JSONObject getBoluscalc() {
@ -168,12 +173,13 @@ public class Treatment implements DataPointWithLabelInterface {
if (date != other.date) {
return false;
}
if (insulin != other.insulin) {
if (!isSame(insulin, other.insulin))
return false;
}
if (carbs != other.carbs) {
if (!isSame(carbs, other.carbs))
return false;
}
return true;
}