fix merge conflict
This commit is contained in:
commit
adceef3641
4 changed files with 36 additions and 12 deletions
|
@ -101,8 +101,6 @@ public class MainApp extends Application {
|
|||
log.info("Version: " + BuildConfig.VERSION_NAME);
|
||||
log.info("BuildVersion: " + BuildConfig.BUILDVERSION);
|
||||
|
||||
Answers.getInstance().logCustom(new CustomEvent("AppStart"));
|
||||
|
||||
sBus = new Bus(ThreadEnforcer.ANY);
|
||||
sInstance = this;
|
||||
sResources = getResources();
|
||||
|
@ -160,6 +158,11 @@ public class MainApp extends Application {
|
|||
MainApp.getConfigBuilder().initialize();
|
||||
}
|
||||
NSUpload.uploadAppStart();
|
||||
if (MainApp.getConfigBuilder().isClosedModeEnabled())
|
||||
Answers.getInstance().logCustom(new CustomEvent("AppStart-ClosedLoop"));
|
||||
else
|
||||
Answers.getInstance().logCustom(new CustomEvent("AppStart"));
|
||||
|
||||
|
||||
startKeepAliveService();
|
||||
|
||||
|
|
|
@ -32,10 +32,20 @@ public class DetailedBolusInfoStorage {
|
|||
log.debug("Existing info: " + new Date(infoTime).toLocaleString());
|
||||
if (bolustime > infoTime - 60 * 1000 && bolustime < infoTime + 60 * 1000) {
|
||||
found = store.get(i);
|
||||
store.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
public static 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) {
|
||||
log.debug("Removing info: " + new Date(infoTime).toLocaleString());
|
||||
store.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -286,10 +286,20 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
|||
detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin);
|
||||
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) {
|
||||
DetailedBolusInfoStorage.add(detailedBolusInfo); // will be picked up on reading history
|
||||
// v2 stores end time for bolus, we need to adjust time
|
||||
// delivery speed is 12 U/min
|
||||
detailedBolusInfo.date += detailedBolusInfo.insulin / 12d * 60 * 1000;
|
||||
// clean carbs to prevent counting them as twice because they will picked up as another record
|
||||
// I don't think it's necessary to copy DetailedBolusInfo right now for carbs records
|
||||
double carbs = detailedBolusInfo.carbs;
|
||||
detailedBolusInfo.carbs = 0;
|
||||
int carbTime = detailedBolusInfo.carbTime;
|
||||
detailedBolusInfo.carbTime = 0;
|
||||
|
||||
Treatment t = new Treatment();
|
||||
boolean connectionOK = false;
|
||||
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
|
||||
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, System.currentTimeMillis() + detailedBolusInfo.carbTime * 60 * 1000 + 1000, t); // +1000 to make the record different
|
||||
if (detailedBolusInfo.insulin > 0 || carbs > 0)
|
||||
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) carbs, System.currentTimeMillis() + carbTime * 60 * 1000 + 1000, t); // +1000 to make the record different
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
result.success = connectionOK;
|
||||
result.bolusDelivered = t.insulin;
|
||||
|
|
|
@ -67,15 +67,10 @@ public class MsgHistoryEvents_v2 extends MessageBase {
|
|||
if (detailedBolusInfo == null) {
|
||||
log.debug("DetailedBolusInfo not found for " + datetime.toLocaleString());
|
||||
detailedBolusInfo = new DetailedBolusInfo();
|
||||
} else {
|
||||
log.debug("DetailedBolusInfo found for " + datetime.toLocaleString() + ": " + new Date(detailedBolusInfo.date).toLocaleString());
|
||||
detailedBolusInfo.carbTime = 0;
|
||||
detailedBolusInfo.carbs = 0;
|
||||
}
|
||||
detailedBolusInfo.date = datetime.getTime();
|
||||
detailedBolusInfo.source = Source.PUMP;
|
||||
detailedBolusInfo.pumpId = datetime.getTime();
|
||||
detailedBolusInfo.source = Source.PUMP;
|
||||
|
||||
switch (recordCode) {
|
||||
case DanaRPump.TEMPSTART:
|
||||
|
@ -102,11 +97,13 @@ public class MsgHistoryEvents_v2 extends MessageBase {
|
|||
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);
|
||||
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);
|
||||
break;
|
||||
case DanaRPump.DUALEXTENDEDSTART:
|
||||
log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
||||
|
@ -134,8 +131,12 @@ public class MsgHistoryEvents_v2 extends MessageBase {
|
|||
log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h");
|
||||
break;
|
||||
case DanaRPump.CARBS:
|
||||
detailedBolusInfo.carbs = param1;
|
||||
newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
||||
DetailedBolusInfo emptyCarbsInfo = new DetailedBolusInfo();
|
||||
emptyCarbsInfo.carbs = param1;
|
||||
emptyCarbsInfo.date = datetime.getTime();
|
||||
emptyCarbsInfo.source = Source.PUMP;
|
||||
emptyCarbsInfo.pumpId = datetime.getTime();
|
||||
newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(emptyCarbsInfo);
|
||||
log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g");
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Reference in a new issue