This commit is contained in:
Milos Kozak 2021-11-23 23:15:56 +01:00
commit 2b6e51cbfd
8 changed files with 77 additions and 58 deletions

View file

@ -574,7 +574,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
OKDialog.showConfirmation( OKDialog.showConfirmation(
context, context,
rh.gs(R.string.run_question, event.title), rh.gs(R.string.run_question, event.title),
{ handler.post { automationPlugin.processEvent(event, true) } } { handler.post { automationPlugin.processEvent(event) } }
) )
} }
binding.buttonsLayout.userButtonsLayout.addView(it) binding.buttonsLayout.userButtonsLayout.addView(it)

View file

@ -28,11 +28,6 @@
android:key="@string/key_enable_pump_unreachable_alert" android:key="@string/key_enable_pump_unreachable_alert"
android:title="@string/enable_pump_unreachable_alert" /> android:title="@string/enable_pump_unreachable_alert" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_enable_carbs_required_alert_local"
android:title="@string/enable_carbs_req_alert" />
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference <info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="30" android:defaultValue="30"
android:dependency="@string/key_enable_pump_unreachable_alert" android:dependency="@string/key_enable_pump_unreachable_alert"
@ -43,6 +38,11 @@
validate:minNumber="30" validate:minNumber="30"
validate:testType="numericRange" /> validate:testType="numericRange" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_enable_carbs_required_alert_local"
android:title="@string/enable_carbs_req_alert" />
<SwitchPreference <SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:key="@string/key_raise_notifications_as_android_notifications" android:key="@string/key_raise_notifications_as_android_notifications"

View file

@ -186,18 +186,18 @@ class AutomationPlugin @Inject constructor(
@Synchronized @Synchronized
private fun processActions() { private fun processActions() {
var userEventsEnabled = config.APS var commonEventsEnabled = true
if (config.APS) {
if (loopPlugin.isSuspended || !(loopPlugin as PluginBase).isEnabled()) { if (loopPlugin.isSuspended || !(loopPlugin as PluginBase).isEnabled()) {
aapsLogger.debug(LTag.AUTOMATION, "Loop deactivated") aapsLogger.debug(LTag.AUTOMATION, "Loop deactivated")
executionLog.add(rh.gs(R.string.loopisdisabled)) executionLog.add(rh.gs(R.string.loopisdisabled))
userEventsEnabled = false rxBus.send(EventAutomationUpdateGui())
commonEventsEnabled = false
} }
val enabled = constraintChecker.isAutomationEnabled() val enabled = constraintChecker.isAutomationEnabled()
if (!enabled.value()) { if (!enabled.value()) {
executionLog.add(enabled.getMostLimitedReasons(aapsLogger)) executionLog.add(enabled.getMostLimitedReasons(aapsLogger))
userEventsEnabled = false rxBus.send(EventAutomationUpdateGui())
} commonEventsEnabled = false
} }
aapsLogger.debug(LTag.AUTOMATION, "processActions") aapsLogger.debug(LTag.AUTOMATION, "processActions")
@ -205,7 +205,7 @@ class AutomationPlugin @Inject constructor(
while (iterator.hasNext()) { while (iterator.hasNext()) {
val event = iterator.next() val event = iterator.next()
if (event.isEnabled && !event.userAction && event.shouldRun()) if (event.isEnabled && !event.userAction && event.shouldRun())
processEvent(event, userEventsEnabled) if (event.systemAction || commonEventsEnabled) processEvent(event)
} }
// we cannot detect connected BT devices // we cannot detect connected BT devices
// so let's collect all connection/disconnections between 2 runs of processActions() // so let's collect all connection/disconnections between 2 runs of processActions()
@ -216,9 +216,8 @@ class AutomationPlugin @Inject constructor(
storeToSP() // save last run time storeToSP() // save last run time
} }
fun processEvent(event: AutomationEvent, userEventsEnabled: Boolean) { fun processEvent(event: AutomationEvent) {
if (event.trigger.shouldRun() && event.getPreconditions().shouldRun()) { if (event.trigger.shouldRun() && event.getPreconditions().shouldRun()) {
if (event.systemAction || userEventsEnabled) {
val actions = event.actions val actions = event.actions
for (action in actions) { for (action in actions) {
action.title = event.title action.title = event.title
@ -226,15 +225,15 @@ class AutomationPlugin @Inject constructor(
action.doAction(object : Callback() { action.doAction(object : Callback() {
override fun run() { override fun run() {
val sb = StringBuilder() val sb = StringBuilder()
sb.append(dateUtil.timeString(dateUtil.now())) .append(dateUtil.timeString(dateUtil.now()))
sb.append(" ") .append(" ")
sb.append(if (result.success) "" else "") .append(if (result.success) "" else "")
sb.append(" <b>") .append(" <b>")
sb.append(event.title) .append(event.title)
sb.append(":</b> ") .append(":</b> ")
sb.append(action.shortDescription()) .append(action.shortDescription())
sb.append(": ") .append(": ")
sb.append(result.comment) .append(result.comment)
executionLog.add(sb.toString()) executionLog.add(sb.toString())
aapsLogger.debug(LTag.AUTOMATION, "Executed: $sb") aapsLogger.debug(LTag.AUTOMATION, "Executed: $sb")
rxBus.send(EventAutomationUpdateGui()) rxBus.send(EventAutomationUpdateGui())
@ -251,7 +250,6 @@ class AutomationPlugin @Inject constructor(
if (event.autoRemove) automationEvents.remove(event) if (event.autoRemove) automationEvents.remove(event)
} }
} }
}
@Synchronized @Synchronized
fun add(event: AutomationEvent) { fun add(event: AutomationEvent) {
@ -306,7 +304,7 @@ class AutomationPlugin @Inject constructor(
val iterator: MutableIterator<AutomationEvent> = automationEvents.iterator() val iterator: MutableIterator<AutomationEvent> = automationEvents.iterator()
while (iterator.hasNext()) { while (iterator.hasNext()) {
val event = iterator.next() val event = iterator.next()
if (event.userAction) list.add(event) if (event.userAction && event.isEnabled) list.add(event)
} }
return list return list
} }

View file

@ -164,7 +164,7 @@ class ProfileViewerDialog : DaggerDialogFragment() {
binding.date.text = date binding.date.text = date
binding.ic.text = it.getIcList(rh, dateUtil) binding.ic.text = it.getIcList(rh, dateUtil)
binding.isf.text = it.getIsfList(rh, dateUtil) binding.isf.text = it.getIsfList(rh, dateUtil)
binding.basal.text = it.getBasalList(rh, dateUtil) binding.basal.text = "" + rh.gs(R.string.formatinsulinunits, it.baseBasalSum()) + "\n" + it.getBasalList(rh, dateUtil)
binding.target.text = it.getTargetList(rh, dateUtil) binding.target.text = it.getTargetList(rh, dateUtil)
binding.basalGraph.show(it) binding.basalGraph.show(it)

View file

@ -409,6 +409,23 @@
<string name="value_out_of_hard_limits">»%1$s« %2$.2f sınırların dışında</string> <string name="value_out_of_hard_limits">»%1$s« %2$.2f sınırların dışında</string>
<string name="basal_value">Bazal değer</string> <string name="basal_value">Bazal değer</string>
<string name="nsclient_version_does_not_match">NSClient sürümü AndroidAPS ile eşleşmiyor. Lütfen güncelle.</string> <string name="nsclient_version_does_not_match">NSClient sürümü AndroidAPS ile eşleşmiyor. Lütfen güncelle.</string>
<!-- readStatus reasons -->
<string name="keepalive_status_outdated" comment="26 characters max for translation">KA.. Durum güncel değil.</string>
<string name="keepalive_basal_outdated" comment="26 characters max for translation">KA.. Bazal güncel değil.</string>
<string name="sms" comment="26 characters max for translation">SMS</string>
<string name="clicked_connect_to_pump" comment="26 characters max for translation">Pompaya bağlan tıklandı</string>
<string name="pump_driver_changed" comment="26 characters max for translation">Pompa sürücüsü değişti.</string>
<string name="pump_driver_change" comment="26 characters max for translation">Pompa sürücüsü değişimi.</string>
<string name="device_changed" comment="26 characters max for translation">Cihaz değişti</string>
<string name="clicked_refresh" comment="26 characters max for translation">Yenileme tıklandı</string>
<string name="scheduled_status_refresh" comment="26 characters max for translation">Zamanlanmış Durum Yenileme</string>
<string name="unconfirmed_command" comment="26 characters max for translation">Onaylanmamış komut</string>
<string name="requested_by_user" comment="26 characters max for translation">Kullanıcı talebi</string>
<string name="user_request" comment="26 characters max for translation">Kullanıcı talebi</string>
<string name="bolus_ok" comment="26 characters max for translation">Bolus OK</string>
<string name="pump_paired" comment="26 characters max for translation">Pompa eşleştirildi</string>
<string name="insight_refresh_button" comment="26 characters max for translation">Insight Yenileme Düğmesi</string>
<string name="read_status" comment="10 characters max for READSTATUS translation">OKUMADURUMU %1$s</string>
<plurals name="days"> <plurals name="days">
<item quantity="one">%1$d gün</item> <item quantity="one">%1$d gün</item>
<item quantity="other">%1$d gün</item> <item quantity="other">%1$d gün</item>

View file

@ -12,8 +12,10 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definitio
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_ALERT_HOURS import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_ALERT_HOURS
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_ALERT_HOURS_DURATION import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_ALERT_HOURS_DURATION
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_IMMINENT_ALERT_HOURS import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_IMMINENT_ALERT_HOURS
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_PULSE_BOLUS_UNITS
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.*
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager
import info.nightscout.androidaps.utils.Round
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import io.reactivex.Observable import io.reactivex.Observable
import io.reactivex.functions.Action import io.reactivex.functions.Action
@ -281,7 +283,7 @@ class OmnipodDashManagerImpl @Inject constructor(
.setUniqueId(podStateManager.uniqueId!!.toInt()) .setUniqueId(podStateManager.uniqueId!!.toInt())
.setSequenceNumber(podStateManager.messageSequenceNumber) .setSequenceNumber(podStateManager.messageSequenceNumber)
.setNonce(NONCE) .setNonce(NONCE)
.setNumberOfUnits(podStateManager.firstPrimeBolusVolume!! * PodConstants.POD_PULSE_BOLUS_UNITS) .setNumberOfUnits(Round.roundTo(podStateManager.firstPrimeBolusVolume!! * PodConstants.POD_PULSE_BOLUS_UNITS, POD_PULSE_BOLUS_UNITS))
.setDelayBetweenPulsesInEighthSeconds(podStateManager.primePulseRate!!.toByte()) .setDelayBetweenPulsesInEighthSeconds(podStateManager.primePulseRate!!.toByte())
.setProgramReminder(ProgramReminder(atStart = false, atEnd = false, atInterval = 0)) .setProgramReminder(ProgramReminder(atStart = false, atEnd = false, atInterval = 0))
.build(), .build(),
@ -383,7 +385,7 @@ class OmnipodDashManagerImpl @Inject constructor(
) )
observables.add( observables.add(
observeSendProgramBolusCommand( observeSendProgramBolusCommand(
podStateManager.secondPrimeBolusVolume!! * PodConstants.POD_PULSE_BOLUS_UNITS, Round.roundTo(podStateManager.secondPrimeBolusVolume!! * PodConstants.POD_PULSE_BOLUS_UNITS, PodConstants.POD_PULSE_BOLUS_UNITS),
podStateManager.primePulseRate!!.toByte(), podStateManager.primePulseRate!!.toByte(),
confirmationBeeps = false, confirmationBeeps = false,
completionBeeps = false completionBeeps = false

View file

@ -16,6 +16,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.DefaultStatusResponse import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.DefaultStatusResponse
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.SetUniqueIdResponse import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.SetUniqueIdResponse
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.VersionResponse import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.VersionResponse
import info.nightscout.androidaps.utils.Round
import info.nightscout.androidaps.utils.sharedPreferences.SP import info.nightscout.androidaps.utils.sharedPreferences.SP
import io.reactivex.Completable import io.reactivex.Completable
import io.reactivex.Maybe import io.reactivex.Maybe
@ -340,7 +341,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
private fun updateLastBolusFromResponse(bolusPulsesRemaining: Short) { private fun updateLastBolusFromResponse(bolusPulsesRemaining: Short) {
podState.lastBolus?.run { podState.lastBolus?.run {
val remainingUnits = bolusPulsesRemaining.toDouble() * PodConstants.POD_PULSE_BOLUS_UNITS val remainingUnits = Round.roundTo(bolusPulsesRemaining * PodConstants.POD_PULSE_BOLUS_UNITS, PodConstants.POD_PULSE_BOLUS_UNITS)
this.bolusUnitsRemaining = remainingUnits this.bolusUnitsRemaining = remainingUnits
if (remainingUnits == 0.0) { if (remainingUnits == 0.0) {
this.deliveryComplete = true this.deliveryComplete = true

View file

@ -85,10 +85,11 @@ public class RileyLinkBLE {
aapsLogger.debug(LTag.PUMPBTCOMM, "Response Count is " + ByteUtil.shortHexString(characteristic.getValue())); aapsLogger.debug(LTag.PUMPBTCOMM, "Response Count is " + ByteUtil.shortHexString(characteristic.getValue()));
} }
} }
if (characteristic.getUuid().equals(UUID.fromString(GattAttributes.CHARA_RADIO_RESPONSE_COUNT))) {
if (radioResponseCountNotified != null) { if (radioResponseCountNotified != null) {
radioResponseCountNotified.run(); radioResponseCountNotified.run();
} }
}
orangeLink.onCharacteristicChanged(characteristic); orangeLink.onCharacteristicChanged(characteristic);
} }