RS,Rv2: more logging on storing boluses

This commit is contained in:
Milos Kozak 2018-08-17 13:28:37 +02:00
parent 91cbe1dd63
commit 9c1e52bd17
6 changed files with 72 additions and 73 deletions

View file

@ -57,6 +57,7 @@ public class DetailedBolusInfo {
@Override @Override
public String toString() { public String toString() {
return new Date(date).toLocaleString() + return new Date(date).toLocaleString() +
" date: " + date +
" insulin: " + insulin + " insulin: " + insulin +
" carbs: " + carbs + " carbs: " + carbs +
" isValid: " + isValid + " isValid: " + isValid +

View file

@ -317,7 +317,11 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
public static long roundDateToSec(long date) { public static long roundDateToSec(long date) {
return date - date % 1000; long rounded = date - date % 1000;
if (rounded != date)
if (L.isEnabled(L.DATABASE))
log.debug("Rounding " + date + " to " + rounded);
return rounded;
} }
// ------------------- BgReading handling ----------------------- // ------------------- BgReading handling -----------------------

View file

@ -33,21 +33,12 @@ public class DetailedBolusInfoStorage {
log.debug("Existing bolus info: " + store.get(i)); log.debug("Existing bolus info: " + store.get(i));
if (bolustime > infoTime - 60 * 1000 && bolustime < infoTime + 60 * 1000) { if (bolustime > infoTime - 60 * 1000 && bolustime < infoTime + 60 * 1000) {
found = store.get(i); found = store.get(i);
if (L.isEnabled(L.PUMP))
log.debug("Using & removing bolus info: " + store.get(i));
store.remove(i);
break; break;
} }
} }
return found; return found;
} }
public static synchronized void remove(long bolustime) {
for (int i = 0; i < store.size(); i++) {
long infoTime = store.get(i).date;
if (bolustime > infoTime - 60 * 1000 && bolustime < infoTime + 60 * 1000) {
if (L.isEnabled(L.PUMP))
log.debug("Removing bolus info: " + store.get(i));
store.remove(i);
break;
}
}
}
} }

View file

@ -94,25 +94,12 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
extendedBolus.source = Source.PUMP; extendedBolus.source = Source.PUMP;
extendedBolus.pumpId = datetime.getTime(); extendedBolus.pumpId = datetime.getTime();
DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(datetime.getTime());
if (detailedBolusInfo == null) {
if (L.isEnabled(L.PUMPCOMM))
log.debug("Detailed bolus info not found for " + datetime.toLocaleString());
detailedBolusInfo = new DetailedBolusInfo();
} else {
if (L.isEnabled(L.PUMPCOMM))
log.debug("Detailed bolus info found: " + detailedBolusInfo);
}
detailedBolusInfo.date = datetime.getTime();
detailedBolusInfo.source = Source.PUMP;
detailedBolusInfo.pumpId = datetime.getTime();
String status; String status;
switch (recordCode) { switch (recordCode) {
case DanaRPump.TEMPSTART: case DanaRPump.TEMPSTART:
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min"); log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " Ratio: " + param1 + "% Duration: " + param2 + "min");
temporaryBasal.percentRate = param1; temporaryBasal.percentRate = param1;
temporaryBasal.durationInMinutes = param2; temporaryBasal.durationInMinutes = param2;
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal); TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal);
@ -126,7 +113,7 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
break; break;
case DanaRPump.EXTENDEDSTART: case DanaRPump.EXTENDEDSTART:
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
extendedBolus.insulin = param1 / 100d; extendedBolus.insulin = param1 / 100d;
extendedBolus.durationInMinutes = param2; extendedBolus.durationInMinutes = param2;
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus); TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
@ -134,29 +121,43 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
break; break;
case DanaRPump.EXTENDEDSTOP: case DanaRPump.EXTENDEDSTOP:
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus); TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
status = "EXTENDEDSTOP " + DateUtil.timeString(datetime); status = "EXTENDEDSTOP " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.BOLUS: case DanaRPump.BOLUS:
DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(datetime.getTime());
if (detailedBolusInfo == null) {
detailedBolusInfo = new DetailedBolusInfo();
}
detailedBolusInfo.date = datetime.getTime();
detailedBolusInfo.source = Source.PUMP;
detailedBolusInfo.pumpId = datetime.getTime();
detailedBolusInfo.insulin = param1 / 100d; detailedBolusInfo.insulin = param1 / 100d;
boolean newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false); boolean newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
status = "BOLUS " + DateUtil.timeString(datetime); status = "BOLUS " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.DUALBOLUS: case DanaRPump.DUALBOLUS:
detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(datetime.getTime());
if (detailedBolusInfo == null) {
detailedBolusInfo = new DetailedBolusInfo();
}
detailedBolusInfo.date = datetime.getTime();
detailedBolusInfo.source = Source.PUMP;
detailedBolusInfo.pumpId = datetime.getTime();
detailedBolusInfo.insulin = param1 / 100d; detailedBolusInfo.insulin = param1 / 100d;
newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false); newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
status = "DUALBOLUS " + DateUtil.timeString(datetime); status = "DUALBOLUS " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.DUALEXTENDEDSTART: case DanaRPump.DUALEXTENDEDSTART:
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
extendedBolus.insulin = param1 / 100d; extendedBolus.insulin = param1 / 100d;
extendedBolus.durationInMinutes = param2; extendedBolus.durationInMinutes = param2;
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus); TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
@ -164,33 +165,33 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
break; break;
case DanaRPump.DUALEXTENDEDSTOP: case DanaRPump.DUALEXTENDEDSTOP:
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus); TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime); status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.SUSPENDON: case DanaRPump.SUSPENDON:
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString()); log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")");
status = "SUSPENDON " + DateUtil.timeString(datetime); status = "SUSPENDON " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.SUSPENDOFF: case DanaRPump.SUSPENDOFF:
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString()); log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")");
status = "SUSPENDOFF " + DateUtil.timeString(datetime); status = "SUSPENDOFF " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.REFILL: case DanaRPump.REFILL:
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " Amount: " + param1 / 100d + "U");
status = "REFILL " + DateUtil.timeString(datetime); status = "REFILL " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.PRIME: case DanaRPump.PRIME:
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " Amount: " + param1 / 100d + "U");
status = "PRIME " + DateUtil.timeString(datetime); status = "PRIME " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.PROFILECHANGE: case DanaRPump.PROFILECHANGE:
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h"); log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h");
status = "PROFILECHANGE " + DateUtil.timeString(datetime); status = "PROFILECHANGE " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.CARBS: case DanaRPump.CARBS:
@ -201,17 +202,17 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
emptyCarbsInfo.pumpId = datetime.getTime(); emptyCarbsInfo.pumpId = datetime.getTime();
newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(emptyCarbsInfo, false); newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(emptyCarbsInfo, false);
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g"); log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " Carbs: " + param1 + "g");
status = "CARBS " + DateUtil.timeString(datetime); status = "CARBS " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.PRIMECANNULA: case DanaRPump.PRIMECANNULA:
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug("EVENT PRIMECANNULA(" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); log.debug("EVENT PRIMECANNULA(" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " Amount: " + param1 / 100d + "U");
status = "PRIMECANNULA " + DateUtil.timeString(datetime); status = "PRIMECANNULA " + DateUtil.timeString(datetime);
break; break;
default: default:
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2); log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " Param1: " + param1 + " Param2: " + param2);
status = "UNKNOWN " + DateUtil.timeString(datetime); status = "UNKNOWN " + DateUtil.timeString(datetime);
break; break;
} }

View file

@ -72,25 +72,12 @@ public class MsgHistoryEvents_v2 extends MessageBase {
extendedBolus.source = Source.PUMP; extendedBolus.source = Source.PUMP;
extendedBolus.pumpId = datetime.getTime(); extendedBolus.pumpId = datetime.getTime();
DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(datetime.getTime());
if (detailedBolusInfo == null) {
if (L.isEnabled(L.PUMPCOMM))
log.debug("Detailed bolus info not found for " + datetime.toLocaleString());
detailedBolusInfo = new DetailedBolusInfo();
} else {
if (L.isEnabled(L.PUMPCOMM))
log.debug("Detailed bolus info found: " + detailedBolusInfo);
}
detailedBolusInfo.date = datetime.getTime();
detailedBolusInfo.source = Source.PUMP;
detailedBolusInfo.pumpId = datetime.getTime();
String status = ""; String status = "";
switch (recordCode) { switch (recordCode) {
case DanaRPump.TEMPSTART: case DanaRPump.TEMPSTART:
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min"); log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " Ratio: " + param1 + "% Duration: " + param2 + "min");
temporaryBasal.percentRate = param1; temporaryBasal.percentRate = param1;
temporaryBasal.durationInMinutes = param2; temporaryBasal.durationInMinutes = param2;
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal); TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal);
@ -104,7 +91,7 @@ public class MsgHistoryEvents_v2 extends MessageBase {
break; break;
case DanaRPump.EXTENDEDSTART: case DanaRPump.EXTENDEDSTART:
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
extendedBolus.insulin = param1 / 100d; extendedBolus.insulin = param1 / 100d;
extendedBolus.durationInMinutes = param2; extendedBolus.durationInMinutes = param2;
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus); TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
@ -112,29 +99,43 @@ public class MsgHistoryEvents_v2 extends MessageBase {
break; break;
case DanaRPump.EXTENDEDSTOP: case DanaRPump.EXTENDEDSTOP:
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus); TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
status = "EXTENDEDSTOP " + DateUtil.timeString(datetime); status = "EXTENDEDSTOP " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.BOLUS: case DanaRPump.BOLUS:
DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(datetime.getTime());
if (detailedBolusInfo == null) {
detailedBolusInfo = new DetailedBolusInfo();
}
detailedBolusInfo.date = datetime.getTime();
detailedBolusInfo.source = Source.PUMP;
detailedBolusInfo.pumpId = datetime.getTime();
detailedBolusInfo.insulin = param1 / 100d; detailedBolusInfo.insulin = param1 / 100d;
boolean newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false); boolean newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
status = "BOLUS " + DateUtil.timeString(datetime); status = "BOLUS " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.DUALBOLUS: case DanaRPump.DUALBOLUS:
detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(datetime.getTime());
if (detailedBolusInfo == null) {
detailedBolusInfo = new DetailedBolusInfo();
}
detailedBolusInfo.date = datetime.getTime();
detailedBolusInfo.source = Source.PUMP;
detailedBolusInfo.pumpId = datetime.getTime();
detailedBolusInfo.insulin = param1 / 100d; detailedBolusInfo.insulin = param1 / 100d;
newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false); newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
status = "DUALBOLUS " + DateUtil.timeString(datetime); status = "DUALBOLUS " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.DUALEXTENDEDSTART: case DanaRPump.DUALEXTENDEDSTART:
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
extendedBolus.insulin = param1 / 100d; extendedBolus.insulin = param1 / 100d;
extendedBolus.durationInMinutes = param2; extendedBolus.durationInMinutes = param2;
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus); TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
@ -142,33 +143,33 @@ public class MsgHistoryEvents_v2 extends MessageBase {
break; break;
case DanaRPump.DUALEXTENDEDSTOP: case DanaRPump.DUALEXTENDEDSTOP:
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus); TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime); status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.SUSPENDON: case DanaRPump.SUSPENDON:
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString()); log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")");
status = "SUSPENDON " + DateUtil.timeString(datetime); status = "SUSPENDON " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.SUSPENDOFF: case DanaRPump.SUSPENDOFF:
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString()); log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")");
status = "SUSPENDOFF " + DateUtil.timeString(datetime); status = "SUSPENDOFF " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.REFILL: case DanaRPump.REFILL:
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " Amount: " + param1 / 100d + "U");
status = "REFILL " + DateUtil.timeString(datetime); status = "REFILL " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.PRIME: case DanaRPump.PRIME:
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " Amount: " + param1 / 100d + "U");
status = "PRIME " + DateUtil.timeString(datetime); status = "PRIME " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.PROFILECHANGE: case DanaRPump.PROFILECHANGE:
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h"); log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h");
status = "PROFILECHANGE " + DateUtil.timeString(datetime); status = "PROFILECHANGE " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.CARBS: case DanaRPump.CARBS:
@ -179,12 +180,12 @@ public class MsgHistoryEvents_v2 extends MessageBase {
emptyCarbsInfo.pumpId = datetime.getTime(); emptyCarbsInfo.pumpId = datetime.getTime();
newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(emptyCarbsInfo, false); newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(emptyCarbsInfo, false);
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g"); log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " Carbs: " + param1 + "g");
status = "CARBS " + DateUtil.timeString(datetime); status = "CARBS " + DateUtil.timeString(datetime);
break; break;
default: default:
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(L.PUMPCOMM))
log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2); log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " (" + datetime.getTime() + ")" + " Param1: " + param1 + " Param2: " + param2);
status = "UNKNOWN " + DateUtil.timeString(datetime); status = "UNKNOWN " + DateUtil.timeString(datetime);
break; break;
} }

View file

@ -10,6 +10,7 @@ import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.Objects; import java.util.Objects;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
@ -91,7 +92,7 @@ public class Treatment implements DataPointWithLabelInterface {
public String toString() { public String toString() {
return "Treatment{" + return "Treatment{" +
"date= " + date + "date= " + date +
", date= " + DateUtil.dateAndTimeString(date) + ", date= " + new Date(date).toLocaleString() +
", isValid= " + isValid + ", isValid= " + isValid +
", isSMB= " + isSMB + ", isSMB= " + isSMB +
", _id= " + _id + ", _id= " + _id +