Merge pull request #2141 from andyrozman/double_bolus_debug
Double bolus debug
This commit is contained in:
commit
c82fd6a56b
13 changed files with 180 additions and 37 deletions
|
@ -34,6 +34,7 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewB
|
|||
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState;
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.data.MedtronicHistoryData;
|
||||
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
|
@ -415,6 +416,9 @@ public abstract class PumpPluginAbstract extends PluginBase implements PumpInter
|
|||
// bolus needed, ask pump to deliver it
|
||||
return deliverBolus(detailedBolusInfo);
|
||||
} else {
|
||||
if (MedtronicHistoryData.doubleBolusDebug)
|
||||
LOG.debug("DoubleBolusDebug: deliverTreatment::(carb only entry)");
|
||||
|
||||
// no bolus required, carb only treatment
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, true);
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.pump.common.bolusInfo
|
|||
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||
import info.nightscout.androidaps.logging.L
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.data.MedtronicHistoryData
|
||||
import info.nightscout.androidaps.utils.T
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.util.*
|
||||
|
@ -19,6 +20,10 @@ object DetailedBolusInfoStorage {
|
|||
|
||||
@Synchronized
|
||||
fun findDetailedBolusInfo(bolusTime: Long, bolus: Double): DetailedBolusInfo? {
|
||||
|
||||
if (MedtronicHistoryData.doubleBolusDebug)
|
||||
log.debug("DoubleBolusDebug: findDetailedBolusInfo::bolusTime={}, bolus={}", bolusTime, bolus)
|
||||
|
||||
// Look for info with bolus
|
||||
for (i in store.indices) {
|
||||
val d = store[i]
|
||||
|
@ -28,6 +33,9 @@ object DetailedBolusInfoStorage {
|
|||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Using & removing bolus info: " + store[i])
|
||||
store.removeAt(i)
|
||||
if (MedtronicHistoryData.doubleBolusDebug)
|
||||
log.debug("DoubleBolusDebug: findDetailedBolusInfo::selectedBolus[DetailedBolusInfo={}]", d)
|
||||
|
||||
return d
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +46,8 @@ object DetailedBolusInfoStorage {
|
|||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Using & removing bolus info: " + store[i])
|
||||
store.removeAt(i)
|
||||
if (MedtronicHistoryData.doubleBolusDebug)
|
||||
log.debug("DoubleBolusDebug: findDetailedBolusInfo::selectedBolus[DetailedBolusInfo={}]", d)
|
||||
return d
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,10 +122,10 @@ public class RileyLinkStatusGeneral extends Fragment implements RefreshableInter
|
|||
this.medtronicPumpStatus = MedtronicUtil.getPumpStatus();
|
||||
|
||||
if (medtronicPumpStatus != null) {
|
||||
this.deviceType.setText(MainApp.gs(RileyLinkUtil.getTargetDevice().getResourceId()));
|
||||
this.deviceType.setText(MainApp.gs(RileyLinkTargetDevice.MedtronicPump.getResourceId()));
|
||||
this.deviceModel.setText(medtronicPumpStatus.pumpType.getDescription());
|
||||
this.serialNumber.setText(medtronicPumpStatus.serialNumber);
|
||||
this.pumpFrequency.setText(medtronicPumpStatus.pumpFrequency);
|
||||
this.pumpFrequency.setText(MainApp.gs(medtronicPumpStatus.pumpFrequency.equals("medtronic_pump_frequency_us_ca") ? R.string.medtronic_pump_frequency_us_ca : R.string.medtronic_pump_frequency_worldwide));
|
||||
|
||||
// TODO extend when Omnipod used
|
||||
|
||||
|
|
|
@ -83,6 +83,13 @@ public class MedtronicHistoryData {
|
|||
|
||||
private long lastIdUsed = 0;
|
||||
|
||||
/**
|
||||
* Double bolus debug. We seem to have small problem with double Boluses (or sometimes also missing boluses
|
||||
* from history. This flag turns on debugging for that (default is off=false)... Debuging is pretty detailed,
|
||||
* so log files will get bigger.
|
||||
*/
|
||||
public static boolean doubleBolusDebug = false;
|
||||
|
||||
|
||||
public MedtronicHistoryData() {
|
||||
this.allHistory = new ArrayList<>();
|
||||
|
@ -584,23 +591,32 @@ public class MedtronicHistoryData {
|
|||
|
||||
long oldestTimestamp = getOldestTimestamp(entryList);
|
||||
|
||||
Gson gson = MedtronicUtil.getGsonInstance();
|
||||
|
||||
List<? extends DbObjectBase> entriesFromHistory = getDatabaseEntriesByLastTimestamp(oldestTimestamp, ProcessHistoryRecord.Bolus);
|
||||
|
||||
// LOG.debug(processHistoryRecord.getDescription() + " List (before filter): {}, FromDb={}", gsonPretty.toJson(entryList),
|
||||
// gsonPretty.toJson(entriesFromHistory));
|
||||
if (doubleBolusDebug)
|
||||
LOG.debug("DoubleBolusDebug: List (before filter): {}, FromDb={}", gson.toJson(entryList),
|
||||
gson.toJson(entriesFromHistory));
|
||||
|
||||
filterOutAlreadyAddedEntries(entryList, entriesFromHistory);
|
||||
|
||||
if (entryList.isEmpty())
|
||||
if (entryList.isEmpty()) {
|
||||
if (doubleBolusDebug)
|
||||
LOG.debug("DoubleBolusDebug: EntryList was filtered out.");
|
||||
return;
|
||||
}
|
||||
|
||||
// LOG.debug(processHistoryRecord.getDescription() + " List (after filter): {}, FromDb={}", gsonPretty.toJson(entryList),
|
||||
// gsonPretty.toJson(entriesFromHistory));
|
||||
if (doubleBolusDebug)
|
||||
LOG.debug("DoubleBolusDebug: List (after filter): {}, FromDb={}", gson.toJson(entryList),
|
||||
gson.toJson(entriesFromHistory));
|
||||
|
||||
if (isCollectionEmpty(entriesFromHistory)) {
|
||||
for (PumpHistoryEntry treatment : entryList) {
|
||||
if (isLogEnabled())
|
||||
LOG.debug("Add Bolus (no db entry): " + treatment);
|
||||
if (doubleBolusDebug)
|
||||
LOG.debug("DoubleBolusDebug: Add Bolus: FromDb=null, Treatment={}", treatment);
|
||||
|
||||
addBolus(treatment, null);
|
||||
}
|
||||
|
@ -609,6 +625,8 @@ public class MedtronicHistoryData {
|
|||
DbObjectBase treatmentDb = findDbEntry(treatment, entriesFromHistory);
|
||||
if (isLogEnabled())
|
||||
LOG.debug("Add Bolus {} - (entryFromDb={}) ", treatment, treatmentDb);
|
||||
if (doubleBolusDebug)
|
||||
LOG.debug("DoubleBolusDebug: Add Bolus: FromDb={}, Treatment={}", treatmentDb, treatment);
|
||||
|
||||
addBolus(treatment, (Treatment) treatmentDb);
|
||||
}
|
||||
|
@ -761,9 +779,30 @@ public class MedtronicHistoryData {
|
|||
|
||||
//proposedTime += (this.pumpTime.timeDifference * 1000);
|
||||
|
||||
if (doubleBolusDebug)
|
||||
LOG.debug("DoubleBolusDebug: findDbEntry Treatment={}, FromDb={}", treatment, gson.toJson(entriesFromHistory));
|
||||
|
||||
if (entriesFromHistory.size() == 0) {
|
||||
if (doubleBolusDebug)
|
||||
LOG.debug("DoubleBolusDebug: findDbEntry Treatment={}, FromDb=null", treatment);
|
||||
return null;
|
||||
} else if (entriesFromHistory.size() == 1) {
|
||||
if (doubleBolusDebug)
|
||||
LOG.debug("DoubleBolusDebug: findDbEntry Treatment={}, FromDb={}. Type=SingleEntry", treatment, entriesFromHistory.get(0));
|
||||
|
||||
// TODO: Fix db code
|
||||
// if difference is bigger than 2 minutes we discard entry
|
||||
long maxMillisAllowed = DateTimeUtil.getMillisFromATDWithAddedMinutes(treatment.atechDateTime, 2);
|
||||
|
||||
if (doubleBolusDebug)
|
||||
LOG.debug("DoubleBolusDebug: findDbEntry maxMillisAllowed={}, AtechDateTime={} (add 2 minutes). ", maxMillisAllowed, treatment.atechDateTime);
|
||||
|
||||
if (entriesFromHistory.get(0).getDate() > maxMillisAllowed) {
|
||||
if (doubleBolusDebug)
|
||||
LOG.debug("DoubleBolusDebug: findDbEntry entry filtered out, returning null. ");
|
||||
return null;
|
||||
}
|
||||
|
||||
return entriesFromHistory.get(0);
|
||||
}
|
||||
|
||||
|
@ -786,10 +825,10 @@ public class MedtronicHistoryData {
|
|||
}
|
||||
}
|
||||
|
||||
// LOG.debug("Entries: (timeDiff=[min={},sec={}],count={},list={})", min, sec, outList.size(),
|
||||
// gsonPretty.toJson(outList));
|
||||
|
||||
if (outList.size() == 1) {
|
||||
if (doubleBolusDebug)
|
||||
LOG.debug("DoubleBolusDebug: findDbEntry Treatment={}, FromDb={}. Type=EntrySelected, AtTimeMin={}, AtTimeSec={}", treatment, entriesFromHistory.get(0), min, sec);
|
||||
|
||||
return outList.get(0);
|
||||
}
|
||||
|
||||
|
@ -797,6 +836,9 @@ public class MedtronicHistoryData {
|
|||
if (isLogEnabled())
|
||||
LOG.error("Too many entries (with too small diff): (timeDiff=[min={},sec={}],count={},list={})",
|
||||
min, sec, outList.size(), gson.toJson(outList));
|
||||
if (doubleBolusDebug)
|
||||
LOG.debug("DoubleBolusDebug: findDbEntry Error - Too many entries (with too small diff): (timeDiff=[min={},sec={}],count={},list={})",
|
||||
min, sec, outList.size(), gson.toJson(outList));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -851,6 +893,8 @@ public class MedtronicHistoryData {
|
|||
BolusDTO bolusDTO = (BolusDTO) bolus.getDecodedData().get("Object");
|
||||
|
||||
if (treatment == null) {
|
||||
if (doubleBolusDebug)
|
||||
LOG.debug("DoubleBolusDebug: addBolus(tretament==null): Bolus={}", bolusDTO);
|
||||
|
||||
switch (bolusDTO.getBolusType()) {
|
||||
case Normal: {
|
||||
|
@ -863,6 +907,9 @@ public class MedtronicHistoryData {
|
|||
|
||||
addCarbsFromEstimate(detailedBolusInfo, bolus);
|
||||
|
||||
if (doubleBolusDebug)
|
||||
LOG.debug("DoubleBolusDebug: addBolus(tretament==null): DetailedBolusInfo={}", detailedBolusInfo);
|
||||
|
||||
boolean newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
||||
|
||||
bolus.setLinkedObject(detailedBolusInfo);
|
||||
|
@ -885,6 +932,9 @@ public class MedtronicHistoryData {
|
|||
|
||||
bolus.setLinkedObject(extendedBolus);
|
||||
|
||||
if (doubleBolusDebug)
|
||||
LOG.debug("DoubleBolusDebug: addBolus(tretament==null): ExtendedBolus={}", extendedBolus);
|
||||
|
||||
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
|
||||
|
||||
if (isLogEnabled())
|
||||
|
@ -898,8 +948,15 @@ public class MedtronicHistoryData {
|
|||
} else {
|
||||
|
||||
DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.INSTANCE.findDetailedBolusInfo(treatment.date, bolusDTO.getDeliveredAmount());
|
||||
|
||||
if (doubleBolusDebug)
|
||||
LOG.debug("DoubleBolusDebug: addBolus(tretament={}): Bolus={}, DetailedBolusInfo={}", treatment, bolusDTO, detailedBolusInfo);
|
||||
|
||||
if (detailedBolusInfo == null) {
|
||||
detailedBolusInfo = new DetailedBolusInfo();
|
||||
|
||||
if (doubleBolusDebug)
|
||||
LOG.debug("DoubleBolusDebug: detailedBolusInfoCouldNotBeRetrived !");
|
||||
}
|
||||
|
||||
detailedBolusInfo.date = treatment.date;
|
||||
|
@ -910,6 +967,9 @@ public class MedtronicHistoryData {
|
|||
|
||||
addCarbsFromEstimate(detailedBolusInfo, bolus);
|
||||
|
||||
if (doubleBolusDebug)
|
||||
LOG.debug("DoubleBolusDebug: addBolus(tretament!=null): DetailedBolusInfo(New)={}", detailedBolusInfo);
|
||||
|
||||
boolean newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
||||
|
||||
bolus.setLinkedObject(detailedBolusInfo);
|
||||
|
@ -928,6 +988,9 @@ public class MedtronicHistoryData {
|
|||
|
||||
BolusWizardDTO bolusWizard = (BolusWizardDTO) bolus.getDecodedData().get("Estimate");
|
||||
|
||||
if (doubleBolusDebug)
|
||||
LOG.debug("DoubleBolusDebug: addCarbsFromEstimate: Bolus={}, BolusWizardDTO={}", bolus, bolusWizard);
|
||||
|
||||
detailedBolusInfo.carbs = bolusWizard.carbs;
|
||||
}
|
||||
}
|
||||
|
@ -1276,24 +1339,26 @@ public class MedtronicHistoryData {
|
|||
}
|
||||
}
|
||||
|
||||
//LocalDateTime oldestEntryTime = null;
|
||||
if (doubleBolusDebug)
|
||||
LOG.debug("DoubleBolusDebug: getOldestTimestamp. Oldest entry found: time={}, object={}", dt, currentTreatment);
|
||||
|
||||
try {
|
||||
|
||||
GregorianCalendar oldestEntryTime = DateTimeUtil.toGregorianCalendar(dt);
|
||||
if (doubleBolusDebug)
|
||||
LOG.debug("DoubleBolusDebug: getOldestTimestamp. oldestEntryTime: {}", DateTimeUtil.toString(oldestEntryTime));
|
||||
oldestEntryTime.add(Calendar.MINUTE, -2);
|
||||
|
||||
if (doubleBolusDebug)
|
||||
LOG.debug("DoubleBolusDebug: getOldestTimestamp. oldestEntryTime (-2m): {}, timeInMillis={}", DateTimeUtil.toString(oldestEntryTime), oldestEntryTime.getTimeInMillis());
|
||||
|
||||
return oldestEntryTime.getTimeInMillis();
|
||||
|
||||
// if (this.pumpTime.timeDifference < 0) {
|
||||
// oldestEntryTime = oldestEntryTime.plusSeconds(this.pumpTime.timeDifference);
|
||||
// }
|
||||
} catch (Exception ex) {
|
||||
LOG.error("Problem decoding date from last record: {}" + currentTreatment);
|
||||
LOG.error("Problem decoding date from last record: {}", currentTreatment);
|
||||
return 8; // default return of 6 minutes
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@ package info.nightscout.androidaps.plugins.pump.medtronic.data.dto;
|
|||
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.BatteryType;
|
||||
|
||||
/**
|
||||
|
@ -38,10 +40,11 @@ public class BatteryStatusDTO {
|
|||
|
||||
|
||||
public String toString() {
|
||||
return String.format("BatteryStatusDTO [voltage=%.2f, alkaline=%d, lithium=%d]",
|
||||
return String.format(Locale.ENGLISH, "BatteryStatusDTO [voltage=%.2f, alkaline=%d, lithium=%d, niZn={}]",
|
||||
voltage == null ? 0.0f : voltage,
|
||||
getCalculatedPercent(BatteryType.Alkaline),
|
||||
getCalculatedPercent(BatteryType.Lithium));
|
||||
getCalculatedPercent(BatteryType.Lithium),
|
||||
getCalculatedPercent(BatteryType.NiZn));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,7 +14,9 @@ public enum BatteryType {
|
|||
|
||||
None(R.string.key_medtronic_pump_battery_no, 0, 0),
|
||||
Alkaline(R.string.key_medtronic_pump_battery_alkaline, 1.20d, 1.47d), //
|
||||
Lithium(R.string.key_medtronic_pump_battery_lithium, 1.22d, 1.64d);
|
||||
Lithium(R.string.key_medtronic_pump_battery_lithium, 1.22d, 1.64d), //
|
||||
NiZn(R.string.key_medtronic_pump_battery_nizn, 1.40d, 1.70d) //
|
||||
;
|
||||
|
||||
private final String description;
|
||||
public double lowVoltage;
|
||||
|
|
|
@ -22,6 +22,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.Rile
|
|||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkTargetFrequency;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.data.MedtronicHistoryData;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.BasalProfileStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.BatteryType;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
|
||||
|
@ -281,6 +282,12 @@ public class MedtronicPumpStatus extends PumpStatus {
|
|||
MedtronicUtil.setBatteryType(this.batteryType);
|
||||
}
|
||||
|
||||
String bolusDebugEnabled = SP.getString(MedtronicConst.Prefs.BolusDebugEnabled, null);
|
||||
|
||||
boolean bolusDebug = bolusDebugEnabled != null && bolusDebugEnabled.equals(MainApp.gs(R.string.common_on));
|
||||
|
||||
MedtronicHistoryData.doubleBolusDebug = bolusDebug;
|
||||
|
||||
reconfigureService();
|
||||
|
||||
return true;
|
||||
|
|
|
@ -11,17 +11,6 @@ public class MedtronicConst {
|
|||
static final String Prefix = "AAPS.Medtronic.";
|
||||
|
||||
public class Prefs {
|
||||
|
||||
// public static final String PrefPrefix = "pref_medtronic_";
|
||||
// public static final String PumpSerial = PrefPrefix + "serial";
|
||||
// public static final String PumpType = PrefPrefix + "pump_type";
|
||||
// public static final String PumpFrequency = PrefPrefix + "frequency";
|
||||
// public static final String MaxBolus = PrefPrefix + "max_bolus";
|
||||
// public static final String MaxBasal = PrefPrefix + "max_basal";
|
||||
// public static final String BolusDelay = PrefPrefix + "bolus_delay";
|
||||
// public static final String Encoding = PrefPrefix + "encoding";
|
||||
// public static final String BatteryType = PrefPrefix + "battery_type";
|
||||
|
||||
public static final int PumpSerial = R.string.key_medtronic_serial;
|
||||
public static final int PumpType = R.string.key_medtronic_pump_type;
|
||||
public static final int PumpFrequency = R.string.key_medtronic_frequency;
|
||||
|
@ -30,6 +19,7 @@ public class MedtronicConst {
|
|||
public static final int BolusDelay = R.string.key_medtronic_bolus_delay;
|
||||
public static final int Encoding = R.string.key_medtronic_encoding;
|
||||
public static final int BatteryType = R.string.key_medtronic_battery_type;
|
||||
public static final int BolusDebugEnabled = R.string.key_medtronic_bolus_debug;
|
||||
}
|
||||
|
||||
public class Statistics {
|
||||
|
|
|
@ -39,6 +39,7 @@ import info.nightscout.androidaps.events.EventTreatmentChange;
|
|||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.data.MedtronicHistoryData;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||
import info.nightscout.androidaps.utils.JsonHelper;
|
||||
|
@ -249,10 +250,14 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
|||
try {
|
||||
Treatment treatment = Treatment.createFromJson(json);
|
||||
if (treatment != null) {
|
||||
|
||||
if (MedtronicHistoryData.doubleBolusDebug)
|
||||
log.debug("DoubleBolusDebug: createTreatmentFromJsonIfNotExists:: medtronicPump={}", MedtronicUtil.isMedtronicPump());
|
||||
|
||||
if (!MedtronicUtil.isMedtronicPump())
|
||||
createOrUpdate(treatment);
|
||||
else
|
||||
createOrUpdateMedtronic(treatment, false);
|
||||
createOrUpdateMedtronic(treatment, true);
|
||||
} else
|
||||
log.error("Date is null: " + treatment.toString());
|
||||
} catch (JSONException e) {
|
||||
|
@ -392,11 +397,18 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
|||
|
||||
|
||||
public UpdateReturn createOrUpdateMedtronic(Treatment treatment, boolean fromNightScout) {
|
||||
|
||||
if (MedtronicHistoryData.doubleBolusDebug)
|
||||
log.debug("DoubleBolusDebug: createOrUpdateMedtronic:: originalTreatment={}, fromNightScout={}", treatment, fromNightScout);
|
||||
|
||||
try {
|
||||
treatment.date = DatabaseHelper.roundDateToSec(treatment.date);
|
||||
|
||||
Treatment existingTreatment = getRecord(treatment.pumpId, treatment.date);
|
||||
|
||||
if (MedtronicHistoryData.doubleBolusDebug)
|
||||
log.debug("DoubleBolusDebug: createOrUpdateMedtronic:: existingTreatment={}", treatment);
|
||||
|
||||
if (existingTreatment == null) {
|
||||
getDao().create(treatment);
|
||||
if (L.isEnabled(L.DATATREATMENTS))
|
||||
|
@ -407,6 +419,9 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
|||
} else {
|
||||
|
||||
if (existingTreatment.date == treatment.date) {
|
||||
if (MedtronicHistoryData.doubleBolusDebug)
|
||||
log.debug("DoubleBolusDebug: createOrUpdateMedtronic::(existingTreatment.date==treatment.date)");
|
||||
|
||||
// we will do update only, if entry changed
|
||||
if (!optionalTreatmentCopy(existingTreatment, treatment, fromNightScout)) {
|
||||
return new UpdateReturn(true, false);
|
||||
|
@ -416,6 +431,9 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
|||
scheduleTreatmentChange(treatment);
|
||||
return new UpdateReturn(true, false);
|
||||
} else {
|
||||
if (MedtronicHistoryData.doubleBolusDebug)
|
||||
log.debug("DoubleBolusDebug: createOrUpdateMedtronic::(existingTreatment.date != treatment.date)");
|
||||
|
||||
// date is different, we need to remove entry
|
||||
getDao().delete(existingTreatment);
|
||||
optionalTreatmentCopy(existingTreatment, treatment, fromNightScout);
|
||||
|
|
|
@ -51,6 +51,7 @@ import info.nightscout.androidaps.plugins.general.overview.notifications.Notific
|
|||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.data.MedtronicHistoryData;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin;
|
||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin;
|
||||
|
@ -344,12 +345,20 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
|||
@Override
|
||||
public List<Treatment> getTreatmentsFromHistoryAfterTimestamp(long fromTimestamp) {
|
||||
List<Treatment> in5minback = new ArrayList<>();
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
synchronized (treatments) {
|
||||
if (MedtronicHistoryData.doubleBolusDebug)
|
||||
log.debug("DoubleBolusDebug: AllTreatmentsInDb: {}", MedtronicUtil.getGsonInstance().toJson(treatments));
|
||||
|
||||
for (Treatment t : treatments) {
|
||||
if (t.date <= time && t.date >= fromTimestamp)
|
||||
in5minback.add(t);
|
||||
}
|
||||
|
||||
if (MedtronicHistoryData.doubleBolusDebug)
|
||||
log.debug("DoubleBolusDebug: FilteredTreatments: AfterTime={}, Items={}", fromTimestamp, MedtronicUtil.getGsonInstance().toJson(in5minback));
|
||||
|
||||
return in5minback;
|
||||
}
|
||||
}
|
||||
|
@ -623,6 +632,9 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
|||
public boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo, boolean allowUpdate) {
|
||||
boolean medtronicPump = MedtronicUtil.isMedtronicPump();
|
||||
|
||||
if (MedtronicHistoryData.doubleBolusDebug)
|
||||
log.debug("DoubleBolusDebug: addToHistoryTreatment::isMedtronicPump={}", medtronicPump);
|
||||
|
||||
Treatment treatment = new Treatment();
|
||||
treatment.date = detailedBolusInfo.date;
|
||||
treatment.source = detailedBolusInfo.source;
|
||||
|
@ -637,6 +649,9 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
|||
treatment.boluscalc = detailedBolusInfo.boluscalc != null ? detailedBolusInfo.boluscalc.toString() : null;
|
||||
TreatmentService.UpdateReturn creatOrUpdateResult;
|
||||
|
||||
if (medtronicPump && MedtronicHistoryData.doubleBolusDebug)
|
||||
log.debug("DoubleBolusDebug: addToHistoryTreatment::treatment={}", treatment);
|
||||
|
||||
if (!medtronicPump)
|
||||
creatOrUpdateResult = getService().createOrUpdate(treatment);
|
||||
else
|
||||
|
@ -645,12 +660,17 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
|||
boolean newRecordCreated = creatOrUpdateResult.newRecord;
|
||||
//log.debug("Adding new Treatment record" + treatment.toString());
|
||||
if (detailedBolusInfo.carbTime != 0) {
|
||||
|
||||
Treatment carbsTreatment = new Treatment();
|
||||
carbsTreatment.source = detailedBolusInfo.source;
|
||||
carbsTreatment.pumpId = detailedBolusInfo.pumpId; // but this should never happen
|
||||
carbsTreatment.date = detailedBolusInfo.date + detailedBolusInfo.carbTime * 60 * 1000L + 1000L; // add 1 sec to make them different records
|
||||
carbsTreatment.carbs = detailedBolusInfo.carbs;
|
||||
carbsTreatment.source = detailedBolusInfo.source;
|
||||
|
||||
if (medtronicPump && MedtronicHistoryData.doubleBolusDebug)
|
||||
log.debug("DoubleBolusDebug: carbTime!=0, creating second treatment. CarbsTreatment={}", carbsTreatment);
|
||||
|
||||
if (!medtronicPump)
|
||||
getService().createOrUpdate(carbsTreatment);
|
||||
else
|
||||
|
|
|
@ -99,7 +99,7 @@
|
|||
<item>@string/use_gps_location</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="locationValues" translatable="false">
|
||||
<string-array name="locationValues" translatable="false">
|
||||
<item>PASSIVE</item>
|
||||
<item>NETWORK</item>
|
||||
<item>GPS</item>
|
||||
|
@ -151,7 +151,7 @@
|
|||
<item>@string/medtronic_pump_frequency_worldwide</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="medtronicPumpFreqValues">
|
||||
<string-array name="medtronicPumpFreqValues">
|
||||
<item>@string/key_medtronic_pump_frequency_us_ca</item>
|
||||
<item>@string/key_medtronic_pump_frequency_worldwide</item>
|
||||
</string-array>
|
||||
|
@ -167,6 +167,11 @@
|
|||
<item>@string/medtronic_pump_encoding_4b6b_rileylink</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="onOff">
|
||||
<item>@string/common_on</item>
|
||||
<item>@string/common_off</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="medtronicEncodingValues">
|
||||
<item>@string/key_medtronic_pump_encoding_4b6b_local</item>
|
||||
<item>@string/key_medtronic_pump_encoding_4b6b_rileylink</item>
|
||||
|
@ -176,12 +181,17 @@
|
|||
<item>@string/medtronic_pump_battery_no</item>
|
||||
<item>@string/medtronic_pump_battery_alkaline</item>
|
||||
<item>@string/medtronic_pump_battery_lithium</item>
|
||||
<item>@string/medtronic_pump_battery_nizn</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="medtronicBatteryTypeValues">
|
||||
<item>@string/key_medtronic_pump_battery_no</item>
|
||||
<item>@string/key_medtronic_pump_battery_alkaline</item>
|
||||
<item>@string/key_medtronic_pump_battery_lithium</item>
|
||||
<item>@string/key_medtronic_pump_battery_nizn</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
key_medtronic_bolus_debug
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -4,15 +4,15 @@
|
|||
<string name="af_lang" translatable="false">Afrikaans</string>
|
||||
<string name="bg_lang" translatable="false">Bulgarian</string>
|
||||
<string name="nl_lang" translatable="false">Dutch</string>
|
||||
<!-- <string name="fi_lang" translatable="false">Finnish</string> -->
|
||||
<!-- <string name="fi_lang" translatable="false">Finnish</string> -->
|
||||
<string name="fr_lang" translatable="false">French</string>
|
||||
<string name="de_lang" translatable="false">German</string>
|
||||
<string name="el_lang" translatable="false">Greek</string>
|
||||
<!-- <string name="he_lang" translatable="false">Hebrew</string> -->
|
||||
<!-- <string name="he_lang" translatable="false">Hebrew</string> -->
|
||||
<string name="zh_lang" translatable="false">Chinese</string>
|
||||
<!-- <string name="ga_lang" translatable="false">Irish</string> -->
|
||||
<!-- <string name="ga_lang" translatable="false">Irish</string> -->
|
||||
<string name="it_lang" translatable="false">Italian</string>
|
||||
<!-- <string name="ja_lang" translatable="false">Japanese</string> -->
|
||||
<!-- <string name="ja_lang" translatable="false">Japanese</string> -->
|
||||
<string name="ko_lang" translatable="false">Korean</string>
|
||||
<string name="lt_lang" translatable="false">Lithuanian</string>
|
||||
<string name="pl_lang" translatable="false">Polish</string>
|
||||
|
@ -1424,6 +1424,7 @@
|
|||
<string name="key_medtronic_bolus_delay" translatable="false">pref_medtronic_bolus_delay</string>
|
||||
<string name="key_medtronic_encoding" translatable="false">pref_medtronic_encoding</string>
|
||||
<string name="key_medtronic_battery_type" translatable="false">pref_medtronic_battery_type</string>
|
||||
<string name="key_medtronic_bolus_debug" translatable="false">pref_medtronic_bolus_debug</string>
|
||||
<string name="key_rileylink_mac_address" translatable="false">pref_rileylink_mac_address</string>
|
||||
<string name="key_medtronic_pump_frequency_us_ca" translatable="false">medtronic_pump_frequency_us_ca</string>
|
||||
<string name="key_medtronic_pump_frequency_worldwide" translatable="false">medtronic_pump_frequency_worldwide</string>
|
||||
|
@ -1432,6 +1433,7 @@
|
|||
<string name="key_medtronic_pump_battery_no" translatable="false">medtronic_pump_battery_no</string>
|
||||
<string name="key_medtronic_pump_battery_alkaline" translatable="false">medtronic_pump_battery_alkaline</string>
|
||||
<string name="key_medtronic_pump_battery_lithium" translatable="false">medtronic_pump_battery_lithium</string>
|
||||
<string name="key_medtronic_pump_battery_nizn" translatable="false">medtronic_pump_battery_nizn</string>
|
||||
|
||||
<string name="medtronic_serial_number">Pump Serial Number</string>
|
||||
<string name="medtronic_pump_type">Pump Type</string>
|
||||
|
@ -1451,6 +1453,8 @@
|
|||
<string name="medtronic_pump_battery_no">Not selected (Simple view)</string>
|
||||
<string name="medtronic_pump_battery_alkaline">Alkaline (Extended view)</string>
|
||||
<string name="medtronic_pump_battery_lithium">Lithium (Extended view)</string>
|
||||
<string name="medtronic_pump_battery_nizn">NiZn (Extended view)</string>
|
||||
<string name="medtronic_bolus_debugging">Bolus/Treatments Debugging</string>
|
||||
|
||||
<!-- RL BLE Scanning -->
|
||||
<string name="rileylink_scanner_scan_scan">SCAN</string>
|
||||
|
@ -1608,5 +1612,7 @@
|
|||
<string name="unit_minute_short">min</string>
|
||||
<string name="key_wizard_calculation_visible" translatable="false">wizard_calculation_visible</string>
|
||||
<string name="format_carbs">%1$dg</string>
|
||||
<string name="common_on">On</string>
|
||||
<string name="common_off">Off</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -68,6 +68,14 @@
|
|||
android:selectable="true"
|
||||
android:title="@string/medtronic_pump_battery_select" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="@string/common_off"
|
||||
android:entries="@array/onOff"
|
||||
android:entryValues="@array/onOff"
|
||||
android:key="@string/key_medtronic_bolus_debug"
|
||||
android:selectable="true"
|
||||
android:title="@string/medtronic_bolus_debugging" />
|
||||
|
||||
<info.nightscout.androidaps.plugins.pump.common.ui.RileyLinkSelectPreference
|
||||
android:enabled="true"
|
||||
android:summary=""
|
||||
|
|
Loading…
Reference in a new issue