Skip to content

Commit

Permalink
Merge pull request #3529 from jbr7rr/medtrum-clarify-strings
Browse files Browse the repository at this point in the history
Medtrum clarify strings
  • Loading branch information
MilosKozak authored Nov 13, 2024
2 parents 93ae83c + 1624e69 commit b01d678
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/ui/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
<string name="bg_label">BG</string>
<string name="calibration">Calibration</string>
<string name="alarminxmin">Run alarm in %1$d min</string>
<string name="treatmentdeliveryerror">Bolus reported an error. Manually check real delivered amount</string>
<string name="treatmentdeliveryerror">Bolus reported an error. Manually check real delivered insulin and carb amount</string>
<string name="bolus_reminder">Bolus reminder</string>
<string name="duration_label">Duration</string>
<string name="shortgramm">g</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,9 @@ import kotlin.math.abs
result.success = connectionOK && abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.bolusStep
result.bolusDelivered = t.insulin
if (!result.success) {
// Note: There are no error codes
result.comment = "failed"
result.comment(medtrumPump.bolusErrorReason ?: rh.gs(R.string.bolus_error_reason_pump_error))
} else {
result.comment = "ok"
result.comment(app.aaps.core.ui.R.string.ok)
}
aapsLogger.debug(LTag.PUMP, "deliverTreatment: OK. Success: ${result.success} Asked: ${detailedBolusInfo.insulin} Delivered: ${result.bolusDelivered}")
return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,13 @@ class MedtrumPump @Inject constructor(
_bolusAmountToBeDelivered = value
sp.putDouble(R.string.key_bolus_amount_to_be_delivered, value)
}


var bolusingTreatment: EventOverviewBolusProgress.Treatment? = null // actually delivered treatment
var bolusProgressLastTimeStamp: Long = 0 // timestamp of last bolus progress message
var bolusStopped = false // bolus stopped by user
var bolusDone = true // Bolus completed or stopped on pump, initialize as true as to don't show bolus on init
var bolusErrorReason: String? = null

private val _bolusAmountDelivered = MutableStateFlow(0.0)
val bolusAmountDeliveredFlow: StateFlow<Double> = _bolusAmountDelivered
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ class MedtrumService : DaggerService(), BLECommCallback {
} else {
aapsLogger.error(LTag.PUMPCOMM, "Failed to load events")
}
// Update ui text to getting pump status (indicating syncing records is finished)
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.getting_pump_status)))
return result
}

Expand Down Expand Up @@ -352,8 +354,10 @@ class MedtrumService : DaggerService(), BLECommCallback {
val insulin = detailedBolusInfo.insulin
medtrumPump.bolusDone = false
medtrumPump.bolusStopped = false
medtrumPump.bolusErrorReason = null

if (!sendBolusCommand(insulin)) {
medtrumPump.bolusErrorReason = rh.gs(R.string.bolus_error_reason_unable_to_send_command)
aapsLogger.error(LTag.PUMPCOMM, "Failed to set bolus")
commandQueue.readStatus(rh.gs(R.string.bolus_error), null) // make sure if anything is delivered (which is highly unlikely at this point) we get it
medtrumPump.bolusDone = true
Expand Down Expand Up @@ -414,14 +418,17 @@ class MedtrumService : DaggerService(), BLECommCallback {
private fun canSetBolus(): Boolean {
if (!isConnected) {
aapsLogger.warn(LTag.PUMPCOMM, "Pump not connected, not setting bolus")
medtrumPump.bolusErrorReason = rh.gs(R.string.bolus_error_reason_not_connected)
return false
}
if (BolusProgressData.stopPressed) {
aapsLogger.warn(LTag.PUMPCOMM, "Bolus stop pressed, not setting bolus")
medtrumPump.bolusErrorReason = rh.gs(R.string.bolus_error_reason_user)
return false
}
if (!medtrumPump.bolusDone) {
aapsLogger.warn(LTag.PUMPCOMM, "Bolus already in progress, not setting new one")
medtrumPump.bolusErrorReason = rh.gs(R.string.bolus_error_reason_already_in_progress)
return false
}
return true
Expand Down Expand Up @@ -454,6 +461,7 @@ class MedtrumService : DaggerService(), BLECommCallback {
connectionRetryCounter++
} else {
communicationLost = true
medtrumPump.bolusErrorReason = rh.gs(R.string.bolus_error_reason_communication_lost)
aapsLogger.warn(LTag.PUMPCOMM, "Retry connection failed, communication stopped")
disconnect("Communication stopped")
}
Expand Down Expand Up @@ -494,6 +502,7 @@ class MedtrumService : DaggerService(), BLECommCallback {

fun stopBolus() {
aapsLogger.debug(LTag.PUMPCOMM, "bolusStop >>>>> @ " + if (medtrumPump.bolusingTreatment == null) "" else medtrumPump.bolusingTreatment?.insulin)
medtrumPump.bolusErrorReason = rh.gs(R.string.bolus_error_reason_user)
if (isConnected) {
var success = sendPacketAndGetResponse(CancelBolusPacket(injector))
val timeout = System.currentTimeMillis() + T.secs(30).msecs()
Expand Down Expand Up @@ -563,6 +572,7 @@ class MedtrumService : DaggerService(), BLECommCallback {
var failureCount = 0
if (medtrumPump.syncedSequenceNumber < medtrumPump.currentSequenceNumber) {
for (sequence in (medtrumPump.syncedSequenceNumber + 1)..medtrumPump.currentSequenceNumber) {
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.syncing_records, (medtrumPump.currentSequenceNumber - sequence + 1))))
val packet = GetRecordPacket(injector, sequence)
result = sendPacketAndGetResponse(packet, COMMAND_SYNC_TIMEOUT_SEC)
if (!result && packet.failed) {
Expand Down
8 changes: 8 additions & 0 deletions pump/medtrum/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,16 @@

<!-- treatment state-->
<string name="getting_pump_status">Getting pump status</string>
<string name="syncing_records">Syncing records, %1$d left</string>
<string name="getting_bolus_status">Getting bolus status</string>
<string name="getting_temp_basal_status">Getting temporary basal status</string>
<string name="setting_pump_settings">Setting user options</string>

<!-- bolus-->
<string name="bolus_error_reason_user">Bolus cancelled by user</string>
<string name="bolus_error_reason_not_connected">Pump not connected</string>
<string name="bolus_error_reason_already_in_progress">Bolus already in progress</string>
<string name="bolus_error_reason_unable_to_send_command">Unable to send bolus command</string>
<string name="bolus_error_reason_communication_lost">Timeout getting bolus status</string>
<string name="bolus_error_reason_pump_error">Pump error</string>
</resources>

0 comments on commit b01d678

Please sign in to comment.