Detailed onscreen history logging
This commit is contained in:
parent
dbf5a5e577
commit
a8751bf35a
|
@ -10,15 +10,14 @@ import java.util.Date;
|
|||
import java.util.GregorianCalendar;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||
import info.nightscout.androidaps.db.Source;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
|
||||
public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
|
||||
|
@ -32,11 +31,11 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
|
|||
private int sec = 0;
|
||||
|
||||
public boolean done;
|
||||
public int totalCount;
|
||||
private int totalCount;
|
||||
|
||||
public static long lastEventTimeLoaded = 0;
|
||||
|
||||
public DanaRS_Packet_APS_History_Events() {
|
||||
DanaRS_Packet_APS_History_Events() {
|
||||
super();
|
||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE__APS_HISTORY_EVENTS;
|
||||
done = false;
|
||||
|
@ -97,70 +96,87 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
|
|||
|
||||
DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(datetime.getTime());
|
||||
if (detailedBolusInfo == null) {
|
||||
log.debug("DetailedBolusInfo not found for " + datetime.toLocaleString());
|
||||
log.debug("Detailed bolus info not found for " + datetime.toLocaleString());
|
||||
detailedBolusInfo = new DetailedBolusInfo();
|
||||
} else {
|
||||
log.debug("Detailed bolus info found: " + detailedBolusInfo);
|
||||
}
|
||||
detailedBolusInfo.date = datetime.getTime();
|
||||
detailedBolusInfo.source = Source.PUMP;
|
||||
detailedBolusInfo.pumpId = datetime.getTime();
|
||||
|
||||
String status;
|
||||
|
||||
switch (recordCode) {
|
||||
case DanaRPump.TEMPSTART:
|
||||
log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min");
|
||||
temporaryBasal.percentRate = param1;
|
||||
temporaryBasal.durationInMinutes = param2;
|
||||
MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal);
|
||||
status = "TEMPSTART " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.TEMPSTOP:
|
||||
log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString());
|
||||
MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal);
|
||||
status = "TEMPSTOP " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.EXTENDEDSTART:
|
||||
log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
||||
extendedBolus.insulin = param1 / 100d;
|
||||
extendedBolus.durationInMinutes = param2;
|
||||
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
|
||||
status = "EXTENDEDSTART " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.EXTENDEDSTOP:
|
||||
log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
|
||||
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
|
||||
status = "EXTENDEDSTOP " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.BOLUS:
|
||||
detailedBolusInfo.insulin = param1 / 100d;
|
||||
boolean newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
||||
log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
||||
DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
|
||||
status = "BOLUS " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.DUALBOLUS:
|
||||
detailedBolusInfo.insulin = param1 / 100d;
|
||||
newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
||||
log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
||||
DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
|
||||
status = "DUALBOLUS " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.DUALEXTENDEDSTART:
|
||||
log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
||||
extendedBolus.insulin = param1 / 100d;
|
||||
extendedBolus.durationInMinutes = param2;
|
||||
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
|
||||
status = "DUALEXTENDEDSTART " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.DUALEXTENDEDSTOP:
|
||||
log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
|
||||
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
|
||||
status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.SUSPENDON:
|
||||
log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString());
|
||||
status = "SUSPENDON " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.SUSPENDOFF:
|
||||
log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString());
|
||||
status = "SUSPENDOFF " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.REFILL:
|
||||
log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U");
|
||||
status = "REFILL " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.PRIME:
|
||||
log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U");
|
||||
status = "PRIME " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.PROFILECHANGE:
|
||||
log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h");
|
||||
status = "PROFILECHANGE " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.CARBS:
|
||||
DetailedBolusInfo emptyCarbsInfo = new DetailedBolusInfo();
|
||||
|
@ -170,17 +186,22 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
|
|||
emptyCarbsInfo.pumpId = datetime.getTime();
|
||||
newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(emptyCarbsInfo);
|
||||
log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g");
|
||||
status = "CARBS " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.PRIMECANNULA:
|
||||
log.debug("EVENT PRIME CANNULA(" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U");
|
||||
log.debug("EVENT PRIMECANNULA(" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U");
|
||||
status = "PRIMECANNULA " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
default:
|
||||
log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2);
|
||||
status = "UNKNOWN " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
}
|
||||
|
||||
if (datetime.getTime() > lastEventTimeLoaded)
|
||||
lastEventTimeLoaded = datetime.getTime();
|
||||
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.processinghistory) + ": " + status));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,13 +7,16 @@ import java.util.Date;
|
|||
import java.util.GregorianCalendar;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||
import info.nightscout.androidaps.db.Source;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
|
||||
public class MsgHistoryEvents_v2 extends MessageBase {
|
||||
private static Logger log = LoggerFactory.getLogger(MsgHistoryEvents_v2.class);
|
||||
|
@ -65,70 +68,87 @@ public class MsgHistoryEvents_v2 extends MessageBase {
|
|||
|
||||
DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(datetime.getTime());
|
||||
if (detailedBolusInfo == null) {
|
||||
log.debug("DetailedBolusInfo not found for " + datetime.toLocaleString());
|
||||
log.debug("Detailed bolus info not found for " + datetime.toLocaleString());
|
||||
detailedBolusInfo = new DetailedBolusInfo();
|
||||
} else {
|
||||
log.debug("Detailed bolus info found: " + detailedBolusInfo);
|
||||
}
|
||||
detailedBolusInfo.date = datetime.getTime();
|
||||
detailedBolusInfo.source = Source.PUMP;
|
||||
detailedBolusInfo.pumpId = datetime.getTime();
|
||||
|
||||
String status = "";
|
||||
|
||||
switch (recordCode) {
|
||||
case DanaRPump.TEMPSTART:
|
||||
log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min");
|
||||
temporaryBasal.percentRate = param1;
|
||||
temporaryBasal.durationInMinutes = param2;
|
||||
MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal);
|
||||
status = "TEMPSTART " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.TEMPSTOP:
|
||||
log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString());
|
||||
MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal);
|
||||
status = "TEMPSTOP " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.EXTENDEDSTART:
|
||||
log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
||||
extendedBolus.insulin = param1 / 100d;
|
||||
extendedBolus.durationInMinutes = param2;
|
||||
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
|
||||
status = "EXTENDEDSTART " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.EXTENDEDSTOP:
|
||||
log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
|
||||
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
|
||||
status = "EXTENDEDSTOP " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.BOLUS:
|
||||
detailedBolusInfo.insulin = param1 / 100d;
|
||||
boolean newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
||||
log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
||||
DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
|
||||
status = "BOLUS " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.DUALBOLUS:
|
||||
detailedBolusInfo.insulin = param1 / 100d;
|
||||
newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
||||
log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
||||
DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
|
||||
status = "DUALBOLUS " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.DUALEXTENDEDSTART:
|
||||
log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
||||
extendedBolus.insulin = param1 / 100d;
|
||||
extendedBolus.durationInMinutes = param2;
|
||||
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
|
||||
status = "DUALEXTENDEDSTART " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.DUALEXTENDEDSTOP:
|
||||
log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
|
||||
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
|
||||
status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.SUSPENDON:
|
||||
log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString());
|
||||
status = "SUSPENDON " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.SUSPENDOFF:
|
||||
log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString());
|
||||
status = "SUSPENDOFF " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.REFILL:
|
||||
log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U");
|
||||
status = "REFILL " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.PRIME:
|
||||
log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U");
|
||||
status = "PRIME " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.PROFILECHANGE:
|
||||
log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h");
|
||||
status = "PROFILECHANGE " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.CARBS:
|
||||
DetailedBolusInfo emptyCarbsInfo = new DetailedBolusInfo();
|
||||
|
@ -138,14 +158,17 @@ public class MsgHistoryEvents_v2 extends MessageBase {
|
|||
emptyCarbsInfo.pumpId = datetime.getTime();
|
||||
newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(emptyCarbsInfo);
|
||||
log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g");
|
||||
status = "CARBS " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
default:
|
||||
log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2);
|
||||
status = "UNKNOWN " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
}
|
||||
|
||||
if (datetime.getTime() > lastEventTimeLoaded)
|
||||
lastEventTimeLoaded = datetime.getTime();
|
||||
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.processinghistory) + ": " + status));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue