combov2: Set enacted to true even if the basal profiles are identical

Signed-off-by: Carlos Rafael Giani <crg7475@mailbox.org>
This commit is contained in:
Carlos Rafael Giani 2022-12-28 22:52:40 +01:00
parent e60e9a21cc
commit 3887cc90ae

View file

@ -786,17 +786,25 @@ class ComboV2Plugin @Inject constructor (
Notification.INFO,
60
)
pumpEnactResult.apply {
success = true
enacted = true
}
} else {
aapsLogger.debug(LTag.PUMP, "Basal profiles are equal; did not have to set anything")
pumpEnactResult.apply {
success = true
enacted = false
}
// Treat this as if the command had been enacted. Setting a basal profile is
// an idempotent operation, meaning that setting the exact same profile factors
// twice in a row does not actually change anything. Therefore, we can just
// completely skip such a redundant set basal profile operation and still get
// the exact same result.
// Furthermore, it is actually important to also set enacted to true in this case
// because even though this _driver_ might know that the Combo uses this profile
// already, _AAPS_ might not. A good example is when AAPS is set up the first time
// and no profile has been activated. If in this case the profile happens to be
// identical to what's already in the Combo, then enacted=false would cause errors,
// because AAPS expects the driver to always enact the profile change in this case
// (since it thinks that no profile is set yet).
}
pumpEnactResult.apply {
success = true
enacted = true
}
}
} catch (e: CancellationException) {