CalibrationDialog + CarbDialog
This commit is contained in:
parent
16959d4de9
commit
bb147deb92
2 changed files with 20 additions and 35 deletions
|
@ -12,7 +12,6 @@ import info.nightscout.androidaps.data.Profile
|
|||
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
|
||||
import info.nightscout.androidaps.database.entities.UserEntry.Action
|
||||
import info.nightscout.androidaps.database.entities.UserEntry.Sources
|
||||
import info.nightscout.androidaps.database.entities.UserEntry.ValueWithUnit
|
||||
import info.nightscout.androidaps.databinding.DialogCalibrationBinding
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||
|
@ -82,8 +81,7 @@ class CalibrationDialog : DialogFragmentWithDate() {
|
|||
if (bg > 0) {
|
||||
activity?.let { activity ->
|
||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_calibration), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
|
||||
//uel.log(Action.CALIBRATION, XXXValueWithUnit.fromGlucoseUnit(bg, units))
|
||||
uel.log(Action.CALIBRATION, ValueWithUnit(Sources.CalibrationDialog), ValueWithUnit(bg, units))
|
||||
uel.log(Action.CALIBRATION, Sources.CalibrationDialog, XXXValueWithUnit.fromGlucoseUnit(bg, units))
|
||||
xdripCalibrations.sendIntent(bg)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -18,8 +18,6 @@ import info.nightscout.androidaps.database.entities.XXXValueWithUnit
|
|||
import info.nightscout.androidaps.database.entities.TemporaryTarget
|
||||
import info.nightscout.androidaps.database.entities.UserEntry.Action
|
||||
import info.nightscout.androidaps.database.entities.UserEntry.Sources
|
||||
import info.nightscout.androidaps.database.entities.UserEntry.Units
|
||||
import info.nightscout.androidaps.database.entities.UserEntry.ValueWithUnit
|
||||
import info.nightscout.androidaps.database.transactions.InsertTemporaryTargetAndCancelCurrentTransaction
|
||||
import info.nightscout.androidaps.databinding.DialogCarbsBinding
|
||||
import info.nightscout.androidaps.interfaces.Constraint
|
||||
|
@ -226,12 +224,10 @@ class CarbsDialog : DialogFragmentWithDate() {
|
|||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.carbs), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
|
||||
when {
|
||||
activitySelected -> {
|
||||
//uel.log(Action.TT, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.ACTIVITY), XXXValueWithUnit.fromGlucoseUnit(activityTT, units) , XXXValueWithUnit.Minute(activityTTDuration))
|
||||
uel.log(Action.TT,
|
||||
ValueWithUnit(Sources.CarbDialog),
|
||||
ValueWithUnit(TemporaryTarget.Reason.ACTIVITY.text, Units.TherapyEvent),
|
||||
ValueWithUnit(activityTT, units) ,
|
||||
ValueWithUnit(activityTTDuration, Units.M))
|
||||
uel.log(Action.TT, Sources.CarbDialog,
|
||||
XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.ACTIVITY),
|
||||
XXXValueWithUnit.fromGlucoseUnit(activityTT, units) ,
|
||||
XXXValueWithUnit.Minute(activityTTDuration))
|
||||
disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
|
||||
timestamp = System.currentTimeMillis(),
|
||||
duration = TimeUnit.MINUTES.toMillis(activityTTDuration.toLong()),
|
||||
|
@ -247,12 +243,10 @@ class CarbsDialog : DialogFragmentWithDate() {
|
|||
}
|
||||
|
||||
eatingSoonSelected -> {
|
||||
//uel.log(Action.TT, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.EATING_SOON), XXXValueWithUnit.fromGlucoseUnit(eatingSoonTT, units) , XXXValueWithUnit.Minute(eatingSoonTTDuration))
|
||||
uel.log(Action.TT,
|
||||
ValueWithUnit(Sources.CarbDialog),
|
||||
ValueWithUnit(TemporaryTarget.Reason.EATING_SOON.text, Units.TherapyEvent),
|
||||
ValueWithUnit(eatingSoonTT, units) ,
|
||||
ValueWithUnit(eatingSoonTTDuration, Units.M))
|
||||
uel.log(Action.TT, Sources.CarbDialog,
|
||||
XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.EATING_SOON),
|
||||
XXXValueWithUnit.fromGlucoseUnit(eatingSoonTT, units) ,
|
||||
XXXValueWithUnit.Minute(eatingSoonTTDuration))
|
||||
disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
|
||||
timestamp = System.currentTimeMillis(),
|
||||
duration = TimeUnit.MINUTES.toMillis(eatingSoonTTDuration.toLong()),
|
||||
|
@ -268,12 +262,10 @@ class CarbsDialog : DialogFragmentWithDate() {
|
|||
}
|
||||
|
||||
hypoSelected -> {
|
||||
//uel.log(Action.TT, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.HYPOGLYCEMIA), XXXValueWithUnit.fromGlucoseUnit(hypoTT, units) , XXXValueWithUnit.Minute(hypoTTDuration))
|
||||
uel.log(Action.TT,
|
||||
ValueWithUnit(Sources.CarbDialog),
|
||||
ValueWithUnit(TemporaryTarget.Reason.HYPOGLYCEMIA.text, Units.TherapyEvent),
|
||||
ValueWithUnit(hypoTT, units) ,
|
||||
ValueWithUnit(hypoTTDuration, Units.M))
|
||||
uel.log(Action.TT, Sources.CarbDialog,
|
||||
XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.HYPOGLYCEMIA),
|
||||
XXXValueWithUnit.fromGlucoseUnit(hypoTT, units) ,
|
||||
XXXValueWithUnit.Minute(hypoTTDuration))
|
||||
disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
|
||||
timestamp = System.currentTimeMillis(),
|
||||
duration = TimeUnit.MINUTES.toMillis(hypoTTDuration.toLong()),
|
||||
|
@ -296,22 +288,17 @@ class CarbsDialog : DialogFragmentWithDate() {
|
|||
detailedBolusInfo.notes = notes
|
||||
detailedBolusInfo.carbsDuration = T.hours(duration.toLong()).msecs()
|
||||
detailedBolusInfo.carbsTimestamp = time
|
||||
uel.log(if (duration == 0) Action.CARBS else Action.EXTENDED_CARBS,
|
||||
detailedBolusInfo.notes,
|
||||
ValueWithUnit(Sources.CarbDialog),
|
||||
ValueWithUnit(detailedBolusInfo.timestamp, Units.Timestamp, eventTimeChanged),
|
||||
ValueWithUnit(carbsAfterConstraints, Units.G),
|
||||
ValueWithUnit(timeOffset, Units.M, timeOffset != 0),
|
||||
ValueWithUnit(duration, Units.H, duration != 0)
|
||||
)
|
||||
//uel.log(Action.CARBS, notes, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.Gram(carbsAfterConstraints), XXXValueWithUnit.Minute(timeOffset).takeIf { timeOffset != 0 }, XXXValueWithUnit.Hour(duration).takeIf { duration != 0 })
|
||||
uel.log(if (duration == 0) Action.CARBS else Action.EXTENDED_CARBS, Sources.CarbDialog,
|
||||
notes,
|
||||
XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged },
|
||||
XXXValueWithUnit.Gram(carbsAfterConstraints),
|
||||
XXXValueWithUnit.Minute(timeOffset).takeIf { timeOffset != 0 },
|
||||
XXXValueWithUnit.Hour(duration).takeIf { duration != 0 })
|
||||
commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
||||
override fun run() {
|
||||
if (!result.success) {
|
||||
ErrorHelperActivity.runAlarm(ctx, result.comment, resourceHelper.gs(R.string.treatmentdeliveryerror), R.raw.boluserror)
|
||||
} else
|
||||
uel.log(Action.CARBS, notes, ValueWithUnit(carbsAfterConstraints, Units.G))
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue