Merge branch 'meallink' of https://github.com/nightscout/AndroidAPS into meallink
This commit is contained in:
commit
429842ecd0
|
@ -214,8 +214,8 @@ class InsulinDialog : DialogFragmentWithDate() {
|
||||||
detailedBolusInfo.timestamp = time
|
detailedBolusInfo.timestamp = time
|
||||||
if (recordOnlyChecked) {
|
if (recordOnlyChecked) {
|
||||||
uel.log(Action.BOLUS, Sources.InsulinDialog,
|
uel.log(Action.BOLUS, Sources.InsulinDialog,
|
||||||
notes,
|
resourceHelper.gs(R.string.record) + if (notes.isNotEmpty()) ": " + notes else "",
|
||||||
ValueWithUnit.StringResource(R.string.record),
|
ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.record)),
|
||||||
ValueWithUnit.Insulin(insulinAfterConstraints),
|
ValueWithUnit.Insulin(insulinAfterConstraints),
|
||||||
ValueWithUnit.Minute(timeOffset).takeIf { timeOffset!= 0 })
|
ValueWithUnit.Minute(timeOffset).takeIf { timeOffset!= 0 })
|
||||||
disposable += repository.runTransactionForResult(detailedBolusInfo.insertBolusTransaction())
|
disposable += repository.runTransactionForResult(detailedBolusInfo.insertBolusTransaction())
|
||||||
|
@ -224,15 +224,14 @@ class InsulinDialog : DialogFragmentWithDate() {
|
||||||
{ aapsLogger.error(LTag.DATABASE, "Error while saving bolus", it) }
|
{ aapsLogger.error(LTag.DATABASE, "Error while saving bolus", it) }
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
uel.log(Action.BOLUS, Sources.InsulinDialog,
|
||||||
|
notes,
|
||||||
|
ValueWithUnit.Insulin(insulinAfterConstraints))
|
||||||
commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
ErrorHelperActivity.runAlarm(ctx, result.comment, resourceHelper.gs(R.string.treatmentdeliveryerror), info.nightscout.androidaps.dana.R.raw.boluserror)
|
ErrorHelperActivity.runAlarm(ctx, result.comment, resourceHelper.gs(R.string.treatmentdeliveryerror), info.nightscout.androidaps.dana.R.raw.boluserror)
|
||||||
} else
|
}
|
||||||
uel.log(Action.BOLUS, Sources.InsulinDialog,
|
|
||||||
notes,
|
|
||||||
ValueWithUnit.Insulin(insulinAfterConstraints))
|
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,9 +149,9 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
||||||
detailedBolusInfo.carbs = carbsAfterConstraints.toDouble()
|
detailedBolusInfo.carbs = carbsAfterConstraints.toDouble()
|
||||||
detailedBolusInfo.context = context
|
detailedBolusInfo.context = context
|
||||||
if (recordOnlyChecked) {
|
if (recordOnlyChecked) {
|
||||||
uel.log(action, Sources.TreatmentDialog,
|
uel.log(action, Sources.TreatmentDialog, if (insulinAfterConstraints != 0.0) resourceHelper.gs(R.string.record) else "",
|
||||||
ValueWithUnit.Timestamp(detailedBolusInfo.timestamp).takeIf { eventTimeChanged },
|
ValueWithUnit.Timestamp(detailedBolusInfo.timestamp).takeIf { eventTimeChanged },
|
||||||
ValueWithUnit.StringResource(R.string.record).takeIf { insulinAfterConstraints != 0.0 },
|
ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.record)).takeIf { insulinAfterConstraints != 0.0 },
|
||||||
ValueWithUnit.Insulin(insulinAfterConstraints).takeIf { insulinAfterConstraints != 0.0 },
|
ValueWithUnit.Insulin(insulinAfterConstraints).takeIf { insulinAfterConstraints != 0.0 },
|
||||||
ValueWithUnit.Gram(carbsAfterConstraints).takeIf { carbsAfterConstraints != 0 })
|
ValueWithUnit.Gram(carbsAfterConstraints).takeIf { carbsAfterConstraints != 0 })
|
||||||
if (detailedBolusInfo.insulin > 0)
|
if (detailedBolusInfo.insulin > 0)
|
||||||
|
|
|
@ -378,8 +378,9 @@ open class LoopPlugin @Inject constructor(
|
||||||
|
|
||||||
// mId allows you to update the notification later on.
|
// mId allows you to update the notification later on.
|
||||||
mNotificationManager.notify(Constants.notificationID, builder.build())
|
mNotificationManager.notify(Constants.notificationID, builder.build())
|
||||||
uel.log(Action.CAREPORTAL, Sources.Loop,
|
uel.log(Action.CAREPORTAL, Sources.Loop, resourceHelper.gs(R.string.carbsreq, resultAfterConstraints.carbsReq, resultAfterConstraints.carbsReqWithin),
|
||||||
ValueWithUnit.StringResource(info.nightscout.androidaps.core.R.string.carbsreq, listOf(ValueWithUnit.Gram(resultAfterConstraints.carbsReq), ValueWithUnit.Minute(resultAfterConstraints.carbsReqWithin))))
|
ValueWithUnit.Gram(resultAfterConstraints.carbsReq),
|
||||||
|
ValueWithUnit.Minute(resultAfterConstraints.carbsReqWithin))
|
||||||
rxBus.send(EventNewOpenLoopNotification())
|
rxBus.send(EventNewOpenLoopNotification())
|
||||||
|
|
||||||
//only send to wear if Native notifications are turned off
|
//only send to wear if Native notifications are turned off
|
||||||
|
|
|
@ -148,8 +148,8 @@ class ConfigBuilderPlugin @Inject constructor(
|
||||||
performPluginSwitch(changedPlugin, newState, type)
|
performPluginSwitch(changedPlugin, newState, type)
|
||||||
pumpSync.connectNewPump()
|
pumpSync.connectNewPump()
|
||||||
sp.putBoolean("allow_hardware_pump", true)
|
sp.putBoolean("allow_hardware_pump", true)
|
||||||
uel.log(Action.HW_PUMP_ALLOWED, Sources.ConfigBuilder,
|
uel.log(Action.HW_PUMP_ALLOWED, Sources.ConfigBuilder, resourceHelper.gs(changedPlugin.pluginDescription.pluginName),
|
||||||
ValueWithUnit.StringResource(changedPlugin.pluginDescription.pluginName))
|
ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(changedPlugin.pluginDescription.pluginName)))
|
||||||
aapsLogger.debug(LTag.PUMP, "First time HW pump allowed!")
|
aapsLogger.debug(LTag.PUMP, "First time HW pump allowed!")
|
||||||
}, {
|
}, {
|
||||||
rxBus.send(EventConfigBuilderUpdateGui())
|
rxBus.send(EventConfigBuilderUpdateGui())
|
||||||
|
@ -160,12 +160,12 @@ class ConfigBuilderPlugin @Inject constructor(
|
||||||
|
|
||||||
override fun performPluginSwitch(changedPlugin: PluginBase, enabled: Boolean, type: PluginType) {
|
override fun performPluginSwitch(changedPlugin: PluginBase, enabled: Boolean, type: PluginType) {
|
||||||
if(enabled && !changedPlugin.isEnabled()) {
|
if(enabled && !changedPlugin.isEnabled()) {
|
||||||
uel.log(Action.PLUGIN_ENABLED, Sources.ConfigBuilder,
|
uel.log(Action.PLUGIN_ENABLED, Sources.ConfigBuilder, resourceHelper.gs(changedPlugin.pluginDescription.pluginName),
|
||||||
ValueWithUnit.StringResource(changedPlugin.pluginDescription.pluginName))
|
ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(changedPlugin.pluginDescription.pluginName)))
|
||||||
}
|
}
|
||||||
else if(!enabled) {
|
else if(!enabled) {
|
||||||
uel.log(Action.PLUGIN_DISABLED, Sources.ConfigBuilder,
|
uel.log(Action.PLUGIN_DISABLED, Sources.ConfigBuilder, resourceHelper.gs(changedPlugin.pluginDescription.pluginName),
|
||||||
ValueWithUnit.StringResource(changedPlugin.pluginDescription.pluginName))
|
ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(changedPlugin.pluginDescription.pluginName)))
|
||||||
}
|
}
|
||||||
changedPlugin.setPluginEnabled(type, enabled)
|
changedPlugin.setPluginEnabled(type, enabled)
|
||||||
changedPlugin.setFragmentVisible(type, enabled)
|
changedPlugin.setFragmentVisible(type, enabled)
|
||||||
|
|
|
@ -76,8 +76,8 @@ class FoodFragment : DaggerFragment() {
|
||||||
binding.refreshFromNightscout.setOnClickListener {
|
binding.refreshFromNightscout.setOnClickListener {
|
||||||
context?.let { context ->
|
context?.let { context ->
|
||||||
OKDialog.showConfirmation(context, resourceHelper.gs(R.string.refresheventsfromnightscout) + " ?", {
|
OKDialog.showConfirmation(context, resourceHelper.gs(R.string.refresheventsfromnightscout) + " ?", {
|
||||||
uel.log(Action.FOOD, Sources.Food,
|
uel.log(Action.FOOD, Sources.Food, resourceHelper.gs(R.string.refresheventsfromnightscout),
|
||||||
ValueWithUnit.StringResource(R.string.refresheventsfromnightscout))
|
ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.refresheventsfromnightscout)))
|
||||||
disposable += Completable.fromAction { repository.deleteAllFoods() }
|
disposable += Completable.fromAction { repository.deleteAllFoods() }
|
||||||
.subscribeOn(aapsSchedulers.io)
|
.subscribeOn(aapsSchedulers.io)
|
||||||
.observeOn(aapsSchedulers.main)
|
.observeOn(aapsSchedulers.main)
|
||||||
|
|
|
@ -587,8 +587,8 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
activePlugin.activeTreatments.doProfileSwitch(store, list[pIndex - 1] as String, 0, finalPercentage, 0, dateUtil.now())
|
activePlugin.activeTreatments.doProfileSwitch(store, list[pIndex - 1] as String, 0, finalPercentage, 0, dateUtil.now())
|
||||||
val replyText = resourceHelper.gs(R.string.profileswitchcreated)
|
val replyText = resourceHelper.gs(R.string.profileswitchcreated)
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
||||||
uel.log(Action.PROFILE_SWITCH, Sources.SMS,
|
uel.log(Action.PROFILE_SWITCH, Sources.SMS, resourceHelper.gs(R.string.profileswitchcreated),
|
||||||
ValueWithUnit.StringResource(R.string.profileswitchcreated))
|
ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.profileswitchcreated)))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -610,14 +610,14 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalcanceled)
|
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalcanceled)
|
||||||
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||||
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
||||||
uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true),
|
uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_tempbasalcanceled),
|
||||||
ValueWithUnit.StringResource(R.string.smscommunicator_tempbasalcanceled))
|
ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.smscommunicator_tempbasalcanceled)))
|
||||||
} else {
|
} else {
|
||||||
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalcancelfailed)
|
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalcancelfailed)
|
||||||
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
||||||
uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true),
|
uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_tempbasalcancelfailed),
|
||||||
ValueWithUnit.StringResource(R.string.smscommunicator_tempbasalcancelfailed))
|
ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.smscommunicator_tempbasalcancelfailed)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -647,18 +647,20 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
||||||
if (result.isPercent)
|
if (result.isPercent)
|
||||||
uel.log(Action.TEMP_BASAL, Sources.SMS,
|
uel.log(Action.TEMP_BASAL, Sources.SMS,
|
||||||
activePlugin.activePump.shortStatus(true),
|
activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_tempbasalset_percent, result.percent, result.duration),
|
||||||
ValueWithUnit.StringResource(R.string.smscommunicator_tempbasalset_percent, listOf(ValueWithUnit.Percent(result.percent), ValueWithUnit.Minute(result.duration))) )
|
ValueWithUnit.Percent(result.percent),
|
||||||
|
ValueWithUnit.Minute(result.duration))
|
||||||
else
|
else
|
||||||
uel.log(Action.TEMP_BASAL, Sources.SMS,
|
uel.log(Action.TEMP_BASAL, Sources.SMS,
|
||||||
activePlugin.activePump.shortStatus(true),
|
activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_tempbasalset, result.absolute, result.duration),
|
||||||
ValueWithUnit.StringResource(R.string.smscommunicator_tempbasalset, listOf( ValueWithUnit.UnitPerHour(result.absolute), ValueWithUnit.Minute(result.duration))))
|
ValueWithUnit.UnitPerHour(result.absolute),
|
||||||
|
ValueWithUnit.Minute(result.duration))
|
||||||
} else {
|
} else {
|
||||||
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed)
|
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed)
|
||||||
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
||||||
uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true),
|
uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_tempbasalfailed),
|
||||||
ValueWithUnit.StringResource(R.string.smscommunicator_tempbasalfailed))
|
ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.smscommunicator_tempbasalfailed)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -689,17 +691,19 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||||
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
||||||
if (result.isPercent)
|
if (result.isPercent)
|
||||||
uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true),
|
uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_tempbasalset_percent, result.percent, result.duration),
|
||||||
ValueWithUnit.StringResource(R.string.smscommunicator_tempbasalset_percent, listOf(ValueWithUnit.Percent(result.percent), ValueWithUnit.Minute(result.duration))))
|
ValueWithUnit.Percent(result.percent),
|
||||||
|
ValueWithUnit.Minute(result.duration))
|
||||||
else
|
else
|
||||||
uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true),
|
uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_tempbasalset, result.absolute, result.duration),
|
||||||
ValueWithUnit.StringResource(R.string.smscommunicator_tempbasalset, listOf(ValueWithUnit.UnitPerHour(result.absolute), ValueWithUnit.Minute(result.duration))))
|
ValueWithUnit.UnitPerHour(result.absolute),
|
||||||
|
ValueWithUnit.Minute(result.duration))
|
||||||
} else {
|
} else {
|
||||||
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed)
|
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed)
|
||||||
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
||||||
uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true),
|
uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_tempbasalfailed),
|
||||||
ValueWithUnit.StringResource(R.string.smscommunicator_tempbasalfailed))
|
ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.smscommunicator_tempbasalfailed)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -726,8 +730,8 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
var replyText = resourceHelper.gs(R.string.smscommunicator_extendedcancelfailed)
|
var replyText = resourceHelper.gs(R.string.smscommunicator_extendedcancelfailed)
|
||||||
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
||||||
uel.log(Action.EXTENDED_BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true),
|
uel.log(Action.EXTENDED_BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_extendedcanceled),
|
||||||
ValueWithUnit.StringResource(R.string.smscommunicator_extendedcanceled))
|
ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.smscommunicator_extendedcanceled)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -754,18 +758,20 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||||
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
||||||
if (config.APS)
|
if (config.APS)
|
||||||
uel.log(Action.EXTENDED_BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true),
|
uel.log(Action.EXTENDED_BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_extendedset, aDouble, duration) + " / " + resourceHelper.gs(R.string.loopsuspended),
|
||||||
ValueWithUnit.StringResource(R.string.smscommunicator_extendedset, listOf(ValueWithUnit.Insulin(aDouble ?: 0.0), ValueWithUnit.Minute(duration))),
|
ValueWithUnit.Insulin(aDouble ?: 0.0),
|
||||||
ValueWithUnit.StringResource(R.string.loopsuspended))
|
ValueWithUnit.Minute(duration),
|
||||||
|
ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.loopsuspended)))
|
||||||
else
|
else
|
||||||
uel.log(Action.EXTENDED_BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true),
|
uel.log(Action.EXTENDED_BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_extendedset, aDouble, duration),
|
||||||
ValueWithUnit.StringResource(R.string.smscommunicator_extendedset, listOf( ValueWithUnit.Insulin(aDouble ?: 0.0), ValueWithUnit.Minute(duration))))
|
ValueWithUnit.Insulin(aDouble ?: 0.0),
|
||||||
|
ValueWithUnit.Minute(duration))
|
||||||
} else {
|
} else {
|
||||||
var replyText = resourceHelper.gs(R.string.smscommunicator_extendedfailed)
|
var replyText = resourceHelper.gs(R.string.smscommunicator_extendedfailed)
|
||||||
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
||||||
uel.log(Action.EXTENDED_BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true),
|
uel.log(Action.EXTENDED_BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_extendedfailed),
|
||||||
ValueWithUnit.StringResource(R.string.smscommunicator_extendedfailed))
|
ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.smscommunicator_extendedfailed)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -842,8 +848,8 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
var replyText = resourceHelper.gs(R.string.smscommunicator_bolusfailed)
|
var replyText = resourceHelper.gs(R.string.smscommunicator_bolusfailed)
|
||||||
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
||||||
uel.log(Action.BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true),
|
uel.log(Action.BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_bolusfailed),
|
||||||
ValueWithUnit.StringResource(R.string.smscommunicator_bolusfailed))
|
ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.smscommunicator_bolusfailed)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -900,14 +906,14 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
var replyText = String.format(resourceHelper.gs(R.string.smscommunicator_carbsset), anInteger)
|
var replyText = String.format(resourceHelper.gs(R.string.smscommunicator_carbsset), anInteger)
|
||||||
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||||
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
||||||
uel.log(Action.CARBS, Sources.SMS, activePlugin.activePump.shortStatus(true),
|
uel.log(Action.CARBS, Sources.SMS, activePlugin.activePump.shortStatus(true) + ": " + resourceHelper.gs(R.string.smscommunicator_carbsset, anInteger),
|
||||||
ValueWithUnit.StringResource(R.string.smscommunicator_carbsset, listOf(ValueWithUnit.Gram(anInteger ?: 0))))
|
ValueWithUnit.Gram(anInteger ?: 0))
|
||||||
} else {
|
} else {
|
||||||
var replyText = resourceHelper.gs(R.string.smscommunicator_carbsfailed, anInteger)
|
var replyText = resourceHelper.gs(R.string.smscommunicator_carbsfailed, anInteger)
|
||||||
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
||||||
uel.log(Action.CARBS, Sources.SMS, activePlugin.activePump.shortStatus(true),
|
uel.log(Action.CARBS, Sources.SMS, activePlugin.activePump.shortStatus(true) + ": " + resourceHelper.gs(R.string.smscommunicator_carbsfailed, anInteger),
|
||||||
ValueWithUnit.StringResource(R.string.smscommunicator_carbsfailed, listOf(ValueWithUnit.Gram(anInteger ?: 0))))
|
ValueWithUnit.Gram(anInteger ?: 0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -997,8 +1003,8 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
})
|
})
|
||||||
val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_tt_canceled))
|
val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_tt_canceled))
|
||||||
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
||||||
uel.log(Action.CANCEL_TT, Sources.SMS,
|
uel.log(Action.CANCEL_TT, Sources.SMS, resourceHelper.gs(R.string.smscommunicator_tt_canceled),
|
||||||
ValueWithUnit.StringResource(R.string.smscommunicator_tt_canceled))
|
ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.smscommunicator_tt_canceled)))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else
|
} else
|
||||||
|
@ -1017,8 +1023,8 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
sp.putBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)
|
sp.putBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)
|
||||||
val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_stoppedsms))
|
val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_stoppedsms))
|
||||||
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
||||||
uel.log(Action.STOP_SMS, Sources.SMS,
|
uel.log(Action.STOP_SMS, Sources.SMS, resourceHelper.gs(R.string.smscommunicator_stoppedsms),
|
||||||
ValueWithUnit.StringResource(R.string.smscommunicator_stoppedsms))
|
ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.smscommunicator_stoppedsms)))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))
|
} else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))
|
||||||
|
@ -1037,11 +1043,11 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
if (result) resourceHelper.gs(R.string.smscommunicator_calibrationsent) else resourceHelper.gs(R.string.smscommunicator_calibrationfailed)
|
if (result) resourceHelper.gs(R.string.smscommunicator_calibrationsent) else resourceHelper.gs(R.string.smscommunicator_calibrationfailed)
|
||||||
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
||||||
if (result)
|
if (result)
|
||||||
uel.log(Action.CALIBRATION, Sources.SMS,
|
uel.log(Action.CALIBRATION, Sources.SMS, resourceHelper.gs(R.string.smscommunicator_calibrationsent),
|
||||||
ValueWithUnit.StringResource(R.string.smscommunicator_calibrationsent))
|
ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.smscommunicator_calibrationsent)))
|
||||||
else
|
else
|
||||||
uel.log(Action.CALIBRATION, Sources.SMS,
|
uel.log(Action.CALIBRATION, Sources.SMS, resourceHelper.gs(R.string.smscommunicator_calibrationfailed),
|
||||||
ValueWithUnit.StringResource(R.string.smscommunicator_calibrationfailed))
|
ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.smscommunicator_calibrationfailed)))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))
|
} else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))
|
||||||
|
|
|
@ -37,8 +37,8 @@ class ActionLoopSuspend(injector: HasAndroidInjector) : Action(injector) {
|
||||||
if (!loopPlugin.isSuspended) {
|
if (!loopPlugin.isSuspended) {
|
||||||
loopPlugin.suspendLoop(minutes.getMinutes())
|
loopPlugin.suspendLoop(minutes.getMinutes())
|
||||||
rxBus.send(EventRefreshOverview("ActionLoopSuspend"))
|
rxBus.send(EventRefreshOverview("ActionLoopSuspend"))
|
||||||
uel.log(UserEntry.Action.SUSPEND, Sources.Automation, title,
|
uel.log(UserEntry.Action.SUSPEND, Sources.Automation, title + ": " + resourceHelper.gs(R.string.suspendloopforXmin, minutes.getMinutes()),
|
||||||
ValueWithUnit.StringResource(R.string.suspendloopforXmin, listOf(ValueWithUnit.Minute(minutes.getMinutes()))))
|
ValueWithUnit.Minute(minutes.getMinutes()))
|
||||||
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
|
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
|
||||||
} else {
|
} else {
|
||||||
callback.result(PumpEnactResult(injector).success(true).comment(R.string.alreadysuspended))?.run()
|
callback.result(PumpEnactResult(injector).success(true).comment(R.string.alreadysuspended))?.run()
|
||||||
|
|
|
@ -42,8 +42,9 @@ class ActionProfileSwitchPercent(injector: HasAndroidInjector) : Action(injector
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doAction(callback: Callback) {
|
override fun doAction(callback: Callback) {
|
||||||
uel.log(UserEntry.Action.PROFILE_SWITCH, Sources.Automation, title,
|
uel.log(UserEntry.Action.PROFILE_SWITCH, Sources.Automation, title + ": " + resourceHelper.gs(R.string.startprofile, pct.value.toInt(), duration.value),
|
||||||
ValueWithUnit.StringResource( R.string.startprofile, listOf(ValueWithUnit.Percent(pct.value.toInt()), ValueWithUnit.Minute(duration.value))))
|
ValueWithUnit.Percent(pct.value.toInt()),
|
||||||
|
ValueWithUnit.Minute(duration.value))
|
||||||
activePlugin.activeTreatments.doProfileSwitch(duration.value, pct.value.toInt(), 0)
|
activePlugin.activeTreatments.doProfileSwitch(duration.value, pct.value.toInt(), 0)
|
||||||
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
|
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.os.SystemClock;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.extensions.PumpStateExtensionKt;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
@ -96,7 +97,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
||||||
*/
|
*/
|
||||||
private volatile boolean scripterIsBolusing;
|
private volatile boolean scripterIsBolusing;
|
||||||
/**
|
/**
|
||||||
* This is set to true to request a bolus cancellation. {@link #deliverBolus(DetailedBolusInfo)}
|
* This is set to true to request a bolus cancellation. {@link #deliverTreatment(DetailedBolusInfo)} (DetailedBolusInfo)}
|
||||||
* will reset this flag.
|
* will reset this flag.
|
||||||
*/
|
*/
|
||||||
private volatile boolean cancelBolus;
|
private volatile boolean cancelBolus;
|
||||||
|
@ -105,7 +106,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
||||||
* This is set (in {@link #checkHistory()} whenever a connection to the pump is made and
|
* This is set (in {@link #checkHistory()} whenever a connection to the pump is made and
|
||||||
* indicates if new history records on the pump have been found. This effectively blocks
|
* indicates if new history records on the pump have been found. This effectively blocks
|
||||||
* high temps ({@link #setTempBasalPercent(Integer, Integer, PumpSync.TemporaryBasalType)} and boluses
|
* high temps ({@link #setTempBasalPercent(Integer, Integer, PumpSync.TemporaryBasalType)} and boluses
|
||||||
* ({@link #deliverBolus(DetailedBolusInfo)} till the queue is empty and the connection
|
* ({@link #deliverTreatment(DetailedBolusInfo)} till the queue is empty and the connection
|
||||||
* is shut down.
|
* is shut down.
|
||||||
* {@link #initializePump()} resets this since on startup the history is allowed to have
|
* {@link #initializePump()} resets this since on startup the history is allowed to have
|
||||||
* changed (and the user can't possible have already calculated anything with out of date IOB).
|
* changed (and the user can't possible have already calculated anything with out of date IOB).
|
||||||
|
@ -120,7 +121,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
||||||
/**
|
/**
|
||||||
* Cache of the last <=2 boluses on the pump. Used to detect changes in pump history,
|
* Cache of the last <=2 boluses on the pump. Used to detect changes in pump history,
|
||||||
* requiring reading more pump history. This is read/set in {@link #checkHistory()} when changed
|
* requiring reading more pump history. This is read/set in {@link #checkHistory()} when changed
|
||||||
* pump history was detected and was read, as well as in {@link #deliverBolus(DetailedBolusInfo)}
|
* pump history was detected and was read, as well as in {@link #deliverTreatment(DetailedBolusInfo)}
|
||||||
* after bolus delivery. Newest record is the first one.
|
* after bolus delivery. Newest record is the first one.
|
||||||
*/
|
*/
|
||||||
private volatile List<Bolus> recentBoluses = new ArrayList<>(0);
|
private volatile List<Bolus> recentBoluses = new ArrayList<>(0);
|
||||||
|
@ -474,41 +475,9 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
||||||
*/
|
*/
|
||||||
@NonNull @Override
|
@NonNull @Override
|
||||||
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
||||||
try {
|
if (detailedBolusInfo.insulin == 0 || detailedBolusInfo.carbs > 0) {
|
||||||
if (detailedBolusInfo.insulin == 0 && detailedBolusInfo.carbs == 0) {
|
throw new IllegalArgumentException(detailedBolusInfo.toString());
|
||||||
// neither carbs nor bolus requested
|
|
||||||
getAapsLogger().error("deliverTreatment: Invalid input");
|
|
||||||
return new PumpEnactResult(getInjector()).success(false).enacted(false)
|
|
||||||
.bolusDelivered(0d).carbsDelivered(0d)
|
|
||||||
.comment(R.string.invalidinput);
|
|
||||||
// } else if (detailedBolusInfo.insulin > 0) {
|
|
||||||
} else {
|
|
||||||
// bolus needed, ask pump to deliver it
|
|
||||||
return deliverBolus(detailedBolusInfo);
|
|
||||||
}
|
}
|
||||||
/* This should not happen anymore
|
|
||||||
else {
|
|
||||||
// no bolus required, carb only treatment
|
|
||||||
treatmentsPlugin.addToHistoryTreatment(detailedBolusInfo, false);
|
|
||||||
|
|
||||||
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.INSTANCE;
|
|
||||||
bolusingEvent.setT(new EventOverviewBolusProgress.Treatment(0.0, 0, detailedBolusInfo.getBolusType() == DetailedBolusInfo.BolusType.SMB));
|
|
||||||
bolusingEvent.setPercent(100);
|
|
||||||
rxBus.send(bolusingEvent);
|
|
||||||
|
|
||||||
return new PumpEnactResult(getInjector()).success(true).enacted(true)
|
|
||||||
.bolusDelivered(0d).carbsDelivered(detailedBolusInfo.carbs)
|
|
||||||
.comment(R.string.virtualpump_resultok);
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
} finally {
|
|
||||||
rxBus.send(new EventComboPumpUpdateGUI());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
private PumpEnactResult deliverBolus(final DetailedBolusInfo detailedBolusInfo) {
|
|
||||||
try {
|
try {
|
||||||
pump.activity = getResourceHelper().gs(R.string.combo_pump_action_bolusing, detailedBolusInfo.insulin);
|
pump.activity = getResourceHelper().gs(R.string.combo_pump_action_bolusing, detailedBolusInfo.insulin);
|
||||||
rxBus.send(new EventComboPumpUpdateGUI());
|
rxBus.send(new EventComboPumpUpdateGUI());
|
||||||
|
@ -668,39 +637,18 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
||||||
* Creates a treatment record based on the request in DetailBolusInfo and the delivered bolus.
|
* Creates a treatment record based on the request in DetailBolusInfo and the delivered bolus.
|
||||||
*/
|
*/
|
||||||
private boolean addBolusToTreatments(DetailedBolusInfo detailedBolusInfo, Bolus lastPumpBolus) {
|
private boolean addBolusToTreatments(DetailedBolusInfo detailedBolusInfo, Bolus lastPumpBolus) {
|
||||||
DetailedBolusInfo bolusInfo = detailedBolusInfo.copy();
|
|
||||||
bolusInfo.setBolusTimestamp(calculateFakeBolusDate(lastPumpBolus));
|
|
||||||
bolusInfo.setPumpType(PumpType.ACCU_CHEK_COMBO);
|
|
||||||
bolusInfo.setPumpSerial(serialNumber());
|
|
||||||
bolusInfo.setBolusPumpId(bolusInfo.timestamp);
|
|
||||||
bolusInfo.insulin = lastPumpBolus.amount;
|
|
||||||
try {
|
try {
|
||||||
/* this should not happen
|
|
||||||
if (bolusInfo.carbs > 0 && bolusInfo.carbTime != 0) {
|
|
||||||
// split out a separate carbs record without a pumpId
|
|
||||||
DetailedBolusInfo carbInfo = new DetailedBolusInfo();
|
|
||||||
carbInfo.timestamp = bolusInfo.timestamp + bolusInfo.carbTime * 60L * 1000L;
|
|
||||||
carbInfo.carbs = bolusInfo.carbs;
|
|
||||||
carbInfo.setPumpType(PumpType.USER);
|
|
||||||
treatmentsPlugin.addToHistoryTreatment(carbInfo, true);
|
|
||||||
|
|
||||||
// remove carbs from bolusInfo to not trigger any unwanted code paths in
|
|
||||||
// TreatmentsPlugin.addToHistoryTreatment() method
|
|
||||||
bolusInfo.carbTime = 0;
|
|
||||||
bolusInfo.carbs = 0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
pumpSync.syncBolusWithPumpId(
|
pumpSync.syncBolusWithPumpId(
|
||||||
calculateFakeBolusDate(lastPumpBolus),
|
lastPumpBolus.timestamp,
|
||||||
lastPumpBolus.amount,
|
lastPumpBolus.amount,
|
||||||
detailedBolusInfo.getBolusType(),
|
detailedBolusInfo.getBolusType(),
|
||||||
bolusInfo.timestamp,
|
generatePumpBolusId(lastPumpBolus),
|
||||||
PumpType.ACCU_CHEK_COMBO,
|
PumpType.ACCU_CHEK_COMBO,
|
||||||
serialNumber()
|
serialNumber()
|
||||||
);
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
getAapsLogger().error("Adding treatment record failed", e);
|
getAapsLogger().error("Adding treatment record failed", e);
|
||||||
if (bolusInfo.getBolusType() == DetailedBolusInfo.BolusType.SMB) {
|
if (detailedBolusInfo.getBolusType() == DetailedBolusInfo.BolusType.SMB) {
|
||||||
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, getResourceHelper().gs(R.string.combo_error_updating_treatment_record), Notification.URGENT);
|
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, getResourceHelper().gs(R.string.combo_error_updating_treatment_record), Notification.URGENT);
|
||||||
rxBus.send(new EventNewNotification(notification));
|
rxBus.send(new EventNewNotification(notification));
|
||||||
}
|
}
|
||||||
|
@ -791,7 +739,12 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
||||||
T.mins(state.tbrRemainingDuration).msecs(),
|
T.mins(state.tbrRemainingDuration).msecs(),
|
||||||
false,
|
false,
|
||||||
tbrType,
|
tbrType,
|
||||||
state.timestamp, // no pumpId available ????
|
// There are no IDs for TBRs on the pump and none is calculated (in contrast to boluses).
|
||||||
|
// The current time is used here as an ID, which has no meaning and does not allow identifying
|
||||||
|
// the record on the pump (which isn't needed), but only needs to be unique.
|
||||||
|
// Generally, TBR records are created when a TBR is set by AAPS or when a change on the pump has
|
||||||
|
// been detected, rather than checking the pumps history of TBRs.
|
||||||
|
state.timestamp,
|
||||||
PumpType.ACCU_CHEK_COMBO,
|
PumpType.ACCU_CHEK_COMBO,
|
||||||
serialNumber()
|
serialNumber()
|
||||||
);
|
);
|
||||||
|
@ -820,9 +773,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
||||||
@NonNull @Override
|
@NonNull @Override
|
||||||
public PumpEnactResult cancelTempBasal(boolean enforceNew) {
|
public PumpEnactResult cancelTempBasal(boolean enforceNew) {
|
||||||
getAapsLogger().debug(LTag.PUMP, "cancelTempBasal called");
|
getAapsLogger().debug(LTag.PUMP, "cancelTempBasal called");
|
||||||
//final TemporaryBasal activeTemp = treatmentsPlugin.getTempBasalFromHistoryIncludingConvertedExtended(System.currentTimeMillis());
|
final PumpSync.PumpState.TemporaryBasal activeTemp = pumpSync.expectedPumpState().getTemporaryBasal();
|
||||||
PumpSync.PumpState pumpSate = pumpSync.expectedPumpState();
|
|
||||||
final PumpSync.PumpState.TemporaryBasal activeTemp = pumpSate.getTemporaryBasal();
|
|
||||||
if (enforceNew) {
|
if (enforceNew) {
|
||||||
CommandResult stateResult = runCommand(getResourceHelper().gs(R.string.combo_pump_action_refreshing), 2, ruffyScripter::readPumpState);
|
CommandResult stateResult = runCommand(getResourceHelper().gs(R.string.combo_pump_action_refreshing), 2, ruffyScripter::readPumpState);
|
||||||
if (!stateResult.success) {
|
if (!stateResult.success) {
|
||||||
|
@ -839,6 +790,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
||||||
if (!cancelResult.state.tbrActive) {
|
if (!cancelResult.state.tbrActive) {
|
||||||
pumpSync.syncStopTemporaryBasalWithPumpId(
|
pumpSync.syncStopTemporaryBasalWithPumpId(
|
||||||
cancelResult.state.timestamp,
|
cancelResult.state.timestamp,
|
||||||
|
// Combo doesn't have nor uses IDs for TBRs, see note in #setTempBasalPercent
|
||||||
cancelResult.state.timestamp,
|
cancelResult.state.timestamp,
|
||||||
PumpType.ACCU_CHEK_COMBO,
|
PumpType.ACCU_CHEK_COMBO,
|
||||||
serialNumber()
|
serialNumber()
|
||||||
|
@ -849,15 +801,16 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
||||||
}
|
}
|
||||||
} else if (activeTemp == null) {
|
} else if (activeTemp == null) {
|
||||||
return new PumpEnactResult(getInjector()).success(true).enacted(false);
|
return new PumpEnactResult(getInjector()).success(true).enacted(false);
|
||||||
} else if ((activeTemp.getRate() >= 90 && activeTemp.getRate() <= 110) && info.nightscout.androidaps.extensions.PumpStateExtensionKt.getPlannedRemainingMinutes(activeTemp) <= 15) {
|
} else if ((activeTemp.getRate() >= 90 && activeTemp.getRate() <= 110)
|
||||||
|
&& PumpStateExtensionKt.getPlannedRemainingMinutes(activeTemp) <= 15) {
|
||||||
// Let fake neutral temp keep run (see below)
|
// Let fake neutral temp keep run (see below)
|
||||||
// Note that since this runs on the queue a connection is opened regardless, but this
|
// Note that since this runs on the queue a connection is opened regardless, but this
|
||||||
// case doesn't occur all that often, so it's not worth optimizing (1.3k SetTBR vs 4 cancelTBR).
|
// case doesn't occur all that often, so it's not worth optimizing (1.3k SetTBR vs 4 cancelTBR).
|
||||||
getAapsLogger().debug(LTag.PUMP, "cancelTempBasal: skipping changing tbr since it already is at " + activeTemp.getRate() + "% and running for another " + info.nightscout.androidaps.extensions.PumpStateExtensionKt.getPlannedRemainingMinutes(activeTemp) + " mins.");
|
getAapsLogger().debug(LTag.PUMP, "cancelTempBasal: skipping changing tbr since it already is at " + activeTemp.getRate() + "% and running for another " + PumpStateExtensionKt.getPlannedRemainingMinutes(activeTemp) + " mins.");
|
||||||
return new PumpEnactResult(getInjector()).success(true).enacted(true)
|
return new PumpEnactResult(getInjector()).success(true).enacted(true)
|
||||||
.comment("cancelTempBasal skipping changing tbr since it already is at "
|
.comment("cancelTempBasal skipping changing tbr since it already is at "
|
||||||
+ activeTemp.getRate() + "% and running for another "
|
+ activeTemp.getRate() + "% and running for another "
|
||||||
+ info.nightscout.androidaps.extensions.PumpStateExtensionKt.getPlannedRemainingMinutes(activeTemp) + " mins.");
|
+ PumpStateExtensionKt.getPlannedRemainingMinutes(activeTemp) + " mins.");
|
||||||
} else {
|
} else {
|
||||||
// Set a fake neutral temp to avoid TBR cancel alert. Decide 90% vs 110% based on
|
// Set a fake neutral temp to avoid TBR cancel alert. Decide 90% vs 110% based on
|
||||||
// on whether the TBR we're cancelling is above or below 100%.
|
// on whether the TBR we're cancelling is above or below 100%.
|
||||||
|
@ -992,7 +945,8 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
||||||
T.mins(15).msecs(),
|
T.mins(15).msecs(),
|
||||||
false,
|
false,
|
||||||
PumpSync.TemporaryBasalType.PUMP_SUSPEND,
|
PumpSync.TemporaryBasalType.PUMP_SUSPEND,
|
||||||
now, // no pumpId available ????
|
// Combo doesn't have nor uses IDs for TBRs, see note in #setTempBasalPercent
|
||||||
|
now,
|
||||||
PumpType.ACCU_CHEK_COMBO,
|
PumpType.ACCU_CHEK_COMBO,
|
||||||
serialNumber()
|
serialNumber()
|
||||||
);
|
);
|
||||||
|
@ -1113,6 +1067,8 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
||||||
private void checkAndResolveTbrMismatch(PumpState state) {
|
private void checkAndResolveTbrMismatch(PumpState state) {
|
||||||
// compare with: info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgStatusTempBasal.updateTempBasalInDB()
|
// compare with: info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgStatusTempBasal.updateTempBasalInDB()
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
|
// Combo doesn't have nor uses IDs for TBRs, see note in #setTempBasalPercent
|
||||||
|
long tbrId = now;
|
||||||
//TemporaryBasal aapsTbr = treatmentsPlugin.getTempBasalFromHistoryIncludingConvertedExtended(now);
|
//TemporaryBasal aapsTbr = treatmentsPlugin.getTempBasalFromHistoryIncludingConvertedExtended(now);
|
||||||
PumpSync.PumpState.TemporaryBasal aapsTbr = pumpSync.expectedPumpState().getTemporaryBasal();
|
PumpSync.PumpState.TemporaryBasal aapsTbr = pumpSync.expectedPumpState().getTemporaryBasal();
|
||||||
if (aapsTbr == null && state.tbrActive && state.tbrRemainingDuration > 2) {
|
if (aapsTbr == null && state.tbrActive && state.tbrRemainingDuration > 2) {
|
||||||
|
@ -1123,36 +1079,40 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
||||||
T.mins(state.tbrRemainingDuration).msecs(),
|
T.mins(state.tbrRemainingDuration).msecs(),
|
||||||
false,
|
false,
|
||||||
PumpSync.TemporaryBasalType.NORMAL,
|
PumpSync.TemporaryBasalType.NORMAL,
|
||||||
now, // no pumpId available ????
|
tbrId,
|
||||||
PumpType.ACCU_CHEK_COMBO,
|
PumpType.ACCU_CHEK_COMBO,
|
||||||
serialNumber()
|
serialNumber()
|
||||||
);
|
);
|
||||||
} else if (aapsTbr != null && info.nightscout.androidaps.extensions.PumpStateExtensionKt.getPlannedRemainingMinutes(aapsTbr) > 2 && !state.tbrActive) {
|
} else if (aapsTbr != null && PumpStateExtensionKt.getPlannedRemainingMinutes(aapsTbr) > 2 && !state.tbrActive) {
|
||||||
getAapsLogger().debug(LTag.PUMP, "Ending AAPS-TBR since pump has no TBR active");
|
getAapsLogger().debug(LTag.PUMP, "Ending AAPS-TBR since pump has no TBR active");
|
||||||
pumpSync.syncStopTemporaryBasalWithPumpId(
|
pumpSync.syncStopTemporaryBasalWithPumpId(
|
||||||
now,
|
now,
|
||||||
now,
|
tbrId,
|
||||||
PumpType.ACCU_CHEK_COMBO,
|
PumpType.ACCU_CHEK_COMBO,
|
||||||
serialNumber()
|
serialNumber()
|
||||||
);
|
);
|
||||||
} else if (aapsTbr != null && state.tbrActive
|
} else if (aapsTbr != null && state.tbrActive
|
||||||
&& (aapsTbr.getRate() != state.tbrPercent ||
|
&& (aapsTbr.getRate() != state.tbrPercent ||
|
||||||
Math.abs(info.nightscout.androidaps.extensions.PumpStateExtensionKt.getPlannedRemainingMinutes(aapsTbr) - state.tbrRemainingDuration) > 2)) {
|
Math.abs(PumpStateExtensionKt.getPlannedRemainingMinutes(aapsTbr) - state.tbrRemainingDuration) > 2)) {
|
||||||
getAapsLogger().debug(LTag.PUMP, "AAPSs and pump-TBR differ; ending AAPS-TBR and creating new TBR based on pump TBR");
|
getAapsLogger().debug(LTag.PUMP, "AAPSs and pump-TBR differ; ending AAPS-TBR and creating new TBR based on pump TBR");
|
||||||
|
|
||||||
|
// crate TBR end record a second ago
|
||||||
pumpSync.syncStopTemporaryBasalWithPumpId(
|
pumpSync.syncStopTemporaryBasalWithPumpId(
|
||||||
now - 1000,
|
now - 1000,
|
||||||
now - 1000,
|
// fake a unique ID that doesn't clash with the record below
|
||||||
|
tbrId - 1000,
|
||||||
PumpType.ACCU_CHEK_COMBO,
|
PumpType.ACCU_CHEK_COMBO,
|
||||||
serialNumber()
|
serialNumber()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Create TBR start record, starting now
|
||||||
pumpSync.syncTemporaryBasalWithPumpId(
|
pumpSync.syncTemporaryBasalWithPumpId(
|
||||||
now,
|
now,
|
||||||
state.tbrPercent,
|
state.tbrPercent,
|
||||||
T.mins(state.tbrRemainingDuration).msecs(),
|
T.mins(state.tbrRemainingDuration).msecs(),
|
||||||
false,
|
false,
|
||||||
PumpSync.TemporaryBasalType.NORMAL,
|
PumpSync.TemporaryBasalType.NORMAL,
|
||||||
now, // no pumpId available ????
|
tbrId,
|
||||||
PumpType.ACCU_CHEK_COMBO,
|
PumpType.ACCU_CHEK_COMBO,
|
||||||
serialNumber()
|
serialNumber()
|
||||||
);
|
);
|
||||||
|
@ -1189,10 +1149,10 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
||||||
boolean updated = false;
|
boolean updated = false;
|
||||||
for (Bolus pumpBolus : history.bolusHistory) {
|
for (Bolus pumpBolus : history.bolusHistory) {
|
||||||
if (pumpSync.syncBolusWithPumpId(
|
if (pumpSync.syncBolusWithPumpId(
|
||||||
calculateFakeBolusDate(pumpBolus),
|
pumpBolus.timestamp,
|
||||||
pumpBolus.amount,
|
pumpBolus.amount,
|
||||||
DetailedBolusInfo.BolusType.NORMAL,
|
DetailedBolusInfo.BolusType.NORMAL,
|
||||||
System.currentTimeMillis(),
|
generatePumpBolusId(pumpBolus),
|
||||||
PumpType.ACCU_CHEK_COMBO,
|
PumpType.ACCU_CHEK_COMBO,
|
||||||
serialNumber()
|
serialNumber()
|
||||||
)) {
|
)) {
|
||||||
|
@ -1209,7 +1169,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
||||||
* Should be good enough, even with command mode, it's a challenge to create that situation
|
* Should be good enough, even with command mode, it's a challenge to create that situation
|
||||||
* and most time clashes will be around SMBs which are covered.
|
* and most time clashes will be around SMBs which are covered.
|
||||||
*/
|
*/
|
||||||
long calculateFakeBolusDate(Bolus pumpBolus) {
|
long generatePumpBolusId(Bolus pumpBolus) {
|
||||||
double bolus = pumpBolus.amount - 0.1;
|
double bolus = pumpBolus.amount - 0.1;
|
||||||
int secondsFromBolus = (int) (bolus * 10 * 1000);
|
int secondsFromBolus = (int) (bolus * 10 * 1000);
|
||||||
return pumpBolus.timestamp + Math.min(secondsFromBolus, 59 * 1000);
|
return pumpBolus.timestamp + Math.min(secondsFromBolus, 59 * 1000);
|
||||||
|
|
|
@ -64,22 +64,22 @@ class ComboPluginTest : TestBase() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun calculateFakePumpTimestamp() {
|
fun `generate bolus ID from timestamp and amount`() {
|
||||||
val now = System.currentTimeMillis()
|
val now = System.currentTimeMillis()
|
||||||
val pumpTimestamp = now - now % 1000
|
val pumpTimestamp = now - now % 1000
|
||||||
// same timestamp, different bolus leads to different fake timestamp
|
// same timestamp, different bolus leads to different fake timestamp
|
||||||
Assert.assertNotEquals(
|
Assert.assertNotEquals(
|
||||||
comboPlugin.calculateFakeBolusDate(Bolus(pumpTimestamp, 0.1, true)),
|
comboPlugin.generatePumpBolusId(Bolus(pumpTimestamp, 0.1, true)),
|
||||||
comboPlugin.calculateFakeBolusDate(Bolus(pumpTimestamp, 0.3, true))
|
comboPlugin.generatePumpBolusId(Bolus(pumpTimestamp, 0.3, true))
|
||||||
)
|
)
|
||||||
// different timestamp, same bolus leads to different fake timestamp
|
// different timestamp, same bolus leads to different fake timestamp
|
||||||
Assert.assertNotEquals(
|
Assert.assertNotEquals(
|
||||||
comboPlugin.calculateFakeBolusDate(Bolus(pumpTimestamp, 0.3, true)),
|
comboPlugin.generatePumpBolusId(Bolus(pumpTimestamp, 0.3, true)),
|
||||||
comboPlugin.calculateFakeBolusDate(Bolus(pumpTimestamp + 60 * 1000, 0.3, true))
|
comboPlugin.generatePumpBolusId(Bolus(pumpTimestamp + 60 * 1000, 0.3, true))
|
||||||
)
|
)
|
||||||
// generated timestamp has second-precision
|
// generated timestamp has second-precision
|
||||||
val bolus = Bolus(pumpTimestamp, 0.2, true)
|
val bolus = Bolus(pumpTimestamp, 0.2, true)
|
||||||
val calculatedTimestamp = comboPlugin.calculateFakeBolusDate(bolus)
|
val calculatedTimestamp = comboPlugin.generatePumpBolusId(bolus)
|
||||||
Assert.assertEquals(calculatedTimestamp, calculatedTimestamp - calculatedTimestamp % 1000)
|
Assert.assertEquals(calculatedTimestamp, calculatedTimestamp - calculatedTimestamp % 1000)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -10,6 +10,7 @@ interface ResourceHelper {
|
||||||
fun gs(@StringRes id: Int): String
|
fun gs(@StringRes id: Int): String
|
||||||
fun gs(@StringRes id: Int, vararg args: Any?): String
|
fun gs(@StringRes id: Int, vararg args: Any?): String
|
||||||
fun gq(@PluralsRes id: Int, quantity: Int, vararg args: Any?): String
|
fun gq(@PluralsRes id: Int, quantity: Int, vararg args: Any?): String
|
||||||
|
fun gsNotLocalised(@StringRes id: Int, vararg args: Any?): String
|
||||||
fun gc(@ColorRes id: Int): Int
|
fun gc(@ColorRes id: Int): Int
|
||||||
fun gd(@DrawableRes id: Int): Drawable?
|
fun gd(@DrawableRes id: Int): Drawable?
|
||||||
fun gb(@BoolRes id :Int) : Boolean
|
fun gb(@BoolRes id :Int) : Boolean
|
||||||
|
|
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.utils.resources
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.res.AssetFileDescriptor
|
import android.content.res.AssetFileDescriptor
|
||||||
|
import android.content.res.Configuration
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
|
@ -10,6 +11,7 @@ import android.util.DisplayMetrics
|
||||||
import androidx.annotation.*
|
import androidx.annotation.*
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import info.nightscout.androidaps.core.R
|
import info.nightscout.androidaps.core.R
|
||||||
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,6 +26,12 @@ class ResourceHelperImplementation @Inject constructor(private val context: Cont
|
||||||
override fun gq(@PluralsRes id: Int, quantity: Int, vararg args: Any?): String =
|
override fun gq(@PluralsRes id: Int, quantity: Int, vararg args: Any?): String =
|
||||||
context.resources.getQuantityString(id, quantity, *args)
|
context.resources.getQuantityString(id, quantity, *args)
|
||||||
|
|
||||||
|
override fun gsNotLocalised(@StringRes id: Int, vararg args: Any?) : String =
|
||||||
|
with(Configuration(context.resources.configuration)) {
|
||||||
|
setLocale(Locale.ENGLISH)
|
||||||
|
context.createConfigurationContext(this).getString(id, args)
|
||||||
|
}
|
||||||
|
|
||||||
override fun gc(@ColorRes id: Int): Int = ContextCompat.getColor(context, id)
|
override fun gc(@ColorRes id: Int): Int = ContextCompat.getColor(context, id)
|
||||||
|
|
||||||
override fun gd(@DrawableRes id: Int): Drawable? = context.getDrawable(id)
|
override fun gd(@DrawableRes id: Int): Drawable? = context.getDrawable(id)
|
||||||
|
|
|
@ -119,7 +119,6 @@ class UserEntryPresentationHelper @Inject constructor(
|
||||||
is ValueWithUnit.UnitPerHour -> DecimalFormatter.to2Decimal(valueWithUnit.value) + translator.translate(valueWithUnit)
|
is ValueWithUnit.UnitPerHour -> DecimalFormatter.to2Decimal(valueWithUnit.value) + translator.translate(valueWithUnit)
|
||||||
is ValueWithUnit.SimpleInt -> valueWithUnit.value.toString()
|
is ValueWithUnit.SimpleInt -> valueWithUnit.value.toString()
|
||||||
is ValueWithUnit.SimpleString -> valueWithUnit.value
|
is ValueWithUnit.SimpleString -> valueWithUnit.value
|
||||||
is ValueWithUnit.StringResource -> resourceHelper.gs(valueWithUnit.value, *(valueWithUnit.params.map { it.value() }.toTypedArray()))
|
|
||||||
is ValueWithUnit.TherapyEventMeterType -> translator.translate(valueWithUnit.value)
|
is ValueWithUnit.TherapyEventMeterType -> translator.translate(valueWithUnit.value)
|
||||||
is ValueWithUnit.TherapyEventTTReason -> translator.translate(valueWithUnit.value)
|
is ValueWithUnit.TherapyEventTTReason -> translator.translate(valueWithUnit.value)
|
||||||
is ValueWithUnit.TherapyEventType -> translator.translate(valueWithUnit.value)
|
is ValueWithUnit.TherapyEventType -> translator.translate(valueWithUnit.value)
|
||||||
|
@ -182,9 +181,6 @@ class UserEntryPresentationHelper @Inject constructor(
|
||||||
var hour = ""
|
var hour = ""
|
||||||
var minute = ""
|
var minute = ""
|
||||||
var other = ""
|
var other = ""
|
||||||
for (valueWithUnit in entry.values) {
|
|
||||||
if (valueWithUnit is ValueWithUnit.StringResource) fullvalueWithUnitList.addAll(valueWithUnit.params)
|
|
||||||
}
|
|
||||||
|
|
||||||
for (valueWithUnit in fullvalueWithUnitList.filterNotNull()) {
|
for (valueWithUnit in fullvalueWithUnitList.filterNotNull()) {
|
||||||
when (valueWithUnit) {
|
when (valueWithUnit) {
|
||||||
|
@ -196,7 +192,6 @@ class UserEntryPresentationHelper @Inject constructor(
|
||||||
is ValueWithUnit.UnitPerHour -> unitPerHour = DecimalFormatter.to2Decimal(valueWithUnit.value)
|
is ValueWithUnit.UnitPerHour -> unitPerHour = DecimalFormatter.to2Decimal(valueWithUnit.value)
|
||||||
is ValueWithUnit.SimpleInt -> other = other.addWithSeparator(valueWithUnit.value)
|
is ValueWithUnit.SimpleInt -> other = other.addWithSeparator(valueWithUnit.value)
|
||||||
is ValueWithUnit.SimpleString -> other = other.addWithSeparator(valueWithUnit.value)
|
is ValueWithUnit.SimpleString -> other = other.addWithSeparator(valueWithUnit.value)
|
||||||
is ValueWithUnit.StringResource -> stringResource = stringResource.addWithSeparator(resourceHelper.gs(valueWithUnit.value, *(valueWithUnit.params.map { it.value() }.toTypedArray())))
|
|
||||||
is ValueWithUnit.TherapyEventMeterType -> therapyEvent = therapyEvent.addWithSeparator(translator.translate(valueWithUnit.value))
|
is ValueWithUnit.TherapyEventMeterType -> therapyEvent = therapyEvent.addWithSeparator(translator.translate(valueWithUnit.value))
|
||||||
is ValueWithUnit.TherapyEventTTReason -> therapyEvent = therapyEvent.addWithSeparator(translator.translate(valueWithUnit.value))
|
is ValueWithUnit.TherapyEventTTReason -> therapyEvent = therapyEvent.addWithSeparator(translator.translate(valueWithUnit.value))
|
||||||
is ValueWithUnit.TherapyEventType -> therapyEvent = therapyEvent.addWithSeparator(translator.translate(valueWithUnit.value))
|
is ValueWithUnit.TherapyEventType -> therapyEvent = therapyEvent.addWithSeparator(translator.translate(valueWithUnit.value))
|
||||||
|
@ -222,9 +217,9 @@ class UserEntryPresentationHelper @Inject constructor(
|
||||||
return "$timestampRec;$dateTimestampRev;$utcOffset;$action;$therapyEvent;$source;$note;$stringResource;$timestamp;$bg;$gram;$insulin;$unitPerHour;$percent;$hour;$minute;$other"
|
return "$timestampRec;$dateTimestampRev;$utcOffset;$action;$therapyEvent;$source;$note;$stringResource;$timestamp;$bg;$gram;$insulin;$unitPerHour;$percent;$hour;$minute;$other"
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun csvString(action: Action): String = "\"" + translator.translate(action).replace("\"", "\"\"") + "\""
|
private fun csvString(action: Action): String = "\"" + translator.translate(action).replace("\"", "\"\"").replace("\n"," / ") + "\""
|
||||||
private fun csvString(id: Int): String = if (id != 0) "\"" + resourceHelper.gs(id).replace("\"", "\"\"") + "\"" else ""
|
private fun csvString(id: Int): String = if (id != 0) "\"" + resourceHelper.gs(id).replace("\"", "\"\"").replace("\n"," / ") + "\"" else ""
|
||||||
private fun csvString(s: String): String = if (s != "") "\"" + s.replace("\"", "\"\"") + "\"" else ""
|
private fun csvString(s: String): String = if (s != "") "\"" + s.replace("\"", "\"\"").replace("\n"," / ") + "\"" else ""
|
||||||
|
|
||||||
private fun String.addWithSeparator(add: Any) =
|
private fun String.addWithSeparator(add: Any) =
|
||||||
this + (if (this.isBlank()) "" else " / ") + add.toString()
|
this + (if (this.isBlank()) "" else " / ") + add.toString()
|
||||||
|
|
|
@ -38,8 +38,6 @@ sealed class ValueWithUnitMapper { //I use a sealed class because of St
|
||||||
|
|
||||||
data class TherapyEventTTReason(val value: TemporaryTarget.Reason) : ValueWithUnitMapper()
|
data class TherapyEventTTReason(val value: TemporaryTarget.Reason) : ValueWithUnitMapper()
|
||||||
|
|
||||||
data class StringResource(@StringRes val value: Int, val params: List<ValueWithUnitMapper> = listOf()) : ValueWithUnitMapper()
|
|
||||||
|
|
||||||
fun db(): ValueWithUnit? {
|
fun db(): ValueWithUnit? {
|
||||||
return when(this) {
|
return when(this) {
|
||||||
is Gram -> ValueWithUnit.Gram(this.value)
|
is Gram -> ValueWithUnit.Gram(this.value)
|
||||||
|
@ -51,7 +49,6 @@ sealed class ValueWithUnitMapper { //I use a sealed class because of St
|
||||||
is Percent -> ValueWithUnit.Percent(this.value)
|
is Percent -> ValueWithUnit.Percent(this.value)
|
||||||
is SimpleInt -> ValueWithUnit.SimpleInt(this.value)
|
is SimpleInt -> ValueWithUnit.SimpleInt(this.value)
|
||||||
is SimpleString -> ValueWithUnit.SimpleString(this.value)
|
is SimpleString -> ValueWithUnit.SimpleString(this.value)
|
||||||
is StringResource -> ValueWithUnit.StringResource(this.value, this.params.map {it.db()}.filterNotNull())
|
|
||||||
is TherapyEventMeterType -> ValueWithUnit.TherapyEventMeterType(this.value)
|
is TherapyEventMeterType -> ValueWithUnit.TherapyEventMeterType(this.value)
|
||||||
is TherapyEventTTReason -> ValueWithUnit.TherapyEventTTReason(this.value)
|
is TherapyEventTTReason -> ValueWithUnit.TherapyEventTTReason(this.value)
|
||||||
is TherapyEventType -> ValueWithUnit.TherapyEventType(this.value)
|
is TherapyEventType -> ValueWithUnit.TherapyEventType(this.value)
|
||||||
|
@ -72,7 +69,6 @@ sealed class ValueWithUnitMapper { //I use a sealed class because of St
|
||||||
is Percent -> this.value
|
is Percent -> this.value
|
||||||
is SimpleInt -> this.value
|
is SimpleInt -> this.value
|
||||||
is SimpleString -> this.value
|
is SimpleString -> this.value
|
||||||
is StringResource -> this.value
|
|
||||||
is TherapyEventMeterType -> this.value
|
is TherapyEventMeterType -> this.value
|
||||||
is TherapyEventTTReason -> this.value
|
is TherapyEventTTReason -> this.value
|
||||||
is TherapyEventType -> this.value
|
is TherapyEventType -> this.value
|
||||||
|
|
|
@ -34,8 +34,6 @@ sealed class ValueWithUnit {
|
||||||
|
|
||||||
data class TherapyEventTTReason(val value: TemporaryTarget.Reason) : ValueWithUnit()
|
data class TherapyEventTTReason(val value: TemporaryTarget.Reason) : ValueWithUnit()
|
||||||
|
|
||||||
data class StringResource(@StringRes val value: Int, val params: List<ValueWithUnit> = listOf()) : ValueWithUnit()
|
|
||||||
|
|
||||||
fun value(): Any? {
|
fun value(): Any? {
|
||||||
return when(this) {
|
return when(this) {
|
||||||
is Gram -> this.value
|
is Gram -> this.value
|
||||||
|
@ -47,7 +45,6 @@ sealed class ValueWithUnit {
|
||||||
is Percent -> this.value
|
is Percent -> this.value
|
||||||
is SimpleInt -> this.value
|
is SimpleInt -> this.value
|
||||||
is SimpleString -> this.value
|
is SimpleString -> this.value
|
||||||
is StringResource -> this.value
|
|
||||||
is TherapyEventMeterType -> this.value
|
is TherapyEventMeterType -> this.value
|
||||||
is TherapyEventTTReason -> this.value
|
is TherapyEventTTReason -> this.value
|
||||||
is TherapyEventType -> this.value
|
is TherapyEventType -> this.value
|
||||||
|
|
Loading…
Reference in a new issue