Simplify IOB calculation call
This commit is contained in:
parent
e3ac451f8d
commit
f37e3ab4c2
|
@ -279,9 +279,7 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
binding.ttcheckbox.isEnabled = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet() is ValueWrapper.Existing
|
||||
|
||||
// IOB calculation
|
||||
treatmentsPlugin.updateTotalIOBTreatments()
|
||||
val bolusIob = treatmentsPlugin.lastCalculationTreatments.round()
|
||||
treatmentsPlugin.updateTotalIOBTempBasals()
|
||||
val basalIob = treatmentsPlugin.lastCalculationTempBasals.round()
|
||||
|
||||
binding.bolusiobinsulin.text = resourceHelper.gs(R.string.formatinsulinunits, -bolusIob.iob)
|
||||
|
|
|
@ -136,9 +136,7 @@ class DataBroadcastPlugin @Inject constructor(
|
|||
|
||||
private fun iobCob(bundle: Bundle) {
|
||||
profileFunction.getProfile() ?: return
|
||||
activePlugin.activeTreatments.updateTotalIOBTreatments()
|
||||
val bolusIob: IobTotal = activePlugin.activeTreatments.lastCalculationTreatments.round()
|
||||
activePlugin.activeTreatments.updateTotalIOBTempBasals()
|
||||
val basalIob: IobTotal = activePlugin.activeTreatments.lastCalculationTempBasals.round()
|
||||
bundle.putDouble("bolusIob", bolusIob.iob)
|
||||
bundle.putDouble("basalIob", basalIob.basaliob)
|
||||
|
|
|
@ -749,8 +749,6 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
processButtonsVisibility()
|
||||
|
||||
// iob
|
||||
treatmentsPlugin.updateTotalIOBTreatments()
|
||||
treatmentsPlugin.updateTotalIOBTempBasals()
|
||||
val bolusIob = treatmentsPlugin.lastCalculationTreatments.round()
|
||||
val basalIob = treatmentsPlugin.lastCalculationTempBasals.round()
|
||||
binding.infoLayout.iob.text = resourceHelper.gs(R.string.formatinsulinunits, bolusIob.iob + basalIob.basaliob)
|
||||
|
|
|
@ -156,8 +156,6 @@ class PersistentNotificationPlugin @Inject constructor(
|
|||
line1aa += " " + activeTemp.toStringShort() + "."
|
||||
}
|
||||
//IOB
|
||||
activePlugins.activeTreatments.updateTotalIOBTreatments()
|
||||
activePlugins.activeTreatments.updateTotalIOBTempBasals()
|
||||
val bolusIob = activePlugins.activeTreatments.lastCalculationTreatments.round()
|
||||
val basalIob = activePlugins.activeTreatments.lastCalculationTempBasals.round()
|
||||
line2 = resourceHelper.gs(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U " + resourceHelper.gs(R.string.cob) + ": " + iobCobCalculatorPlugin.getCobInfo(false, "PersistentNotificationPlugin").generateCOBString()
|
||||
|
|
|
@ -325,9 +325,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
}
|
||||
val glucoseStatus = glucoseStatusProvider.glucoseStatusData
|
||||
if (glucoseStatus != null) reply += resourceHelper.gs(R.string.sms_delta) + " " + Profile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units + ", "
|
||||
activePlugin.activeTreatments.updateTotalIOBTreatments()
|
||||
val bolusIob = activePlugin.activeTreatments.lastCalculationTreatments.round()
|
||||
activePlugin.activeTreatments.updateTotalIOBTempBasals()
|
||||
val basalIob = activePlugin.activeTreatments.lastCalculationTempBasals.round()
|
||||
val cobInfo = iobCobCalculatorPlugin.getCobInfo(false, "SMS COB")
|
||||
reply += (resourceHelper.gs(R.string.sms_iob) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
|
||||
|
|
|
@ -685,9 +685,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
|||
String iobSum, iobDetail, cobString, currentBasal, bgiString;
|
||||
iobSum = iobDetail = cobString = currentBasal = bgiString = "";
|
||||
if (profile != null) {
|
||||
treatmentsPlugin.updateTotalIOBTreatments();
|
||||
IobTotal bolusIob = treatmentsPlugin.getLastCalculationTreatments().round();
|
||||
treatmentsPlugin.updateTotalIOBTempBasals();
|
||||
IobTotal basalIob = treatmentsPlugin.getLastCalculationTempBasals().round();
|
||||
|
||||
iobSum = DecimalFormatter.INSTANCE.to2Decimal(bolusIob.iob + basalIob.basaliob);
|
||||
|
|
|
@ -132,9 +132,7 @@ class StatusLinePlugin @Inject constructor(
|
|||
status += activeTemp.toStringShort() + " "
|
||||
}
|
||||
//IOB
|
||||
activePlugin.activeTreatments.updateTotalIOBTreatments()
|
||||
val bolusIob = activePlugin.activeTreatments.lastCalculationTreatments.round()
|
||||
activePlugin.activeTreatments.updateTotalIOBTempBasals()
|
||||
val basalIob = activePlugin.activeTreatments.lastCalculationTempBasals.round()
|
||||
status += DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U"
|
||||
if (sp.getBoolean(R.string.key_xdripstatus_detailediob, true)) {
|
||||
|
|
|
@ -85,9 +85,6 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
|||
|
||||
protected TreatmentServiceInterface service;
|
||||
|
||||
private IobTotal lastTreatmentCalculation;
|
||||
private IobTotal lastTempBasalsCalculation;
|
||||
|
||||
private final ArrayList<Treatment> treatments = new ArrayList<>();
|
||||
private final Intervals<TemporaryBasal> tempBasals = new NonOverlappingIntervals<>();
|
||||
private final Intervals<ExtendedBolus> extendedBoluses = new NonOverlappingIntervals<>();
|
||||
|
@ -149,7 +146,6 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
|||
getAapsLogger().debug(LTag.DATATREATMENTS, "EventReloadTreatmentData");
|
||||
initializeTreatmentData(range());
|
||||
initializeExtendedBolusData(range());
|
||||
updateTotalIOBTreatments();
|
||||
rxBus.send(event.getNext());
|
||||
},
|
||||
fabricPrivacy::logException
|
||||
|
@ -166,7 +162,6 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
|||
.subscribe(event -> {
|
||||
getAapsLogger().debug(LTag.DATATREATMENTS, "EventReloadTempBasalData");
|
||||
initializeTempBasalData(range());
|
||||
updateTotalIOBTempBasals();
|
||||
},
|
||||
fabricPrivacy::logException
|
||||
));
|
||||
|
@ -230,7 +225,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
|||
|
||||
@Override
|
||||
public IobTotal getLastCalculationTreatments() {
|
||||
return lastTreatmentCalculation;
|
||||
return getCalculationToTimeTreatments(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -278,11 +273,6 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
|||
return total;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTotalIOBTreatments() {
|
||||
lastTreatmentCalculation = getCalculationToTimeTreatments(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Treatment> getTreatmentsFromHistory() {
|
||||
synchronized (treatments) {
|
||||
|
@ -399,7 +389,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
|||
|
||||
@Override
|
||||
public IobTotal getLastCalculationTempBasals() {
|
||||
return lastTempBasalsCalculation;
|
||||
return getCalculationToTimeTempBasals(DateUtil.now());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -537,11 +527,6 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
|||
return total;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTotalIOBTempBasals() {
|
||||
lastTempBasalsCalculation = getCalculationToTimeTempBasals(DateUtil.now());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TemporaryBasal getTempBasalFromHistory(long time) {
|
||||
|
|
|
@ -205,9 +205,7 @@ class BolusWizard @Inject constructor(
|
|||
|
||||
// Insulin from IOB
|
||||
// IOB calculation
|
||||
activePlugin.activeTreatments.updateTotalIOBTreatments()
|
||||
val bolusIob = activePlugin.activeTreatments.lastCalculationTreatments.round()
|
||||
activePlugin.activeTreatments.updateTotalIOBTempBasals()
|
||||
val basalIob = activePlugin.activeTreatments.lastCalculationTempBasals.round()
|
||||
|
||||
insulinFromBolusIOB = if (includeBolusIOB) -bolusIob.iob else 0.0
|
||||
|
|
|
@ -9,7 +9,6 @@ import info.nightscout.androidaps.database.entities.GlucoseValue
|
|||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
|
@ -99,7 +98,6 @@ class QuickWizardEntry @Inject constructor(private val injector: HasAndroidInjec
|
|||
bolusIOB = true
|
||||
}
|
||||
// Basal IOB
|
||||
treatmentsPlugin.updateTotalIOBTempBasals()
|
||||
val basalIob = treatmentsPlugin.lastCalculationTempBasals.round()
|
||||
var basalIOB = false
|
||||
if (useBasalIOB() == YES) {
|
||||
|
|
|
@ -22,10 +22,6 @@ public interface TreatmentsInterface {
|
|||
|
||||
TreatmentServiceInterface getService();
|
||||
|
||||
void updateTotalIOBTreatments();
|
||||
|
||||
void updateTotalIOBTempBasals();
|
||||
|
||||
IobTotal getLastCalculationTreatments();
|
||||
|
||||
IobTotal getCalculationToTimeTreatments(long time);
|
||||
|
|
Loading…
Reference in a new issue