don't send carbs entered in the past to the pump
This commit is contained in:
parent
e9883dcc3a
commit
126f3925e0
|
@ -11,6 +11,7 @@ import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
|
import info.nightscout.utils.T;
|
||||||
|
|
||||||
import static info.nightscout.utils.DateUtil.now;
|
import static info.nightscout.utils.DateUtil.now;
|
||||||
|
|
||||||
|
@ -35,7 +36,7 @@ public class CarbsGenerator {
|
||||||
carbInfo.context = MainApp.instance();
|
carbInfo.context = MainApp.instance();
|
||||||
carbInfo.source = Source.USER;
|
carbInfo.source = Source.USER;
|
||||||
carbInfo.notes = notes;
|
carbInfo.notes = notes;
|
||||||
if (ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().storesCarbInfo && carbInfo.date <= now()) {
|
if (ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().storesCarbInfo && carbInfo.date <= now() && carbInfo.date > now()- T.mins(2).msecs()) {
|
||||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().bolus(carbInfo, new Callback() {
|
ConfigBuilderPlugin.getPlugin().getCommandQueue().bolus(carbInfo, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -50,6 +51,8 @@ public class CarbsGenerator {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
// Don't send to pump if it is in the future or more than 5 minutes in the past
|
||||||
|
// as pumps might return those as as "now" when reading the history.
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(carbInfo, false);
|
TreatmentsPlugin.getPlugin().addToHistoryTreatment(carbInfo, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue