- Merge branch 'dev' into fr420_rl_battery_level

- fixing problem with logging, had to wrap them in String.format for this to work
- fixed problem with uploading event to nightscout, there was exception because entry was added where glucose value was not set
This commit is contained in:
Andy Rozman 2021-03-19 23:34:53 +00:00
commit 3fde3a03a8
101 changed files with 4050 additions and 484 deletions

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.activities
import android.os.Bundle import android.os.Bundle
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.ActivityStatsBinding import info.nightscout.androidaps.databinding.ActivityStatsBinding
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.utils.ActivityMonitor import info.nightscout.androidaps.utils.ActivityMonitor
@ -31,7 +32,7 @@ class StatsActivity : NoSplashAppCompatActivity() {
binding.ok.setOnClickListener { finish() } binding.ok.setOnClickListener { finish() }
binding.reset.setOnClickListener { binding.reset.setOnClickListener {
OKDialog.showConfirmation(this, resourceHelper.gs(R.string.doyouwantresetstats)) { OKDialog.showConfirmation(this, resourceHelper.gs(R.string.doyouwantresetstats)) {
uel.log("STATS RESET") uel.log(Action.STAT_RESET)
activityMonitor.reset() activityMonitor.reset()
recreate() recreate()
} }

View file

@ -9,10 +9,10 @@ import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.DialogCalibrationBinding import info.nightscout.androidaps.databinding.DialogCalibrationBinding
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.androidaps.utils.HtmlHelper import info.nightscout.androidaps.utils.HtmlHelper
import info.nightscout.androidaps.utils.XdripCalibrations import info.nightscout.androidaps.utils.XdripCalibrations
@ -79,7 +79,7 @@ class CalibrationDialog : DialogFragmentWithDate() {
if (bg > 0) { if (bg > 0) {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_calibration), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_calibration), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
uel.log("CALIBRATION", d1 = bg) uel.log(Action.CALIBRATION, ValueWithUnit(bg, units))
xdripCalibrations.sendIntent(bg) xdripCalibrations.sendIntent(bg)
}) })
} }

View file

@ -14,6 +14,7 @@ import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.TemporaryTarget import info.nightscout.androidaps.database.entities.TemporaryTarget
import info.nightscout.androidaps.database.entities.TherapyEvent import info.nightscout.androidaps.database.entities.TherapyEvent
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.database.transactions.InsertTemporaryTargetAndCancelCurrentTransaction import info.nightscout.androidaps.database.transactions.InsertTemporaryTargetAndCancelCurrentTransaction
import info.nightscout.androidaps.databinding.DialogCarbsBinding import info.nightscout.androidaps.databinding.DialogCarbsBinding
import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.interfaces.Constraint
@ -221,7 +222,7 @@ class CarbsDialog : DialogFragmentWithDate() {
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.carbs), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.carbs), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
when { when {
activitySelected -> { activitySelected -> {
uel.log("TT ACTIVITY", d1 = activityTT, i1 = activityTTDuration) uel.log(Action.TT, ValueWithUnit(TemporaryTarget.Reason.ACTIVITY.text, Units.TherapyEvent), ValueWithUnit(activityTT, units) , ValueWithUnit(activityTTDuration, Units.M))
disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction( disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
timestamp = System.currentTimeMillis(), timestamp = System.currentTimeMillis(),
duration = TimeUnit.MINUTES.toMillis(activityTTDuration.toLong()), duration = TimeUnit.MINUTES.toMillis(activityTTDuration.toLong()),
@ -237,7 +238,7 @@ class CarbsDialog : DialogFragmentWithDate() {
} }
eatingSoonSelected -> { eatingSoonSelected -> {
uel.log("TT EATING SOON", d1 = eatingSoonTT, i1 = eatingSoonTTDuration) uel.log(Action.TT, ValueWithUnit(TemporaryTarget.Reason.EATING_SOON.text, Units.TherapyEvent), ValueWithUnit(eatingSoonTT, units) , ValueWithUnit(eatingSoonTTDuration, Units.M))
disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction( disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
timestamp = System.currentTimeMillis(), timestamp = System.currentTimeMillis(),
duration = TimeUnit.MINUTES.toMillis(eatingSoonTTDuration.toLong()), duration = TimeUnit.MINUTES.toMillis(eatingSoonTTDuration.toLong()),
@ -253,7 +254,7 @@ class CarbsDialog : DialogFragmentWithDate() {
} }
hypoSelected -> { hypoSelected -> {
uel.log("TT HYPO", d1 = hypoTT, i1 = hypoTTDuration) uel.log(Action.TT, ValueWithUnit(TemporaryTarget.Reason.HYPOGLYCEMIA.text, Units.TherapyEvent), ValueWithUnit(hypoTT, units) , ValueWithUnit(hypoTTDuration, Units.M))
disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction( disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
timestamp = System.currentTimeMillis(), timestamp = System.currentTimeMillis(),
duration = TimeUnit.MINUTES.toMillis(hypoTTDuration.toLong()), duration = TimeUnit.MINUTES.toMillis(hypoTTDuration.toLong()),
@ -270,13 +271,12 @@ class CarbsDialog : DialogFragmentWithDate() {
} }
if (carbsAfterConstraints > 0) { if (carbsAfterConstraints > 0) {
if (duration == 0) { if (duration == 0) {
uel.log("CARBS", d1 = carbsAfterConstraints.toDouble(), i1 = timeOffset)
carbsGenerator.createCarb(carbsAfterConstraints, time, TherapyEvent.Type.CARBS_CORRECTION.text, notes) carbsGenerator.createCarb(carbsAfterConstraints, time, TherapyEvent.Type.CARBS_CORRECTION.text, notes)
} else { } else {
uel.log("CARBS", d1 = carbsAfterConstraints.toDouble(), i1 = timeOffset, i2 = duration)
carbsGenerator.generateCarbs(carbsAfterConstraints, time, duration, notes) carbsGenerator.generateCarbs(carbsAfterConstraints, time, duration, notes)
nsUpload.uploadEvent(TherapyEvent.Type.NOTE.text, DateUtil.now() - 2000, resourceHelper.gs(R.string.generated_ecarbs_note, carbsAfterConstraints, duration, timeOffset)) nsUpload.uploadEvent(TherapyEvent.Type.NOTE.text, DateUtil.now() - 2000, resourceHelper.gs(R.string.generated_ecarbs_note, carbsAfterConstraints, duration, timeOffset))
} }
uel.log(Action.CARBS, notes, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(carbsAfterConstraints, Units.G), ValueWithUnit(timeOffset, Units.M, timeOffset != 0), ValueWithUnit(duration, Units.H, duration != 0))
} }
if (useAlarm && carbs > 0 && timeOffset > 0) { if (useAlarm && carbs > 0 && timeOffset > 0) {
carbTimer.scheduleReminder(dateUtil._now() + T.mins(timeOffset.toLong()).msecs()) carbTimer.scheduleReminder(dateUtil._now() + T.mins(timeOffset.toLong()).msecs())

View file

@ -16,6 +16,7 @@ import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.TherapyEvent import info.nightscout.androidaps.database.entities.TherapyEvent
import info.nightscout.androidaps.database.transactions.InsertTherapyEventIfNewTransaction import info.nightscout.androidaps.database.transactions.InsertTherapyEventIfNewTransaction
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.DialogCareBinding import info.nightscout.androidaps.databinding.DialogCareBinding
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
@ -59,6 +60,7 @@ class CareDialog : DialogFragmentWithDate() {
} }
private var options: EventType = EventType.BGCHECK private var options: EventType = EventType.BGCHECK
private var valuesWithUnit = mutableListOf<ValueWithUnit>()
@StringRes @StringRes
private var event: Int = R.string.none private var event: Int = R.string.none
@ -200,10 +202,13 @@ class CareDialog : DialogFragmentWithDate() {
actions.add(resourceHelper.gs(R.string.treatments_wizard_bg_label) + ": " + Profile.toCurrentUnitsString(profileFunction, binding.bg.value) + " " + resourceHelper.gs(unitResId)) actions.add(resourceHelper.gs(R.string.treatments_wizard_bg_label) + ": " + Profile.toCurrentUnitsString(profileFunction, binding.bg.value) + " " + resourceHelper.gs(unitResId))
therapyEvent.glucoseType = meterType therapyEvent.glucoseType = meterType
therapyEvent.glucose = binding.bg.value therapyEvent.glucose = binding.bg.value
valuesWithUnit.add(ValueWithUnit(binding.bg.value.toDouble(), profileFunction.getUnits()))
valuesWithUnit.add(ValueWithUnit(meterType.text, Units.TherapyEvent))
} }
if (options == EventType.NOTE || options == EventType.EXERCISE) { if (options == EventType.NOTE || options == EventType.EXERCISE) {
actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_duration_label) + ": " + resourceHelper.gs(R.string.format_mins, binding.duration.value.toInt())) actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_duration_label) + ": " + resourceHelper.gs(R.string.format_mins, binding.duration.value.toInt()))
therapyEvent.duration = T.mins(binding.duration.value.toLong()).msecs() therapyEvent.duration = T.mins(binding.duration.value.toLong()).msecs()
valuesWithUnit.add(ValueWithUnit(binding.duration.value.toInt(), Units.M, !binding.duration.value.equals(0.0)))
} }
val notes = binding.notesLayout.notes.text.toString() val notes = binding.notesLayout.notes.text.toString()
if (notes.isNotEmpty()) { if (notes.isNotEmpty()) {
@ -211,8 +216,7 @@ class CareDialog : DialogFragmentWithDate() {
therapyEvent.note = notes therapyEvent.note = notes
} }
if (eventTimeChanged) if (eventTimeChanged) actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime))
actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime))
therapyEvent.enteredBy = enteredBy therapyEvent.enteredBy = enteredBy
@ -223,8 +227,9 @@ class CareDialog : DialogFragmentWithDate() {
}, { }, {
aapsLogger.error(LTag.BGSOURCE, "Error while saving therapy event", it) aapsLogger.error(LTag.BGSOURCE, "Error while saving therapy event", it)
}) })
valuesWithUnit.add(0, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged))
uel.log("CAREPORTAL", therapyEvent.type.text) valuesWithUnit.add(1, ValueWithUnit(therapyEvent.type.text, Units.TherapyEvent))
uel.log(Action.CAREPORTAL, notes, valuesWithUnit)
}, null) }, null)
} }
return true return true

View file

@ -8,6 +8,7 @@ import android.view.ViewGroup
import com.google.common.base.Joiner import com.google.common.base.Joiner
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.DialogExtendedbolusBinding import info.nightscout.androidaps.databinding.DialogExtendedbolusBinding
import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider
@ -87,7 +88,7 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.extended_bolus), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.extended_bolus), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
uel.log("EXTENDED BOLUS", d1 = insulinAfterConstraint, i1 = durationInMinutes) uel.log(Action.EXTENDED_BOLUS, ValueWithUnit(insulinAfterConstraint, Units.U), ValueWithUnit(durationInMinutes, Units.M))
commandQueue.extendedBolus(insulinAfterConstraint, durationInMinutes, object : Callback() { commandQueue.extendedBolus(insulinAfterConstraint, durationInMinutes, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {

View file

@ -12,6 +12,7 @@ import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.TherapyEvent import info.nightscout.androidaps.database.entities.TherapyEvent
import info.nightscout.androidaps.database.transactions.InsertTherapyEventIfNewTransaction import info.nightscout.androidaps.database.transactions.InsertTherapyEventIfNewTransaction
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.DialogFillBinding import info.nightscout.androidaps.databinding.DialogFillBinding
import info.nightscout.androidaps.db.Source import info.nightscout.androidaps.db.Source
import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.ActivePluginProvider
@ -135,11 +136,11 @@ class FillDialog : DialogFragmentWithDate() {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.primefill), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.primefill), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
if (insulinAfterConstraints > 0) { if (insulinAfterConstraints > 0) {
uel.log("PRIME BOLUS", d1 = insulinAfterConstraints) uel.log(Action.PRIME_BOLUS, notes, ValueWithUnit(insulinAfterConstraints, Units.U, insulinAfterConstraints != 0.0))
requestPrimeBolus(insulinAfterConstraints, notes) requestPrimeBolus(insulinAfterConstraints, notes)
} }
if (siteChange) { if (siteChange) {
uel.log("SITE CHANGE") uel.log(Action.CAREPORTAL, notes, ValueWithUnit(TherapyEvent.Type.CANNULA_CHANGE.text, Units.TherapyEvent))
disposable += repository.runTransactionForResult(InsertTherapyEventIfNewTransaction( disposable += repository.runTransactionForResult(InsertTherapyEventIfNewTransaction(
timestamp = eventTime, timestamp = eventTime,
type = TherapyEvent.Type.CANNULA_CHANGE, type = TherapyEvent.Type.CANNULA_CHANGE,
@ -153,7 +154,7 @@ class FillDialog : DialogFragmentWithDate() {
} }
if (insulinChange) { if (insulinChange) {
// add a second for case of both checked // add a second for case of both checked
uel.log("INSULIN CHANGE") uel.log(Action.CAREPORTAL, notes, ValueWithUnit(TherapyEvent.Type.INSULIN_CHANGE.text, Units.TherapyEvent))
disposable += repository.runTransactionForResult(InsertTherapyEventIfNewTransaction( disposable += repository.runTransactionForResult(InsertTherapyEventIfNewTransaction(
timestamp = eventTime + 1000, timestamp = eventTime + 1000,
type = TherapyEvent.Type.INSULIN_CHANGE, type = TherapyEvent.Type.INSULIN_CHANGE,

View file

@ -17,6 +17,7 @@ import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.TemporaryTarget import info.nightscout.androidaps.database.entities.TemporaryTarget
import info.nightscout.androidaps.database.entities.TherapyEvent import info.nightscout.androidaps.database.entities.TherapyEvent
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.database.transactions.InsertTemporaryTargetAndCancelCurrentTransaction import info.nightscout.androidaps.database.transactions.InsertTemporaryTargetAndCancelCurrentTransaction
import info.nightscout.androidaps.databinding.DialogInsulinBinding import info.nightscout.androidaps.databinding.DialogInsulinBinding
import info.nightscout.androidaps.db.Source import info.nightscout.androidaps.db.Source
@ -188,7 +189,7 @@ class InsulinDialog : DialogFragmentWithDate() {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.bolus), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.bolus), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
if (eatingSoonChecked) { if (eatingSoonChecked) {
uel.log("TT EATING SOON", d1 = eatingSoonTT, i1 = eatingSoonTTDuration) uel.log(Action.TT, notes, ValueWithUnit(TemporaryTarget.Reason.EATING_SOON.text, Units.TherapyEvent), ValueWithUnit(eatingSoonTT, units), ValueWithUnit(eatingSoonTTDuration, Units.M))
disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction( disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
timestamp = System.currentTimeMillis(), timestamp = System.currentTimeMillis(),
duration = TimeUnit.MINUTES.toMillis(eatingSoonTTDuration.toLong()), duration = TimeUnit.MINUTES.toMillis(eatingSoonTTDuration.toLong()),
@ -210,11 +211,11 @@ class InsulinDialog : DialogFragmentWithDate() {
detailedBolusInfo.source = Source.USER detailedBolusInfo.source = Source.USER
detailedBolusInfo.notes = notes detailedBolusInfo.notes = notes
if (recordOnlyChecked) { if (recordOnlyChecked) {
uel.log("BOLUS RECORD", d1 = insulinAfterConstraints, i1 = timeOffset) uel.log(Action.BOLUS_RECORD, notes, ValueWithUnit(insulinAfterConstraints, Units.U), ValueWithUnit(timeOffset, Units.M, timeOffset!= 0))
detailedBolusInfo.date = time detailedBolusInfo.date = time
activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false) activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false)
} else { } else {
uel.log("BOLUS", d1 = insulinAfterConstraints) uel.log(Action.BOLUS, notes, ValueWithUnit(insulinAfterConstraints, Units.U))
detailedBolusInfo.date = DateUtil.now() detailedBolusInfo.date = DateUtil.now()
commandQueue.bolus(detailedBolusInfo, object : Callback() { commandQueue.bolus(detailedBolusInfo, object : Callback() {
override fun run() { override fun run() {

View file

@ -12,6 +12,7 @@ import androidx.fragment.app.FragmentManager
import dagger.android.support.DaggerDialogFragment import dagger.android.support.DaggerDialogFragment
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.DialogLoopBinding import info.nightscout.androidaps.databinding.DialogLoopBinding
import info.nightscout.androidaps.events.EventPreferenceChange import info.nightscout.androidaps.events.EventPreferenceChange
import info.nightscout.androidaps.events.EventRefreshOverview import info.nightscout.androidaps.events.EventRefreshOverview
@ -238,28 +239,28 @@ class LoopDialog : DaggerDialogFragment() {
val profile = profileFunction.getProfile() ?: return true val profile = profileFunction.getProfile() ?: return true
when (v.id) { when (v.id) {
R.id.overview_closeloop -> { R.id.overview_closeloop -> {
uel.log("CLOSED LOOP MODE") uel.log(Action.CLOSED_LOOP_MODE)
sp.putString(R.string.key_aps_mode, "closed") sp.putString(R.string.key_aps_mode, "closed")
rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.closedloop))) rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.closedloop)))
return true return true
} }
R.id.overview_lgsloop -> { R.id.overview_lgsloop -> {
uel.log("LGS LOOP MODE") uel.log(Action.LGS_LOOP_MODE)
sp.putString(R.string.key_aps_mode, "lgs") sp.putString(R.string.key_aps_mode, "lgs")
rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend))) rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend)))
return true return true
} }
R.id.overview_openloop -> { R.id.overview_openloop -> {
uel.log("OPEN LOOP MODE") uel.log(Action.OPEN_LOOP_MODE)
sp.putString(R.string.key_aps_mode, "open") sp.putString(R.string.key_aps_mode, "open")
rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend))) rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend)))
return true return true
} }
R.id.overview_disable -> { R.id.overview_disable -> {
uel.log("LOOP DISABLED") uel.log(Action.LOOP_DISABLED)
loopPlugin.setPluginEnabled(PluginType.LOOP, false) loopPlugin.setPluginEnabled(PluginType.LOOP, false)
loopPlugin.setFragmentVisible(PluginType.LOOP, false) loopPlugin.setFragmentVisible(PluginType.LOOP, false)
configBuilderPlugin.storeSettings("DisablingLoop") configBuilderPlugin.storeSettings("DisablingLoop")
@ -276,7 +277,7 @@ class LoopDialog : DaggerDialogFragment() {
} }
R.id.overview_enable -> { R.id.overview_enable -> {
uel.log("LOOP ENABLED") uel.log(Action.LOOP_ENABLED)
loopPlugin.setPluginEnabled(PluginType.LOOP, true) loopPlugin.setPluginEnabled(PluginType.LOOP, true)
loopPlugin.setFragmentVisible(PluginType.LOOP, true) loopPlugin.setFragmentVisible(PluginType.LOOP, true)
configBuilderPlugin.storeSettings("EnablingLoop") configBuilderPlugin.storeSettings("EnablingLoop")
@ -286,7 +287,7 @@ class LoopDialog : DaggerDialogFragment() {
} }
R.id.overview_resume, R.id.overview_reconnect -> { R.id.overview_resume, R.id.overview_reconnect -> {
uel.log("RESUME") uel.log(if (v.id==R.id.overview_resume) Action.RESUME else Action.RECONNECT )
loopPlugin.suspendTo(0L) loopPlugin.suspendTo(0L)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
commandQueue.cancelTempBasal(true, object : Callback() { commandQueue.cancelTempBasal(true, object : Callback() {
@ -302,49 +303,49 @@ class LoopDialog : DaggerDialogFragment() {
} }
R.id.overview_suspend_1h -> { R.id.overview_suspend_1h -> {
uel.log("SUSPEND 1h") uel.log(Action.SUSPEND, ValueWithUnit(1, Units.H))
loopPlugin.suspendLoop(60) loopPlugin.suspendLoop(60)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
return true return true
} }
R.id.overview_suspend_2h -> { R.id.overview_suspend_2h -> {
uel.log("SUSPEND 2h") uel.log(Action.SUSPEND, ValueWithUnit(2, Units.H))
loopPlugin.suspendLoop(120) loopPlugin.suspendLoop(120)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
return true return true
} }
R.id.overview_suspend_3h -> { R.id.overview_suspend_3h -> {
uel.log("SUSPEND 3h") uel.log(Action.SUSPEND, ValueWithUnit(3, Units.H))
loopPlugin.suspendLoop(180) loopPlugin.suspendLoop(180)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
return true return true
} }
R.id.overview_suspend_10h -> { R.id.overview_suspend_10h -> {
uel.log("SUSPEND 10h") uel.log(Action.SUSPEND, ValueWithUnit(10, Units.H))
loopPlugin.suspendLoop(600) loopPlugin.suspendLoop(600)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
return true return true
} }
R.id.overview_disconnect_15m -> { R.id.overview_disconnect_15m -> {
uel.log("DISCONNECT 15m") uel.log(Action.DISCONNECT, ValueWithUnit(15, Units.M))
loopPlugin.disconnectPump(15, profile) loopPlugin.disconnectPump(15, profile)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
return true return true
} }
R.id.overview_disconnect_30m -> { R.id.overview_disconnect_30m -> {
uel.log("DISCONNECT 30m") uel.log(Action.DISCONNECT, ValueWithUnit(30, Units.M))
loopPlugin.disconnectPump(30, profile) loopPlugin.disconnectPump(30, profile)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
return true return true
} }
R.id.overview_disconnect_1h -> { R.id.overview_disconnect_1h -> {
uel.log("DISCONNECT 1h") uel.log(Action.DISCONNECT, ValueWithUnit(1, Units.H))
loopPlugin.disconnectPump(60, profile) loopPlugin.disconnectPump(60, profile)
sp.putBoolean(R.string.key_objectiveusedisconnect, true) sp.putBoolean(R.string.key_objectiveusedisconnect, true)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
@ -352,14 +353,14 @@ class LoopDialog : DaggerDialogFragment() {
} }
R.id.overview_disconnect_2h -> { R.id.overview_disconnect_2h -> {
uel.log("DISCONNECT 2h") uel.log(Action.DISCONNECT, ValueWithUnit(2, Units.H))
loopPlugin.disconnectPump(120, profile) loopPlugin.disconnectPump(120, profile)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
return true return true
} }
R.id.overview_disconnect_3h -> { R.id.overview_disconnect_3h -> {
uel.log("DISCONNECT 3h") uel.log(Action.DISCONNECT, ValueWithUnit(3, Units.H))
loopPlugin.disconnectPump(180, profile) loopPlugin.disconnectPump(180, profile)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
return true return true

View file

@ -8,6 +8,7 @@ import android.widget.ArrayAdapter
import com.google.common.base.Joiner import com.google.common.base.Joiner
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.DialogProfileswitchBinding import info.nightscout.androidaps.databinding.DialogProfileswitchBinding
import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
@ -124,7 +125,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
uel.log("PROFILE SWITCH", d1 = percent.toDouble(), i1 = timeShift, i2 = duration) uel.log(Action.PROFILE_SWITCH, notes, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(profile, Units.None), ValueWithUnit(percent, Units.Percent), ValueWithUnit(timeShift, Units.H, timeShift != 0), ValueWithUnit(duration, Units.M, duration != 0))
treatmentsPlugin.doProfileSwitch(profileStore, profile, duration, percent, timeShift, eventTime) treatmentsPlugin.doProfileSwitch(profileStore, profile, duration, percent, timeShift, eventTime)
}) })
} }

View file

@ -8,6 +8,7 @@ import android.view.ViewGroup
import com.google.common.base.Joiner import com.google.common.base.Joiner
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.DialogTempbasalBinding import info.nightscout.androidaps.databinding.DialogTempbasalBinding
import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider
@ -125,10 +126,10 @@ class TempBasalDialog : DialogFragmentWithDate() {
} }
} }
if (isPercentPump) { if (isPercentPump) {
uel.log("TEMP BASAL", d1 = percent.toDouble(), i1 = durationInMinutes) uel.log(Action.TEMP_BASAL, ValueWithUnit(percent, Units.Percent), ValueWithUnit(durationInMinutes, Units.M))
commandQueue.tempBasalPercent(percent, durationInMinutes, true, profile, callback) commandQueue.tempBasalPercent(percent, durationInMinutes, true, profile, callback)
} else { } else {
uel.log("TEMP BASAL", d1 = absolute, i1 = durationInMinutes) uel.log(Action.TEMP_BASAL, ValueWithUnit(absolute, Units.U), ValueWithUnit(durationInMinutes, Units.M))
commandQueue.tempBasalAbsolute(absolute, durationInMinutes, true, profile, callback) commandQueue.tempBasalAbsolute(absolute, durationInMinutes, true, profile, callback)
} }
}) })

View file

@ -13,6 +13,7 @@ import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.ValueWrapper import info.nightscout.androidaps.database.ValueWrapper
import info.nightscout.androidaps.database.entities.TemporaryTarget import info.nightscout.androidaps.database.entities.TemporaryTarget
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.database.transactions.CancelCurrentTemporaryTargetIfAnyTransaction import info.nightscout.androidaps.database.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
import info.nightscout.androidaps.database.transactions.InsertTemporaryTargetAndCancelCurrentTransaction import info.nightscout.androidaps.database.transactions.InsertTemporaryTargetAndCancelCurrentTransaction
import info.nightscout.androidaps.databinding.DialogTemptargetBinding import info.nightscout.androidaps.databinding.DialogTemptargetBinding
@ -145,6 +146,10 @@ class TempTargetDialog : DialogFragmentWithDate() {
binding.duration.value = defaultValueHelper.determineHypoTTDuration().toDouble() binding.duration.value = defaultValueHelper.determineHypoTTDuration().toDouble()
binding.reason.setSelection(reasonList.indexOf(resourceHelper.gs(R.string.hypo))) binding.reason.setSelection(reasonList.indexOf(resourceHelper.gs(R.string.hypo)))
} }
R.id.cancel -> {
binding.duration.value = 0.0
}
} }
} }
@ -157,7 +162,7 @@ class TempTargetDialog : DialogFragmentWithDate() {
override fun submit(): Boolean { override fun submit(): Boolean {
if (_binding == null) return false if (_binding == null) return false
val actions: LinkedList<String> = LinkedList() val actions: LinkedList<String> = LinkedList()
val reason = binding.reason.selectedItem?.toString() ?: return false var reason = binding.reason.selectedItem?.toString() ?: return false
val unitResId = if (profileFunction.getUnits() == Constants.MGDL) R.string.mgdl else R.string.mmol val unitResId = if (profileFunction.getUnits() == Constants.MGDL) R.string.mgdl else R.string.mmol
val target = binding.temptarget.value val target = binding.temptarget.value
val duration = binding.duration.value.toInt() val duration = binding.duration.value.toInt()
@ -167,13 +172,21 @@ class TempTargetDialog : DialogFragmentWithDate() {
actions.add(resourceHelper.gs(R.string.duration) + ": " + resourceHelper.gs(R.string.format_mins, duration)) actions.add(resourceHelper.gs(R.string.duration) + ": " + resourceHelper.gs(R.string.format_mins, duration))
} else { } else {
actions.add(resourceHelper.gs(R.string.stoptemptarget)) actions.add(resourceHelper.gs(R.string.stoptemptarget))
reason = resourceHelper.gs(R.string.stoptemptarget)
} }
if (eventTimeChanged) if (eventTimeChanged)
actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime)) actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime))
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
uel.log("TT", d1 = target, i1 = duration) val units = profileFunction.getUnits()
when(reason) {
resourceHelper.gs(R.string.eatingsoon) -> uel.log(Action.TT, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.EATING_SOON.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
resourceHelper.gs(R.string.activity) -> uel.log(Action.TT, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.ACTIVITY.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
resourceHelper.gs(R.string.hypo) -> uel.log(Action.TT, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.HYPOGLYCEMIA.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
resourceHelper.gs(R.string.manual) -> uel.log(Action.TT, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.CUSTOM.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
resourceHelper.gs(R.string.stoptemptarget) -> uel.log(Action.CANCEL_TT, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged))
}
if (target == 0.0 || duration == 0) { if (target == 0.0 || duration == 0) {
disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(eventTime)) disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(eventTime))
.subscribe({ result -> .subscribe({ result ->
@ -200,6 +213,7 @@ class TempTargetDialog : DialogFragmentWithDate() {
aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", it) aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", it)
}) })
} }
if (duration == 10) sp.putBoolean(R.string.key_objectiveusetemptarget, true) if (duration == 10) sp.putBoolean(R.string.key_objectiveusetemptarget, true)
}) })
} }

View file

@ -13,6 +13,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.database.entities.TherapyEvent import info.nightscout.androidaps.database.entities.TherapyEvent
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.DialogTreatmentBinding import info.nightscout.androidaps.databinding.DialogTreatmentBinding
import info.nightscout.androidaps.db.Source import info.nightscout.androidaps.db.Source
import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.ActivePluginProvider
@ -129,7 +130,7 @@ class TreatmentDialog : DialogFragmentWithDate() {
if (insulinAfterConstraints > 0 || carbsAfterConstraints > 0) { if (insulinAfterConstraints > 0 || carbsAfterConstraints > 0) {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_treatment_label), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_treatment_label), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
uel.log("TREATMENT", d1 = insulin, i1 = carbs) uel.log(Action.TREATMENT, ValueWithUnit(insulin, Units.U, insulin != 0.0), ValueWithUnit(carbs, Units.G, carbs != 0))
val detailedBolusInfo = DetailedBolusInfo() val detailedBolusInfo = DetailedBolusInfo()
if (insulinAfterConstraints == 0.0) detailedBolusInfo.eventType = TherapyEvent.Type.CARBS_CORRECTION.text if (insulinAfterConstraints == 0.0) detailedBolusInfo.eventType = TherapyEvent.Type.CARBS_CORRECTION.text
if (carbsAfterConstraints == 0) detailedBolusInfo.eventType = TherapyEvent.Type.CORRECTION_BOLUS.text if (carbsAfterConstraints == 0) detailedBolusInfo.eventType = TherapyEvent.Type.CORRECTION_BOLUS.text

View file

@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.configBuilder
import androidx.fragment.app.FragmentActivity import androidx.fragment.app.FragmentActivity
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.events.EventAppInitialized import info.nightscout.androidaps.events.EventAppInitialized
import info.nightscout.androidaps.events.EventConfigBuilderChange import info.nightscout.androidaps.events.EventConfigBuilderChange
import info.nightscout.androidaps.events.EventRebuildTabs import info.nightscout.androidaps.events.EventRebuildTabs
@ -142,7 +143,7 @@ class ConfigBuilderPlugin @Inject constructor(
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.allow_hardware_pump_text), Runnable { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.allow_hardware_pump_text), Runnable {
performPluginSwitch(changedPlugin, newState, type) performPluginSwitch(changedPlugin, newState, type)
sp.putBoolean("allow_hardware_pump", true) sp.putBoolean("allow_hardware_pump", true)
uel.log("HW PUMP ALLOWED") uel.log(Action.HW_PUMP_ALLOWED)
aapsLogger.debug(LTag.PUMP, "First time HW pump allowed!") aapsLogger.debug(LTag.PUMP, "First time HW pump allowed!")
}, Runnable { }, Runnable {
rxBus.send(EventConfigBuilderUpdateGui()) rxBus.send(EventConfigBuilderUpdateGui())

View file

@ -17,6 +17,7 @@ import androidx.recyclerview.widget.LinearSmoothScroller
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.ObjectivesFragmentBinding import info.nightscout.androidaps.databinding.ObjectivesFragmentBinding
import info.nightscout.androidaps.databinding.ObjectivesItemBinding import info.nightscout.androidaps.databinding.ObjectivesItemBinding
import info.nightscout.androidaps.dialogs.NtpProgressDialog import info.nightscout.androidaps.dialogs.NtpProgressDialog
@ -307,7 +308,7 @@ class ObjectivesFragment : DaggerFragment() {
holder.binding.unstart.setOnClickListener { holder.binding.unstart.setOnClickListener {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.objectives), resourceHelper.gs(R.string.doyouwantresetstart), Runnable { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.objectives), resourceHelper.gs(R.string.doyouwantresetstart), Runnable {
uel.log("OBJECTIVE UNSTARTED", i1 = position + 1) uel.log(Action.OBJECTIVE_UNSTARTED, ValueWithUnit(position + 1, Units.None))
objective.startedOn = 0 objective.startedOn = 0
scrollToCurrentObjective() scrollToCurrentObjective()
rxBus.send(EventObjectivesUpdateGui()) rxBus.send(EventObjectivesUpdateGui())

View file

@ -7,6 +7,7 @@ import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.BuildConfig import info.nightscout.androidaps.BuildConfig
import info.nightscout.androidaps.Config import info.nightscout.androidaps.Config
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.interfaces.* import info.nightscout.androidaps.interfaces.*
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
@ -142,7 +143,7 @@ class ObjectivesPlugin @Inject constructor(
sp.putLong("Objectives_" + "auto" + "_accomplished", DateUtil.now()) sp.putLong("Objectives_" + "auto" + "_accomplished", DateUtil.now())
setupObjectives() setupObjectives()
OKDialog.show(activity, resourceHelper.gs(R.string.objectives), resourceHelper.gs(R.string.codeaccepted)) OKDialog.show(activity, resourceHelper.gs(R.string.objectives), resourceHelper.gs(R.string.codeaccepted))
uel.log("OBJECTIVES SKIPPED") uel.log(Action.OBJECTIVES_SKIPPED)
} else { } else {
OKDialog.show(activity, resourceHelper.gs(R.string.objectives), resourceHelper.gs(R.string.codeinvalid)) OKDialog.show(activity, resourceHelper.gs(R.string.objectives), resourceHelper.gs(R.string.codeinvalid))
} }

View file

@ -16,6 +16,7 @@ import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.activities.TDDStatsActivity import info.nightscout.androidaps.activities.TDDStatsActivity
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.dialogs.* import info.nightscout.androidaps.dialogs.*
import info.nightscout.androidaps.events.* import info.nightscout.androidaps.events.*
import info.nightscout.androidaps.historyBrowser.HistoryBrowseActivity import info.nightscout.androidaps.historyBrowser.HistoryBrowseActivity
@ -154,7 +155,7 @@ class ActionsFragment : DaggerFragment() {
} }
extendedBolusCancel?.setOnClickListener { extendedBolusCancel?.setOnClickListener {
if (activePlugin.activeTreatments.isInHistoryExtendedBolusInProgress) { if (activePlugin.activeTreatments.isInHistoryExtendedBolusInProgress) {
uel.log("CANCEL EXTENDED BOLUS") uel.log(Action.CANCEL_EXTENDED_BOLUS)
commandQueue.cancelExtended(object : Callback() { commandQueue.cancelExtended(object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
@ -169,7 +170,7 @@ class ActionsFragment : DaggerFragment() {
} }
cancelTempBasal?.setOnClickListener { cancelTempBasal?.setOnClickListener {
if (activePlugin.activeTreatments.isTempBasalInProgress) { if (activePlugin.activeTreatments.isTempBasalInProgress) {
uel.log("CANCEL TEMP BASAL") uel.log(Action.CANCEL_TEMP_BASAL)
commandQueue.cancelTempBasal(true, object : Callback() { commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {

View file

@ -15,6 +15,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.FoodFragmentBinding import info.nightscout.androidaps.databinding.FoodFragmentBinding
import info.nightscout.androidaps.databinding.FoodItemBinding import info.nightscout.androidaps.databinding.FoodItemBinding
import info.nightscout.androidaps.events.EventFoodDatabaseChanged import info.nightscout.androidaps.events.EventFoodDatabaseChanged
@ -216,7 +217,7 @@ class FoodFragment : DaggerFragment() {
val food = v.tag as Food val food = v.tag as Food
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.confirmation), resourceHelper.gs(R.string.removerecord) + "\n" + food.name, DialogInterface.OnClickListener { _: DialogInterface?, _: Int -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.confirmation), resourceHelper.gs(R.string.removerecord) + "\n" + food.name, DialogInterface.OnClickListener { _: DialogInterface?, _: Int ->
uel.log("FOOD REMOVED", food.name) uel.log(Action.FOOD_REMOVED, food.name)
if (food._id != null && food._id != "") { if (food._id != null && food._id != "") {
nsUpload.removeFoodFromNS(food._id) nsUpload.removeFoodFromNS(food._id)
} }

View file

@ -15,6 +15,8 @@ import info.nightscout.androidaps.BuildConfig
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.DaggerAppCompatActivityWithResult import info.nightscout.androidaps.activities.DaggerAppCompatActivityWithResult
import info.nightscout.androidaps.activities.PreferencesActivity import info.nightscout.androidaps.activities.PreferencesActivity
import info.nightscout.androidaps.database.entities.UserEntry
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.events.EventAppExit import info.nightscout.androidaps.events.EventAppExit
import info.nightscout.androidaps.interfaces.ConfigInterface import info.nightscout.androidaps.interfaces.ConfigInterface
import info.nightscout.androidaps.interfaces.ImportExportPrefsInterface import info.nightscout.androidaps.interfaces.ImportExportPrefsInterface
@ -34,6 +36,7 @@ import info.nightscout.androidaps.utils.buildHelper.BuildHelper
import info.nightscout.androidaps.utils.protection.PasswordCheck import info.nightscout.androidaps.utils.protection.PasswordCheck
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP import info.nightscout.androidaps.utils.sharedPreferences.SP
import io.reactivex.Single
import java.io.File import java.io.File
import java.io.FileNotFoundException import java.io.FileNotFoundException
import java.io.IOException import java.io.IOException
@ -344,7 +347,7 @@ class ImportExportPrefs @Inject constructor(
private fun restartAppAfterImport(context: Context) { private fun restartAppAfterImport(context: Context) {
sp.putBoolean(R.string.key_setupwizard_processed, true) sp.putBoolean(R.string.key_setupwizard_processed, true)
OKDialog.show(context, resourceHelper.gs(R.string.setting_imported), resourceHelper.gs(R.string.restartingapp), Runnable { OKDialog.show(context, resourceHelper.gs(R.string.setting_imported), resourceHelper.gs(R.string.restartingapp), Runnable {
uel.log("IMPORT") uel.log(Action.IMPORT_SETTINGS)
log.debug(LTag.CORE, "Exiting") log.debug(LTag.CORE, "Exiting")
rxBus.send(EventAppExit()) rxBus.send(EventAppExit())
if (context is AppCompatActivity) { if (context is AppCompatActivity) {
@ -354,4 +357,22 @@ class ImportExportPrefs @Inject constructor(
exitProcess(0) exitProcess(0)
}) })
} }
override fun exportUserEntriesCsv(activity: FragmentActivity, listEntries: Single<List<UserEntry>>) {
val entries = listEntries.blockingGet()
prefFileList.ensureExportDirExists()
val newFile = prefFileList.newExportXmlFile()
//log.debug("XXXXX " + classicPrefsFormat.UserEntriesToCsv(entries))
try {
classicPrefsFormat.saveCsv(newFile, entries)
ToastUtils.okToast(activity, resourceHelper.gs(R.string.ue_exported))
} catch (e: FileNotFoundException) {
ToastUtils.errorToast(activity, resourceHelper.gs(R.string.filenotfound) + " " + newFile)
log.error(LTag.CORE, "Unhandled exception", e)
} catch (e: IOException) {
ToastUtils.errorToast(activity, e.message)
log.error(LTag.CORE, "Unhandled exception", e)
}
}
} }

View file

@ -8,6 +8,7 @@ import android.view.ViewGroup
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.MaintenanceFragmentBinding import info.nightscout.androidaps.databinding.MaintenanceFragmentBinding
import info.nightscout.androidaps.events.EventNewBG import info.nightscout.androidaps.events.EventNewBG
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface import info.nightscout.androidaps.interfaces.DatabaseHelperInterface
@ -57,13 +58,13 @@ class MaintenanceFragment : DaggerFragment() {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
binding.logSend.setOnClickListener { maintenancePlugin.sendLogs() } binding.logSend.setOnClickListener { maintenancePlugin.sendLogs() }
binding.logDelete.setOnClickListener { binding.logDelete.setOnClickListener {
uel.log("DELETE LOGS") uel.log(Action.DELETE_LOGS)
maintenancePlugin.deleteLogs() maintenancePlugin.deleteLogs()
} }
binding.navResetdb.setOnClickListener { binding.navResetdb.setOnClickListener {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.maintenance), resourceHelper.gs(R.string.reset_db_confirm), Runnable { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.maintenance), resourceHelper.gs(R.string.reset_db_confirm), Runnable {
uel.log("RESET DATABASES") uel.log(Action.RESET_DATABASES)
compositeDisposable.add( compositeDisposable.add(
fromAction { fromAction {
databaseHelper.resetDatabases() databaseHelper.resetDatabases()
@ -84,20 +85,28 @@ class MaintenanceFragment : DaggerFragment() {
} }
} }
binding.navExport.setOnClickListener { binding.navExport.setOnClickListener {
uel.log("EXPORT SETTINGS") uel.log(Action.EXPORT_SETTINGS)
// start activity for checking permissions... // start activity for checking permissions...
importExportPrefs.verifyStoragePermissions(this) { importExportPrefs.verifyStoragePermissions(this) {
importExportPrefs.exportSharedPreferences(this) importExportPrefs.exportSharedPreferences(this)
} }
} }
binding.navImport.setOnClickListener { binding.navImport.setOnClickListener {
uel.log("IMPORT SETTINGS") uel.log(Action.IMPORT_SETTINGS)
// start activity for checking permissions... // start activity for checking permissions...
importExportPrefs.verifyStoragePermissions(this) { importExportPrefs.verifyStoragePermissions(this) {
importExportPrefs.importSharedPreferences(this) importExportPrefs.importSharedPreferences(this)
} }
} }
binding.navLogsettings.setOnClickListener { startActivity(Intent(activity, LogSettingActivity::class.java)) } binding.navLogsettings.setOnClickListener { startActivity(Intent(activity, LogSettingActivity::class.java)) }
binding.exportCsv.setOnClickListener {
activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.ue_export_to_csv) + "?") {
uel.log(Action.EXPORT_CSV)
importExportPrefs.exportUserEntriesCsv(activity, repository.getAllUserEntries())
}
}
}
} }
@Synchronized @Synchronized

View file

@ -16,6 +16,8 @@ import javax.inject.Inject;
import dagger.android.support.DaggerFragment; import dagger.android.support.DaggerFragment;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.database.entities.UserEntry;
import info.nightscout.androidaps.database.entities.UserEntry.*;
import info.nightscout.androidaps.logging.UserEntryLogger; import info.nightscout.androidaps.logging.UserEntryLogger;
import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientNewLog; import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientNewLog;
@ -123,7 +125,7 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList
break; break;
case R.id.nsclientinternal_clearqueue: case R.id.nsclientinternal_clearqueue:
OKDialog.showConfirmation(getContext(), resourceHelper.gs(R.string.nsclientinternal), resourceHelper.gs(R.string.clearqueueconfirm), () -> { OKDialog.showConfirmation(getContext(), resourceHelper.gs(R.string.nsclientinternal), resourceHelper.gs(R.string.clearqueueconfirm), () -> {
uel.log("NS QUEUE CLEARED", "", 0.0, 0.0, 0, 0); uel.log(Action.NS_QUEUE_CLEARED);
uploadQueue.clearQueue(); uploadQueue.clearQueue();
updateGui(); updateGui();
fabricPrivacy.logCustom("NSClientClearQueue"); fabricPrivacy.logCustom("NSClientClearQueue");
@ -139,7 +141,7 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
switch (buttonView.getId()) { switch (buttonView.getId()) {
case R.id.nsclientinternal_paused: case R.id.nsclientinternal_paused:
uel.log("NS PAUSED", "", 0.0, 0.0, isChecked ? 1 : 0, 0); uel.log(isChecked ? Action.NS_PAUSED : Action.NS_RESUME);
nsClientPlugin.pause(isChecked); nsClientPlugin.pause(isChecked);
updateGui(); updateGui();
fabricPrivacy.logCustom("NSClientPause"); fabricPrivacy.logCustom("NSClientPause");

View file

@ -31,6 +31,7 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.database.AppRepository; import info.nightscout.androidaps.database.AppRepository;
import info.nightscout.androidaps.database.entities.TemporaryTarget; import info.nightscout.androidaps.database.entities.TemporaryTarget;
import info.nightscout.androidaps.database.entities.TherapyEvent; import info.nightscout.androidaps.database.entities.TherapyEvent;
import info.nightscout.androidaps.database.entities.UserEntry.*;
import info.nightscout.androidaps.database.transactions.SyncTemporaryTargetTransaction; import info.nightscout.androidaps.database.transactions.SyncTemporaryTargetTransaction;
import info.nightscout.androidaps.database.transactions.SyncTherapyEventTransaction; import info.nightscout.androidaps.database.transactions.SyncTherapyEventTransaction;
import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.events.EventAppExit;
@ -427,12 +428,12 @@ public class NSClientPlugin extends PluginBase {
// room Temporary target // room Temporary target
TemporaryTarget temporaryTarget = temporaryTargetFromNsIdForInvalidating(_id); TemporaryTarget temporaryTarget = temporaryTargetFromNsIdForInvalidating(_id);
disposable.add(repository.runTransactionForResult(new SyncTemporaryTargetTransaction(temporaryTarget)).subscribe( disposable.add(repository.runTransactionForResult(new SyncTemporaryTargetTransaction(temporaryTarget)).subscribe(
result -> result.getInvalidated().forEach(record -> uel.log("TT DELETED FROM NS", record.getReason().getText(), record.getLowTarget(), record.getHighTarget(), (int) record.getDuration(), 0)), result -> result.getInvalidated().forEach(record -> uel.log(Action.TT_DELETED_FROM_NS, new ValueWithUnit(record.getReason().getText(), Units.TherapyEvent), new ValueWithUnit(record.getLowTarget(), Units.Mg_Dl, true), new ValueWithUnit(record.getHighTarget(), Units.Mg_Dl, record.getLowTarget() != record.getHighTarget()), new ValueWithUnit((int) record.getDuration()/60000, Units.M, record.getDuration() != 0))),
error -> aapsLogger.error(LTag.DATABASE, "Error while removing temporary target", error))); error -> aapsLogger.error(LTag.DATABASE, "Error while removing temporary target", error)));
// room Therapy Event // room Therapy Event
TherapyEvent therapyEvent = therapyEventFromNsIdForInvalidating(_id); TherapyEvent therapyEvent = therapyEventFromNsIdForInvalidating(_id);
disposable.add(repository.runTransactionForResult(new SyncTherapyEventTransaction(therapyEvent)).subscribe( disposable.add(repository.runTransactionForResult(new SyncTherapyEventTransaction(therapyEvent)).subscribe(
result -> result.getInvalidated().forEach(record -> uel.log("CAREPORTAL EVENT DELETED FROM NS", record.getType().getText(), 0.0, 0.0, 0, 0)), result -> result.getInvalidated().forEach(record -> uel.log(Action.CAREPORTAL_DELETED_FROM_NS, record.getNote() , new ValueWithUnit(record.getTimestamp(), Units.Timestamp, true), new ValueWithUnit(record.getType().getText(), Units.TherapyEvent))),
error -> aapsLogger.error(LTag.DATABASE, "Error while removing therapy event", error))); error -> aapsLogger.error(LTag.DATABASE, "Error while removing therapy event", error)));
// new DB model // new DB model
EventNsTreatment evtTreatment = new EventNsTreatment(EventNsTreatment.Companion.getREMOVE(), json); EventNsTreatment evtTreatment = new EventNsTreatment(EventNsTreatment.Companion.getREMOVE(), json);
@ -462,9 +463,9 @@ public class NSClientPlugin extends PluginBase {
disposable.add(repository.runTransactionForResult(new SyncTemporaryTargetTransaction(temporaryTarget)) disposable.add(repository.runTransactionForResult(new SyncTemporaryTargetTransaction(temporaryTarget))
.subscribe( .subscribe(
result -> { result -> {
result.getInserted().forEach(record -> uel.log("TT FROM NS", record.getReason().getText(), record.getLowTarget(), record.getHighTarget(), (int) record.getDuration(), 0)); result.getInserted().forEach(record -> uel.log(Action.TT_FROM_NS, new ValueWithUnit(record.getReason().getText(), Units.TherapyEvent), new ValueWithUnit(record.getLowTarget(), Units.Mg_Dl, true), new ValueWithUnit(record.getHighTarget(), Units.Mg_Dl, record.getLowTarget() != record.getHighTarget()), new ValueWithUnit((int) record.getDuration()/60000, Units.M, true)));
result.getInvalidated().forEach(record -> uel.log("TT DELETED FROM NS", record.getReason().getText(), record.getLowTarget(), record.getHighTarget(), (int) record.getDuration(), 0)); result.getInvalidated().forEach(record -> uel.log(Action.TT_DELETED_FROM_NS, new ValueWithUnit(record.getReason().getText(), Units.TherapyEvent), new ValueWithUnit(record.getLowTarget(), Units.Mg_Dl, true), new ValueWithUnit(record.getHighTarget(), Units.Mg_Dl, record.getLowTarget() != record.getHighTarget()), new ValueWithUnit((int) record.getDuration()/60000, Units.M, true)));
result.getEnded().forEach(record -> uel.log("TT CANCELED FROM NS", record.getReason().getText(), record.getLowTarget(), record.getHighTarget(), (int) record.getDuration(), 0)); result.getEnded().forEach(record -> uel.log(Action.TT_CANCELED_FROM_NS, new ValueWithUnit(record.getReason().getText(), Units.TherapyEvent), new ValueWithUnit(record.getLowTarget(), Units.Mg_Dl, true), new ValueWithUnit(record.getHighTarget(), Units.Mg_Dl, record.getLowTarget() != record.getHighTarget()), new ValueWithUnit((int) record.getDuration()/60000, Units.M, true)));
}, },
error -> aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", error))); error -> aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", error)));
} else { } else {
@ -492,8 +493,8 @@ public class NSClientPlugin extends PluginBase {
disposable.add(repository.runTransactionForResult(new SyncTherapyEventTransaction(therapyEvent)) disposable.add(repository.runTransactionForResult(new SyncTherapyEventTransaction(therapyEvent))
.subscribe( .subscribe(
result -> { result -> {
result.getInserted().forEach(record -> uel.log("CAREPORTAL EVENT NS", record.getType().getText(), 0.0, 0.0, 0, 0)); result.getInserted().forEach(record -> uel.log(Action.CAREPORTAL_FROM_NS, record.getNote() , new ValueWithUnit(record.getTimestamp(), Units.Timestamp, true), new ValueWithUnit(record.getType().getText(), Units.TherapyEvent)));
result.getInvalidated().forEach(record -> uel.log("CAREPORTAL EVENT DELETED FROM NS", "", 0.0, 0.0, (int) record.getTimestamp(), 0)); result.getInvalidated().forEach(record -> uel.log(Action.CAREPORTAL_DELETED_FROM_NS, record.getNote() , new ValueWithUnit(record.getTimestamp(), Units.Timestamp, true), new ValueWithUnit(record.getType().getText(), Units.TherapyEvent)));
}, },
error -> aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", error))); error -> aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", error)));
} else { } else {

View file

@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.general.nsclient.data
import android.content.Context import android.content.Context
import info.nightscout.androidaps.Config import info.nightscout.androidaps.Config
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
@ -235,7 +236,7 @@ class NSSettingsStatus @Inject constructor(
getExtendedWarnValue("sage", "urgent")?.let { sp.putDouble(R.string.key_statuslights_sage_critical, it) } getExtendedWarnValue("sage", "urgent")?.let { sp.putDouble(R.string.key_statuslights_sage_critical, it) }
getExtendedWarnValue("bage", "warn")?.let { sp.putDouble(R.string.key_statuslights_bage_warning, it) } getExtendedWarnValue("bage", "warn")?.let { sp.putDouble(R.string.key_statuslights_bage_warning, it) }
getExtendedWarnValue("bage", "urgent")?.let { sp.putDouble(R.string.key_statuslights_bage_critical, it) } getExtendedWarnValue("bage", "urgent")?.let { sp.putDouble(R.string.key_statuslights_bage_critical, it) }
uel.log("NS SETTINGS COPIED") uel.log(Action.NS_SETTINGS_COPIED)
} }
if (context != null) OKDialog.showConfirmation(context, resourceHelper.gs(R.string.statuslights), resourceHelper.gs(R.string.copyexistingvalues), action) if (context != null) OKDialog.showConfirmation(context, resourceHelper.gs(R.string.statuslights), resourceHelper.gs(R.string.copyexistingvalues), action)

View file

@ -31,6 +31,7 @@ import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.ValueWrapper import info.nightscout.androidaps.database.ValueWrapper
import info.nightscout.androidaps.database.entities.TemporaryTarget import info.nightscout.androidaps.database.entities.TemporaryTarget
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.database.interfaces.end import info.nightscout.androidaps.database.interfaces.end
import info.nightscout.androidaps.databinding.OverviewFragmentBinding import info.nightscout.androidaps.databinding.OverviewFragmentBinding
import info.nightscout.androidaps.dialogs.* import info.nightscout.androidaps.dialogs.*
@ -350,7 +351,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable {
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.tempbasal_label), lastRun.constraintsProcessed?.toSpanned() OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.tempbasal_label), lastRun.constraintsProcessed?.toSpanned()
?: "".toSpanned(), { ?: "".toSpanned(), {
uel.log("ACCEPT TEMP BASAL") uel.log(Action.ACCEPTS_TEMP_BASAL)
binding.buttonsLayout.acceptTempButton.visibility = View.GONE binding.buttonsLayout.acceptTempButton.visibility = View.GONE
(context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).cancel(Constants.notificationID) (context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).cancel(Constants.notificationID)
rxBus.send(EventWearInitiateAction("cancelChangeRequest")) rxBus.send(EventWearInitiateAction("cancelChangeRequest"))

View file

@ -17,6 +17,7 @@ import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.TemporaryTarget import info.nightscout.androidaps.database.entities.TemporaryTarget
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.database.transactions.CancelCurrentTemporaryTargetIfAnyTransaction import info.nightscout.androidaps.database.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
import info.nightscout.androidaps.database.transactions.InsertTemporaryTargetAndCancelCurrentTransaction import info.nightscout.androidaps.database.transactions.InsertTemporaryTargetAndCancelCurrentTransaction
import info.nightscout.androidaps.db.Source import info.nightscout.androidaps.db.Source
@ -348,7 +349,7 @@ class SmsCommunicatorPlugin @Inject constructor(
receivedSms.processed = true receivedSms.processed = true
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
override fun run() { override fun run() {
uel.log("SMS LOOP DISABLE") uel.log(Action.SMS_LOOP_DISABLED)
loopPlugin.setPluginEnabled(PluginType.LOOP, false) loopPlugin.setPluginEnabled(PluginType.LOOP, false)
commandQueue.cancelTempBasal(true, object : Callback() { commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() { override fun run() {
@ -372,7 +373,7 @@ class SmsCommunicatorPlugin @Inject constructor(
receivedSms.processed = true receivedSms.processed = true
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
override fun run() { override fun run() {
uel.log("SMS LOOP ENABLE") uel.log(Action.SMS_LOOP_ENABLED)
loopPlugin.setPluginEnabled(PluginType.LOOP, true) loopPlugin.setPluginEnabled(PluginType.LOOP, true)
sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_loophasbeenenabled))) sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_loophasbeenenabled)))
rxBus.send(EventRefreshOverview("SMS_LOOP_START")) rxBus.send(EventRefreshOverview("SMS_LOOP_START"))
@ -399,7 +400,7 @@ class SmsCommunicatorPlugin @Inject constructor(
receivedSms.processed = true receivedSms.processed = true
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
override fun run() { override fun run() {
uel.log("SMS LOOP RESUME") uel.log(Action.SMS_LOOP_RESUME)
loopPlugin.suspendTo(0L) loopPlugin.suspendTo(0L)
rxBus.send(EventRefreshOverview("SMS_LOOP_RESUME")) rxBus.send(EventRefreshOverview("SMS_LOOP_RESUME"))
commandQueue.cancelTempBasal(true, object : Callback() { commandQueue.cancelTempBasal(true, object : Callback() {
@ -432,7 +433,7 @@ class SmsCommunicatorPlugin @Inject constructor(
receivedSms.processed = true receivedSms.processed = true
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(duration) { messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(duration) {
override fun run() { override fun run() {
uel.log("SMS LOOP SUSPEND") uel.log(Action.SMS_LOOP_SUSPEND)
commandQueue.cancelTempBasal(true, object : Callback() { commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() { override fun run() {
if (result.success) { if (result.success) {
@ -516,7 +517,7 @@ class SmsCommunicatorPlugin @Inject constructor(
receivedSms.processed = true receivedSms.processed = true
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
override fun run() { override fun run() {
uel.log("SMS PUMP CONNECT") uel.log(Action.SMS_PUMP_CONNECT)
commandQueue.cancelTempBasal(true, object : Callback() { commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
@ -545,7 +546,7 @@ class SmsCommunicatorPlugin @Inject constructor(
receivedSms.processed = true receivedSms.processed = true
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
override fun run() { override fun run() {
uel.log("SMS PUMP DISCONNECT") uel.log(Action.SMS_PUMP_DISCONNECT)
val profile = profileFunction.getProfile() val profile = profileFunction.getProfile()
loopPlugin.disconnectPump(duration, profile) loopPlugin.disconnectPump(duration, profile)
rxBus.send(EventRefreshOverview("SMS_PUMP_DISCONNECT")) rxBus.send(EventRefreshOverview("SMS_PUMP_DISCONNECT"))
@ -602,7 +603,7 @@ 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("SMS PROFILE", replyText) uel.log(Action.SMS_PROFILE, ValueWithUnit(R.string.profileswitchcreated, Units.R_String))
} }
}) })
} }
@ -624,12 +625,12 @@ 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("SMS BASAL", replyText) uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalcanceled, Units.R_String))
} 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("SMS BASAL", replyText) uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalcancelfailed, Units.R_String))
} }
} }
}) })
@ -657,12 +658,15 @@ class SmsCommunicatorPlugin @Inject constructor(
var replyText = if (result.isPercent) String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset_percent), result.percent, result.duration) else String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset), result.absolute, result.duration) var replyText = if (result.isPercent) String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset_percent), result.percent, result.duration) else String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset), result.absolute, result.duration)
replyText += "\n" + activePlugin.activePump.shortStatus(true) replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
uel.log("SMS BASAL", replyText) if (result.isPercent)
uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalset_percent, 2), ValueWithUnit(result.percent, Units.Percent), ValueWithUnit(result.duration, Units.M))
else
uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalset, 2), ValueWithUnit(result.absolute, Units.U_H), ValueWithUnit(result.duration, Units.M))
} 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("SMS BASAL", replyText) uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalfailed, Units.R_String))
} }
} }
}) })
@ -692,12 +696,15 @@ class SmsCommunicatorPlugin @Inject constructor(
else String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset), result.absolute, result.duration) else String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset), result.absolute, result.duration)
replyText += "\n" + activePlugin.activePump.shortStatus(true) replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
uel.log("SMS BASAL", replyText) if (result.isPercent)
uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalset_percent, 2), ValueWithUnit(result.percent, Units.Percent), ValueWithUnit(result.duration, Units.M))
else
uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalset, 2), ValueWithUnit(result.absolute, Units.U_H), ValueWithUnit(result.duration, Units.M))
} 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("SMS BASAL", replyText) uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalfailed, Units.R_String))
} }
} }
}) })
@ -724,7 +731,7 @@ 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("SMS EXTENDED", replyText) uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true),ValueWithUnit(R.string.smscommunicator_extendedcanceled, Units.R_String))
} }
} }
}) })
@ -750,12 +757,15 @@ class SmsCommunicatorPlugin @Inject constructor(
if (config.APS) replyText += "\n" + resourceHelper.gs(R.string.loopsuspended) if (config.APS) replyText += "\n" + resourceHelper.gs(R.string.loopsuspended)
replyText += "\n" + activePlugin.activePump.shortStatus(true) replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
uel.log("SMS EXTENDED", replyText) if (config.APS)
uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_extendedset, 2), ValueWithUnit(aDouble ?:0.0, Units.U), ValueWithUnit(duration, Units.M), ValueWithUnit(R.string.loopsuspended, Units.R_String))
else
uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_extendedset, 2), ValueWithUnit(aDouble ?:0.0, Units.U), ValueWithUnit(duration, Units.M))
} 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("SMS EXTENDED", replyText) uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true),ValueWithUnit(R.string.smscommunicator_extendedfailed, Units.R_String))
} }
} }
}) })
@ -828,12 +838,12 @@ class SmsCommunicatorPlugin @Inject constructor(
} }
} }
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
uel.log("SMS BOLUS", replyText) uel.log(Action.SMS_BOLUS, replyText)
} else { } else {
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("SMS BOLUS", replyText) uel.log(Action.SMS_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_bolusfailed, Units.R_String))
} }
} }
}) })
@ -873,12 +883,12 @@ 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("SMS CARBS", replyText) uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_carbsset, 1), ValueWithUnit(anInteger ?:0,Units.G))
} else { } else {
var replyText = resourceHelper.gs(R.string.smscommunicator_carbsfailed) 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("SMS CARBS", replyText) uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_carbsfailed, 1), ValueWithUnit(anInteger ?:0,Units.G))
} }
} }
}) })
@ -887,7 +897,7 @@ 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("SMS CARBS", replyText) uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_carbsset, 1), ValueWithUnit(anInteger ?:0,Units.G))
} }
} }
}) })
@ -956,7 +966,8 @@ class SmsCommunicatorPlugin @Inject constructor(
val ttString = if (units == Constants.MMOL) DecimalFormatter.to1Decimal(tt) else DecimalFormatter.to0Decimal(tt) val ttString = if (units == Constants.MMOL) DecimalFormatter.to1Decimal(tt) else DecimalFormatter.to0Decimal(tt)
val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_tt_set), ttString, ttDuration) val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_tt_set), ttString, ttDuration)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
uel.log("SMS TARGET", replyText) //uel.log(Action.SMS_TT, ValueWithUnit(R.string.smscommunicator_tt_set, 2), ValueWithUnit(tt, units), ValueWithUnit(ttDuration, Units.M))
uel.log(Action.SMS_TT, ValueWithUnit(tt, units), ValueWithUnit(ttDuration, Units.M))
} }
}) })
} else if (isStop) { } else if (isStop) {
@ -973,7 +984,7 @@ 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("SMS TARGET", reply) uel.log(Action.SMS_TT, ValueWithUnit(R.string.smscommunicator_tt_canceled, Units.R_String))
} }
}) })
} else } else
@ -992,7 +1003,7 @@ 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("SMS SMS", replyText) uel.log(Action.SMS_SMS, ValueWithUnit(R.string.smscommunicator_stoppedsms, Units.R_String))
} }
}) })
} else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat))) } else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))
@ -1010,7 +1021,10 @@ class SmsCommunicatorPlugin @Inject constructor(
val replyText = val replyText =
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))
uel.log("SMS CAL", replyText) if (result)
uel.log(Action.SMS_CAL, ValueWithUnit(R.string.smscommunicator_calibrationsent, Units.R_String))
else
uel.log(Action.SMS_CAL, ValueWithUnit(R.string.smscommunicator_calibrationfailed, Units.R_String))
} }
}) })
} else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat))) } else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))

View file

@ -14,6 +14,7 @@ import com.google.common.primitives.Ints.min
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.ActivitySmscommunicatorOtpBinding import info.nightscout.androidaps.databinding.ActivitySmscommunicatorOtpBinding
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
@ -72,7 +73,7 @@ class SmsCommunicatorOtpActivity : NoSplashAppCompatActivity() {
resourceHelper.gs(R.string.smscommunicator_otp_reset_title), resourceHelper.gs(R.string.smscommunicator_otp_reset_title),
resourceHelper.gs(R.string.smscommunicator_otp_reset_prompt), resourceHelper.gs(R.string.smscommunicator_otp_reset_prompt),
Runnable { Runnable {
uel.log("OTP RESET") uel.log(Action.OTP_RESET)
otp.ensureKey(true) otp.ensureKey(true)
updateGui() updateGui()
ToastUtils.Long.infoToast(this, resourceHelper.gs(R.string.smscommunicator_otp_reset_successful)) ToastUtils.Long.infoToast(this, resourceHelper.gs(R.string.smscommunicator_otp_reset_successful))
@ -88,7 +89,7 @@ class SmsCommunicatorOtpActivity : NoSplashAppCompatActivity() {
val clip = ClipData.newPlainText("OTP Secret", otp.provisioningSecret()) val clip = ClipData.newPlainText("OTP Secret", otp.provisioningSecret())
clipboard.primaryClip = clip clipboard.primaryClip = clip
ToastUtils.Long.infoToast(this, resourceHelper.gs(R.string.smscommunicator_otp_export_successful)) ToastUtils.Long.infoToast(this, resourceHelper.gs(R.string.smscommunicator_otp_export_successful))
uel.log("OTP EXPORT") uel.log(Action.OTP_EXPORT)
}) })
true true

View file

@ -12,6 +12,7 @@ import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.LocalprofileFragmentBinding import info.nightscout.androidaps.databinding.LocalprofileFragmentBinding
import info.nightscout.androidaps.dialogs.ProfileSwitchDialog import info.nightscout.androidaps.dialogs.ProfileSwitchDialog
import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.ActivePluginProvider
@ -162,7 +163,7 @@ class LocalProfileFragment : DaggerFragment() {
if (localProfilePlugin.isEdited) { if (localProfilePlugin.isEdited) {
activity?.let { OKDialog.show(it, "", resourceHelper.gs(R.string.saveorresetchangesfirst)) } activity?.let { OKDialog.show(it, "", resourceHelper.gs(R.string.saveorresetchangesfirst)) }
} else { } else {
uel.log("NEW PROFILE") uel.log(Action.NEW_PROFILE)
localProfilePlugin.addNewProfile() localProfilePlugin.addNewProfile()
build() build()
} }
@ -172,7 +173,7 @@ class LocalProfileFragment : DaggerFragment() {
if (localProfilePlugin.isEdited) { if (localProfilePlugin.isEdited) {
activity?.let { OKDialog.show(it, "", resourceHelper.gs(R.string.saveorresetchangesfirst)) } activity?.let { OKDialog.show(it, "", resourceHelper.gs(R.string.saveorresetchangesfirst)) }
} else { } else {
uel.log("CLONE PROFILE", localProfilePlugin.currentProfile()?.name ?: "") uel.log(Action.CLONE_PROFILE, localProfilePlugin.currentProfile()?.name ?: "")
localProfilePlugin.cloneProfile() localProfilePlugin.cloneProfile()
build() build()
} }
@ -181,7 +182,7 @@ class LocalProfileFragment : DaggerFragment() {
binding.profileRemove.setOnClickListener { binding.profileRemove.setOnClickListener {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.deletecurrentprofile), { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.deletecurrentprofile), {
uel.log("REMOVE PROFILE", localProfilePlugin.currentProfile()?.name ?: "") uel.log(Action.PROFILE_REMOVED, localProfilePlugin.currentProfile()?.name ?: "")
localProfilePlugin.removeCurrentProfile() localProfilePlugin.removeCurrentProfile()
build() build()
}, null) }, null)

View file

@ -5,6 +5,7 @@ import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.events.EventProfileStoreChanged import info.nightscout.androidaps.events.EventProfileStoreChanged
import info.nightscout.androidaps.interfaces.* import info.nightscout.androidaps.interfaces.*
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
@ -115,7 +116,7 @@ class LocalProfilePlugin @Inject constructor(
createAndStoreConvertedProfile() createAndStoreConvertedProfile()
isEdited = false isEdited = false
aapsLogger.debug(LTag.PROFILE, "Storing settings: " + rawProfile?.data.toString()) aapsLogger.debug(LTag.PROFILE, "Storing settings: " + rawProfile?.data.toString())
uel.log("STORE PROFILE") uel.log(Action.STORE_PROFILE)
rxBus.send(EventProfileStoreChanged()) rxBus.send(EventProfileStoreChanged())
var namesOK = true var namesOK = true
profiles.forEach { profiles.forEach {

View file

@ -8,6 +8,7 @@ import android.widget.AdapterView
import android.widget.ArrayAdapter import android.widget.ArrayAdapter
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.NsprofileFragmentBinding import info.nightscout.androidaps.databinding.NsprofileFragmentBinding
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
@ -61,7 +62,7 @@ class NSProfileFragment : DaggerFragment() {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.nsprofile), OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.nsprofile),
resourceHelper.gs(R.string.activate_profile) + ": " + name + " ?", Runnable { resourceHelper.gs(R.string.activate_profile) + ": " + name + " ?", Runnable {
uel.log("PROFILE SWITCH", name, i1 = 100) uel.log(Action.PROFILE_SWITCH, ValueWithUnit(name, Units.None), ValueWithUnit(100.toInt(), Units.Percent))
treatmentsPlugin.doProfileSwitch(store, name, 0, 100, 0, DateUtil.now()) treatmentsPlugin.doProfileSwitch(store, name, 0, 100, 0, DateUtil.now())
}) })
} }

View file

@ -11,6 +11,7 @@ import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.GlucoseValue import info.nightscout.androidaps.database.entities.GlucoseValue
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.database.transactions.InvalidateGlucoseValueTransaction import info.nightscout.androidaps.database.transactions.InvalidateGlucoseValueTransaction
import info.nightscout.androidaps.databinding.BgsourceFragmentBinding import info.nightscout.androidaps.databinding.BgsourceFragmentBinding
import info.nightscout.androidaps.databinding.BgsourceItemBinding import info.nightscout.androidaps.databinding.BgsourceItemBinding
@ -128,7 +129,7 @@ class BGSourceFragment : DaggerFragment() {
activity?.let { activity -> activity?.let { activity ->
val text = dateUtil.dateAndTimeString(glucoseValue.timestamp) + "\n" + glucoseValue.valueToUnitsString(profileFunction.getUnits()) val text = dateUtil.dateAndTimeString(glucoseValue.timestamp) + "\n" + glucoseValue.valueToUnitsString(profileFunction.getUnits())
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable {
uel.log("BG REMOVED", dateUtil.dateAndTimeString(glucoseValue.timestamp)) uel.log(Action.BG_REMOVED, ValueWithUnit(glucoseValue.timestamp, Units.Timestamp))
disposable += repository.runTransaction(InvalidateGlucoseValueTransaction(glucoseValue.id)).subscribe() disposable += repository.runTransaction(InvalidateGlucoseValueTransaction(glucoseValue.id)).subscribe()
}) })
} }

View file

@ -9,6 +9,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.TreatmentsBolusFragmentBinding import info.nightscout.androidaps.databinding.TreatmentsBolusFragmentBinding
import info.nightscout.androidaps.databinding.TreatmentsBolusItemBinding import info.nightscout.androidaps.databinding.TreatmentsBolusItemBinding
import info.nightscout.androidaps.db.Source import info.nightscout.androidaps.db.Source
@ -68,7 +69,7 @@ class TreatmentsBolusFragment : DaggerFragment() {
binding.refreshFromNightscout.setOnClickListener { binding.refreshFromNightscout.setOnClickListener {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.refresheventsfromnightscout) + "?") { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.refresheventsfromnightscout) + "?") {
uel.log("TREAT NS REFRESH") uel.log(Action.TREATMENTS_NS_REFRESH)
treatmentsPlugin.service.resetTreatments() treatmentsPlugin.service.resetTreatments()
rxBus.send(EventNSClientRestart()) rxBus.send(EventNSClientRestart())
} }
@ -77,7 +78,7 @@ class TreatmentsBolusFragment : DaggerFragment() {
binding.deleteFutureTreatments.setOnClickListener { binding.deleteFutureTreatments.setOnClickListener {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_treatment_label), resourceHelper.gs(R.string.deletefuturetreatments) + "?", Runnable { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_treatment_label), resourceHelper.gs(R.string.deletefuturetreatments) + "?", Runnable {
uel.log("DELETE FUTURE TREATMENTS") uel.log(Action.DELETE_FUTURE_TREATMENTS)
val futureTreatments = treatmentsPlugin.service.getTreatmentDataFromTime(DateUtil.now() + 1000, true) val futureTreatments = treatmentsPlugin.service.getTreatmentDataFromTime(DateUtil.now() + 1000, true)
for (treatment in futureTreatments) { for (treatment in futureTreatments) {
if (NSUpload.isIdValid(treatment._id)) if (NSUpload.isIdValid(treatment._id))
@ -174,7 +175,7 @@ class TreatmentsBolusFragment : DaggerFragment() {
resourceHelper.gs(R.string.carbs) + ": " + resourceHelper.gs(R.string.format_carbs, treatment.carbs.toInt()) + "\n" + resourceHelper.gs(R.string.carbs) + ": " + resourceHelper.gs(R.string.format_carbs, treatment.carbs.toInt()) + "\n" +
resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(treatment.date) resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(treatment.date)
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable {
uel.log("REMOVED TREATMENT", text) uel.log(Action.TREATMENT_REMOVED, ValueWithUnit(treatment.date, Units.Timestamp), ValueWithUnit(treatment.insulin, Units.U, treatment.insulin != 0.0), ValueWithUnit(treatment.carbs.toInt(), Units.G, treatment.carbs != 0.0))
if (treatment.source == Source.PUMP) { if (treatment.source == Source.PUMP) {
treatment.isValid = false treatment.isValid = false
treatmentsPlugin.service.update(treatment) treatmentsPlugin.service.update(treatment)

View file

@ -13,6 +13,7 @@ import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.TherapyEvent import info.nightscout.androidaps.database.entities.TherapyEvent
import info.nightscout.androidaps.database.transactions.InvalidateAAPSStartedTherapyEventTransaction import info.nightscout.androidaps.database.transactions.InvalidateAAPSStartedTherapyEventTransaction
import info.nightscout.androidaps.database.transactions.InvalidateTherapyEventTransaction import info.nightscout.androidaps.database.transactions.InvalidateTherapyEventTransaction
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.TreatmentsCareportalFragmentBinding import info.nightscout.androidaps.databinding.TreatmentsCareportalFragmentBinding
import info.nightscout.androidaps.databinding.TreatmentsCareportalItemBinding import info.nightscout.androidaps.databinding.TreatmentsCareportalItemBinding
import info.nightscout.androidaps.events.EventTherapyEventChange import info.nightscout.androidaps.events.EventTherapyEventChange
@ -78,7 +79,7 @@ class TreatmentsCareportalFragment : DaggerFragment() {
binding.refreshFromNightscout.setOnClickListener { binding.refreshFromNightscout.setOnClickListener {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal), resourceHelper.gs(R.string.refresheventsfromnightscout) + " ?", Runnable { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal), resourceHelper.gs(R.string.refresheventsfromnightscout) + " ?", Runnable {
uel.log("CAREPORTAL NS REFRESH") uel.log(Action.CAREPORTAL_NS_REFRESH)
disposable += Completable.fromAction { repository.deleteAllTherapyEventsEntries() } disposable += Completable.fromAction { repository.deleteAllTherapyEventsEntries() }
.subscribeOn(aapsSchedulers.io) .subscribeOn(aapsSchedulers.io)
.observeOn(aapsSchedulers.main) .observeOn(aapsSchedulers.main)
@ -93,7 +94,7 @@ class TreatmentsCareportalFragment : DaggerFragment() {
binding.removeAndroidapsStartedEvents.setOnClickListener { binding.removeAndroidapsStartedEvents.setOnClickListener {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal), resourceHelper.gs(R.string.careportal_removestartedevents), Runnable { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal), resourceHelper.gs(R.string.careportal_removestartedevents), Runnable {
uel.log("REMOVED RESTART EVENTS") uel.log(Action.RESTART_EVENTS_REMOVED)
// val events = databaseHelper.getCareportalEvents(false) // val events = databaseHelper.getCareportalEvents(false)
repository.runTransactionForResult(InvalidateAAPSStartedTherapyEventTransaction()) repository.runTransactionForResult(InvalidateAAPSStartedTherapyEventTransaction())
.subscribe({ result -> .subscribe({ result ->
@ -195,7 +196,7 @@ class TreatmentsCareportalFragment : DaggerFragment() {
resourceHelper.gs(R.string.notes_label) + ": " + (therapyEvent.note ?: "") + "\n" + resourceHelper.gs(R.string.notes_label) + ": " + (therapyEvent.note ?: "") + "\n" +
resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(therapyEvent.timestamp) resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(therapyEvent.timestamp)
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable {
uel.log("REMOVED CAREPORTAL", text) uel.log(Action.CAREPORTAL_REMOVED, therapyEvent.note ?: "", ValueWithUnit(therapyEvent.type.text, Units.TherapyEvent), ValueWithUnit(therapyEvent.timestamp, Units.Timestamp))
disposable += repository.runTransactionForResult(InvalidateTherapyEventTransaction(therapyEvent.id)) disposable += repository.runTransactionForResult(InvalidateTherapyEventTransaction(therapyEvent.id))
.subscribe({ .subscribe({
val id = therapyEvent.interfaceIDs.nightscoutId val id = therapyEvent.interfaceIDs.nightscoutId

View file

@ -12,6 +12,7 @@ import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.Intervals import info.nightscout.androidaps.data.Intervals
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.TreatmentsExtendedbolusFragmentBinding import info.nightscout.androidaps.databinding.TreatmentsExtendedbolusFragmentBinding
import info.nightscout.androidaps.databinding.TreatmentsExtendedbolusItemBinding import info.nightscout.androidaps.databinding.TreatmentsExtendedbolusItemBinding
import info.nightscout.androidaps.db.ExtendedBolus import info.nightscout.androidaps.db.ExtendedBolus
@ -122,7 +123,7 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() {
${resourceHelper.gs(R.string.extended_bolus)} ${resourceHelper.gs(R.string.extended_bolus)}
${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(extendedBolus.date)} ${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(extendedBolus.date)}
""".trimIndent(), { _: DialogInterface, _: Int -> """.trimIndent(), { _: DialogInterface, _: Int ->
uel.log("REMOVED EB") uel.log(Action.EXTENDED_BOLUS_REMOVED)
val id = extendedBolus._id val id = extendedBolus._id
if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id) if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id)
else uploadQueue.removeID("dbAdd", id) else uploadQueue.removeID("dbAdd", id)

View file

@ -9,6 +9,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.TreatmentsProfileswitchFragmentBinding import info.nightscout.androidaps.databinding.TreatmentsProfileswitchFragmentBinding
import info.nightscout.androidaps.databinding.TreatmentsProfileswitchItemBinding import info.nightscout.androidaps.databinding.TreatmentsProfileswitchItemBinding
import info.nightscout.androidaps.db.ProfileSwitch import info.nightscout.androidaps.db.ProfileSwitch
@ -70,7 +71,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
binding.refreshFromNightscout.setOnClickListener { binding.refreshFromNightscout.setOnClickListener {
activity?.let { activity -> activity?.let { activity ->
uel.log("PROFILE SWITCH NS REFRESH") uel.log(Action.PROFILE_SWITCH_NS_REFRESH)
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.refresheventsfromnightscout) + "?") { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.refresheventsfromnightscout) + "?") {
databaseHelper.resetProfileSwitch() databaseHelper.resetProfileSwitch()
rxBus.send(EventNSClientRestart()) rxBus.send(EventNSClientRestart())
@ -147,7 +148,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord),
resourceHelper.gs(R.string.careportal_profileswitch) + ": " + profileSwitch.profileName + resourceHelper.gs(R.string.careportal_profileswitch) + ": " + profileSwitch.profileName +
"\n" + resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(profileSwitch.date), Runnable { "\n" + resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(profileSwitch.date), Runnable {
uel.log("REMOVED PROFILE SWITCH", profileSwitch.profileName + " " + dateUtil.dateAndTimeString(profileSwitch.date)) uel.log(Action.PROFILE_SWITCH_REMOVED, profileSwitch.profileName, ValueWithUnit(profileSwitch.date, Units.Timestamp))
val id = profileSwitch._id val id = profileSwitch._id
if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id) if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id)
else uploadQueue.removeID("dbAdd", id) else uploadQueue.removeID("dbAdd", id)
@ -160,7 +161,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
val profileSwitch = it.tag as ProfileSwitch val profileSwitch = it.tag as ProfileSwitch
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), resourceHelper.gs(R.string.copytolocalprofile) + "\n" + profileSwitch.customizedName + "\n" + dateUtil.dateAndTimeString(profileSwitch.date), Runnable { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), resourceHelper.gs(R.string.copytolocalprofile) + "\n" + profileSwitch.customizedName + "\n" + dateUtil.dateAndTimeString(profileSwitch.date), Runnable {
profileSwitch.profileObject?.let { profileSwitch.profileObject?.let {
uel.log("PROFILE SWITCH CLONE", profileSwitch.profileName + " " + dateUtil.dateAndTimeString(profileSwitch.date)) uel.log(Action.PROFILE_SWITCH_CLONED, ValueWithUnit(profileSwitch.date, Units.Timestamp), ValueWithUnit(profileSwitch.profileName, Units.None))
val nonCustomized = it.convertToNonCustomizedProfile() val nonCustomized = it.convertToNonCustomizedProfile()
if (nonCustomized.isValid(resourceHelper.gs(R.string.careportal_profileswitch, false))) { if (nonCustomized.isValid(resourceHelper.gs(R.string.careportal_profileswitch, false))) {
localProfilePlugin.addProfile(localProfilePlugin.copyFrom(nonCustomized, profileSwitch.customizedName + " " + dateUtil.dateAndTimeString(profileSwitch.date).replace(".", "_"))) localProfilePlugin.addProfile(localProfilePlugin.copyFrom(nonCustomized, profileSwitch.customizedName + " " + dateUtil.dateAndTimeString(profileSwitch.date).replace(".", "_")))

View file

@ -14,6 +14,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.ValueWrapper import info.nightscout.androidaps.database.ValueWrapper
import info.nightscout.androidaps.database.entities.TemporaryTarget import info.nightscout.androidaps.database.entities.TemporaryTarget
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.database.interfaces.end import info.nightscout.androidaps.database.interfaces.end
import info.nightscout.androidaps.database.transactions.InvalidateTemporaryTargetTransaction import info.nightscout.androidaps.database.transactions.InvalidateTemporaryTargetTransaction
import info.nightscout.androidaps.databinding.TreatmentsTemptargetFragmentBinding import info.nightscout.androidaps.databinding.TreatmentsTemptargetFragmentBinding
@ -85,7 +86,7 @@ class TreatmentsTempTargetFragment : 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("TT NS REFRESH") uel.log(Action.TT_NS_REFRESH)
disposable += Completable.fromAction { repository.deleteAllTempTargetEntries() } disposable += Completable.fromAction { repository.deleteAllTempTargetEntries() }
.subscribeOn(aapsSchedulers.io) .subscribeOn(aapsSchedulers.io)
.observeOn(aapsSchedulers.main) .observeOn(aapsSchedulers.main)
@ -195,7 +196,7 @@ class TreatmentsTempTargetFragment : DaggerFragment() {
${dateUtil.dateAndTimeString(tempTarget.timestamp)} ${dateUtil.dateAndTimeString(tempTarget.timestamp)}
""".trimIndent(), """.trimIndent(),
{ _: DialogInterface?, _: Int -> { _: DialogInterface?, _: Int ->
uel.log("TT REMOVE", tempTarget.friendlyDescription(profileFunction.getUnits(), resourceHelper)) uel.log(Action.TT_REMOVED, ValueWithUnit(tempTarget.reason.text, Units.TherapyEvent), ValueWithUnit(tempTarget.timestamp, Units.Timestamp), ValueWithUnit(tempTarget.lowTarget, Units.Mg_Dl), ValueWithUnit(tempTarget.highTarget, Units.Mg_Dl, tempTarget.lowTarget != tempTarget.highTarget), ValueWithUnit(tempTarget.duration.toInt(), Units.M))
disposable += repository.runTransactionForResult(InvalidateTemporaryTargetTransaction(tempTarget.id)) disposable += repository.runTransactionForResult(InvalidateTemporaryTargetTransaction(tempTarget.id))
.subscribe({ .subscribe({
val id = tempTarget.interfaceIDs.nightscoutId val id = tempTarget.interfaceIDs.nightscoutId

View file

@ -12,6 +12,7 @@ import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.Intervals import info.nightscout.androidaps.data.Intervals
import info.nightscout.androidaps.data.IobTotal import info.nightscout.androidaps.data.IobTotal
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.TreatmentsTempbasalsFragmentBinding import info.nightscout.androidaps.databinding.TreatmentsTempbasalsFragmentBinding
import info.nightscout.androidaps.databinding.TreatmentsTempbasalsItemBinding import info.nightscout.androidaps.databinding.TreatmentsTempbasalsItemBinding
import info.nightscout.androidaps.db.Source import info.nightscout.androidaps.db.Source
@ -163,7 +164,7 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() {
${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(tempBasal.date)} ${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(tempBasal.date)}
""".trimIndent(), """.trimIndent(),
{ _: DialogInterface?, _: Int -> { _: DialogInterface?, _: Int ->
uel.log("REMOVED TT", dateUtil.dateAndTimeString(tempBasal.date)) uel.log(Action.TT_REMOVED, ValueWithUnit(tempBasal.date, Units.Timestamp))
activePlugin.activeTreatments.removeTempBasal(tempBasal) activePlugin.activeTreatments.removeTempBasal(tempBasal)
}, null) }, null)
} }

View file

@ -7,22 +7,41 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.database.entities.UserEntry
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.TreatmentsUserEntryFragmentBinding import info.nightscout.androidaps.databinding.TreatmentsUserEntryFragmentBinding
import info.nightscout.androidaps.databinding.TreatmentsUserEntryItemBinding import info.nightscout.androidaps.databinding.TreatmentsUserEntryItemBinding
import info.nightscout.androidaps.events.EventPreferenceChange
import info.nightscout.androidaps.interfaces.ImportExportPrefsInterface
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.Translator
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.extensions.*
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import io.reactivex.disposables.CompositeDisposable import io.reactivex.disposables.CompositeDisposable
import io.reactivex.rxkotlin.plusAssign
import javax.inject.Inject import javax.inject.Inject
class TreatmentsUserEntryFragment : DaggerFragment() { class TreatmentsUserEntryFragment : DaggerFragment() {
@Inject lateinit var repository: AppRepository @Inject lateinit var repository: AppRepository
@Inject lateinit var aapsSchedulers: AapsSchedulers @Inject lateinit var aapsSchedulers: AapsSchedulers
@Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var dateUtil: DateUtil @Inject lateinit var dateUtil: DateUtil
@Inject lateinit var profileFunction: ProfileFunction
@Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var rxBus: RxBusWrapper
@Inject lateinit var translator: Translator
@Inject lateinit var importExportPrefs: ImportExportPrefsInterface
@Inject lateinit var uel: UserEntryLogger
private val disposable = CompositeDisposable() private val disposable = CompositeDisposable()
@ -39,11 +58,40 @@ class TreatmentsUserEntryFragment : DaggerFragment() {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
binding.recyclerview.setHasFixedSize(true) binding.recyclerview.setHasFixedSize(true)
binding.recyclerview.layoutManager = LinearLayoutManager(view.context) binding.recyclerview.layoutManager = LinearLayoutManager(view.context)
binding.ueExportToXml.setOnClickListener {
activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.ue_export_to_csv) + "?") {
uel.log(Action.EXPORT_CSV)
importExportPrefs.exportUserEntriesCsv(activity, repository.getAllUserEntries())
}
}
}
disposable += repository }
fun swapAdapter() {
disposable.add( repository
.getAllUserEntries() .getAllUserEntries()
.observeOn(aapsSchedulers.main) .observeOn(aapsSchedulers.main)
.subscribe { list -> binding.recyclerview.swapAdapter(UserEntryAdapter(list), true) } .subscribe { list -> binding.recyclerview.swapAdapter(UserEntryAdapter(list), true) }
)
}
@Synchronized
override fun onResume() {
super.onResume()
swapAdapter()
disposable.add(rxBus
.toObservable(EventPreferenceChange::class.java)
.observeOn(aapsSchedulers.io)
.subscribe({ swapAdapter() }, fabricPrivacy::logException))
}
@Synchronized
override fun onPause() {
super.onPause()
disposable.clear()
} }
@Synchronized @Synchronized
@ -63,12 +111,44 @@ class TreatmentsUserEntryFragment : DaggerFragment() {
override fun onBindViewHolder(holder: UserEntryViewHolder, position: Int) { override fun onBindViewHolder(holder: UserEntryViewHolder, position: Int) {
val current = entries[position] val current = entries[position]
holder.binding.date.text = dateUtil.dateAndTimeAndSecondsString(current.timestamp) holder.binding.date.text = dateUtil.dateAndTimeAndSecondsString(current.timestamp)
holder.binding.action.text = current.action holder.binding.action.text = translator.translate(current.action.name)
if (current.s != "") holder.binding.s.text = current.s else holder.binding.s.visibility = View.GONE holder.binding.action.setTextColor(resourceHelper.gc(current.action.colorGroup.colorId()))
if (current.d1 != 0.0) holder.binding.d1.text = current.d1.toString() else holder.binding.d1.visibility = View.GONE if (current.s != "") {
if (current.d2 != 0.0) holder.binding.d2.text = current.d2.toString() else holder.binding.d2.visibility = View.GONE holder.binding.s.text = current.s
if (current.i1 != 0) holder.binding.i1.text = current.i1.toString() else holder.binding.i1.visibility = View.GONE holder.binding.s.visibility = View.VISIBLE
if (current.i2 != 0) holder.binding.i2.text = current.i2.toString() else holder.binding.i2.visibility = View.GONE } else
holder.binding.s.visibility = View.GONE
var valuesWithUnitString = ""
var rStringParam = 0
val separator = " "
for(v in current.values) {
if (rStringParam >0)
rStringParam--
else
when (v.unit) {
Units.Timestamp -> valuesWithUnitString += dateUtil.dateAndTimeAndSecondsString(v.lValue) + separator
Units.TherapyEvent -> valuesWithUnitString += translator.translate(v.sValue) + separator
Units.R_String -> {
rStringParam = v.lValue.toInt()
when (rStringParam) { //
0 -> valuesWithUnitString += resourceHelper.gs(v.iValue) + separator
1 -> valuesWithUnitString += resourceHelper.gs(v.iValue, current.values[current.values.indexOf(v)+1].value()) + separator
2 -> valuesWithUnitString += resourceHelper.gs(v.iValue, current.values[current.values.indexOf(v)+1].value(), current.values[current.values.indexOf(v)+2].value()) + separator
3 -> valuesWithUnitString += resourceHelper.gs(v.iValue, current.values[current.values.indexOf(v)+1].value(), current.values[current.values.indexOf(v)+2].value(), current.values[current.values.indexOf(v)+3].value()) + separator
4 -> rStringParam = 0
}
}
Units.Mg_Dl -> valuesWithUnitString += if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue) + translator.translate(Units.Mg_Dl.name) + separator else DecimalFormatter.to1Decimal(v.dValue/Constants.MMOLL_TO_MGDL) + translator.translate(Units.Mmol_L.name) + separator
Units.Mmol_L -> valuesWithUnitString += if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue*Constants.MMOLL_TO_MGDL) + translator.translate(Units.Mg_Dl.name) + separator else DecimalFormatter.to1Decimal(v.dValue) + translator.translate(Units.Mmol_L.name) + separator
Units.U_H, Units.U
-> valuesWithUnitString += DecimalFormatter.to2Decimal(v.dValue) + translator.translate(v.unit.name) + separator
Units.G, Units.M, Units.H, Units.Percent
-> valuesWithUnitString += v.iValue.toString() + translator.translate(v.unit.name) + separator
else -> valuesWithUnitString += if (v.iValue != 0 || v.sValue != "") { v.value().toString() + separator } else ""
}
}
holder.binding.values.text = valuesWithUnitString.trim()
holder.binding.values.visibility = if (current.values.size > 0) View.VISIBLE else View.GONE
} }
inner class UserEntryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { inner class UserEntryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {

View file

@ -12,6 +12,7 @@ import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.database.entities.TemporaryTarget import info.nightscout.androidaps.database.entities.TemporaryTarget
import info.nightscout.androidaps.database.entities.TherapyEvent import info.nightscout.androidaps.database.entities.TherapyEvent
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.db.Source import info.nightscout.androidaps.db.Source
import info.nightscout.androidaps.events.EventRefreshOverview import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.interfaces.* import info.nightscout.androidaps.interfaces.*
@ -348,7 +349,7 @@ class BolusWizard @Inject constructor(
boluscalc = nsJSON() boluscalc = nsJSON()
source = Source.USER source = Source.USER
notes = this@BolusWizard.notes notes = this@BolusWizard.notes
uel.log("BOLUS ADVISOR", d1 = insulinAfterConstraints) uel.log(Action.BOLUS_ADVISOR, notes, ValueWithUnit(eventType, Units.TherapyEvent), ValueWithUnit(insulinAfterConstraints, Units.U))
if (insulin > 0) { if (insulin > 0) {
commandQueue.bolus(this, object : Callback() { commandQueue.bolus(this, object : Callback() {
override fun run() { override fun run() {
@ -371,7 +372,7 @@ class BolusWizard @Inject constructor(
OKDialog.showConfirmation(ctx, resourceHelper.gs(R.string.boluswizard), confirmMessage, { OKDialog.showConfirmation(ctx, resourceHelper.gs(R.string.boluswizard), confirmMessage, {
if (insulinAfterConstraints > 0 || carbs > 0) { if (insulinAfterConstraints > 0 || carbs > 0) {
if (useSuperBolus) { if (useSuperBolus) {
uel.log("SUPERBOLUS TBR") uel.log(Action.SUPERBOLUS_TBR)
if (loopPlugin.isEnabled(PluginType.LOOP)) { if (loopPlugin.isEnabled(PluginType.LOOP)) {
loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000) loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000)
rxBus.send(EventRefreshOverview("WizardDialog")) rxBus.send(EventRefreshOverview("WizardDialog"))
@ -412,7 +413,7 @@ class BolusWizard @Inject constructor(
boluscalc = nsJSON() boluscalc = nsJSON()
source = Source.USER source = Source.USER
notes = this@BolusWizard.notes notes = this@BolusWizard.notes
uel.log("BOLUS WIZARD", "", insulinAfterConstraints, carbs) uel.log(Action.BOLUS, notes, ValueWithUnit(eventType,Units.TherapyEvent), ValueWithUnit(insulinAfterConstraints, Units.U), ValueWithUnit(this@BolusWizard.carbs, Units.G, this@BolusWizard.carbs != 0), ValueWithUnit(carbTime, Units.M, carbTime != 0))
if (insulin > 0 || pump.pumpDescription.storesCarbInfo) { if (insulin > 0 || pump.pumpDescription.storesCarbInfo) {
commandQueue.bolus(this, object : Callback() { commandQueue.bolus(this, object : Callback() {
override fun run() { override fun run() {

View file

@ -4,6 +4,6 @@
android:viewportHeight="24" android:viewportHeight="24"
android:viewportWidth="24" android:viewportWidth="24"
xmlns:android="http://schemas.android.com/apk/res/android"> xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#67DFE8" android:pathData="M15.714,7.697l0.353,-0.684c0.18,-0.348 0.043,-0.775 -0.305,-0.955c-0.351,-0.181 -0.775,-0.043 -0.955,0.305l-0.354,0.685c-0.379,-0.148 -0.772,-0.265 -1.18,-0.344V6.106c0.45,-0.061 0.802,-0.431 0.802,-0.897c0,-0.509 -0.412,-0.921 -0.921,-0.921h-2.313c-0.509,0 -0.921,0.413 -0.921,0.921c0,0.467 0.352,0.836 0.802,0.897v0.598c-3.125,0.599 -5.495,3.349 -5.495,6.646c0,3.732 3.037,6.77 6.77,6.77c3.732,0 6.77,-3.037 6.77,-6.77C18.768,10.989 17.551,8.909 15.714,7.697zM11.998,19.119c-3.182,0 -5.77,-2.588 -5.77,-5.77s2.588,-5.77 5.77,-5.77s5.77,2.588 5.77,5.77S15.18,19.119 11.998,19.119z"/> <path android:fillColor="@color/extendedBolus" android:pathData="M15.714,7.697l0.353,-0.684c0.18,-0.348 0.043,-0.775 -0.305,-0.955c-0.351,-0.181 -0.775,-0.043 -0.955,0.305l-0.354,0.685c-0.379,-0.148 -0.772,-0.265 -1.18,-0.344V6.106c0.45,-0.061 0.802,-0.431 0.802,-0.897c0,-0.509 -0.412,-0.921 -0.921,-0.921h-2.313c-0.509,0 -0.921,0.413 -0.921,0.921c0,0.467 0.352,0.836 0.802,0.897v0.598c-3.125,0.599 -5.495,3.349 -5.495,6.646c0,3.732 3.037,6.77 6.77,6.77c3.732,0 6.77,-3.037 6.77,-6.77C18.768,10.989 17.551,8.909 15.714,7.697zM11.998,19.119c-3.182,0 -5.77,-2.588 -5.77,-5.77s2.588,-5.77 5.77,-5.77s5.77,2.588 5.77,5.77S15.18,19.119 11.998,19.119z"/>
<path android:fillColor="#67DFE8" android:pathData="M12,8.814c-0.086,0 -0.169,0.035 -0.23,0.096s-0.096,0.144 -0.096,0.23v4.198c0,0.08 0.029,0.157 0.083,0.217l2.789,3.14c0.058,0.064 0.139,0.104 0.226,0.108c0.006,0.001 0.013,0.001 0.019,0.001c0.08,0 0.157,-0.029 0.217,-0.083c0.971,-0.866 1.527,-2.095 1.527,-3.372C16.533,10.85 14.5,8.816 12,8.814z"/> <path android:fillColor="@color/extendedBolus" android:pathData="M12,8.814c-0.086,0 -0.169,0.035 -0.23,0.096s-0.096,0.144 -0.096,0.23v4.198c0,0.08 0.029,0.157 0.083,0.217l2.789,3.14c0.058,0.064 0.139,0.104 0.226,0.108c0.006,0.001 0.013,0.001 0.019,0.001c0.08,0 0.157,-0.029 0.217,-0.083c0.971,-0.866 1.527,-2.095 1.527,-3.372C16.533,10.85 14.5,8.816 12,8.814z"/>
</vector> </vector>

View file

@ -5,11 +5,11 @@
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:pathData="M7.305,4.482c1.782,2.914 4.332,5.382 3.916,9.05c-0.256,2.254 -2.529,3.635 -4.783,3.199c-2.145,-0.415 -3.625,-2.546 -3.171,-4.728C3.858,9.168 5.537,6.894 7.305,4.482zM5.08,10.061c-0.212,0.638 -0.489,1.262 -0.621,1.916c-0.205,1.017 -0.065,1.994 0.764,2.731c0.297,0.264 0.68,0.354 1.038,0.077c0.242,-0.187 0.269,-0.46 0.096,-0.692C5.468,12.903 5.032,11.589 5.08,10.061z" android:pathData="M7.305,4.482c1.782,2.914 4.332,5.382 3.916,9.05c-0.256,2.254 -2.529,3.635 -4.783,3.199c-2.145,-0.415 -3.625,-2.546 -3.171,-4.728C3.858,9.168 5.537,6.894 7.305,4.482zM5.08,10.061c-0.212,0.638 -0.489,1.262 -0.621,1.916c-0.205,1.017 -0.065,1.994 0.764,2.731c0.297,0.264 0.68,0.354 1.038,0.077c0.242,-0.187 0.269,-0.46 0.096,-0.692C5.468,12.903 5.032,11.589 5.08,10.061z"
android:fillColor="#E83258"/> android:fillColor="@color/calibration"/>
<path <path
android:pathData="M17.959,4.566c1.073,1.453 2.073,2.837 2.489,4.535c0.28,1.143 -0.069,2.1 -1.037,2.763c-0.943,0.645 -1.961,0.655 -2.904,0.009c-0.967,-0.662 -1.318,-1.635 -1.041,-2.769C15.88,7.408 16.875,6.019 17.959,4.566z" android:pathData="M17.959,4.566c1.073,1.453 2.073,2.837 2.489,4.535c0.28,1.143 -0.069,2.1 -1.037,2.763c-0.943,0.645 -1.961,0.655 -2.904,0.009c-0.967,-0.662 -1.318,-1.635 -1.041,-2.769C15.88,7.408 16.875,6.019 17.959,4.566z"
android:fillColor="#E83258"/> android:fillColor="@color/calibration"/>
<path <path
android:pathData="M14.82,14.425c0.797,1.094 1.535,2.104 1.819,3.355c0.188,0.826 -0.096,1.498 -0.784,1.965c-0.669,0.454 -1.393,0.467 -2.067,0.014c-0.688,-0.462 -0.985,-1.13 -0.8,-1.959C13.272,16.531 14.004,15.503 14.82,14.425z" android:pathData="M14.82,14.425c0.797,1.094 1.535,2.104 1.819,3.355c0.188,0.826 -0.096,1.498 -0.784,1.965c-0.669,0.454 -1.393,0.467 -2.067,0.014c-0.688,-0.462 -0.985,-1.13 -0.8,-1.959C13.272,16.531 14.004,15.503 14.82,14.425z"
android:fillColor="#E83258"/> android:fillColor="@color/calibration"/>
</vector> </vector>

View file

@ -5,5 +5,5 @@
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:pathData="M24,9.343l-5.781,-3.968l-1.328,6.688l2.102,-1.757c0.014,0.056 0.03,0.111 0.043,0.168c0.116,0.512 0.183,1.042 0.183,1.589c0,3.952 -3.204,7.156 -7.156,7.156s-7.156,-3.204 -7.156,-7.156s3.204,-7.156 7.156,-7.156c1.072,0 2.085,0.242 2.998,0.665c0.325,0.151 0.639,0.321 0.936,0.517l0.002,-0.002l-0.352,-1.784l1.876,-0.538c-1.567,-1.033 -3.442,-1.639 -5.46,-1.639c-5.488,0 -9.938,4.449 -9.938,9.938S6.574,22 12.063,22S22,17.551 22,12.063c0,-0.759 -0.093,-1.496 -0.254,-2.206c-0.04,-0.176 -0.085,-0.35 -0.134,-0.523L24,9.343L24,9.343z" android:pathData="M24,9.343l-5.781,-3.968l-1.328,6.688l2.102,-1.757c0.014,0.056 0.03,0.111 0.043,0.168c0.116,0.512 0.183,1.042 0.183,1.589c0,3.952 -3.204,7.156 -7.156,7.156s-7.156,-3.204 -7.156,-7.156s3.204,-7.156 7.156,-7.156c1.072,0 2.085,0.242 2.998,0.665c0.325,0.151 0.639,0.321 0.936,0.517l0.002,-0.002l-0.352,-1.784l1.876,-0.538c-1.567,-1.033 -3.442,-1.639 -5.46,-1.639c-5.488,0 -9.938,4.449 -9.938,9.938S6.574,22 12.063,22S22,17.551 22,12.063c0,-0.759 -0.093,-1.496 -0.254,-2.206c-0.04,-0.176 -0.085,-0.35 -0.134,-0.523L24,9.343L24,9.343z"
android:fillColor="#00C03E"/> android:fillColor="@color/loopClosed"/>
</vector> </vector>

View file

@ -5,11 +5,11 @@
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:pathData="M24,9.343l-5.781,-3.968l-1.328,6.688l2.102,-1.757c0.014,0.056 0.03,0.111 0.043,0.168c0.116,0.512 0.183,1.042 0.183,1.589c0,3.952 -3.204,7.156 -7.156,7.156s-7.156,-3.204 -7.156,-7.156s3.204,-7.156 7.156,-7.156c1.072,0 2.085,0.242 2.998,0.665c0.325,0.151 0.639,0.321 0.936,0.517l0.002,-0.002l-0.352,-1.784l1.876,-0.538c-1.567,-1.033 -3.442,-1.639 -5.46,-1.639c-5.488,0 -9.938,4.449 -9.938,9.938S6.574,22 12.063,22S22,17.551 22,12.063c0,-0.759 -0.093,-1.496 -0.254,-2.206c-0.04,-0.176 -0.085,-0.35 -0.134,-0.523L24,9.343L24,9.343z" android:pathData="M24,9.343l-5.781,-3.968l-1.328,6.688l2.102,-1.757c0.014,0.056 0.03,0.111 0.043,0.168c0.116,0.512 0.183,1.042 0.183,1.589c0,3.952 -3.204,7.156 -7.156,7.156s-7.156,-3.204 -7.156,-7.156s3.204,-7.156 7.156,-7.156c1.072,0 2.085,0.242 2.998,0.665c0.325,0.151 0.639,0.321 0.936,0.517l0.002,-0.002l-0.352,-1.784l1.876,-0.538c-1.567,-1.033 -3.442,-1.639 -5.46,-1.639c-5.488,0 -9.938,4.449 -9.938,9.938S6.574,22 12.063,22S22,17.551 22,12.063c0,-0.759 -0.093,-1.496 -0.254,-2.206c-0.04,-0.176 -0.085,-0.35 -0.134,-0.523L24,9.343L24,9.343z"
android:fillColor="#FF1313"/> android:fillColor="@color/loopDisabled"/>
<path <path
android:pathData="M10.2429,8.7408l5.0162,5.0162l-1.5026,1.5026l-5.0162,-5.0162z" android:pathData="M10.2429,8.7408l5.0162,5.0162l-1.5026,1.5026l-5.0162,-5.0162z"
android:fillColor="#FF1313"/> android:fillColor="@color/loopDisabled"/>
<path <path
android:pathData="M8.7408,13.7571l5.0162,-5.0162l1.5026,1.5026l-5.0162,5.0162z" android:pathData="M8.7408,13.7571l5.0162,-5.0162l1.5026,1.5026l-5.0162,5.0162z"
android:fillColor="#FF1313"/> android:fillColor="@color/loopDisabled"/>
</vector> </vector>

View file

@ -5,8 +5,8 @@
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:pathData="M17.523,3.764c-1.567,-1.033 -3.442,-1.639 -5.46,-1.639c-5.488,0 -9.938,4.449 -9.938,9.938c0,1.803 0.484,3.49 1.325,4.945l-0.319,0.365c-0.001,0.842 0.325,1.681 1.01,2.277l2.416,2.103l0.872,-1.002l1.746,1.523l0.472,-0.542l-1.747,-1.523l1.272,-1.461l1.748,1.524l0.472,-0.542l-1.749,-1.525l0.872,-1.001l-2.416,-2.103c-0.684,-0.596 -1.557,-0.803 -2.39,-0.687l-0.277,0.318c-0.335,-0.825 -0.528,-1.723 -0.528,-2.67c0,-3.952 3.204,-7.156 7.156,-7.156c1.072,0 2.085,0.242 2.998,0.665c0.325,0.151 0.639,0.321 0.936,0.517l0.002,-0.002l-0.352,-1.784L17.523,3.764z" android:pathData="M17.523,3.764c-1.567,-1.033 -3.442,-1.639 -5.46,-1.639c-5.488,0 -9.938,4.449 -9.938,9.938c0,1.803 0.484,3.49 1.325,4.945l-0.319,0.365c-0.001,0.842 0.325,1.681 1.01,2.277l2.416,2.103l0.872,-1.002l1.746,1.523l0.472,-0.542l-1.747,-1.523l1.272,-1.461l1.748,1.524l0.472,-0.542l-1.749,-1.525l0.872,-1.001l-2.416,-2.103c-0.684,-0.596 -1.557,-0.803 -2.39,-0.687l-0.277,0.318c-0.335,-0.825 -0.528,-1.723 -0.528,-2.67c0,-3.952 3.204,-7.156 7.156,-7.156c1.072,0 2.085,0.242 2.998,0.665c0.325,0.151 0.639,0.321 0.936,0.517l0.002,-0.002l-0.352,-1.784L17.523,3.764z"
android:fillColor="#939393"/> android:fillColor="@color/loopDisconnected"/>
<path <path
android:pathData="M24,9.343l-5.781,-3.968l-1.328,6.688l2.102,-1.757c0.014,0.056 0.03,0.111 0.043,0.168c0.116,0.512 0.183,1.042 0.183,1.589c0,0.938 -0.183,1.833 -0.511,2.653l-0.263,-0.302c-0.833,-0.116 -1.706,0.091 -2.39,0.687l-2.416,2.103l3.96,4.549l2.416,-2.103c0.685,-0.596 1.011,-1.435 1.01,-2.277l-0.346,-0.397C21.51,15.526 22,13.855 22,12.063c0,-0.759 -0.093,-1.496 -0.254,-2.206c-0.04,-0.176 -0.085,-0.35 -0.134,-0.523L24,9.343L24,9.343z" android:pathData="M24,9.343l-5.781,-3.968l-1.328,6.688l2.102,-1.757c0.014,0.056 0.03,0.111 0.043,0.168c0.116,0.512 0.183,1.042 0.183,1.589c0,0.938 -0.183,1.833 -0.511,2.653l-0.263,-0.302c-0.833,-0.116 -1.706,0.091 -2.39,0.687l-2.416,2.103l3.96,4.549l2.416,-2.103c0.685,-0.596 1.011,-1.435 1.01,-2.277l-0.346,-0.397C21.51,15.526 22,13.855 22,12.063c0,-0.759 -0.093,-1.496 -0.254,-2.206c-0.04,-0.176 -0.085,-0.35 -0.134,-0.523L24,9.343L24,9.343z"
android:fillColor="#939393"/> android:fillColor="@color/loopDisconnected"/>
</vector> </vector>

View file

@ -5,20 +5,20 @@
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:pathData="M6.349,7.767c0.408,-0.542 0.89,-1.022 1.433,-1.429L6.38,3.917C5.424,4.584 4.593,5.415 3.924,6.37L6.349,7.767z" android:pathData="M6.349,7.767c0.408,-0.542 0.89,-1.022 1.433,-1.429L6.38,3.917C5.424,4.584 4.593,5.415 3.924,6.37L6.349,7.767z"
android:fillColor="#00C03E"/> android:fillColor="@color/loopClosed"/>
<path <path
android:pathData="M9.258,5.478c0.613,-0.262 1.272,-0.436 1.959,-0.517l-0.003,-2.793c-1.191,0.101 -2.318,0.414 -3.352,0.898L9.258,5.478z" android:pathData="M9.258,5.478c0.613,-0.262 1.272,-0.436 1.959,-0.517l-0.003,-2.793c-1.191,0.101 -2.318,0.414 -3.352,0.898L9.258,5.478z"
android:fillColor="#00C03E"/> android:fillColor="@color/loopClosed"/>
<path <path
android:pathData="M12.922,2.189l0.003,2.773c0.754,0.093 1.472,0.301 2.135,0.608c0.325,0.151 0.639,0.321 0.936,0.517l0.002,-0.002l-0.352,-1.784l1.876,-0.538C16.182,2.88 14.61,2.336 12.922,2.189z" android:pathData="M12.922,2.189l0.003,2.773c0.754,0.093 1.472,0.301 2.135,0.608c0.325,0.151 0.639,0.321 0.936,0.517l0.002,-0.002l-0.352,-1.784l1.876,-0.538C16.182,2.88 14.61,2.336 12.922,2.189z"
android:fillColor="#00C03E"/> android:fillColor="@color/loopClosed"/>
<path <path
android:pathData="M4.963,11.199c0.083,-0.687 0.259,-1.345 0.523,-1.958L3.072,7.85c-0.485,1.034 -0.801,2.16 -0.903,3.351L4.963,11.199z" android:pathData="M4.963,11.199c0.083,-0.687 0.259,-1.345 0.523,-1.958L3.072,7.85c-0.485,1.034 -0.801,2.16 -0.903,3.351L4.963,11.199z"
android:fillColor="#00C03E"/> android:fillColor="@color/loopClosed"/>
<path <path
android:pathData="M24,9.343l-5.781,-3.968l-1.328,6.688l2.102,-1.757c0.014,0.056 0.03,0.111 0.043,0.168c0.116,0.512 0.183,1.042 0.183,1.589c0,3.952 -3.204,7.156 -7.156,7.156c-2.345,0 -4.42,-1.133 -5.725,-2.876l-2.421,1.401C5.712,20.315 8.689,22 12.063,22C17.551,22 22,17.551 22,12.063c0,-0.759 -0.093,-1.496 -0.254,-2.206c-0.04,-0.176 -0.085,-0.35 -0.134,-0.523L24,9.343L24,9.343z" android:pathData="M24,9.343l-5.781,-3.968l-1.328,6.688l2.102,-1.757c0.014,0.056 0.03,0.111 0.043,0.168c0.116,0.512 0.183,1.042 0.183,1.589c0,3.952 -3.204,7.156 -7.156,7.156c-2.345,0 -4.42,-1.133 -5.725,-2.876l-2.421,1.401C5.712,20.315 8.689,22 12.063,22C17.551,22 22,17.551 22,12.063c0,-0.759 -0.093,-1.496 -0.254,-2.206c-0.04,-0.176 -0.085,-0.35 -0.134,-0.523L24,9.343L24,9.343z"
android:fillColor="#00C03E"/> android:fillColor="@color/loopClosed"/>
<path <path
android:pathData="M5.478,14.867c-0.262,-0.614 -0.436,-1.272 -0.517,-1.96L2.168,12.91c0.101,1.191 0.414,2.319 0.898,3.353L5.478,14.867z" android:pathData="M5.478,14.867c-0.262,-0.614 -0.436,-1.272 -0.517,-1.96L2.168,12.91c0.101,1.191 0.414,2.319 0.898,3.353L5.478,14.867z"
android:fillColor="#00C03E"/> android:fillColor="@color/loopClosed"/>
</vector> </vector>

View file

@ -5,23 +5,23 @@
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:pathData="M6.349,7.767c0.408,-0.542 0.89,-1.022 1.433,-1.429L6.38,3.917C5.424,4.584 4.593,5.415 3.924,6.37L6.349,7.767z" android:pathData="M6.349,7.767c0.408,-0.542 0.89,-1.022 1.433,-1.429L6.38,3.917C5.424,4.584 4.593,5.415 3.924,6.37L6.349,7.767z"
android:fillColor="#4983D7"/> android:fillColor="@color/loopOpened"/>
<path <path
android:pathData="M3.072,7.85c-0.485,1.034 -0.801,2.16 -0.903,3.351l2.795,-0.003c0.083,-0.687 0.259,-1.345 0.523,-1.958L3.072,7.85z" android:pathData="M3.072,7.85c-0.485,1.034 -0.801,2.16 -0.903,3.351l2.795,-0.003c0.083,-0.687 0.259,-1.345 0.523,-1.958L3.072,7.85z"
android:fillColor="#4983D7"/> android:fillColor="@color/loopOpened"/>
<path <path
android:pathData="M21.059,7.862l-2.412,1.396c0.262,0.614 0.437,1.272 0.518,1.96l2.793,-0.003C21.856,10.024 21.543,8.896 21.059,7.862z" android:pathData="M21.059,7.862l-2.412,1.396c0.262,0.614 0.437,1.272 0.518,1.96l2.793,-0.003C21.856,10.024 21.543,8.896 21.059,7.862z"
android:fillColor="#4983D7"/> android:fillColor="@color/loopOpened"/>
<path <path
android:pathData="M17.787,7.781l2.421,-1.401c-0.668,-0.956 -1.499,-1.787 -2.454,-2.456l-1.397,2.425C16.9,6.757 17.38,7.238 17.787,7.781z" android:pathData="M17.787,7.781l2.421,-1.401c-0.668,-0.956 -1.499,-1.787 -2.454,-2.456l-1.397,2.425C16.9,6.757 17.38,7.238 17.787,7.781z"
android:fillColor="#4983D7"/> android:fillColor="@color/loopOpened"/>
<path <path
android:pathData="M19.162,12.926c-0.427,3.544 -3.44,6.293 -7.099,6.293c-3.666,0 -6.684,-2.758 -7.102,-6.312L2.168,12.91C2.599,18.001 6.86,22 12.063,22c5.198,0 9.457,-3.992 9.894,-9.077L19.162,12.926z" android:pathData="M19.162,12.926c-0.427,3.544 -3.44,6.293 -7.099,6.293c-3.666,0 -6.684,-2.758 -7.102,-6.312L2.168,12.91C2.599,18.001 6.86,22 12.063,22c5.198,0 9.457,-3.992 9.894,-9.077L19.162,12.926z"
android:fillColor="#4983D7"/> android:fillColor="@color/loopOpened"/>
<path <path
android:pathData="M9.258,5.478c0.613,-0.262 1.272,-0.436 1.959,-0.517l-0.003,-2.793c-1.191,0.101 -2.318,0.414 -3.352,0.898L9.258,5.478z" android:pathData="M9.258,5.478c0.613,-0.262 1.272,-0.436 1.959,-0.517l-0.003,-2.793c-1.191,0.101 -2.318,0.414 -3.352,0.898L9.258,5.478z"
android:fillColor="#4983D7"/> android:fillColor="@color/loopOpened"/>
<path <path
android:pathData="M12.925,4.963c0.687,0.083 1.345,0.259 1.958,0.522l1.391,-2.414c-1.034,-0.485 -2.161,-0.801 -3.352,-0.903L12.925,4.963z" android:pathData="M12.925,4.963c0.687,0.083 1.345,0.259 1.958,0.522l1.391,-2.414c-1.034,-0.485 -2.161,-0.801 -3.352,-0.903L12.925,4.963z"
android:fillColor="#4983D7"/> android:fillColor="@color/loopOpened"/>
</vector> </vector>

View file

@ -5,11 +5,11 @@
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:pathData="M24,9.343l-5.781,-3.968l-1.328,6.688l2.102,-1.757c0.014,0.056 0.03,0.111 0.043,0.168c0.116,0.512 0.183,1.042 0.183,1.589c0,3.952 -3.204,7.156 -7.156,7.156s-7.156,-3.204 -7.156,-7.156s3.204,-7.156 7.156,-7.156c1.072,0 2.085,0.242 2.998,0.665c0.325,0.151 0.639,0.321 0.936,0.517l0.002,-0.002l-0.352,-1.784l1.876,-0.538c-1.567,-1.033 -3.442,-1.639 -5.46,-1.639c-5.488,0 -9.938,4.449 -9.938,9.938S6.574,22 12.063,22S22,17.551 22,12.063c0,-0.759 -0.093,-1.496 -0.254,-2.206c-0.04,-0.176 -0.085,-0.35 -0.134,-0.523L24,9.343L24,9.343z" android:pathData="M24,9.343l-5.781,-3.968l-1.328,6.688l2.102,-1.757c0.014,0.056 0.03,0.111 0.043,0.168c0.116,0.512 0.183,1.042 0.183,1.589c0,3.952 -3.204,7.156 -7.156,7.156s-7.156,-3.204 -7.156,-7.156s3.204,-7.156 7.156,-7.156c1.072,0 2.085,0.242 2.998,0.665c0.325,0.151 0.639,0.321 0.936,0.517l0.002,-0.002l-0.352,-1.784l1.876,-0.538c-1.567,-1.033 -3.442,-1.639 -5.46,-1.639c-5.488,0 -9.938,4.449 -9.938,9.938S6.574,22 12.063,22S22,17.551 22,12.063c0,-0.759 -0.093,-1.496 -0.254,-2.206c-0.04,-0.176 -0.085,-0.35 -0.134,-0.523L24,9.343L24,9.343z"
android:fillColor="#FFFF13"/> android:fillColor="@color/loopSuspended"/>
<path <path
android:pathData="M8.813,8.453h2.125v7.094h-2.125z" android:pathData="M8.813,8.453h2.125v7.094h-2.125z"
android:fillColor="#FFFF13"/> android:fillColor="@color/loopSuspended"/>
<path <path
android:pathData="M13.063,8.453h2.125v7.094h-2.125z" android:pathData="M13.063,8.453h2.125v7.094h-2.125z"
android:fillColor="#FFFF13"/> android:fillColor="@color/loopSuspended"/>
</vector> </vector>

View file

@ -5,8 +5,8 @@
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:pathData="M24,9.343l-5.781,-3.968l-1.328,6.688l2.102,-1.757c0.014,0.056 0.03,0.111 0.043,0.168c0.116,0.512 0.183,1.042 0.183,1.589c0,3.952 -3.204,7.156 -7.156,7.156c-3.952,0 -7.156,-3.204 -7.156,-7.156c0,-3.952 3.204,-7.156 7.156,-7.156c1.072,0 2.085,0.242 2.998,0.665c0.325,0.151 0.639,0.321 0.936,0.517l0.002,-0.002l-0.352,-1.784l1.876,-0.538c-1.567,-1.033 -3.442,-1.639 -5.46,-1.639c-5.488,0 -9.937,4.449 -9.937,9.938c0,5.488 4.449,9.937 9.937,9.937C17.551,22 22,17.551 22,12.063c0,-0.759 -0.093,-1.496 -0.254,-2.206c-0.04,-0.176 -0.085,-0.35 -0.134,-0.523L24,9.343L24,9.343z" android:pathData="M24,9.343l-5.781,-3.968l-1.328,6.688l2.102,-1.757c0.014,0.056 0.03,0.111 0.043,0.168c0.116,0.512 0.183,1.042 0.183,1.589c0,3.952 -3.204,7.156 -7.156,7.156c-3.952,0 -7.156,-3.204 -7.156,-7.156c0,-3.952 3.204,-7.156 7.156,-7.156c1.072,0 2.085,0.242 2.998,0.665c0.325,0.151 0.639,0.321 0.936,0.517l0.002,-0.002l-0.352,-1.784l1.876,-0.538c-1.567,-1.033 -3.442,-1.639 -5.46,-1.639c-5.488,0 -9.937,4.449 -9.937,9.938c0,5.488 4.449,9.937 9.937,9.937C17.551,22 22,17.551 22,12.063c0,-0.759 -0.093,-1.496 -0.254,-2.206c-0.04,-0.176 -0.085,-0.35 -0.134,-0.523L24,9.343L24,9.343z"
android:fillColor="#939393"/> android:fillColor="@color/loopDisconnected"/>
<path <path
android:pathData="M14.868,22.154c0.794,0 1.49,-0.418 1.973,-1.054l-0.001,-3.926c-0.482,-0.634 -1.177,-1.052 -1.969,-1.052l-5.612,-0.001c-0.793,0 -1.487,0.416 -1.97,1.05l-0.004,3.926c0.482,0.636 1.178,1.055 1.972,1.055" android:pathData="M14.868,22.154c0.794,0 1.49,-0.418 1.973,-1.054l-0.001,-3.926c-0.482,-0.634 -1.177,-1.052 -1.969,-1.052l-5.612,-0.001c-0.793,0 -1.487,0.416 -1.97,1.05l-0.004,3.926c0.482,0.636 1.178,1.055 1.972,1.055"
android:fillColor="#939393"/> android:fillColor="@color/loopDisconnected"/>
</vector> </vector>

View file

@ -5,8 +5,8 @@
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:pathData="M24,9.343l-5.781,-3.968l-1.328,6.688l2.102,-1.757c0.014,0.056 0.03,0.111 0.043,0.168c0.116,0.512 0.183,1.042 0.183,1.589c0,3.952 -3.204,7.156 -7.156,7.156c-3.952,0 -7.156,-3.204 -7.156,-7.156c0,-3.952 3.204,-7.156 7.156,-7.156c1.072,0 2.085,0.242 2.998,0.665c0.325,0.151 0.639,0.321 0.936,0.517l0.002,-0.002l-0.352,-1.784l1.876,-0.538c-1.567,-1.033 -3.442,-1.639 -5.46,-1.639c-5.488,0 -9.937,4.449 -9.937,9.938c0,5.488 4.449,9.937 9.937,9.937C17.551,22 22,17.551 22,12.063c0,-0.759 -0.093,-1.496 -0.254,-2.206c-0.04,-0.176 -0.085,-0.35 -0.134,-0.523L24,9.343L24,9.343z" android:pathData="M24,9.343l-5.781,-3.968l-1.328,6.688l2.102,-1.757c0.014,0.056 0.03,0.111 0.043,0.168c0.116,0.512 0.183,1.042 0.183,1.589c0,3.952 -3.204,7.156 -7.156,7.156c-3.952,0 -7.156,-3.204 -7.156,-7.156c0,-3.952 3.204,-7.156 7.156,-7.156c1.072,0 2.085,0.242 2.998,0.665c0.325,0.151 0.639,0.321 0.936,0.517l0.002,-0.002l-0.352,-1.784l1.876,-0.538c-1.567,-1.033 -3.442,-1.639 -5.46,-1.639c-5.488,0 -9.937,4.449 -9.937,9.938c0,5.488 4.449,9.937 9.937,9.937C17.551,22 22,17.551 22,12.063c0,-0.759 -0.093,-1.496 -0.254,-2.206c-0.04,-0.176 -0.085,-0.35 -0.134,-0.523L24,9.343L24,9.343z"
android:fillColor="#00C03E"/> android:fillColor="@color/loopClosed"/>
<path <path
android:pathData="M9.401,8.391l6.599,3.609l-6.599,3.609z" android:pathData="M9.401,8.391l6.599,3.609l-6.599,3.609z"
android:fillColor="#00C03E"/> android:fillColor="@color/loopClosed"/>
</vector> </vector>

View file

@ -75,6 +75,20 @@
android:text="@string/nav_import" android:text="@string/nav_import"
android:textColor="@color/colorTreatmentButton" /> android:textColor="@color/colorTreatmentButton" />
<Button
android:id="@+id/export_csv"
style="?android:attr/buttonStyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="3dp"
android:layout_weight="0.5"
android:text="@string/ue_export_to_csv"
android:textColor="@color/colorTreatmentButton" />
<Button <Button
android:id="@+id/nav_resetdb" android:id="@+id/nav_resetdb"
style="?android:attr/buttonStyle" style="?android:attr/buttonStyle"

View file

@ -5,6 +5,15 @@
android:orientation="vertical" android:orientation="vertical"
tools:context=".plugins.treatments.fragments.TreatmentsUserEntryFragment"> tools:context=".plugins.treatments.fragments.TreatmentsUserEntryFragment">
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/ue_export_to_xml"
style="?android:attr/buttonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:drawableStart="@drawable/ic_header_export"
android:text="@string/ue_export_to_csv" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview" android:id="@+id/recyclerview"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -1,8 +1,21 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center"
card_view:cardBackgroundColor="?android:colorBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="true"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
@ -23,48 +36,37 @@
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
tools:ignore="HardcodedText,RtlSymmetry" /> tools:ignore="HardcodedText,RtlSymmetry" />
</LinearLayout>
<TextView
android:id="@+id/values"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingStart="20dp"
android:paddingEnd="10dp"
android:textStyle="bold"
android:visibility="gone"
android:text="Values with units" />
<TextView <TextView
android:id="@+id/s" android:id="@+id/s"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="10dp" android:paddingStart="20dp"
android:visibility="gone"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
tools:ignore="HardcodedText,RtlSymmetry" /> tools:ignore="HardcodedText,RtlSymmetry" />
<TextView <View
android:id="@+id/d1" android:layout_width="fill_parent"
android:layout_width="wrap_content" android:layout_height="2dip"
android:layout_height="wrap_content" android:layout_marginBottom="5dp"
android:paddingStart="10dp" android:layout_marginStart="5dp"
android:text="0.0" android:layout_marginEnd="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" android:layout_marginTop="5dp"
tools:ignore="HardcodedText,RtlSymmetry" /> android:background="@color/list_delimiter" />
<TextView </LinearLayout>
android:id="@+id/d2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="10dp"
android:text="0.0"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:ignore="HardcodedText,RtlSymmetry" />
<TextView </androidx.cardview.widget.CardView>
android:id="@+id/i1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="10dp"
android:text="0.0"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:ignore="HardcodedText,RtlSymmetry" />
<TextView
android:id="@+id/i2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="10dp"
android:text="0.0"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:ignore="HardcodedText,RtlSymmetry" />
</LinearLayout>

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="prediction">#ff00ff</color> <color name="prediction">#ff00ff</color>
<color name="basal">#00ffff</color>
<color name="iobPred">#00d2d2</color> <color name="iobPred">#00d2d2</color>
<color name="bolus">#1ea3e5</color> <color name="bolus">#1ea3e5</color>
<color name="ratio">#FFFFFF</color> <color name="ratio">#FFFFFF</color>
@ -22,7 +21,6 @@
<color name="ok_background">#323232</color> <color name="ok_background">#323232</color>
<color name="defaultbackground">#424242</color> <color name="defaultbackground">#424242</color>
<color name="defaulttext">#BBBBBB</color>
<color name="defaulttextcolor">#B3FFFFFF</color> <color name="defaulttextcolor">#B3FFFFFF</color>
<color name="tempTargetBackground">#77dd77</color> <color name="tempTargetBackground">#77dd77</color>

View file

@ -179,6 +179,7 @@
<string name="configbuilder_nightscoutversion_label">Nightscout version:</string> <string name="configbuilder_nightscoutversion_label">Nightscout version:</string>
<string name="missing_carbs">Missing %1$d g</string> <string name="missing_carbs">Missing %1$d g</string>
<string name="exported">Preferences exported</string> <string name="exported">Preferences exported</string>
<string name="ue_exported">User Entries exported</string>
<string name="export_to">Export settings to</string> <string name="export_to">Export settings to</string>
<string name="import_from">Import settings from</string> <string name="import_from">Import settings from</string>
<string name="setting_imported">Settings imported</string> <string name="setting_imported">Settings imported</string>
@ -932,7 +933,6 @@
<string name="format_carbs_ic">%1$.0fg IC: %2$.1f</string> <string name="format_carbs_ic">%1$.0fg IC: %2$.1f</string>
<string name="format_cob_ic">%1$.1fg IC: %2$.1f</string> <string name="format_cob_ic">%1$.1fg IC: %2$.1f</string>
<string name="format_percent">%1$d%%</string> <string name="format_percent">%1$d%%</string>
<string name="boluswizard">Bolus wizard</string>
<string name="unit_minute_short">min</string> <string name="unit_minute_short">min</string>
<string name="profile_name">Profile name:</string> <string name="profile_name">Profile name:</string>
<string name="selected_profile">Selected:</string> <string name="selected_profile">Selected:</string>
@ -1126,4 +1126,6 @@
<string name="current_basal_value">Current basal value</string> <string name="current_basal_value">Current basal value</string>
<string name="profile_carbs_ratio_value">Profile carbs ratio value</string> <string name="profile_carbs_ratio_value">Profile carbs ratio value</string>
</resources> </resources>

View file

@ -20,6 +20,7 @@ import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.automation.databinding.AutomationEventItemBinding import info.nightscout.androidaps.automation.databinding.AutomationEventItemBinding
import info.nightscout.androidaps.automation.databinding.AutomationFragmentBinding import info.nightscout.androidaps.automation.databinding.AutomationFragmentBinding
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.automation.dialogs.EditEventDialog import info.nightscout.androidaps.plugins.general.automation.dialogs.EditEventDialog
@ -216,7 +217,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener {
holder.binding.iconTrash.setOnClickListener { holder.binding.iconTrash.setOnClickListener {
OKDialog.showConfirmation(requireContext(), resourceHelper.gs(R.string.removerecord) + " " + automationPlugin.at(position).title, OKDialog.showConfirmation(requireContext(), resourceHelper.gs(R.string.removerecord) + " " + automationPlugin.at(position).title,
{ {
uel.log("AUTOM REMOVED", automationPlugin.at(position).title) uel.log(Action.AUTOMATION_REMOVED, automationPlugin.at(position).title)
automationPlugin.removeAt(position) automationPlugin.removeAt(position)
notifyItemRemoved(position) notifyItemRemoved(position)
}, { }, {
@ -239,7 +240,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord) + " " + automationPlugin.at(position).title, OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord) + " " + automationPlugin.at(position).title,
Runnable { Runnable {
uel.log("AUTOM REMOVED", automationPlugin.at(position).title) uel.log(Action.AUTOMATION_REMOVED, automationPlugin.at(position).title)
automationPlugin.removeAt(position) automationPlugin.removeAt(position)
notifyItemRemoved(position) notifyItemRemoved(position)
rxBus.send(EventAutomationDataChanged()) rxBus.send(EventAutomationDataChanged())

View file

@ -1,13 +1,14 @@
package info.nightscout.androidaps; package info.nightscout.androidaps;
import info.nightscout.androidaps.utils.T; import info.nightscout.androidaps.utils.T;
import info.nightscout.androidaps.database.entities.UserEntry.*;
/** /**
* Created by mike on 07.06.2016. * Created by mike on 07.06.2016.
*/ */
public class Constants { public class Constants {
public static final String MGDL = "mg/dl"; // This is Nightscout's representation public static final String MGDL = Units.Mg_Dl.getText(); // This is Nightscout's representation
public static final String MMOL = "mmol"; public static final String MMOL = Units.Mmol_L.getText();
public static final double MMOLL_TO_MGDL = 18; // 18.0182; public static final double MMOLL_TO_MGDL = 18; // 18.0182;
public static final double MGDL_TO_MMOLL = 1 / MMOLL_TO_MGDL; public static final double MGDL_TO_MMOLL = 1 / MMOLL_TO_MGDL;

View file

@ -11,6 +11,7 @@ import dagger.android.support.DaggerDialogFragment
import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.core.databinding.DialogErrorBinding import info.nightscout.androidaps.core.databinding.DialogErrorBinding
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.services.AlarmSoundServiceHelper import info.nightscout.androidaps.services.AlarmSoundServiceHelper
@ -58,15 +59,15 @@ class ErrorDialog : DaggerDialogFragment() {
binding.title.text = title binding.title.text = title
binding.ok.setOnClickListener { binding.ok.setOnClickListener {
uel.log("Error dialog ok button pressed") uel.log(Action.ERROR_DIALOG_OK)
dismiss() dismiss()
} }
binding.mute.setOnClickListener { binding.mute.setOnClickListener {
uel.log("Error dialog mute button pressed") uel.log(Action.ERROR_DIALOG_MUTE)
stopAlarm() stopAlarm()
} }
binding.mute5min.setOnClickListener { binding.mute5min.setOnClickListener {
uel.log("Error dialog mute 5 min button pressed") uel.log(Action.ERROR_DIALOG_MUTE_5MIN)
stopAlarm() stopAlarm()
loopHandler.postDelayed(this::startAlarm, T.mins(5).msecs()) loopHandler.postDelayed(this::startAlarm, T.mins(5).msecs())
} }

View file

@ -2,7 +2,9 @@ package info.nightscout.androidaps.interfaces
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity import androidx.fragment.app.FragmentActivity
import info.nightscout.androidaps.database.entities.UserEntry
import info.nightscout.androidaps.plugins.general.maintenance.PrefsFile import info.nightscout.androidaps.plugins.general.maintenance.PrefsFile
import io.reactivex.Single
interface ImportExportPrefsInterface { interface ImportExportPrefsInterface {
@ -12,4 +14,5 @@ interface ImportExportPrefsInterface {
fun prefsFileExists(): Boolean fun prefsFileExists(): Boolean
fun verifyStoragePermissions(fragment: Fragment, onGranted: Runnable) fun verifyStoragePermissions(fragment: Fragment, onGranted: Runnable)
fun exportSharedPreferences(f: Fragment) fun exportSharedPreferences(f: Fragment)
fun exportUserEntriesCsv(activity: FragmentActivity, entries: Single<List<UserEntry>>)
} }

View file

@ -1,6 +1,8 @@
package info.nightscout.androidaps.logging package info.nightscout.androidaps.logging
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.database.transactions.UserEntryTransaction import info.nightscout.androidaps.database.transactions.UserEntryTransaction
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import io.reactivex.disposables.CompositeDisposable import io.reactivex.disposables.CompositeDisposable
@ -18,20 +20,66 @@ class UserEntryLogger @Inject constructor(
private val compositeDisposable = CompositeDisposable() private val compositeDisposable = CompositeDisposable()
fun log(action: String, s: String = "", d1: Double = 0.0, d2: Double = 0.0, i1: Int = 0, i2: Int = 0) { fun log(action: Action, s: String, vararg listvalues: ValueWithUnit) {
val values = mutableListOf<ValueWithUnit>()
for (v in listvalues){
if (v.condition) values.add(v)
}
compositeDisposable += repository.runTransaction(UserEntryTransaction( compositeDisposable += repository.runTransaction(UserEntryTransaction(
action = action, action = action,
s = s, s = s,
d1 = d1, values = values
d2 = d2,
i1 = i1,
i2 = i2
)) ))
.subscribeOn(aapsSchedulers.io) .subscribeOn(aapsSchedulers.io)
.observeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io)
.subscribeBy( .subscribeBy(
onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $s ${if (d1 == 0.0) d1 else ""} ${if (d2 == 0.0) d2 else ""} ${if (i1 == 0) i1 else ""} ${if (i2 == 0) i2 else ""}") }, onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $s $values") },
onComplete = { aapsLogger.debug("USER ENTRY: $action $s ${if (d1 == 0.0) d1 else ""} ${if (d2 == 0.0) d2 else ""} ${if (i1 == 0) i1 else ""} ${if (i2 == 0) i2 else ""}") } onComplete = { aapsLogger.debug("USER ENTRY: $action $s $values") }
)
}
fun log(action: Action, vararg listvalues: ValueWithUnit) {
val values = mutableListOf<ValueWithUnit>()
for (v in listvalues){
if (v.condition) values.add(v)
}
compositeDisposable += repository.runTransaction(UserEntryTransaction(
action = action,
s = "",
values = values
))
.subscribeOn(aapsSchedulers.io)
.observeOn(aapsSchedulers.io)
.subscribeBy(
onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $values") },
onComplete = { aapsLogger.debug("USER ENTRY: $action $values") }
)
}
fun log(action: Action, s: String = "") {
compositeDisposable += repository.runTransaction(UserEntryTransaction(
action = action,
s = s
))
.subscribeOn(aapsSchedulers.io)
.observeOn(aapsSchedulers.io)
.subscribeBy(
onError = { aapsLogger.debug("ERRORED USER ENTRY: $action") },
onComplete = { aapsLogger.debug("USER ENTRY: $action") }
)
}
fun log(action: Action, s: String = "", values: MutableList<ValueWithUnit>) {
compositeDisposable += repository.runTransaction(UserEntryTransaction(
action = action,
s = s,
values = values
))
.subscribeOn(aapsSchedulers.io)
.observeOn(aapsSchedulers.io)
.subscribeBy(
onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $s $values") },
onComplete = { aapsLogger.debug("USER ENTRY: $action $s $values") }
) )
} }
} }

View file

@ -31,6 +31,7 @@ class PrefFileListProvider @Inject constructor(
private val path = File(Environment.getExternalStorageDirectory().toString()) private val path = File(Environment.getExternalStorageDirectory().toString())
private val aapsPath = File(path, "AAPS" + File.separator + "preferences") private val aapsPath = File(path, "AAPS" + File.separator + "preferences")
private val exportsPath = File(path, "AAPS" + File.separator + "exports")
private const val IMPORT_AGE_NOT_YET_OLD_DAYS = 60 private const val IMPORT_AGE_NOT_YET_OLD_DAYS = 60
} }
@ -93,6 +94,9 @@ class PrefFileListProvider @Inject constructor(
if (!aapsPath.exists()) { if (!aapsPath.exists()) {
aapsPath.mkdirs() aapsPath.mkdirs()
} }
if (!exportsPath.exists()) {
exportsPath.mkdirs()
}
} }
fun newExportFile(): File { fun newExportFile(): File {
@ -100,6 +104,11 @@ class PrefFileListProvider @Inject constructor(
return File(aapsPath, timeLocal + "_" + config.FLAVOR + ".json") return File(aapsPath, timeLocal + "_" + config.FLAVOR + ".json")
} }
fun newExportXmlFile(): File {
val timeLocal = LocalDateTime.now().toString(DateTimeFormat.forPattern("yyyy-MM-dd'_'HHmmss"))
return File(exportsPath, timeLocal + "_UserEntry.csv")
}
// check metadata for known issues, change their status and add info with explanations // check metadata for known issues, change their status and add info with explanations
fun checkMetadata(metadata: Map<PrefsMetadataKey, PrefMetadata>): Map<PrefsMetadataKey, PrefMetadata> { fun checkMetadata(metadata: Map<PrefsMetadataKey, PrefMetadata>): Map<PrefsMetadataKey, PrefMetadata> {
val meta = metadata.toMutableMap() val meta = metadata.toMutableMap()

View file

@ -2,6 +2,12 @@ package info.nightscout.androidaps.plugins.general.maintenance.formats
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.database.entities.UserEntry
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.Translator
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.storage.Storage import info.nightscout.androidaps.utils.storage.Storage
import java.io.File import java.io.File
@ -13,6 +19,9 @@ import javax.inject.Singleton
@Singleton @Singleton
class ClassicPrefsFormat @Inject constructor( class ClassicPrefsFormat @Inject constructor(
private var resourceHelper: ResourceHelper, private var resourceHelper: ResourceHelper,
private var dateUtil: DateUtil,
private var translator: Translator,
private var profileFunction: ProfileFunction,
private var storage: Storage private var storage: Storage
) : PrefsFormat { ) : PrefsFormat {
@ -67,4 +76,57 @@ class ClassicPrefsFormat @Inject constructor(
return metadata return metadata
} }
fun saveCsv(file: File, userEntries: List<UserEntry>) {
try {
val contents = UserEntriesToCsv(userEntries)
storage.putFileContents(file, contents)
} catch (e: FileNotFoundException) {
throw PrefFileNotFoundError(file.absolutePath)
} catch (e: IOException) {
throw PrefIOError(file.absolutePath)
}
}
fun UserEntriesToCsv(userEntries: List<UserEntry>): String {
val userEntryHeader = resourceHelper.gs(R.string.ue_csv_header) + "\n"
return userEntryHeader + userEntries.joinToString("\n") { entry ->
if (entry.values.size > 0) {
entry.values.joinToString("\n") { value ->
entry.timestamp.toString() + ";" +
dateUtil.dateAndTimeAndSecondsString(entry.timestamp) + ";" +
dateUtil.timeString(entry.utcOffset) + ";" +
csvString(entry.action) + ";" +
csvString(entry.s) + ";" +
valueWithUnitToCsv(value)
}
} else {
entry.timestamp.toString() + ";" +
dateUtil.dateAndTimeAndSecondsString(entry.timestamp) + ";" +
dateUtil.timeString(entry.utcOffset) + ";" +
csvString(entry.action) + ";" +
csvString(entry.s) + ";;"
}
}
}
fun valueWithUnitToCsv(v: ValueWithUnit): String {
return when (v.unit) {
Units.Timestamp -> dateUtil.dateAndTimeAndSecondsString(v.lValue) + ";" + csvString(R.string.date)
Units.TherapyEvent -> csvString(translator.translate(v.sValue)) + ";"
Units.R_String -> if (v.lValue.toInt() == 0) csvString(v.iValue) + ";" else ";" //If lValue > 0 it's a formated string, so hidden for
Units.Mg_Dl -> if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue) + ";" + csvString(Units.Mg_Dl) else DecimalFormatter.to1Decimal(v.dValue/Constants.MMOLL_TO_MGDL) + ";" + csvString(Units.Mmol_L)
Units.Mmol_L -> if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue*Constants.MMOLL_TO_MGDL) + ";" + csvString(Units.Mg_Dl) else DecimalFormatter.to1Decimal(v.dValue) + ";" + csvString(Units.Mmol_L)
Units.U_H, Units.U -> DecimalFormatter.to2Decimal(v.dValue) + ";" + csvString(v.unit)
Units.G, Units.M, Units.H, Units.Percent
-> v.iValue.toString() + ";" + csvString(v.unit)
else -> if (v.sValue != "") { csvString(v.sValue) + ";" + csvString(v.unit)}
else if (v.iValue != 0) { v.iValue.toString() + ";" + csvString(v.unit)}
else ";"
}
}
private fun csvString(action: Action): String = "\"" + translator.translate(action.name).replace("\"", "\"\"") + "\""
private fun csvString(unit: Units): String = "\"" + translator.translate(unit.name).replace("\"", "\"\"") + "\""
private fun csvString(id: Int): String = if (id != 0) "\"" + resourceHelper.gs(id).replace("\"", "\"\"") + "\"" else ""
private fun csvString(s: String): String = if (s != "") "\"" + s.replace("\"", "\"\"") + "\"" else ""
} }

View file

@ -3,6 +3,7 @@ package info.nightscout.androidaps.utils
import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.database.entities.TemporaryTarget import info.nightscout.androidaps.database.entities.TemporaryTarget
import info.nightscout.androidaps.database.entities.TherapyEvent import info.nightscout.androidaps.database.entities.TherapyEvent
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@ -19,6 +20,7 @@ class Translator @Inject internal constructor(
TherapyEvent.Type.MEAL_BOLUS.text -> resourceHelper.gs(R.string.careportal_mealbolus) TherapyEvent.Type.MEAL_BOLUS.text -> resourceHelper.gs(R.string.careportal_mealbolus)
TherapyEvent.Type.CORRECTION_BOLUS.text -> resourceHelper.gs(R.string.careportal_correctionbolus) TherapyEvent.Type.CORRECTION_BOLUS.text -> resourceHelper.gs(R.string.careportal_correctionbolus)
TherapyEvent.Type.CARBS_CORRECTION.text -> resourceHelper.gs(R.string.careportal_carbscorrection) TherapyEvent.Type.CARBS_CORRECTION.text -> resourceHelper.gs(R.string.careportal_carbscorrection)
TherapyEvent.Type.BOLUS_WIZARD.text -> resourceHelper.gs(R.string.boluswizard)
TherapyEvent.Type.COMBO_BOLUS.text -> resourceHelper.gs(R.string.careportal_combobolus) TherapyEvent.Type.COMBO_BOLUS.text -> resourceHelper.gs(R.string.careportal_combobolus)
TherapyEvent.Type.ANNOUNCEMENT.text -> resourceHelper.gs(R.string.careportal_announcement) TherapyEvent.Type.ANNOUNCEMENT.text -> resourceHelper.gs(R.string.careportal_announcement)
TherapyEvent.Type.NOTE.text -> resourceHelper.gs(R.string.careportal_note) TherapyEvent.Type.NOTE.text -> resourceHelper.gs(R.string.careportal_note)
@ -41,12 +43,112 @@ class Translator @Inject internal constructor(
TherapyEvent.MeterType.FINGER.text -> resourceHelper.gs(R.string.glucosetype_finger) TherapyEvent.MeterType.FINGER.text -> resourceHelper.gs(R.string.glucosetype_finger)
TherapyEvent.MeterType.SENSOR.text -> resourceHelper.gs(R.string.glucosetype_sensor) TherapyEvent.MeterType.SENSOR.text -> resourceHelper.gs(R.string.glucosetype_sensor)
TherapyEvent.MeterType.MANUAL.text -> resourceHelper.gs(R.string.manual) TherapyEvent.MeterType.MANUAL.text -> resourceHelper.gs(R.string.manual)
TemporaryTarget.Reason.CUSTOM.text -> resourceHelper.gs(R.string.custom) TemporaryTarget.Reason.CUSTOM.text -> resourceHelper.gs(R.string.custom)
TemporaryTarget.Reason.HYPOGLYCEMIA.text -> resourceHelper.gs(R.string.hypo) TemporaryTarget.Reason.HYPOGLYCEMIA.text -> resourceHelper.gs(R.string.hypo)
TemporaryTarget.Reason.EATING_SOON.text -> resourceHelper.gs(R.string.eatingsoon) TemporaryTarget.Reason.EATING_SOON.text -> resourceHelper.gs(R.string.eatingsoon)
TemporaryTarget.Reason.ACTIVITY.text -> resourceHelper.gs(R.string.activity) TemporaryTarget.Reason.ACTIVITY.text -> resourceHelper.gs(R.string.activity)
TemporaryTarget.Reason.AUTOMATION.text -> resourceHelper.gs(R.string.automation) TemporaryTarget.Reason.AUTOMATION.text -> resourceHelper.gs(R.string.automation)
TemporaryTarget.Reason.WEAR.text -> resourceHelper.gs(R.string.wear) TemporaryTarget.Reason.WEAR.text -> resourceHelper.gs(R.string.wear)
Action.BOLUS.name -> resourceHelper.gs(R.string.uel_bolus)
Action.BOLUS_ADVISOR.name -> resourceHelper.gs(R.string.uel_bolus_advisor)
Action.BOLUS_RECORD.name -> resourceHelper.gs(R.string.uel_bolus_record)
Action.EXTENDED_BOLUS.name -> resourceHelper.gs(R.string.uel_extended_bolus)
Action.SUPERBOLUS_TBR.name -> resourceHelper.gs(R.string.uel_superbolus_tbr)
Action.CARBS.name -> resourceHelper.gs(R.string.uel_carbs)
Action.EXTENDED_CARBS.name -> resourceHelper.gs(R.string.uel_extended_carbs)
Action.TEMP_BASAL.name -> resourceHelper.gs(R.string.uel_temp_basal)
Action.TT.name -> resourceHelper.gs(R.string.uel_tt)
Action.NEW_PROFILE.name -> resourceHelper.gs(R.string.uel_new_profile)
Action.CLONE_PROFILE.name -> resourceHelper.gs(R.string.uel_clone_profile)
Action.STORE_PROFILE.name -> resourceHelper.gs(R.string.uel_store_profile)
Action.PROFILE_SWITCH.name -> resourceHelper.gs(R.string.uel_profile_switch)
Action.PROFILE_SWITCH_CLONED.name -> resourceHelper.gs(R.string.uel_profile_switch_cloned)
Action.CLOSED_LOOP_MODE.name -> resourceHelper.gs(R.string.uel_closed_loop_mode)
Action.LGS_LOOP_MODE.name -> resourceHelper.gs(R.string.uel_lgs_loop_mode)
Action.OPEN_LOOP_MODE.name -> resourceHelper.gs(R.string.uel_open_loop_mode)
Action.LOOP_DISABLED.name -> resourceHelper.gs(R.string.uel_loop_disabled)
Action.LOOP_ENABLED.name -> resourceHelper.gs(R.string.uel_loop_enabled)
Action.RECONNECT.name -> resourceHelper.gs(R.string.uel_reconnect)
Action.DISCONNECT.name -> resourceHelper.gs(R.string.uel_disconnect)
Action.RESUME.name -> resourceHelper.gs(R.string.uel_resume)
Action.SUSPEND.name -> resourceHelper.gs(R.string.uel_suspend)
Action.HW_PUMP_ALLOWED.name -> resourceHelper.gs(R.string.uel_hw_pump_allowed)
Action.CLEAR_PAIRING_KEYS.name -> resourceHelper.gs(R.string.uel_clear_pairing_keys)
Action.ACCEPTS_TEMP_BASAL.name -> resourceHelper.gs(R.string.uel_accepts_temp_basal)
Action.CANCEL_TEMP_BASAL.name -> resourceHelper.gs(R.string.uel_cancel_temp_basal)
Action.CANCEL_EXTENDED_BOLUS.name -> resourceHelper.gs(R.string.uel_cancel_extended_bolus)
Action.CANCEL_TT.name -> resourceHelper.gs(R.string.uel_cancel_tt)
Action.CAREPORTAL.name -> resourceHelper.gs(R.string.uel_careportal)
Action.CALIBRATION.name -> resourceHelper.gs(R.string.uel_calibration)
Action.PRIME_BOLUS.name -> resourceHelper.gs(R.string.uel_prime_bolus)
Action.TREATMENT.name -> resourceHelper.gs(R.string.uel_treatment)
Action.CAREPORTAL_NS_REFRESH.name -> resourceHelper.gs(R.string.uel_careportal_ns_refresh)
Action.PROFILE_SWITCH_NS_REFRESH.name -> resourceHelper.gs(R.string.uel_profile_switch_ns_refresh)
Action.TREATMENTS_NS_REFRESH.name -> resourceHelper.gs(R.string.uel_treatments_ns_refresh)
Action.TT_NS_REFRESH.name -> resourceHelper.gs(R.string.uel_tt_ns_refresh)
Action.AUTOMATION_REMOVED.name -> resourceHelper.gs(R.string.uel_automation_removed)
Action.BG_REMOVED.name -> resourceHelper.gs(R.string.uel_bg_removed)
Action.CAREPORTAL_REMOVED.name -> resourceHelper.gs(R.string.uel_careportal_removed)
Action.EXTENDED_BOLUS_REMOVED.name -> resourceHelper.gs(R.string.uel_extended_bolus_removed)
Action.FOOD_REMOVED.name -> resourceHelper.gs(R.string.uel_food_removed)
Action.PROFILE_REMOVED.name -> resourceHelper.gs(R.string.uel_profile_removed)
Action.PROFILE_SWITCH_REMOVED.name -> resourceHelper.gs(R.string.uel_profile_switch_removed)
Action.RESTART_EVENTS_REMOVED.name -> resourceHelper.gs(R.string.uel_restart_events_removed)
Action.TREATMENT_REMOVED.name -> resourceHelper.gs(R.string.uel_treatment_removed)
Action.TT_REMOVED.name -> resourceHelper.gs(R.string.uel_tt_removed)
Action.NS_PAUSED.name -> resourceHelper.gs(R.string.uel_ns_paused)
Action.NS_RESUME.name -> resourceHelper.gs(R.string.uel_ns_resume)
Action.NS_QUEUE_CLEARED.name -> resourceHelper.gs(R.string.uel_ns_queue_cleared)
Action.NS_SETTINGS_COPIED.name -> resourceHelper.gs(R.string.uel_ns_settings_copied)
Action.ERROR_DIALOG_OK.name -> resourceHelper.gs(R.string.uel_error_dialog_ok)
Action.ERROR_DIALOG_MUTE.name -> resourceHelper.gs(R.string.uel_error_dialog_mute)
Action.ERROR_DIALOG_MUTE_5MIN.name -> resourceHelper.gs(R.string.uel_error_dialog_mute_5min)
Action.OBJECTIVE_STARTED.name -> resourceHelper.gs(R.string.uel_objective_started)
Action.OBJECTIVE_UNSTARTED.name -> resourceHelper.gs(R.string.uel_objective_unstarted)
Action.OBJECTIVES_SKIPPED.name -> resourceHelper.gs(R.string.uel_objectives_skipped)
Action.STAT_RESET.name -> resourceHelper.gs(R.string.uel_stat_reset)
Action.DELETE_LOGS.name -> resourceHelper.gs(R.string.uel_delete_logs)
Action.DELETE_FUTURE_TREATMENTS.name -> resourceHelper.gs(R.string.uel_delete_future_treatments)
Action.EXPORT_SETTINGS.name -> resourceHelper.gs(R.string.uel_export_settings)
Action.IMPORT_SETTINGS.name -> resourceHelper.gs(R.string.uel_import_settings)
Action.RESET_DATABASES.name -> resourceHelper.gs(R.string.uel_reset_databases)
Action.EXPORT_DATABASES.name -> resourceHelper.gs(R.string.uel_export_databases)
Action.IMPORT_DATABASES.name -> resourceHelper.gs(R.string.uel_import_databases)
Action.OTP_EXPORT.name -> resourceHelper.gs(R.string.uel_otp_export)
Action.OTP_RESET.name -> resourceHelper.gs(R.string.uel_otp_reset)
Action.SMS_BASAL.name -> resourceHelper.gs(R.string.uel_sms_basal)
Action.SMS_BOLUS.name -> resourceHelper.gs(R.string.uel_sms_bolus)
Action.SMS_CAL.name -> resourceHelper.gs(R.string.uel_sms_cal)
Action.SMS_CARBS.name -> resourceHelper.gs(R.string.uel_sms_carbs)
Action.SMS_EXTENDED_BOLUS.name -> resourceHelper.gs(R.string.uel_sms_extended_bolus)
Action.SMS_LOOP_DISABLED.name -> resourceHelper.gs(R.string.uel_sms_loop_disabled)
Action.SMS_LOOP_ENABLED.name -> resourceHelper.gs(R.string.uel_sms_loop_enabled)
Action.SMS_LOOP_RESUME.name -> resourceHelper.gs(R.string.uel_sms_loop_resume)
Action.SMS_LOOP_SUSPEND.name -> resourceHelper.gs(R.string.uel_sms_loop_suspend)
Action.SMS_PROFILE.name -> resourceHelper.gs(R.string.uel_sms_profile)
Action.SMS_PUMP_CONNECT.name -> resourceHelper.gs(R.string.uel_sms_pump_connect)
Action.SMS_PUMP_DISCONNECT.name -> resourceHelper.gs(R.string.uel_sms_pump_disconnect)
Action.SMS_SMS.name -> resourceHelper.gs(R.string.uel_sms_sms)
Action.SMS_TT.name -> resourceHelper.gs(R.string.uel_sms_tt)
Action.TT_DELETED_FROM_NS.name -> resourceHelper.gs(R.string.uel_tt_deleted_from_ns)
Action.TT_FROM_NS.name -> resourceHelper.gs(R.string.uel_tt_from_ns)
Action.TT_CANCELED_FROM_NS.name -> resourceHelper.gs(R.string.uel_tt_canceleted_from_ns)
Action.CAREPORTAL_DELETED_FROM_NS.name -> resourceHelper.gs(R.string.uel_careportal_deleted_from_ns)
Action.CAREPORTAL_FROM_NS.name -> resourceHelper.gs(R.string.uel_careportal_from_ns)
Action.EXPORT_CSV.name -> resourceHelper.gs(R.string.uel_export_csv)
Units.Mg_Dl.name -> resourceHelper.gs(R.string.mgdl)
Units.Mmol_L.name -> resourceHelper.gs(R.string.mmol)
Units.U.name -> resourceHelper.gs(R.string.insulin_unit_shortname)
Units.U_H.name -> resourceHelper.gs(R.string.profile_ins_units_per_hour)
Units.G.name -> resourceHelper.gs(R.string.shortgram)
Units.M.name -> resourceHelper.gs(R.string.shortminute)
Units.H.name -> resourceHelper.gs(R.string.shorthour)
Units.Percent.name -> resourceHelper.gs(R.string.shortpercent)
Units.None.name -> ""
else -> resourceHelper.gs(R.string.unknown) else -> resourceHelper.gs(R.string.unknown)
} }
} }

View file

@ -0,0 +1,19 @@
package info.nightscout.androidaps.utils.extensions
import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.database.entities.UserEntry.*
fun ColorGroup.colorId(): Int {
return when (this) {
ColorGroup.InsulinTreatment -> R.color.basal
ColorGroup.CarbTreatment -> R.color.carbs
ColorGroup.TT -> R.color.tempTargetConfirmation
ColorGroup.Profile -> R.color.white
ColorGroup.Loop -> R.color.loopClosed
ColorGroup.Careportal -> R.color.high
ColorGroup.Pump -> R.color.iob
ColorGroup.Aaps -> R.color.defaulttext
else -> R.color.defaulttext
}
}

View file

@ -5,11 +5,11 @@
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:pathData="M6.384,15.052c-0.018,-0.323 0.025,-0.625 0.418,-0.671c0.36,-0.042 0.49,0.218 0.531,0.516c0.155,1.131 0.771,1.799 1.92,1.948c0.336,0.043 0.592,0.192 0.528,0.573c-0.059,0.351 -0.373,0.388 -0.654,0.387C7.775,17.801 6.4,16.415 6.384,15.052z" android:pathData="M6.384,15.052c-0.018,-0.323 0.025,-0.625 0.418,-0.671c0.36,-0.042 0.49,0.218 0.531,0.516c0.155,1.131 0.771,1.799 1.92,1.948c0.336,0.043 0.592,0.192 0.528,0.573c-0.059,0.351 -0.373,0.388 -0.654,0.387C7.775,17.801 6.4,16.415 6.384,15.052z"
android:fillColor="#E9375C"/> android:fillColor="@color/calibration"/>
<path <path
android:pathData="M18.817,9.875c-0.377,-1.485 -1.932,-3.719 -2.256,-3.719c-0.325,0 -1.884,2.238 -2.26,3.721c-0.251,0.991 0.067,1.842 0.943,2.421c0.855,0.565 1.778,0.556 2.632,-0.008C18.755,11.712 19.071,10.874 18.817,9.875zM17.437,11.623c-0.297,0.196 -0.595,0.295 -0.886,0.295c-0.286,0 -0.577,-0.097 -0.866,-0.287c-0.586,-0.387 -0.779,-0.882 -0.608,-1.558c0.236,-0.933 0.997,-2.169 1.484,-2.813c0.486,0.644 1.244,1.878 1.481,2.812C18.213,10.745 18.021,11.237 17.437,11.623z" android:pathData="M18.817,9.875c-0.377,-1.485 -1.932,-3.719 -2.256,-3.719c-0.325,0 -1.884,2.238 -2.26,3.721c-0.251,0.991 0.067,1.842 0.943,2.421c0.855,0.565 1.778,0.556 2.632,-0.008C18.755,11.712 19.071,10.874 18.817,9.875zM17.437,11.623c-0.297,0.196 -0.595,0.295 -0.886,0.295c-0.286,0 -0.577,-0.097 -0.866,-0.287c-0.586,-0.387 -0.779,-0.882 -0.608,-1.558c0.236,-0.933 0.997,-2.169 1.484,-2.813c0.486,0.644 1.244,1.878 1.481,2.812C18.213,10.745 18.021,11.237 17.437,11.623z"
android:fillColor="#E83258"/> android:fillColor="@color/calibration"/>
<path <path
android:pathData="M13.737,13.869c-0.726,-2.859 -3.893,-7.275 -4.343,-7.275c-0.45,0 -3.627,4.425 -4.349,7.278c-0.483,1.908 0.128,3.546 1.816,4.66c1.646,1.087 3.422,1.07 5.067,-0.015C13.617,17.403 14.225,15.791 13.737,13.869zM11.487,17.85c-0.694,0.457 -1.405,0.689 -2.112,0.689c-0.698,0 -1.396,-0.227 -2.074,-0.675c-1.389,-0.916 -1.887,-2.193 -1.481,-3.796c0.563,-2.22 3.332,-6.141 3.574,-6.141s3.003,3.917 3.568,6.138C13.368,15.663 12.871,16.937 11.487,17.85z" android:pathData="M13.737,13.869c-0.726,-2.859 -3.893,-7.275 -4.343,-7.275c-0.45,0 -3.627,4.425 -4.349,7.278c-0.483,1.908 0.128,3.546 1.816,4.66c1.646,1.087 3.422,1.07 5.067,-0.015C13.617,17.403 14.225,15.791 13.737,13.869zM11.487,17.85c-0.694,0.457 -1.405,0.689 -2.112,0.689c-0.698,0 -1.396,-0.227 -2.074,-0.675c-1.389,-0.916 -1.887,-2.193 -1.481,-3.796c0.563,-2.22 3.332,-6.141 3.574,-6.141s3.003,3.917 3.568,6.138C13.368,15.663 12.871,16.937 11.487,17.85z"
android:fillColor="#E83258"/> android:fillColor="@color/calibration"/>
</vector> </vector>

View file

@ -25,22 +25,34 @@
<color name="errorAlertBackground">#FFFF5555</color> <color name="errorAlertBackground">#FFFF5555</color>
<color name="errorAlertHeaderText">#FF000000</color> <color name="errorAlertHeaderText">#FF000000</color>
<color name="examinedProfile">#FFFF5555</color> <color name="examinedProfile">#FFFF5555</color>
<color name="defaulttext">#BBBBBB</color>
<!-- Treatment--> <!-- Treatment-->
<color name="tempbasal">#C803A9F4</color> <color name="tempbasal">#C803A9F4</color>
<color name="list_delimiter">#505050</color> <color name="list_delimiter">#505050</color>
<color name="basal">#00ffff</color>
<!-- Loop -->
<color name="loopDisconnected">#939393</color>
<color name="loopClosed">#00C03E</color>
<color name="loopSuspended">#FFFF13</color>
<color name="loopOpened">#4983D7</color>
<color name="loopDisabled">#FF1313</color>
<!-- BgReading--> <!-- BgReading-->
<color name="inrange">#00FF00</color> <color name="inrange">#00FF00</color>
<color name="low">#FF0000</color> <color name="low">#FF0000</color>
<color name="high">#FFFF00</color> <color name="high">#FFFF00</color>
<color name="iob">#1e88e5</color> <color name="iob">#1e88e5</color>
<color name="extendedBolus">#67DFE8</color>
<color name="iobPredAS">#1ea3e5</color> <color name="iobPredAS">#1ea3e5</color>
<color name="cob">#FFFB8C00</color> <color name="cob">#FFFB8C00</color>
<color name="carbs">#FFFB8C00</color> <color name="carbs">#FFFB8C00</color>
<color name="uam">#c9bd60</color> <color name="uam">#c9bd60</color>
<color name="zt">#00d2d2</color> <color name="zt">#00d2d2</color>
<color name="white">#ffffff</color> <color name="white">#ffffff</color>
<color name="calibration">#E83258</color>
<color name="ribbonDefault">#5a595b</color> <color name="ribbonDefault">#5a595b</color>
<color name="daySelected">#D000FF00</color> <color name="daySelected">#D000FF00</color>

View file

@ -118,6 +118,8 @@
<string name="eventtype">Event type</string> <string name="eventtype">Event type</string>
<string name="mgdl">mg/dl</string> <string name="mgdl">mg/dl</string>
<string name="mmol">mmol/l</string> <string name="mmol">mmol/l</string>
<string name="shortgram">g</string>
<string name="shortpercent">%</string>
<string name="advancedsettings_title">Advanced Settings</string> <string name="advancedsettings_title">Advanced Settings</string>
<string name="bluetooth">Bluetooth</string> <string name="bluetooth">Bluetooth</string>
<string name="btwatchdog_title">BT Watchdog</string> <string name="btwatchdog_title">BT Watchdog</string>
@ -263,6 +265,7 @@
<string name="careportal_pumpbatterychange">Pump Battery Change</string> <string name="careportal_pumpbatterychange">Pump Battery Change</string>
<string name="careportal_temporarytarget">Temporary target</string> <string name="careportal_temporarytarget">Temporary target</string>
<string name="careportal_temporarytargetcancel">Temporary target cancel</string> <string name="careportal_temporarytargetcancel">Temporary target cancel</string>
<string name="boluswizard">Bolus wizard</string>
<string name="glucosetype_finger">Finger</string> <string name="glucosetype_finger">Finger</string>
<string name="glucosetype_sensor">Sensor</string> <string name="glucosetype_sensor">Sensor</string>
<string name="manual">Manual</string> <string name="manual">Manual</string>
@ -395,6 +398,99 @@
<string name="saturday_short">S</string> <string name="saturday_short">S</string>
<string name="sunday_short">S</string> <string name="sunday_short">S</string>
<!-- User Entry -->
<string name="uel_bolus">BOLUS</string>
<string name="uel_bolus_advisor">BOLUS ADVISOR</string>
<string name="uel_bolus_record">BOLUS RECORD</string>
<string name="uel_extended_bolus">EXTENDED BOLUS</string>
<string name="uel_superbolus_tbr">SUPERBOLUS TBR</string>
<string name="uel_carbs">CARBS</string>
<string name="uel_extended_carbs">EXTENDED CARBS</string>
<string name="uel_temp_basal">TEMP BASAL</string>
<string name="uel_tt">TT</string>
<string name="uel_new_profile">NEW PROFILE</string>
<string name="uel_clone_profile">CLONE PROFILE</string>
<string name="uel_store_profile">STORE PROFILE</string>
<string name="uel_profile_switch">PROFILE SWITCH</string>
<string name="uel_profile_switch_cloned">PROFILE SWITCH CLONED</string>
<string name="uel_closed_loop_mode">CLOSED LOOP MODE</string>
<string name="uel_lgs_loop_mode">LGS LOOP MODE</string>
<string name="uel_open_loop_mode">OPEN LOOP MODE</string>
<string name="uel_loop_disabled">LOOP DISABLED</string>
<string name="uel_loop_enabled">LOOP ENABLED</string>
<string name="uel_reconnect">RECONNECT</string>
<string name="uel_disconnect">DISCONNECT</string>
<string name="uel_resume">RESUME</string>
<string name="uel_suspend">SUSPEND</string>
<string name="uel_hw_pump_allowed">HW PUMP ALLOWED</string>
<string name="uel_clear_pairing_keys">CLEAR PAIRING KEYS</string>
<string name="uel_accepts_temp_basal">ACCEPTS TEMP BASAL</string>
<string name="uel_cancel_temp_basal">CANCEL TEMP BASAL</string>
<string name="uel_cancel_extended_bolus">CANCEL EXTENDED BOLUS</string>
<string name="uel_cancel_tt">CANCEL TT</string>
<string name="uel_careportal">CAREPORTAL</string>
<string name="uel_calibration">CALIBRATION</string>
<string name="uel_prime_bolus">PRIME BOLUS</string>
<string name="uel_treatment">TREATMENT</string>
<string name="uel_careportal_ns_refresh">CAREPORTAL NS REFRESH</string>
<string name="uel_profile_switch_ns_refresh">PROFILE SWITCH NS REFRESH</string>
<string name="uel_treatments_ns_refresh">TREATMENTS NS REFRESH</string>
<string name="uel_tt_ns_refresh">TT NS REFRESH</string>
<string name="uel_automation_removed">AUTOMATION REMOVED</string>
<string name="uel_bg_removed">BG REMOVED</string>
<string name="uel_careportal_removed">CAREPORTAL REMOVED</string>
<string name="uel_extended_bolus_removed">EXTENDED BOLUS REMOVED</string>
<string name="uel_food_removed">FOOD REMOVED</string>
<string name="uel_profile_removed">PROFILE REMOVED</string>
<string name="uel_profile_switch_removed">PROFILE SWITCH REMOVED</string>
<string name="uel_restart_events_removed">RESTART EVENTS REMOVED</string>
<string name="uel_treatment_removed">TREATMENT REMOVED</string>
<string name="uel_tt_removed">TT REMOVED</string>
<string name="uel_ns_paused">NS PAUSED</string>
<string name="uel_ns_resume">NS RESUME</string>
<string name="uel_ns_queue_cleared">NS QUEUE CLEARED</string>
<string name="uel_ns_settings_copied">NS SETTINGS COPIED</string>
<string name="uel_error_dialog_ok">ERROR DIALOG OK</string>
<string name="uel_error_dialog_mute">ERROR DIALOG MUTE </string>
<string name="uel_error_dialog_mute_5min">ERROR DIALOG MUTE 5MIN</string>
<string name="uel_objective_started">OBJECTIVE STARTED</string>
<string name="uel_objective_unstarted">OBJECTIVE UNSTARTED</string>
<string name="uel_objectives_skipped">OBJECTIVES SKIPPED</string>
<string name="uel_stat_reset">STAT RESET</string>
<string name="uel_delete_logs">DELETE LOGS</string>
<string name="uel_delete_future_treatments">DELETE FUTURE TREATMENTS</string>
<string name="uel_export_settings">EXPORT SETTINGS</string>
<string name="uel_import_settings">IMPORT SETTINGS</string>
<string name="uel_reset_databases">RESET DATABASES</string>
<string name="uel_export_databases">EXPORT DATABASES</string>
<string name="uel_import_databases">IMPORT DATABASES</string>
<string name="uel_otp_export">OTP EXPORT</string>
<string name="uel_otp_reset">OTP RESET</string>
<string name="uel_sms_basal">SMS BASAL</string>
<string name="uel_sms_bolus">SMS BOLUS</string>
<string name="uel_sms_cal">SMS CAL</string>
<string name="uel_sms_carbs">SMS CARBS</string>
<string name="uel_sms_extended_bolus">SMS EXTENDED BOLUS</string>
<string name="uel_sms_loop_disabled">SMS LOOP DISABLED</string>
<string name="uel_sms_loop_enabled">SMS LOOP ENABLED</string>
<string name="uel_sms_loop_resume">SMS LOOP RESUME</string>
<string name="uel_sms_loop_suspend">SMS LOOP SUSPEND</string>
<string name="uel_sms_profile">SMS PROFILE</string>
<string name="uel_sms_pump_connect">SMS PUMP CONNECT</string>
<string name="uel_sms_pump_disconnect">SMS PUMP DISCONNECT</string>
<string name="uel_sms_sms">SMS SMS</string>
<string name="uel_sms_tt">SMS TT</string>
<string name="uel_tt_deleted_from_ns">TT DELETED FROM NS</string>
<string name="uel_careportal_deleted_from_ns">CAREPORTAL DELETED FROM NS</string>
<string name="uel_careportal_from_ns">CAREPORTAL FROM NS</string>
<string name="uel_tt_from_ns">TT FROM NS</string>
<string name="uel_tt_canceleted_from_ns">TT CANCELED FROM NS</string>
<string name="uel_export_csv">EXPORT USER ENTRIES</string>
<string name="uel_unknown">UNKNOWN</string>
<string name="formated_string">Formated string</string>
<string name="ue_export_to_csv">Export User Entries to Excel (csv)</string>
<string name="ue_csv_header">"Timestamp;Date;UTC Offset;Action;Note;Value;Unit"</string>
<plurals name="days"> <plurals name="days">
<item quantity="one">%1$d day</item> <item quantity="one">%1$d day</item>
<item quantity="other">%1$d days</item> <item quantity="other">%1$d days</item>

View file

@ -1,8 +1,10 @@
package info.nightscout.androidaps.plugins.general.maintenance.formats package info.nightscout.androidaps.plugins.general.maintenance.formats
import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.Translator
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP
import org.junit.Assert import org.junit.Assert
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
@ -13,19 +15,20 @@ import org.powermock.modules.junit4.PowerMockRunner
import java.io.File import java.io.File
@RunWith(PowerMockRunner::class) @RunWith(PowerMockRunner::class)
@PrepareForTest(File::class) @PrepareForTest(File::class, Translator::class)
class ClassicPrefsFormatTest : TestBase() { class ClassicPrefsFormatTest : TestBase() {
@Mock lateinit var resourceHelper: ResourceHelper @Mock lateinit var resourceHelper: ResourceHelper
@Mock lateinit var sp: SP @Mock lateinit var dateUtil: DateUtil
@Mock lateinit var translator: Translator
@Mock lateinit var profileFunction: ProfileFunction
@Mock lateinit var file: MockedFile @Mock lateinit var file: MockedFile
@Test @Test
fun preferenceLoadingTest() { fun preferenceLoadingTest() {
val test = "key1::val1\nkeyB::valB" val test = "key1::val1\nkeyB::valB"
val classicFormat = ClassicPrefsFormat(resourceHelper, SingleStringStorage(test)) val classicFormat = ClassicPrefsFormat(resourceHelper, dateUtil, translator, profileFunction, SingleStringStorage(test))
val prefs = classicFormat.loadPreferences(getMockedFile(), "") val prefs = classicFormat.loadPreferences(getMockedFile(), "")
Assert.assertEquals(prefs.values.size, 2) Assert.assertEquals(prefs.values.size, 2)
@ -37,7 +40,7 @@ class ClassicPrefsFormatTest : TestBase() {
@Test @Test
fun preferenceSavingTest() { fun preferenceSavingTest() {
val storage = SingleStringStorage("") val storage = SingleStringStorage("")
val classicFormat = ClassicPrefsFormat(resourceHelper, storage) val classicFormat = ClassicPrefsFormat(resourceHelper, dateUtil, translator, profileFunction, storage)
val prefs = Prefs( val prefs = Prefs(
mapOf( mapOf(
"key1" to "A", "key1" to "A",

View file

@ -17,4 +17,5 @@ android {
dependencies { dependencies {
implementation project(':core') implementation project(':core')
implementation project(':database')
} }

View file

@ -10,6 +10,7 @@ import android.view.ViewGroup
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.activities.TDDStatsActivity import info.nightscout.androidaps.activities.TDDStatsActivity
import info.nightscout.androidaps.dana.databinding.DanarFragmentBinding import info.nightscout.androidaps.dana.databinding.DanarFragmentBinding
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.dialogs.ProfileViewerDialog import info.nightscout.androidaps.dialogs.ProfileViewerDialog
import info.nightscout.androidaps.events.EventExtendedBolusChange import info.nightscout.androidaps.events.EventExtendedBolusChange
import info.nightscout.androidaps.events.EventInitializationChanged import info.nightscout.androidaps.events.EventInitializationChanged
@ -108,7 +109,7 @@ class DanaFragment : DaggerFragment() {
binding.btconnection.setOnLongClickListener { binding.btconnection.setOnLongClickListener {
activity?.let { activity?.let {
OKDialog.showConfirmation(it, resourceHelper.gs(R.string.resetpairing)) { OKDialog.showConfirmation(it, resourceHelper.gs(R.string.resetpairing)) {
uel.log("CLEAR PAIRING KEYS") uel.log(Action.CLEAR_PAIRING_KEYS)
(activePlugin.activePump as DanaPumpInterface).clearPairing() (activePlugin.activePump as DanaPumpInterface).clearPairing()
} }
} }

View file

@ -2,7 +2,7 @@
"formatVersion": 1, "formatVersion": 1,
"database": { "database": {
"version": 4, "version": 4,
"identityHash": "e8b8785efbd1699431eef90a5b441ed3", "identityHash": "c6cb19c6cfa6d0fb738b3f58818172ff",
"entities": [ "entities": [
{ {
"tableName": "apsResults", "tableName": "apsResults",
@ -2699,7 +2699,7 @@
}, },
{ {
"tableName": "userEntry", "tableName": "userEntry",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `action` TEXT NOT NULL, `s` TEXT NOT NULL, `d1` REAL NOT NULL, `d2` REAL NOT NULL, `i1` INTEGER NOT NULL, `i2` INTEGER NOT NULL)", "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `action` TEXT NOT NULL, `s` TEXT NOT NULL, `values` TEXT NOT NULL)",
"fields": [ "fields": [
{ {
"fieldPath": "id", "fieldPath": "id",
@ -2732,27 +2732,9 @@
"notNull": true "notNull": true
}, },
{ {
"fieldPath": "d1", "fieldPath": "values",
"columnName": "d1", "columnName": "values",
"affinity": "REAL", "affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "d2",
"columnName": "d2",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "i1",
"columnName": "i1",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "i2",
"columnName": "i2",
"affinity": "INTEGER",
"notNull": true "notNull": true
} }
], ],
@ -2769,7 +2751,7 @@
"views": [], "views": [],
"setupQueries": [ "setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'e8b8785efbd1699431eef90a5b441ed3')" "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'c6cb19c6cfa6d0fb738b3f58818172ff')"
] ]
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -6,7 +6,7 @@ import androidx.room.TypeConverters
import info.nightscout.androidaps.database.daos.* import info.nightscout.androidaps.database.daos.*
import info.nightscout.androidaps.database.entities.* import info.nightscout.androidaps.database.entities.*
const val DATABASE_VERSION = 5 const val DATABASE_VERSION = 6
@Database(version = DATABASE_VERSION, @Database(version = DATABASE_VERSION,
entities = [APSResult::class, Bolus::class, BolusCalculatorResult::class, Carbs::class, entities = [APSResult::class, Bolus::class, BolusCalculatorResult::class, Carbs::class,

View file

@ -5,11 +5,44 @@ import info.nightscout.androidaps.database.data.Block
import info.nightscout.androidaps.database.data.TargetBlock import info.nightscout.androidaps.database.data.TargetBlock
import info.nightscout.androidaps.database.embedments.InterfaceIDs import info.nightscout.androidaps.database.embedments.InterfaceIDs
import info.nightscout.androidaps.database.entities.* import info.nightscout.androidaps.database.entities.*
import info.nightscout.androidaps.database.entities.UserEntry.*
import org.json.JSONArray import org.json.JSONArray
import org.json.JSONObject import org.json.JSONObject
class Converters { class Converters {
@TypeConverter
fun fromAction(action: Action?) = action?.name
@TypeConverter
fun toAction(action: String?) = action?.let { Action.fromString(it) }
@TypeConverter
fun fromMutableListOfValueWithUnit(values: MutableList<ValueWithUnit>?): String? {
if (values == null) return null
val jsonArray = JSONArray()
values.forEach {
if (it.condition) {
val jsonObject = JSONObject()
jsonObject.put("dValue", it.dValue).put("iValue", it.iValue).put("lValue", it.lValue).put("sValue", it.sValue).put("unit", it.unit.name)
jsonArray.put(jsonObject)
}
}
return jsonArray.toString()
}
@TypeConverter
fun toMutableListOfValueWithUnit(jsonString: String?): MutableList<ValueWithUnit>? {
if (jsonString == null) return null
val jsonArray = JSONArray(jsonString)
val list = mutableListOf<ValueWithUnit>()
for (i in 0 until jsonArray.length()) {
val jsonObject = jsonArray.getJSONObject(i)
list.add(ValueWithUnit(jsonObject.getDouble("dValue"), jsonObject.getInt("iValue"), jsonObject.getLong("lValue"), jsonObject.getString("sValue"), Units.fromString(jsonObject.getString("unit"))))
}
return list
}
@TypeConverter @TypeConverter
fun fromBolusType(bolusType: Bolus.Type?) = bolusType?.name fun fromBolusType(bolusType: Bolus.Type?) = bolusType?.name

View file

@ -21,16 +21,17 @@ open class DatabaseModule {
internal fun provideAppDatabase(context: Context, @DbFileName fileName: String) = internal fun provideAppDatabase(context: Context, @DbFileName fileName: String) =
Room Room
.databaseBuilder(context, AppDatabase::class.java, fileName) .databaseBuilder(context, AppDatabase::class.java, fileName)
.addMigrations(migration1to2) .addMigrations(migration5to6)
.fallbackToDestructiveMigration() .fallbackToDestructiveMigration()
.build() .build()
@Qualifier @Qualifier
annotation class DbFileName annotation class DbFileName
private val migration1to2 = object : Migration(1, 2) { private val migration5to6 = object : Migration(5, 6) {
override fun migrate(database: SupportSQLiteDatabase) { override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("CREATE TABLE IF NOT EXISTS userEntry (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `action` TEXT NOT NULL, `s` TEXT NOT NULL, `d1` REAL NOT NULL, `d2` REAL NOT NULL, `i1` INTEGER NOT NULL, `i2` INTEGER NOT NULL)") database.execSQL("DROP TABLE IF EXISTS userEntry")
database.execSQL("CREATE TABLE userEntry (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `action` TEXT NOT NULL, `s` TEXT NOT NULL, `values` TEXT NOT NULL)")
} }
} }
} }

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.database.entities
import androidx.room.Entity import androidx.room.Entity
import androidx.room.PrimaryKey import androidx.room.PrimaryKey
import com.google.gson.annotations.SerializedName
import info.nightscout.androidaps.database.TABLE_USER_ENTRY import info.nightscout.androidaps.database.TABLE_USER_ENTRY
import info.nightscout.androidaps.database.interfaces.DBEntry import info.nightscout.androidaps.database.interfaces.DBEntry
import info.nightscout.androidaps.database.interfaces.DBEntryWithTime import info.nightscout.androidaps.database.interfaces.DBEntryWithTime
@ -13,10 +14,149 @@ data class UserEntry(
override var id: Long = 0L, override var id: Long = 0L,
override var timestamp: Long, override var timestamp: Long,
override var utcOffset: Long = TimeZone.getDefault().getOffset(timestamp).toLong(), override var utcOffset: Long = TimeZone.getDefault().getOffset(timestamp).toLong(),
var action: String, var action: Action,
var s: String, var s: String,
var d1: Double, var values: MutableList<ValueWithUnit>
var d2: Double, ) : DBEntry, DBEntryWithTime {
var i1: Int, enum class Action (val colorGroup: ColorGroup) {
var i2: Int @SerializedName("BOLUS") BOLUS (ColorGroup.InsulinTreatment),
) : DBEntry, DBEntryWithTime @SerializedName("BOLUS_ADVISOR") BOLUS_ADVISOR (ColorGroup.InsulinTreatment),
@SerializedName("BOLUS_RECORD") BOLUS_RECORD (ColorGroup.InsulinTreatment),
@SerializedName("EXTENDED_BOLUS") EXTENDED_BOLUS (ColorGroup.InsulinTreatment),
@SerializedName("SUPERBOLUS_TBR") SUPERBOLUS_TBR (ColorGroup.InsulinTreatment),
@SerializedName("CARBS") CARBS (ColorGroup.CarbTreatment),
@SerializedName("EXTENDED_CARBS") EXTENDED_CARBS (ColorGroup.CarbTreatment),
@SerializedName("TEMP_BASAL") TEMP_BASAL (ColorGroup.InsulinTreatment),
@SerializedName("TT") TT (ColorGroup.TT),
@SerializedName("NEW_PROFILE") NEW_PROFILE (ColorGroup.Profile),
@SerializedName("CLONE_PROFILE") CLONE_PROFILE (ColorGroup.Profile),
@SerializedName("STORE_PROFILE") STORE_PROFILE (ColorGroup.Profile),
@SerializedName("PROFILE_SWITCH") PROFILE_SWITCH (ColorGroup.Profile),
@SerializedName("PROFILE_SWITCH_CLONED") PROFILE_SWITCH_CLONED (ColorGroup.Profile),
@SerializedName("CLOSED_LOOP_MODE") CLOSED_LOOP_MODE (ColorGroup.Loop),
@SerializedName("LGS_LOOP_MODE") LGS_LOOP_MODE (ColorGroup.Loop),
@SerializedName("OPEN_LOOP_MODE") OPEN_LOOP_MODE (ColorGroup.Loop),
@SerializedName("LOOP_DISABLED") LOOP_DISABLED (ColorGroup.Loop),
@SerializedName("LOOP_ENABLED") LOOP_ENABLED (ColorGroup.Loop),
@SerializedName("RECONNECT") RECONNECT (ColorGroup.Pump),
@SerializedName("DISCONNECT") DISCONNECT (ColorGroup.Pump),
@SerializedName("RESUME") RESUME (ColorGroup.Loop),
@SerializedName("SUSPEND") SUSPEND (ColorGroup.Loop),
@SerializedName("HW_PUMP_ALLOWED") HW_PUMP_ALLOWED (ColorGroup.Pump),
@SerializedName("CLEAR_PAIRING_KEYS") CLEAR_PAIRING_KEYS (ColorGroup.Pump),
@SerializedName("ACCEPTS_TEMP_BASAL") ACCEPTS_TEMP_BASAL (ColorGroup.InsulinTreatment),
@SerializedName("CANCEL_TEMP_BASAL") CANCEL_TEMP_BASAL (ColorGroup.InsulinTreatment),
@SerializedName("CANCEL_EXTENDED_BOLUS") CANCEL_EXTENDED_BOLUS (ColorGroup.InsulinTreatment),
@SerializedName("CANCEL_TT") CANCEL_TT (ColorGroup.TT),
@SerializedName("CAREPORTAL") CAREPORTAL (ColorGroup.Careportal),
@SerializedName("CALIBRATION") CALIBRATION (ColorGroup.Careportal),
@SerializedName("PRIME_BOLUS") PRIME_BOLUS (ColorGroup.Careportal),
@SerializedName("TREATMENT") TREATMENT (ColorGroup.InsulinTreatment),
@SerializedName("CAREPORTAL_NS_REFRESH") CAREPORTAL_NS_REFRESH (ColorGroup.Aaps),
@SerializedName("PROFILE_SWITCH_NS_REFRESH") PROFILE_SWITCH_NS_REFRESH (ColorGroup.Aaps),
@SerializedName("TREATMENTS_NS_REFRESH") TREATMENTS_NS_REFRESH (ColorGroup.Aaps),
@SerializedName("TT_NS_REFRESH") TT_NS_REFRESH (ColorGroup.Aaps),
@SerializedName("AUTOMATION_REMOVED") AUTOMATION_REMOVED (ColorGroup.Aaps),
@SerializedName("BG_REMOVED") BG_REMOVED (ColorGroup.Careportal),
@SerializedName("CAREPORTAL_REMOVED") CAREPORTAL_REMOVED (ColorGroup.Careportal),
@SerializedName("EXTENDED_BOLUS_REMOVED") EXTENDED_BOLUS_REMOVED (ColorGroup.InsulinTreatment),
@SerializedName("FOOD_REMOVED") FOOD_REMOVED (ColorGroup.Careportal),
@SerializedName("PROFILE_REMOVED") PROFILE_REMOVED (ColorGroup.Profile),
@SerializedName("PROFILE_SWITCH_REMOVED") PROFILE_SWITCH_REMOVED (ColorGroup.Profile),
@SerializedName("RESTART_EVENTS_REMOVED") RESTART_EVENTS_REMOVED (ColorGroup.Aaps),
@SerializedName("TREATMENT_REMOVED") TREATMENT_REMOVED (ColorGroup.InsulinTreatment),
@SerializedName("TT_REMOVED") TT_REMOVED (ColorGroup.TT),
@SerializedName("NS_PAUSED") NS_PAUSED (ColorGroup.Aaps),
@SerializedName("NS_RESUME") NS_RESUME (ColorGroup.Aaps),
@SerializedName("NS_QUEUE_CLEARED") NS_QUEUE_CLEARED (ColorGroup.Aaps),
@SerializedName("NS_SETTINGS_COPIED") NS_SETTINGS_COPIED (ColorGroup.Aaps),
@SerializedName("ERROR_DIALOG_OK") ERROR_DIALOG_OK (ColorGroup.Aaps),
@SerializedName("ERROR_DIALOG_MUTE") ERROR_DIALOG_MUTE (ColorGroup.Aaps),
@SerializedName("ERROR_DIALOG_MUTE_5MIN") ERROR_DIALOG_MUTE_5MIN (ColorGroup.Aaps),
@SerializedName("OBJECTIVE_STARTED") OBJECTIVE_STARTED (ColorGroup.Aaps),
@SerializedName("OBJECTIVE_UNSTARTED") OBJECTIVE_UNSTARTED (ColorGroup.Aaps),
@SerializedName("OBJECTIVES_SKIPPED") OBJECTIVES_SKIPPED (ColorGroup.Aaps),
@SerializedName("STAT_RESET") STAT_RESET (ColorGroup.Aaps),
@SerializedName("DELETE_LOGS") DELETE_LOGS (ColorGroup.Aaps),
@SerializedName("DELETE_FUTURE_TREATMENTS") DELETE_FUTURE_TREATMENTS (ColorGroup.Aaps),
@SerializedName("EXPORT_SETTINGS") EXPORT_SETTINGS (ColorGroup.Aaps),
@SerializedName("IMPORT_SETTINGS") IMPORT_SETTINGS (ColorGroup.Aaps),
@SerializedName("RESET_DATABASES") RESET_DATABASES (ColorGroup.Aaps),
@SerializedName("EXPORT_DATABASES") EXPORT_DATABASES (ColorGroup.Aaps),
@SerializedName("IMPORT_DATABASES") IMPORT_DATABASES (ColorGroup.Aaps),
@SerializedName("OTP_EXPORT") OTP_EXPORT (ColorGroup.Aaps),
@SerializedName("OTP_RESET") OTP_RESET (ColorGroup.Aaps),
@SerializedName("SMS_BASAL") SMS_BASAL (ColorGroup.InsulinTreatment),
@SerializedName("SMS_BOLUS") SMS_BOLUS (ColorGroup.InsulinTreatment),
@SerializedName("SMS_CAL") SMS_CAL (ColorGroup.Careportal),
@SerializedName("SMS_CARBS") SMS_CARBS (ColorGroup.CarbTreatment),
@SerializedName("SMS_EXTENDED_BOLUS") SMS_EXTENDED_BOLUS (ColorGroup.InsulinTreatment),
@SerializedName("SMS_LOOP_DISABLED") SMS_LOOP_DISABLED (ColorGroup.Loop),
@SerializedName("SMS_LOOP_ENABLED") SMS_LOOP_ENABLED (ColorGroup.Loop),
@SerializedName("SMS_LOOP_RESUME") SMS_LOOP_RESUME (ColorGroup.Loop),
@SerializedName("SMS_LOOP_SUSPEND") SMS_LOOP_SUSPEND (ColorGroup.Loop),
@SerializedName("SMS_PROFILE") SMS_PROFILE (ColorGroup.Profile),
@SerializedName("SMS_PUMP_CONNECT") SMS_PUMP_CONNECT (ColorGroup.Pump),
@SerializedName("SMS_PUMP_DISCONNECT") SMS_PUMP_DISCONNECT (ColorGroup.Pump),
@SerializedName("SMS_SMS") SMS_SMS (ColorGroup.Aaps),
@SerializedName("SMS_TT") SMS_TT (ColorGroup.TT),
@SerializedName("TT_DELETED_FROM_NS") TT_DELETED_FROM_NS (ColorGroup.TT),
@SerializedName("CAREPORTAL_DELETED_FROM_NS") CAREPORTAL_DELETED_FROM_NS (ColorGroup.Careportal),
@SerializedName("CAREPORTAL_FROM_NS") CAREPORTAL_FROM_NS (ColorGroup.Careportal),
@SerializedName("TT_FROM_NS") TT_FROM_NS (ColorGroup.TT),
@SerializedName("TT_CANCELED_FROM_NS") TT_CANCELED_FROM_NS (ColorGroup.TT),
@SerializedName("EXPORT_CSV") EXPORT_CSV (ColorGroup.Aaps),
@SerializedName("UNKNOWN") UNKNOWN (ColorGroup.Aaps)
;
companion object {
fun fromString(source: String?) = values().firstOrNull { it.name == source } ?: UNKNOWN
}
}
data class ValueWithUnit (val dValue: Double=0.0, val iValue: Int=0, val lValue: Long=0, val sValue: String="", val unit: Units=Units.None, val condition:Boolean=true){
constructor(dvalue: Double, unit: Units, condition:Boolean = true) : this(dvalue, 0, 0, "", unit, condition)
constructor(ivalue: Int, unit: Units, condition:Boolean = true) : this(0.0, ivalue, 0, "", unit, condition)
constructor(lvalue: Long, unit: Units, condition:Boolean = true) : this(0.0,0, lvalue, "", unit, condition)
constructor(svalue: String, unit:Units) : this(0.0,0, 0, svalue, unit, svalue != "")
constructor(dvalue: Double, unit:String) : this(dvalue,0, 0, "", Units.fromText(unit))
constructor(rStringRef: Int, nbParam: Long) : this(0.0, rStringRef, nbParam, "", Units.R_String, !rStringRef.equals(0)) // additionnal constructors for formated strings with additional values as parameters (define number of parameters as long
fun value() : Any {
if (sValue != "") return sValue
if (!dValue.equals(0.0)) return dValue
if (!iValue.equals(0)) return iValue
return lValue
}
}
enum class Units(val text: String) {
@SerializedName("None") None (""), //Int or String
@SerializedName("Mg_Dl") Mg_Dl ("mg/dl"), //Double
@SerializedName("Mmol_L") Mmol_L ("mmol"), //Double
@SerializedName("Timestamp") Timestamp("Timestamp"), //long
@SerializedName("U") U ("U"), //Double
@SerializedName("U_H") U_H ("U/h"), //Double
@SerializedName("G") G ("g"), //Int
@SerializedName("M") M ("m"), //Int
@SerializedName("H") H ("h"), //Int
@SerializedName("Percent") Percent ("%"), //Int
@SerializedName("TherapyEvent") TherapyEvent ("TherapyEvent"), //String (All enum key translated by Translator function, mainly TherapyEvent)
@SerializedName("R_String") R_String ("R.string") //Int
;
companion object {
fun fromString(unit: String?) = values().firstOrNull { it.name == unit } ?: None
fun fromText(unit: String?) = values().firstOrNull { it.text == unit } ?: None
}
}
enum class ColorGroup() {
InsulinTreatment,
CarbTreatment,
TT,
Profile,
Loop,
Careportal,
Pump,
Aaps
}
}

View file

@ -1,26 +1,20 @@
package info.nightscout.androidaps.database.transactions package info.nightscout.androidaps.database.transactions
import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.database.entities.UserEntry
import info.nightscout.androidaps.database.entities.UserEntry.*
class UserEntryTransaction( class UserEntryTransaction(
val action: String, val action: Action,
val s: String = "", val s: String,
val d1: Double = 0.0, val values: MutableList<ValueWithUnit> = mutableListOf<ValueWithUnit>()
val d2: Double = 0.0,
val i1: Int = 0,
val i2: Int = 0,
) : Transaction<Unit>() { ) : Transaction<Unit>() {
override fun run() { override fun run() {
database.userEntryDao.insert(UserEntry( database.userEntryDao.insert(UserEntry(
timestamp = System.currentTimeMillis(), timestamp = System.currentTimeMillis(),
action = action, action = action,
s = s, s = s,
d1 = d1, values = values
d2 = d2,
i1 = i1,
i2 = i2
)) ))
} }
} }

View file

@ -780,7 +780,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
if ((clock.localDeviceTime.getYear() <= 2015) || (timeDiff <= 24 * 60 * 60)) { if ((clock.localDeviceTime.getYear() <= 2015) || (timeDiff <= 24 * 60 * 60)) {
aapsLogger.info(LTag.PUMP, "MedtronicPumpPlugin::checkTimeAndOptionallySetTime - Time difference is %d s. Set time on pump.", timeDiff); aapsLogger.info(LTag.PUMP, String.format(Locale.ENGLISH, "MedtronicPumpPlugin::checkTimeAndOptionallySetTime - Time difference is %d s. Set time on pump.", timeDiff));
rileyLinkMedtronicService.getMedtronicUIComm().executeCommand(MedtronicCommandType.SetRealTimeClock); rileyLinkMedtronicService.getMedtronicUIComm().executeCommand(MedtronicCommandType.SetRealTimeClock);
@ -790,13 +790,13 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
} }
} else { } else {
if ((clock.localDeviceTime.getYear() > 2015)) { if ((clock.localDeviceTime.getYear() > 2015)) {
aapsLogger.error("MedtronicPumpPlugin::checkTimeAndOptionallySetTime - Time difference over 24h requested [diff=%d s]. Doing nothing.", timeDiff); aapsLogger.error(String.format(Locale.ENGLISH, "MedtronicPumpPlugin::checkTimeAndOptionallySetTime - Time difference over 24h requested [diff=%d s]. Doing nothing.", timeDiff));
medtronicUtil.sendNotification(MedtronicNotificationType.TimeChangeOver24h, getResourceHelper(), rxBus); medtronicUtil.sendNotification(MedtronicNotificationType.TimeChangeOver24h, getResourceHelper(), rxBus);
} }
} }
} else { } else {
aapsLogger.info(LTag.PUMP, "MedtronicPumpPlugin::checkTimeAndOptionallySetTime - Time difference is %d s. Do nothing.", timeDiff); aapsLogger.info(LTag.PUMP, String.format(Locale.ENGLISH, "MedtronicPumpPlugin::checkTimeAndOptionallySetTime - Time difference is %d s. Do nothing.", timeDiff));
} }
scheduleNextRefresh(MedtronicStatusRefreshType.PumpTime, 0); scheduleNextRefresh(MedtronicStatusRefreshType.PumpTime, 0);

View file

@ -7,6 +7,7 @@ import org.joda.time.LocalDateTime;
import java.util.Calendar; import java.util.Calendar;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
@ -171,8 +172,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
PumpMessage pumpResponse = createResponseMessage(radioResponse.getPayload()); PumpMessage pumpResponse = createResponseMessage(radioResponse.getPayload());
if (!pumpResponse.isValid()) { if (!pumpResponse.isValid()) {
aapsLogger.warn(LTag.PUMPCOMM, "Response is invalid ! [interrupted=%b, timeout=%b]", rfSpyResponse.wasInterrupted(), aapsLogger.warn(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Response is invalid ! [interrupted=%b, timeout=%b]", rfSpyResponse.wasInterrupted(),
rfSpyResponse.wasTimeout()); rfSpyResponse.wasTimeout()));
} else { } else {
// radioResponse.rssi; // radioResponse.rssi;
@ -186,8 +187,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
medtronicUtil.setMedtronicPumpModel(pumpModel); medtronicUtil.setMedtronicPumpModel(pumpModel);
} }
aapsLogger.debug(LTag.PUMPCOMM, "isDeviceReachable. PumpModel is %s - Valid: %b (rssi=%d)", pumpModel.name(), valid, aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "isDeviceReachable. PumpModel is %s - Valid: %b (rssi=%d)", pumpModel.name(), valid,
radioResponse.rssi); radioResponse.rssi));
if (valid) { if (valid) {
if (state == PumpDeviceState.PumpUnreachable) if (state == PumpDeviceState.PumpUnreachable)
@ -245,7 +246,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
rval = sendAndListen(msg); rval = sendAndListen(msg);
if (debugSetCommands) if (debugSetCommands)
aapsLogger.debug(LTag.PUMPCOMM, "2nd Response: %s", rval); aapsLogger.debug(LTag.PUMPCOMM, "2nd Response: " + rval);
return rval; return rval;
} else { } else {
@ -258,7 +259,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
private PumpMessage runCommandWithFrames(MedtronicCommandType commandType, List<List<Byte>> frames) private PumpMessage runCommandWithFrames(MedtronicCommandType commandType, List<List<Byte>> frames)
throws RileyLinkCommunicationException { throws RileyLinkCommunicationException {
aapsLogger.debug(LTag.PUMPCOMM, "Run command with Frames: %s", commandType.name()); aapsLogger.debug(LTag.PUMPCOMM, "Run command with Frames: " + commandType.name());
PumpMessage rval = null; PumpMessage rval = null;
PumpMessage shortMessage = makePumpMessage(commandType, new CarelinkShortMessageBody(new byte[]{0})); PumpMessage shortMessage = makePumpMessage(commandType, new CarelinkShortMessageBody(new byte[]{0}));
@ -288,14 +289,14 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
// aapsLogger.debug(LTag.PUMPCOMM,"PumpResponse: " + rval); // aapsLogger.debug(LTag.PUMPCOMM,"PumpResponse: " + rval);
if (rval.commandType != MedtronicCommandType.CommandACK) { if (rval.commandType != MedtronicCommandType.CommandACK) {
aapsLogger.error(LTag.PUMPCOMM, "runCommandWithFrames: Pump did not ACK frame #%d", frameNr); aapsLogger.error(LTag.PUMPCOMM, "runCommandWithFrames: Pump did not ACK frame #" + frameNr);
aapsLogger.error(LTag.PUMPCOMM, "Run command with Frames FAILED (command=%s, response=%s)", commandType.name(), aapsLogger.error(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Run command with Frames FAILED (command=%s, response=%s)", commandType.name(),
rval.toString()); rval.toString()));
return new PumpMessage(aapsLogger, "No ACK after frame #" + frameNr); return new PumpMessage(aapsLogger, "No ACK after frame #" + frameNr);
} else { } else {
aapsLogger.debug(LTag.PUMPCOMM, "Run command with Frames: Got ACK response for frame #%d", frameNr); aapsLogger.debug(LTag.PUMPCOMM, "Run command with Frames: Got ACK response for frame #" + frameNr);
} }
frameNr++; frameNr++;
@ -326,7 +327,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
PumpMessage getHistoryMsg = makePumpMessage(MedtronicCommandType.GetHistoryData, PumpMessage getHistoryMsg = makePumpMessage(MedtronicCommandType.GetHistoryData,
new GetHistoryPageCarelinkMessageBody(pageNumber)); new GetHistoryPageCarelinkMessageBody(pageNumber));
aapsLogger.info(LTag.PUMPCOMM, "getPumpHistory: Page %d", pageNumber); aapsLogger.info(LTag.PUMPCOMM, "getPumpHistory: Page " + pageNumber);
// aapsLogger.info(LTag.PUMPCOMM,"getPumpHistoryPage("+pageNumber+"): "+ByteUtil.shortHexString(getHistoryMsg.getTxData())); // aapsLogger.info(LTag.PUMPCOMM,"getPumpHistoryPage("+pageNumber+"): "+ByteUtil.shortHexString(getHistoryMsg.getTxData()));
// Ask the pump to transfer history (we get first frame?) // Ask the pump to transfer history (we get first frame?)
@ -342,7 +343,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
failed = false; failed = false;
break; break;
} catch (RileyLinkCommunicationException e) { } catch (RileyLinkCommunicationException e) {
aapsLogger.error(LTag.PUMPCOMM, "First call for PumpHistory failed (retry=%d)", retries); aapsLogger.error(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "First call for PumpHistory failed (retry=%d)", retries));
failed = true; failed = true;
} }
} }
@ -379,7 +380,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
medtronicUtil.setCurrentCommand(MedtronicCommandType.GetHistoryData, pageNumber, medtronicUtil.setCurrentCommand(MedtronicCommandType.GetHistoryData, pageNumber,
currentResponse.getFrameNumber()); currentResponse.getFrameNumber());
aapsLogger.info(LTag.PUMPCOMM, "getPumpHistory: Got frame %d of Page %d", currentResponse.getFrameNumber(), pageNumber); aapsLogger.info(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "getPumpHistory: Got frame %d of Page %d", currentResponse.getFrameNumber(), pageNumber));
// Do we need to ask for the next frame? // Do we need to ask for the next frame?
if (expectedFrameNum < 16) { // This number may not be correct for pumps other than 522/722 if (expectedFrameNum < 16) { // This number may not be correct for pumps other than 522/722
expectedFrameNum++; expectedFrameNum++;
@ -390,16 +391,16 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
if (frameData == null) { if (frameData == null) {
aapsLogger.error(LTag.PUMPCOMM, "null frame data, retrying"); aapsLogger.error(LTag.PUMPCOMM, "null frame data, retrying");
} else if (currentResponse.getFrameNumber() != expectedFrameNum) { } else if (currentResponse.getFrameNumber() != expectedFrameNum) {
aapsLogger.warn(LTag.PUMPCOMM, "Expected frame number %d, received %d (retrying)", expectedFrameNum, aapsLogger.warn(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Expected frame number %d, received %d (retrying)", expectedFrameNum,
currentResponse.getFrameNumber()); currentResponse.getFrameNumber()));
} else if (frameData.length == 0) { } else if (frameData.length == 0) {
aapsLogger.warn(LTag.PUMPCOMM, "Frame has zero length, retrying"); aapsLogger.warn(LTag.PUMPCOMM, "Frame has zero length, retrying");
} }
failures++; failures++;
if (failures == 6) { if (failures == 6) {
aapsLogger.error(LTag.PUMPCOMM, aapsLogger.error(LTag.PUMPCOMM,
"getPumpHistory: 6 failures in attempting to download frame %d of page %d, giving up.", String.format(Locale.ENGLISH, "getPumpHistory: 6 failures in attempting to download frame %d of page %d, giving up.",
expectedFrameNum, pageNumber); expectedFrameNum, pageNumber));
done = true; // failure completion. done = true; // failure completion.
doneWithError = true; doneWithError = true;
} }
@ -415,7 +416,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
nextMsg = sendAndListen(ackMsg); nextMsg = sendAndListen(ackMsg);
break; break;
} catch (RileyLinkCommunicationException e) { } catch (RileyLinkCommunicationException e) {
aapsLogger.error(LTag.PUMPCOMM, "Problem acknowledging frame response. (retry=%d)", retries); aapsLogger.error(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Problem acknowledging frame response. (retry=%d)", retries));
} }
} }
@ -447,11 +448,11 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
List<PumpHistoryEntry> medtronicHistoryEntries = medtronicPumpHistoryDecoder.processPageAndCreateRecords(rawHistoryPage); List<PumpHistoryEntry> medtronicHistoryEntries = medtronicPumpHistoryDecoder.processPageAndCreateRecords(rawHistoryPage);
aapsLogger.debug(LTag.PUMPCOMM, "getPumpHistory: Found %d history entries.", medtronicHistoryEntries.size()); aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "getPumpHistory: Found %d history entries.", medtronicHistoryEntries.size()));
pumpTotalResult.addHistoryEntries(medtronicHistoryEntries, pageNumber); pumpTotalResult.addHistoryEntries(medtronicHistoryEntries, pageNumber);
aapsLogger.debug(LTag.PUMPCOMM, "getPumpHistory: Search status: Search finished: %b", pumpTotalResult.isSearchFinished()); aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "getPumpHistory: Search status: Search finished: %b", pumpTotalResult.isSearchFinished()));
if (pumpTotalResult.isSearchFinished()) { if (pumpTotalResult.isSearchFinished()) {
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Sleeping); medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Sleeping);
@ -563,7 +564,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
private Object sendAndGetResponseWithCheck(MedtronicCommandType commandType, byte[] bodyData) { private Object sendAndGetResponseWithCheck(MedtronicCommandType commandType, byte[] bodyData) {
aapsLogger.debug(LTag.PUMPCOMM, "getDataFromPump: %s", commandType); aapsLogger.debug(LTag.PUMPCOMM, "getDataFromPump: " + commandType);
for (int retries = 0; retries < MAX_COMMAND_TRIES; retries++) { for (int retries = 0; retries < MAX_COMMAND_TRIES; retries++) {
@ -578,7 +579,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
if (dataResponse != null) { if (dataResponse != null) {
this.errorMessage = null; this.errorMessage = null;
aapsLogger.debug(LTag.PUMPCOMM, "Converted response for %s is %s.", commandType.name(), dataResponse); aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Converted response for %s is %s.", commandType.name(), dataResponse));
return dataResponse; return dataResponse;
} else { } else {
@ -590,7 +591,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
} }
} catch (RileyLinkCommunicationException e) { } catch (RileyLinkCommunicationException e) {
aapsLogger.warn(LTag.PUMPCOMM, "Error getting response from RileyLink (error=%s, retry=%d)", e.getMessage(), retries + 1); aapsLogger.warn(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Error getting response from RileyLink (error=%s, retry=%d)", e.getMessage(), retries + 1));
} }
} }
@ -611,7 +612,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
if (contents != null) { if (contents != null) {
if (contents.length >= expectedLength) { if (contents.length >= expectedLength) {
aapsLogger.debug(LTag.PUMPCOMM, "%s: Content: %s", method, ByteUtil.shortHexString(contents)); aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "%s: Content: %s", method, ByteUtil.shortHexString(contents)));
return null; return null;
} else { } else {
@ -656,7 +657,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
MedtronicCommandType commandType = MedtronicCommandType.GetBasalProfileSTD; MedtronicCommandType commandType = MedtronicCommandType.GetBasalProfileSTD;
aapsLogger.debug(LTag.PUMPCOMM, "getDataFromPump: %s", commandType); aapsLogger.debug(LTag.PUMPCOMM, "getDataFromPump: " + commandType);
medtronicUtil.setCurrentCommand(commandType); medtronicUtil.setCurrentCommand(commandType);
@ -714,7 +715,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
BasalProfile basalProfile = (BasalProfile) medtronicConverter.convertResponse(medtronicPumpPlugin.getPumpDescription().getPumpType(), commandType, data); BasalProfile basalProfile = (BasalProfile) medtronicConverter.convertResponse(medtronicPumpPlugin.getPumpDescription().getPumpType(), commandType, data);
if (basalProfile != null) { if (basalProfile != null) {
aapsLogger.debug(LTag.PUMPCOMM, "Converted response for %s is %s.", commandType.name(), basalProfile); aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Converted response for %s is %s.", commandType.name(), basalProfile));
medtronicUtil.setCurrentCommand(null); medtronicUtil.setCurrentCommand(null);
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Sleeping); medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Sleeping);
@ -723,7 +724,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
} }
} catch (RileyLinkCommunicationException e) { } catch (RileyLinkCommunicationException e) {
aapsLogger.error(LTag.PUMPCOMM, "Error getting response from RileyLink (error=%s, retry=%d)", e.getMessage(), retries + 1); aapsLogger.error(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Error getting response from RileyLink (error=%s, retry=%d)", e.getMessage(), retries + 1));
} }
} }
@ -850,24 +851,24 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
wakeUp(false); wakeUp(false);
if (debugSetCommands) if (debugSetCommands)
aapsLogger.debug(LTag.PUMPCOMM, "%s: Body - %s", commandType.getCommandDescription(), aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "%s: Body - %s", commandType.getCommandDescription(),
ByteUtil.getHex(body)); ByteUtil.getHex(body)));
PumpMessage msg = makePumpMessage(commandType, new CarelinkLongMessageBody(body)); PumpMessage msg = makePumpMessage(commandType, new CarelinkLongMessageBody(body));
PumpMessage pumpMessage = runCommandWithArgs(msg); PumpMessage pumpMessage = runCommandWithArgs(msg);
if (debugSetCommands) if (debugSetCommands)
aapsLogger.debug(LTag.PUMPCOMM, "%s: %s", commandType.getCommandDescription(), pumpMessage.getResponseContent()); aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "%s: %s", commandType.getCommandDescription(), pumpMessage.getResponseContent()));
if (pumpMessage.commandType == MedtronicCommandType.CommandACK) { if (pumpMessage.commandType == MedtronicCommandType.CommandACK) {
return true; return true;
} else { } else {
aapsLogger.warn(LTag.PUMPCOMM, "We received non-ACK response from pump: %s", pumpMessage.getResponseContent()); aapsLogger.warn(LTag.PUMPCOMM, "We received non-ACK response from pump: " + pumpMessage.getResponseContent());
} }
} catch (RileyLinkCommunicationException e) { } catch (RileyLinkCommunicationException e) {
aapsLogger.warn(LTag.PUMPCOMM, "Error getting response from RileyLink (error=%s, retry=%d)", e.getMessage(), retries + 1); aapsLogger.warn(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Error getting response from RileyLink (error=%s, retry=%d)", e.getMessage(), retries + 1));
} }
} }
@ -903,11 +904,11 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
return true; return true;
} catch (RileyLinkCommunicationException e) { } catch (RileyLinkCommunicationException e) {
aapsLogger.warn(LTag.PUMPCOMM, "Error getting response from RileyLink (error=%s, retry=%d)", e.getMessage(), retries + 1); aapsLogger.warn(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Error getting response from RileyLink (error=%s, retry=%d)", e.getMessage(), retries + 1));
} }
if (responseMessage != null) if (responseMessage != null)
aapsLogger.warn(LTag.PUMPCOMM, "Set Basal Profile: Invalid response: commandType=%s,rawData=%s", responseMessage.commandType, ByteUtil.shortHexString(responseMessage.getRawContent())); aapsLogger.warn(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Set Basal Profile: Invalid response: commandType=%s,rawData=%s", responseMessage.commandType, ByteUtil.shortHexString(responseMessage.getRawContent())));
else else
aapsLogger.warn(LTag.PUMPCOMM, "Set Basal Profile: Null response."); aapsLogger.warn(LTag.PUMPCOMM, "Set Basal Profile: Null response.");
} }

View file

@ -4,6 +4,7 @@ import org.joda.time.IllegalFieldValueException;
import org.joda.time.LocalDateTime; import org.joda.time.LocalDateTime;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
@ -46,8 +47,8 @@ public class MedtronicConverter {
Object convertResponse(PumpType pumpType, MedtronicCommandType commandType, byte[] rawContent) { Object convertResponse(PumpType pumpType, MedtronicCommandType commandType, byte[] rawContent) {
if ((rawContent == null || rawContent.length < 1) && commandType != MedtronicCommandType.PumpModel) { if ((rawContent == null || rawContent.length < 1) && commandType != MedtronicCommandType.PumpModel) {
aapsLogger.warn(LTag.PUMPCOMM, "Content is empty or too short, no data to convert (type=%s,isNull=%b,length=%s)", aapsLogger.warn(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Content is empty or too short, no data to convert (type=%s,isNull=%b,length=%s)",
commandType.name(), rawContent == null, rawContent == null ? "-" : rawContent.length); commandType.name(), rawContent == null, rawContent == null ? "-" : rawContent.length));
return null; return null;
} }
@ -120,7 +121,7 @@ public class MedtronicConverter {
String rawModel = StringUtil.fromBytes(ByteUtil.substring(rawContent, 1, 3)); String rawModel = StringUtil.fromBytes(ByteUtil.substring(rawContent, 1, 3));
MedtronicDeviceType pumpModel = MedtronicDeviceType.getByDescription(rawModel); MedtronicDeviceType pumpModel = MedtronicDeviceType.getByDescription(rawModel);
aapsLogger.debug(LTag.PUMPCOMM, "PumpModel: [raw=%s, resolved=%s]", rawModel, pumpModel.name()); aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "PumpModel: [raw=%s, resolved=%s]", rawModel, pumpModel.name()));
if (pumpModel != MedtronicDeviceType.Unknown_Device) { if (pumpModel != MedtronicDeviceType.Unknown_Device) {
if (!medtronicUtil.isModelSet()) { if (!medtronicUtil.isModelSet()) {
@ -204,8 +205,8 @@ public class MedtronicConverter {
return pumpTime; return pumpTime;
} catch (IllegalFieldValueException e) { } catch (IllegalFieldValueException e) {
aapsLogger.error(LTag.PUMPCOMM, aapsLogger.error(LTag.PUMPCOMM,
"decodeTime: Failed to parse pump time value: year=%d, month=%d, hours=%d, minutes=%d, seconds=%d", String.format(Locale.ENGLISH, "decodeTime: Failed to parse pump time value: year=%d, month=%d, hours=%d, minutes=%d, seconds=%d",
year, month, day, hours, minutes, seconds); year, month, day, hours, minutes, seconds));
return null; return null;
} }

View file

@ -5,6 +5,7 @@ import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
@ -25,8 +26,8 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
public abstract class MedtronicHistoryDecoder<T extends MedtronicHistoryEntry> implements MedtronicHistoryDecoderInterface<T> { public abstract class MedtronicHistoryDecoder<T extends MedtronicHistoryEntry> implements MedtronicHistoryDecoderInterface<T> {
@Inject AAPSLogger aapsLogger; @Inject protected AAPSLogger aapsLogger;
@Inject MedtronicUtil medtronicUtil; @Inject protected MedtronicUtil medtronicUtil;
protected ByteUtil bitUtils; protected ByteUtil bitUtils;
@ -121,7 +122,7 @@ public abstract class MedtronicHistoryDecoder<T extends MedtronicHistoryEntry> i
aapsLogger.info(LTag.PUMPCOMM, "STATISTICS OF PUMP DECODE"); aapsLogger.info(LTag.PUMPCOMM, "STATISTICS OF PUMP DECODE");
if (unknownOpCodes.size() > 0) { if (unknownOpCodes.size() > 0) {
aapsLogger.warn(LTag.PUMPCOMM, "Unknown Op Codes: %s", sb.toString()); aapsLogger.warn(LTag.PUMPCOMM, "Unknown Op Codes: " + sb.toString());
} }
for (Map.Entry<RecordDecodeStatus, Map<String, String>> entry : mapStatistics.entrySet()) { for (Map.Entry<RecordDecodeStatus, Map<String, String>> entry : mapStatistics.entrySet()) {
@ -137,9 +138,9 @@ public abstract class MedtronicHistoryDecoder<T extends MedtronicHistoryEntry> i
String spaces = StringUtils.repeat(" ", 14 - entry.getKey().name().length()); String spaces = StringUtils.repeat(" ", 14 - entry.getKey().name().length());
aapsLogger.info(LTag.PUMPCOMM, " %s%s - %d. Elements: %s", entry.getKey().name(), spaces, entry.getValue().size(), sb.toString()); aapsLogger.info(LTag.PUMPCOMM, String.format(Locale.ENGLISH, " %s%s - %d. Elements: %s", entry.getKey().name(), spaces, entry.getValue().size(), sb.toString()));
} else { } else {
aapsLogger.info(LTag.PUMPCOMM, " %s - %d", entry.getKey().name(), entry.getValue().size()); aapsLogger.info(LTag.PUMPCOMM, String.format(Locale.ENGLISH, " %s - %d", entry.getKey().name(), entry.getValue().size()));
} }
} }
} }

View file

@ -171,7 +171,7 @@ public abstract class MedtronicHistoryEntry implements MedtronicHistoryEntryInte
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (this.DT == null) { if (this.DT == null) {
LOG.error("DT is null. RawData=%s", ByteUtil.getHex(this.rawData)); LOG.error("DT is null. RawData=" + ByteUtil.getHex(this.rawData));
} }
sb.append(getToStringStart()); sb.append(getToStringStart());

View file

@ -1,6 +1,7 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.history; package info.nightscout.androidaps.plugins.pump.medtronic.comm.history;
import java.util.Arrays; import java.util.Arrays;
import java.util.Locale;
import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.logging.LTag;
@ -53,8 +54,8 @@ public class RawHistoryPage {
int crcStored = ByteUtil.toInt(data[1022], data[1023]); int crcStored = ByteUtil.toInt(data[1022], data[1023]);
if (crcCalculated != crcStored) { if (crcCalculated != crcStored) {
aapsLogger.error(LTag.PUMPBTCOMM, "Stored CRC (%d) is different than calculated (%d), but ignored for now.", crcStored, aapsLogger.error(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Stored CRC (%d) is different than calculated (%d), but ignored for now.", crcStored,
crcCalculated); crcCalculated));
} else { } else {
if (MedtronicUtil.isLowLevelDebug()) if (MedtronicUtil.isLowLevelDebug())
aapsLogger.debug(LTag.PUMPBTCOMM, "CRC ok."); aapsLogger.debug(LTag.PUMPBTCOMM, "CRC ok.");
@ -81,6 +82,6 @@ public class RawHistoryPage {
offset += linesize; offset += linesize;
} }
aapsLogger.debug(LTag.PUMPBTCOMM, "History Page Data:\n%s", sb.toString()); aapsLogger.info(LTag.PUMPBTCOMM, "History Page Data:\n" + sb.toString());
} }
} }

View file

@ -32,9 +32,6 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
@Singleton @Singleton
public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHistoryEntry> { public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHistoryEntry> {
private final AAPSLogger aapsLogger;
private final MedtronicUtil medtronicUtil;
private PumpHistoryEntry tbrPreviousRecord; private PumpHistoryEntry tbrPreviousRecord;
private PumpHistoryEntry changeTimeRecord; private PumpHistoryEntry changeTimeRecord;
@ -43,7 +40,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
AAPSLogger aapsLogger, AAPSLogger aapsLogger,
MedtronicUtil medtronicUtil MedtronicUtil medtronicUtil
) { ) {
this.aapsLogger = aapsLogger; super.aapsLogger = aapsLogger;
this.medtronicUtil = medtronicUtil; this.medtronicUtil = medtronicUtil;
} }
@ -67,6 +64,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
int opCode = dataClear.get(counter); int opCode = dataClear.get(counter);
boolean special = false; boolean special = false;
incompletePacket = false; incompletePacket = false;
boolean skippedRecords = false;
if (opCode == 0) { if (opCode == 0) {
counter++; counter++;
@ -79,9 +77,14 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
if (skipped != null) { if (skipped != null) {
aapsLogger.warn(LTag.PUMPBTCOMM, " ... Skipped " + skipped); aapsLogger.warn(LTag.PUMPBTCOMM, " ... Skipped " + skipped);
skipped = null; skipped = null;
skippedRecords = true;
} }
} }
if (skippedRecords) {
aapsLogger.error(LTag.PUMPBTCOMM, "We had some skipped bytes, which might indicate error in pump history. Please report this problem.");
}
PumpHistoryEntryType entryType = PumpHistoryEntryType.getByCode(opCode); PumpHistoryEntryType entryType = PumpHistoryEntryType.getByCode(opCode);
PumpHistoryEntry pe = new PumpHistoryEntry(); PumpHistoryEntry pe = new PumpHistoryEntry();
@ -176,7 +179,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
try { try {
return decodeRecord(record, false); return decodeRecord(record, false);
} catch (Exception ex) { } catch (Exception ex) {
aapsLogger.error(LTag.PUMPBTCOMM, " Error decoding: type=%s, ex=%s", record.getEntryType().name(), ex.getMessage(), ex); aapsLogger.error(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, " Error decoding: type=%s, ex=%s", record.getEntryType().name(), ex.getMessage(), ex));
return RecordDecodeStatus.Error; return RecordDecodeStatus.Error;
} }
} }
@ -216,12 +219,12 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
case SelfTest: case SelfTest:
case JournalEntryInsulinMarker: case JournalEntryInsulinMarker:
case JournalEntryOtherMarker: case JournalEntryOtherMarker:
case ChangeBolusWizardSetup512: case BolusWizardSetup512:
case ChangeSensorSetup2: case ChangeSensorSetup2:
case ChangeSensorAlarmSilenceConfig: case ChangeSensorAlarmSilenceConfig:
case ChangeSensorRateOfChangeAlertSetup: case ChangeSensorRateOfChangeAlertSetup:
case ChangeBolusScrollStepSize: case ChangeBolusScrollStepSize:
case ChangeBolusWizardSetup: case BolusWizardSetup:
case ChangeVariableBolus: case ChangeVariableBolus:
case ChangeAudioBolus: case ChangeAudioBolus:
case ChangeBGReminderEnable: case ChangeBGReminderEnable:
@ -418,7 +421,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
//LOG.info("Basal Profile Start: offset={}, rate={}, index={}, body_raw={}", offset, rate, index, body); //LOG.info("Basal Profile Start: offset={}, rate={}, index={}, body_raw={}", offset, rate, index, body);
if (rate == null) { if (rate == null) {
aapsLogger.warn(LTag.PUMPBTCOMM, "Basal Profile Start (ERROR): offset=%d, rate=%.3f, index=%d, body_raw=%s", offset, rate, index, ByteUtil.getHex(body)); aapsLogger.warn(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Basal Profile Start (ERROR): offset=%d, rate=%.3f, index=%d, body_raw=%s", offset, rate, index, ByteUtil.getHex(body)));
return RecordDecodeStatus.Error; return RecordDecodeStatus.Error;
} else { } else {
entry.addDecodedData("Value", getFormattedFloat(rate, 3)); entry.addDecodedData("Value", getFormattedFloat(rate, 3));
@ -680,8 +683,8 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
//LOG.debug("DT: {} {} {}", year, month, dayOfMonth); //LOG.debug("DT: {} {} {}", year, month, dayOfMonth);
if (dayOfMonth == 32) { if (dayOfMonth == 32) {
aapsLogger.warn(LTag.PUMPBTCOMM, "Entry: Day 32 %s = [%s] %s", entry.getEntryType().name(), aapsLogger.warn(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Entry: Day 32 %s = [%s] %s", entry.getEntryType().name(),
ByteUtil.getHex(entry.getRawData()), entry); ByteUtil.getHex(entry.getRawData()), entry));
} }
if (isEndResults(entry.getEntryType())) { if (isEndResults(entry.getEntryType())) {

View file

@ -70,13 +70,14 @@ public class PumpHistoryEntry extends MedtronicHistoryEntry {
public String toString() { public String toString() {
Object object = this.getDecodedDataEntry("Object");
if (object == null) {
return super.toString(); return super.toString();
} else { // Object object = this.getDecodedDataEntry("Object");
return "PumpHistoryEntry [DT: " + DT + ", Object=" + object.toString() + "]"; //
} // if (object == null) {
// return super.toString();
// } else {
// return super.toString() + "PumpHistoryEntry [type=" + StringUtil.getStringInLength(entryType.name(), 20) + ", DT: " + DT + ", Object=" + object.toString() + "]";
// }
} }

View file

@ -89,7 +89,7 @@ public enum PumpHistoryEntryType // implements CodeEnum
/**/EventUnknown_MM522_0x4c(0x4c, "Unknown Event 0x4c", PumpHistoryEntryGroup.Unknown, 2, 5, 1), // /**/EventUnknown_MM522_0x4c(0x4c, "Unknown Event 0x4c", PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
/**/EventUnknown_0x4d(0x4d, "Unknown Event 0x4d", PumpHistoryEntryGroup.Unknown), // V5: 512: 7, 522: 8 ????NS /**/EventUnknown_0x4d(0x4d, "Unknown Event 0x4d", PumpHistoryEntryGroup.Unknown), // V5: 512: 7, 522: 8 ????NS
/**/EventUnknown_MM512_0x4e(0x4e, "Unknown Event 0x4e", PumpHistoryEntryGroup.Unknown), // /**/ /**/EventUnknown_MM512_0x4e(0x4e, "Unknown Event 0x4e", PumpHistoryEntryGroup.Unknown), // /**/
ChangeBolusWizardSetup512(0x4f, "Bolus Wizard Setup (512)", PumpHistoryEntryGroup.Configuration, 2, 5, 32), // BolusWizardSetup512(0x4f, "Bolus Wizard Setup (512)", PumpHistoryEntryGroup.Configuration, 2, 5, 32), //
ChangeSensorSetup2(0x50, "Sensor Setup2", PumpHistoryEntryGroup.Configuration, 2, 5, 30), // Ian50 ChangeSensorSetup2(0x50, "Sensor Setup2", PumpHistoryEntryGroup.Configuration, 2, 5, 30), // Ian50
/**/Sensor_0x51(0x51, "Unknown Event 0x51", PumpHistoryEntryGroup.Unknown), // /**/Sensor_0x51(0x51, "Unknown Event 0x51", PumpHistoryEntryGroup.Unknown), //
/**/Sensor_0x52(0x52, "Unknown Event 0x52", PumpHistoryEntryGroup.Unknown), // /**/Sensor_0x52(0x52, "Unknown Event 0x52", PumpHistoryEntryGroup.Unknown), //
@ -102,8 +102,8 @@ public enum PumpHistoryEntryType // implements CodeEnum
// V4 // V4
// Andy58(0x58, "Unknown", 13, 5, 0), // TO DO is this one really there ??? // Andy58(0x58, "Unknown", 13, 5, 0), // TO DO is this one really there ???
BolusWizardSetup(0x5a, "Bolus Wizard Setup (522)", PumpHistoryEntryGroup.Configuration, 2, 5, 117),
ChangeBolusWizardSetup(0x5a, "Bolus Wizard Setup (512)", PumpHistoryEntryGroup.Configuration, 2, 5, 137), // V2: 522+[B=143] // V6 124 -> 144 // V2: 522+[B=143]; V6: 124, v6: 137, v7: 117/137 [523]
BolusWizard(0x5b, "Bolus Wizard Estimate", PumpHistoryEntryGroup.Configuration, 2, 5, 13), // 15 // BolusWizard(0x5b, "Bolus Wizard Estimate", PumpHistoryEntryGroup.Configuration, 2, 5, 13), // 15 //
UnabsorbedInsulin(0x5c, "Unabsorbed Insulin", PumpHistoryEntryGroup.Statistic, 5, 0, 0), // head[1] -> body UnabsorbedInsulin(0x5c, "Unabsorbed Insulin", PumpHistoryEntryGroup.Statistic, 5, 0, 0), // head[1] -> body
SaveSettings(0x5d, "Save Settings", PumpHistoryEntryGroup.Configuration), // SaveSettings(0x5d, "Save Settings", PumpHistoryEntryGroup.Configuration), //
@ -212,9 +212,7 @@ public enum PumpHistoryEntryType // implements CodeEnum
static void setSpecialRulesForEntryTypes() { static void setSpecialRulesForEntryTypes() {
EndResultTotals.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 3)); EndResultTotals.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 3));
Bolus.addSpecialRuleHead(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 8)); Bolus.addSpecialRuleHead(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 8));
// BolusWizardChange.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_522andHigher, 143)); BolusWizardSetup.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 137));
//ChangeBolusWizardSetup.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 137)); // V5:
// 522 has old form
BolusWizard.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 15)); BolusWizard.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 15));
BolusReminder.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 2)); BolusReminder.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 2));
ChangeSensorSetup2.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 34)); ChangeSensorSetup2.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 34));

View file

@ -89,13 +89,13 @@ public class PumpHistoryResult {
} }
break; break;
case Date: { case Date: {
aapsLogger.debug(LTag.PUMPCOMM, "PE. Date search: Search date: %d", this.searchDate); aapsLogger.debug(LTag.PUMPCOMM, "PE. Date search: Search date: " + this.searchDate);
for (PumpHistoryEntry unprocessedEntry : unprocessedEntries) { for (PumpHistoryEntry unprocessedEntry : unprocessedEntries) {
if (unprocessedEntry.atechDateTime == null || unprocessedEntry.atechDateTime == 0) { if (unprocessedEntry.atechDateTime == null || unprocessedEntry.atechDateTime == 0) {
aapsLogger.debug(LTag.PUMPCOMM, "PE. PumpHistoryResult. Search entry date: Entry with no date: %s", unprocessedEntry); aapsLogger.debug(LTag.PUMPCOMM, "PE. PumpHistoryResult. Search entry date: Entry with no date: " + unprocessedEntry);
continue; continue;
} }

View file

@ -4,6 +4,7 @@ import org.joda.time.DateTimeZone;
import org.joda.time.Duration; import org.joda.time.Duration;
import java.util.Date; import java.util.Date;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
@ -85,10 +86,10 @@ public class MedtronicUIPostprocessor {
} else { } else {
uiTask.responseType = MedtronicUIResponseType.Error; uiTask.responseType = MedtronicUIResponseType.Error;
uiTask.errorDescription = "No profile found."; uiTask.errorDescription = "No profile found.";
aapsLogger.error("Basal Profile was NOT valid. [%s]", basalProfile.basalProfileToStringError()); aapsLogger.error(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Basal Profile was NOT valid. [%s]", basalProfile.basalProfileToStringError()));
} }
} catch (Exception ex) { } catch (Exception ex) {
aapsLogger.error("Basal Profile was returned, but was invalid. [%s]", basalProfile.basalProfileToStringError()); aapsLogger.error(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Basal Profile was returned, but was invalid. [%s]", basalProfile.basalProfileToStringError()));
uiTask.responseType = MedtronicUIResponseType.Error; uiTask.responseType = MedtronicUIResponseType.Error;
uiTask.errorDescription = "No profile found."; uiTask.errorDescription = "No profile found.";
} }
@ -121,7 +122,7 @@ public class MedtronicUIPostprocessor {
case SetRealTimeClock: { case SetRealTimeClock: {
boolean response = (Boolean) uiTask.returnData; boolean response = (Boolean) uiTask.returnData;
aapsLogger.debug(LTag.PUMP, "New time was %s set.", response ? "" : "NOT"); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "New time was %s set.", response ? "" : "NOT"));
if (response) { if (response) {
medtronicUtil.getPumpTime().timeDifference = 0; medtronicUtil.getPumpTime().timeDifference = 0;
@ -139,7 +140,7 @@ public class MedtronicUIPostprocessor {
medtronicPumpStatus.batteryVoltage = batteryStatusDTO.voltage; medtronicPumpStatus.batteryVoltage = batteryStatusDTO.voltage;
} }
aapsLogger.debug(LTag.PUMP, "BatteryStatus: %s", batteryStatusDTO.toString()); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "BatteryStatus: %s", batteryStatusDTO.toString()));
} }
break; break;
@ -236,14 +237,14 @@ public class MedtronicUIPostprocessor {
checkValue = settings.get("PCFG_MAX_BOLUS"); checkValue = settings.get("PCFG_MAX_BOLUS");
if (!MedtronicUtil.isSame(Double.parseDouble(checkValue.value), medtronicPumpStatus.maxBolus)) { if (!MedtronicUtil.isSame(Double.parseDouble(checkValue.value), medtronicPumpStatus.maxBolus)) {
aapsLogger.error("Wrong Max Bolus set on Pump (current=%s, required=%.2f).", checkValue.value, medtronicPumpStatus.maxBolus); aapsLogger.error(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Wrong Max Bolus set on Pump (current=%s, required=%.2f).", checkValue.value, medtronicPumpStatus.maxBolus));
medtronicUtil.sendNotification(MedtronicNotificationType.PumpWrongMaxBolusSet, resourceHelper, rxBus, medtronicPumpStatus.maxBolus); medtronicUtil.sendNotification(MedtronicNotificationType.PumpWrongMaxBolusSet, resourceHelper, rxBus, medtronicPumpStatus.maxBolus);
} }
checkValue = settings.get("PCFG_MAX_BASAL"); checkValue = settings.get("PCFG_MAX_BASAL");
if (!MedtronicUtil.isSame(Double.parseDouble(checkValue.value), medtronicPumpStatus.maxBasal)) { if (!MedtronicUtil.isSame(Double.parseDouble(checkValue.value), medtronicPumpStatus.maxBasal)) {
aapsLogger.error("Wrong Max Basal set on Pump (current=%s, required=%.2f).", checkValue.value, medtronicPumpStatus.maxBasal); aapsLogger.error(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Wrong Max Basal set on Pump (current=%s, required=%.2f).", checkValue.value, medtronicPumpStatus.maxBasal));
medtronicUtil.sendNotification(MedtronicNotificationType.PumpWrongMaxBasalSet, resourceHelper, rxBus, medtronicPumpStatus.maxBasal); medtronicUtil.sendNotification(MedtronicNotificationType.PumpWrongMaxBasalSet, resourceHelper, rxBus, medtronicPumpStatus.maxBasal);
} }

View file

@ -2,6 +2,8 @@ package info.nightscout.androidaps.plugins.pump.medtronic.comm.ui;
import org.joda.time.LocalDateTime; import org.joda.time.LocalDateTime;
import java.util.Locale;
import javax.inject.Inject; import javax.inject.Inject;
import dagger.android.HasAndroidInjector; import dagger.android.HasAndroidInjector;
@ -59,7 +61,7 @@ public class MedtronicUITask {
public void execute(MedtronicCommunicationManager communicationManager) { public void execute(MedtronicCommunicationManager communicationManager) {
aapsLogger.debug(LTag.PUMP, "MedtronicUITask: @@@ In execute. %s", commandType); aapsLogger.debug(LTag.PUMP, "MedtronicUITask: @@@ In execute. " + commandType);
switch (commandType) { switch (commandType) {
case PumpModel: { case PumpModel: {
@ -141,7 +143,7 @@ public class MedtronicUITask {
break; break;
default: { default: {
aapsLogger.warn(LTag.PUMP, "This commandType is not supported (yet) - %s.", commandType); aapsLogger.warn(LTag.PUMP, String.format(Locale.ENGLISH, "This commandType is not supported (yet) - %s.", commandType));
// invalid = true; // invalid = true;
responseType = MedtronicUIResponseType.Invalid; responseType = MedtronicUIResponseType.Invalid;
} }
@ -194,7 +196,7 @@ public class MedtronicUITask {
void postProcess(MedtronicUIPostprocessor postprocessor) { void postProcess(MedtronicUIPostprocessor postprocessor) {
aapsLogger.debug(LTag.PUMP, "MedtronicUITask: @@@ In execute. %s", commandType); aapsLogger.debug(LTag.PUMP, "MedtronicUITask: @@@ In execute. " + commandType);
if (responseType == MedtronicUIResponseType.Data) { if (responseType == MedtronicUIResponseType.Data) {
postprocessor.postProcessData(this); postprocessor.postProcessData(this);

View file

@ -171,7 +171,7 @@ public class MedtronicHistoryData {
if (StringUtils.isNotBlank(data)) { if (StringUtils.isNotBlank(data)) {
for (final String token : StringUtil.splitString(data, 3500)) { for (final String token : StringUtil.splitString(data, 3500)) {
aapsLogger.debug(LTag.PUMP, "%s", token); aapsLogger.debug(LTag.PUMP, token);
} }
} else { } else {
aapsLogger.debug(LTag.PUMP, "No data."); aapsLogger.debug(LTag.PUMP, "No data.");
@ -232,7 +232,7 @@ public class MedtronicHistoryData {
sort(this.newHistory); sort(this.newHistory);
} }
aapsLogger.debug(LTag.PUMP, "New History entries found: %d", this.newHistory.size()); aapsLogger.debug(LTag.PUMP, "New History entries found: " + this.newHistory.size());
showLogs("List of history (after filtering): [" + this.newHistory.size() + "]", gson().toJson(this.newHistory)); showLogs("List of history (after filtering): [" + this.newHistory.size() + "]", gson().toJson(this.newHistory));
@ -313,8 +313,8 @@ public class MedtronicHistoryData {
this.sort(this.allHistory); this.sort(this.allHistory);
aapsLogger.debug(LTag.PUMP, "All History records [afterFilterCount=%d, removedItemsCount=%d, newItemsCount=%d]", aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "All History records [afterFilterCount=%d, removedItemsCount=%d, newItemsCount=%d]",
allHistory.size(), removeList.size(), newHistory.size()); allHistory.size(), removeList.size(), newHistory.size()));
} else { } else {
aapsLogger.error("Since we couldn't determine date, we don't clean full history. This is just workaround."); aapsLogger.error("Since we couldn't determine date, we don't clean full history. This is just workaround.");
} }
@ -360,7 +360,7 @@ public class MedtronicHistoryData {
pumpHistoryEntryType == PumpHistoryEntryType.BatteryChange || // pumpHistoryEntryType == PumpHistoryEntryType.BatteryChange || //
pumpHistoryEntryType == PumpHistoryEntryType.Prime); pumpHistoryEntryType == PumpHistoryEntryType.Prime);
aapsLogger.debug(LTag.PUMP, "isPumpSuspended. Last entry type=%s, isSuspended=%b", pumpHistoryEntryType, isSuspended); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "isPumpSuspended. Last entry type=%s, isSuspended=%b", pumpHistoryEntryType, isSuspended));
return isSuspended; return isSuspended;
} else } else
@ -433,13 +433,13 @@ public class MedtronicHistoryData {
// Prime (for reseting autosense) // Prime (for reseting autosense)
List<PumpHistoryEntry> primeRecords = getFilteredItems(PumpHistoryEntryType.Prime); List<PumpHistoryEntry> primeRecords = getFilteredItems(PumpHistoryEntryType.Prime);
aapsLogger.debug(LTag.PUMP, "ProcessHistoryData: Prime [count=%d, items=%s]", primeRecords.size(), gson().toJson(primeRecords)); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "ProcessHistoryData: Prime [count=%d, items=%s]", primeRecords.size(), gson().toJson(primeRecords)));
if (isCollectionNotEmpty(primeRecords)) { if (isCollectionNotEmpty(primeRecords)) {
try { try {
processPrime(primeRecords); processPrime(primeRecords);
} catch (Exception ex) { } catch (Exception ex) {
aapsLogger.error("ProcessHistoryData: Error processing Prime entries: " + ex.getMessage(), ex); aapsLogger.error(LTag.PUMP, "ProcessHistoryData: Error processing Prime entries: " + ex.getMessage(), ex);
throw ex; throw ex;
} }
} }
@ -447,13 +447,13 @@ public class MedtronicHistoryData {
// Rewind (for marking insulin change) // Rewind (for marking insulin change)
List<PumpHistoryEntry> rewindRecords = getFilteredItems(PumpHistoryEntryType.Rewind); List<PumpHistoryEntry> rewindRecords = getFilteredItems(PumpHistoryEntryType.Rewind);
aapsLogger.debug(LTag.PUMP, "ProcessHistoryData: Rewind [count=%d, items=%s]", rewindRecords.size(), gson().toJson(rewindRecords)); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "ProcessHistoryData: Rewind [count=%d, items=%s]", rewindRecords.size(), gson().toJson(rewindRecords)));
if (isCollectionNotEmpty(rewindRecords)) { if (isCollectionNotEmpty(rewindRecords)) {
try { try {
processRewind(rewindRecords); processRewind(rewindRecords);
} catch (Exception ex) { } catch (Exception ex) {
aapsLogger.error("ProcessHistoryData: Error processing Rewind entries: " + ex.getMessage(), ex); aapsLogger.error(LTag.PUMP, "ProcessHistoryData: Error processing Rewind entries: " + ex.getMessage(), ex);
throw ex; throw ex;
} }
} }
@ -461,7 +461,7 @@ public class MedtronicHistoryData {
// TDD // TDD
List<PumpHistoryEntry> tdds = getFilteredItems(PumpHistoryEntryType.EndResultTotals, getTDDType()); List<PumpHistoryEntry> tdds = getFilteredItems(PumpHistoryEntryType.EndResultTotals, getTDDType());
aapsLogger.debug(LTag.PUMP, "ProcessHistoryData: TDD [count=%d, items=%s]", tdds.size(), gson().toJson(tdds)); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "ProcessHistoryData: TDD [count=%d, items=%s]", tdds.size(), gson().toJson(tdds)));
if (isCollectionNotEmpty(tdds)) { if (isCollectionNotEmpty(tdds)) {
try { try {
@ -477,13 +477,13 @@ public class MedtronicHistoryData {
// Bolus // Bolus
List<PumpHistoryEntry> treatments = getFilteredItems(PumpHistoryEntryType.Bolus); List<PumpHistoryEntry> treatments = getFilteredItems(PumpHistoryEntryType.Bolus);
aapsLogger.debug(LTag.PUMP, "ProcessHistoryData: Bolus [count=%d, items=%s]", treatments.size(), gson().toJson(treatments)); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "ProcessHistoryData: Bolus [count=%d, items=%s]", treatments.size(), gson().toJson(treatments)));
if (treatments.size() > 0) { if (treatments.size() > 0) {
try { try {
processBolusEntries(treatments); processBolusEntries(treatments);
} catch (Exception ex) { } catch (Exception ex) {
aapsLogger.error("ProcessHistoryData: Error processing Bolus entries: " + ex.getMessage(), ex); aapsLogger.error(LTag.PUMP, "ProcessHistoryData: Error processing Bolus entries: " + ex.getMessage(), ex);
throw ex; throw ex;
} }
} }
@ -491,13 +491,13 @@ public class MedtronicHistoryData {
// TBR // TBR
List<PumpHistoryEntry> tbrs = getFilteredItems(PumpHistoryEntryType.TempBasalCombined); List<PumpHistoryEntry> tbrs = getFilteredItems(PumpHistoryEntryType.TempBasalCombined);
aapsLogger.debug(LTag.PUMP, "ProcessHistoryData: TBRs Processed [count=%d, items=%s]", tbrs.size(), gson().toJson(tbrs)); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "ProcessHistoryData: TBRs Processed [count=%d, items=%s]", tbrs.size(), gson().toJson(tbrs)));
if (tbrs.size() > 0) { if (tbrs.size() > 0) {
try { try {
processTBREntries(tbrs); processTBREntries(tbrs);
} catch (Exception ex) { } catch (Exception ex) {
aapsLogger.error("ProcessHistoryData: Error processing TBR entries: " + ex.getMessage(), ex); aapsLogger.error(LTag.PUMP, "ProcessHistoryData: Error processing TBR entries: " + ex.getMessage(), ex);
throw ex; throw ex;
} }
} }
@ -512,14 +512,14 @@ public class MedtronicHistoryData {
throw ex; throw ex;
} }
aapsLogger.debug(LTag.PUMP, "ProcessHistoryData: 'Delivery Suspend' Processed [count=%d, items=%s]", suspends.size(), aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "ProcessHistoryData: 'Delivery Suspend' Processed [count=%d, items=%s]", suspends.size(),
gson().toJson(suspends)); gson().toJson(suspends)));
if (isCollectionNotEmpty(suspends)) { if (isCollectionNotEmpty(suspends)) {
try { try {
processSuspends(suspends); processSuspends(suspends);
} catch (Exception ex) { } catch (Exception ex) {
aapsLogger.error("ProcessHistoryData: Error processing Suspends entries: " + ex.getMessage(), ex); aapsLogger.error(LTag.PUMP, "ProcessHistoryData: Error processing Suspends entries: " + ex.getMessage(), ex);
throw ex; throw ex;
} }
} }
@ -586,7 +586,9 @@ public class MedtronicHistoryData {
private void uploadCareportalEvent(long date, TherapyEvent.Type event) { private void uploadCareportalEvent(long date, TherapyEvent.Type event) {
if (repository.getTherapyEventByTimestamp(event, date) != null) return; if (repository.getTherapyEventByTimestamp(event, date) != null) return;
disposable.add(repository.runTransactionForResult(new InsertTherapyEventIfNewTransaction(date, event, 0, null, sp.getString("careportal_enteredby", "AndroidAPS"), null, null, null)) disposable.add(repository.runTransactionForResult(new InsertTherapyEventIfNewTransaction(date,
event, 0, null, sp.getString("careportal_enteredby", "AndroidAPS"),
null, null, TherapyEvent.GlucoseUnit.MGDL))
.subscribe( .subscribe(
result -> result.getInserted().forEach(nsUpload::uploadEvent), result -> result.getInserted().forEach(nsUpload::uploadEvent),
error -> aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", error) error -> aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", error)
@ -597,7 +599,7 @@ public class MedtronicHistoryData {
List<PumpHistoryEntry> tdds = filterTDDs(tddsIn); List<PumpHistoryEntry> tdds = filterTDDs(tddsIn);
aapsLogger.debug(LTag.PUMP, getLogPrefix() + "TDDs found: %d.\n%s", tdds.size(), gson().toJson(tdds)); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, getLogPrefix() + "TDDs found: %d.\n%s", tdds.size(), gson().toJson(tdds)));
List<TDD> tddsDb = databaseHelper.getTDDsForLastXDays(3); List<TDD> tddsDb = databaseHelper.getTDDsForLastXDays(3);
@ -613,7 +615,7 @@ public class MedtronicHistoryData {
TDD tddNew = new TDD(); TDD tddNew = new TDD();
totalsDTO.setTDD(tddNew); totalsDTO.setTDD(tddNew);
aapsLogger.debug(LTag.PUMP, "TDD Add: %s", tddNew); aapsLogger.debug(LTag.PUMP, "TDD Add: " + tddNew);
databaseHelper.createOrUpdateTDD(tddNew); databaseHelper.createOrUpdateTDD(tddNew);
@ -622,7 +624,7 @@ public class MedtronicHistoryData {
if (!totalsDTO.doesEqual(tddDbEntry)) { if (!totalsDTO.doesEqual(tddDbEntry)) {
totalsDTO.setTDD(tddDbEntry); totalsDTO.setTDD(tddDbEntry);
aapsLogger.debug(LTag.PUMP, "TDD Edit: %s", tddDbEntry); aapsLogger.debug(LTag.PUMP, "TDD Edit: " + tddDbEntry);
databaseHelper.createOrUpdateTDD(tddDbEntry); databaseHelper.createOrUpdateTDD(tddDbEntry);
} }
@ -656,8 +658,8 @@ public class MedtronicHistoryData {
List<? extends DbObjectBase> entriesFromHistory = getDatabaseEntriesByLastTimestamp(oldestTimestamp, ProcessHistoryRecord.Bolus); List<? extends DbObjectBase> entriesFromHistory = getDatabaseEntriesByLastTimestamp(oldestTimestamp, ProcessHistoryRecord.Bolus);
if (doubleBolusDebug) if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: List (before filter): %s, FromDb=%s", gson().toJson(entryList), aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: List (before filter): %s, FromDb=%s", gson().toJson(entryList),
gsonCore().toJson(entriesFromHistory)); gsonCore().toJson(entriesFromHistory)));
filterOutAlreadyAddedEntries(entryList, entriesFromHistory); filterOutAlreadyAddedEntries(entryList, entriesFromHistory);
@ -670,23 +672,23 @@ public class MedtronicHistoryData {
filterOutNonInsulinEntries(entriesFromHistory); filterOutNonInsulinEntries(entriesFromHistory);
if (doubleBolusDebug) if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: List (after filter): %s, FromDb=%s", gson().toJson(entryList), aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: List (after filter): %s, FromDb=%s", gson().toJson(entryList),
gsonCore().toJson(entriesFromHistory)); gsonCore().toJson(entriesFromHistory)));
if (isCollectionEmpty(entriesFromHistory)) { if (isCollectionEmpty(entriesFromHistory)) {
for (PumpHistoryEntry treatment : entryList) { for (PumpHistoryEntry treatment : entryList) {
aapsLogger.debug(LTag.PUMP, "Add Bolus (no db entry): " + treatment); aapsLogger.debug(LTag.PUMP, "Add Bolus (no db entry): " + treatment);
if (doubleBolusDebug) if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: Add Bolus: FromDb=null, Treatment=%s", treatment); aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: Add Bolus: FromDb=null, Treatment=" + treatment);
addBolus(treatment, null); addBolus(treatment, null);
} }
} else { } else {
for (PumpHistoryEntry treatment : entryList) { for (PumpHistoryEntry treatment : entryList) {
DbObjectBase treatmentDb = findDbEntry(treatment, entriesFromHistory); DbObjectBase treatmentDb = findDbEntry(treatment, entriesFromHistory);
aapsLogger.debug(LTag.PUMP, "Add Bolus %s - (entryFromDb=%s) ", treatment, treatmentDb); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "Add Bolus %s - (entryFromDb=%s) ", treatment, treatmentDb));
if (doubleBolusDebug) if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: Add Bolus: FromDb=%s, Treatment=%s", treatmentDb, treatment); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: Add Bolus: FromDb=%s, Treatment=%s", treatmentDb, treatment));
addBolus(treatment, (Treatment) treatmentDb); addBolus(treatment, (Treatment) treatmentDb);
} }
@ -734,8 +736,8 @@ public class MedtronicHistoryData {
List<? extends DbObjectBase> entriesFromHistory = getDatabaseEntriesByLastTimestamp(oldestTimestamp, ProcessHistoryRecord.TBR); List<? extends DbObjectBase> entriesFromHistory = getDatabaseEntriesByLastTimestamp(oldestTimestamp, ProcessHistoryRecord.TBR);
aapsLogger.debug(LTag.PUMP, ProcessHistoryRecord.TBR.getDescription() + " List (before filter): %s, FromDb=%s", gson().toJson(entryList), aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, ProcessHistoryRecord.TBR.getDescription() + " List (before filter): %s, FromDb=%s", gson().toJson(entryList),
gson().toJson(entriesFromHistory)); gson().toJson(entriesFromHistory)));
TempBasalProcessDTO processDTO = null; TempBasalProcessDTO processDTO = null;
@ -755,7 +757,7 @@ public class MedtronicHistoryData {
readOldItem = false; readOldItem = false;
} }
} else { } else {
aapsLogger.error("processDTO was null - shouldn't happen. ItemTwo=%s", treatment); aapsLogger.error("processDTO was null - shouldn't happen. ItemTwo=" + treatment);
} }
} else { } else {
if (processDTO != null) { if (processDTO != null) {
@ -787,9 +789,9 @@ public class MedtronicHistoryData {
databaseHelper.createOrUpdate(tempBasal); databaseHelper.createOrUpdate(tempBasal);
aapsLogger.debug(LTag.PUMP, "Edit " + ProcessHistoryRecord.TBR.getDescription() + " - (entryFromDb=%s) ", tempBasal); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "Edit " + ProcessHistoryRecord.TBR.getDescription() + " - (entryFromDb=%s) ", tempBasal));
} else { } else {
aapsLogger.error("TempBasal not found. Item: %s", tempBasalProcessDTO.itemOne); aapsLogger.error(LTag.PUMP, "TempBasal not found. Item: " + tempBasalProcessDTO.itemOne);
} }
} else { } else {
@ -805,7 +807,7 @@ public class MedtronicHistoryData {
if (tempBasal == null) { if (tempBasal == null) {
DbObjectBase treatmentDb = findDbEntry(treatment, entriesFromHistory); DbObjectBase treatmentDb = findDbEntry(treatment, entriesFromHistory);
aapsLogger.debug(LTag.PUMP, "Add " + ProcessHistoryRecord.TBR.getDescription() + " %s - (entryFromDb=%s) ", treatment, treatmentDb); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "Add " + ProcessHistoryRecord.TBR.getDescription() + " %s - (entryFromDb=%s) ", treatment, treatmentDb));
addTBR(treatment, (TemporaryBasal) treatmentDb); addTBR(treatment, (TemporaryBasal) treatmentDb);
} else { } else {
@ -854,22 +856,22 @@ public class MedtronicHistoryData {
//proposedTime += (this.pumpTime.timeDifference * 1000); //proposedTime += (this.pumpTime.timeDifference * 1000);
if (doubleBolusDebug) if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: findDbEntry Treatment=%s, FromDb=%s", treatment, gson().toJson(entriesFromHistory)); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: findDbEntry Treatment=%s, FromDb=%s", treatment, gson().toJson(entriesFromHistory)));
if (entriesFromHistory.size() == 0) { if (entriesFromHistory.size() == 0) {
if (doubleBolusDebug) if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: findDbEntry Treatment=%s, FromDb=null", treatment); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: findDbEntry Treatment=%s, FromDb=null", treatment));
return null; return null;
} else if (entriesFromHistory.size() == 1) { } else if (entriesFromHistory.size() == 1) {
if (doubleBolusDebug) if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: findDbEntry Treatment=%s, FromDb=%s. Type=SingleEntry", treatment, entriesFromHistory.get(0)); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: findDbEntry Treatment=%s, FromDb=%s. Type=SingleEntry", treatment, entriesFromHistory.get(0)));
// TODO: Fix db code // TODO: Fix db code
// if difference is bigger than 2 minutes we discard entry // if difference is bigger than 2 minutes we discard entry
long maxMillisAllowed = DateTimeUtil.getMillisFromATDWithAddedMinutes(treatment.atechDateTime, 2); long maxMillisAllowed = DateTimeUtil.getMillisFromATDWithAddedMinutes(treatment.atechDateTime, 2);
if (doubleBolusDebug) if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: findDbEntry maxMillisAllowed=%d, AtechDateTime=%d (add 2 minutes). ", maxMillisAllowed, treatment.atechDateTime); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: findDbEntry maxMillisAllowed=%d, AtechDateTime=%d (add 2 minutes). ", maxMillisAllowed, treatment.atechDateTime));
if (entriesFromHistory.get(0).getDate() > maxMillisAllowed) { if (entriesFromHistory.get(0).getDate() > maxMillisAllowed) {
if (doubleBolusDebug) if (doubleBolusDebug)
@ -901,17 +903,17 @@ public class MedtronicHistoryData {
if (outList.size() == 1) { if (outList.size() == 1) {
if (doubleBolusDebug) if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: findDbEntry Treatment={}, FromDb={}. Type=EntrySelected, AtTimeMin={}, AtTimeSec={}", treatment, entriesFromHistory.get(0), min, sec); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: findDbEntry Treatment={}, FromDb={}. Type=EntrySelected, AtTimeMin={}, AtTimeSec={}", treatment, entriesFromHistory.get(0), min, sec));
return outList.get(0); return outList.get(0);
} }
if (min == 0 && sec == 10 && outList.size() > 1) { if (min == 0 && sec == 10 && outList.size() > 1) {
aapsLogger.error("Too many entries (with too small diff): (timeDiff=[min=%d,sec=%d],count=%d,list=%s)", aapsLogger.error(String.format(Locale.ENGLISH, "Too many entries (with too small diff): (timeDiff=[min=%d,sec=%d],count=%d,list=%s)",
min, sec, outList.size(), gson().toJson(outList)); min, sec, outList.size(), gson().toJson(outList)));
if (doubleBolusDebug) if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: findDbEntry Error - Too many entries (with too small diff): (timeDiff=[min=%d,sec=%d],count=%d,list=%s)", aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: findDbEntry Error - Too many entries (with too small diff): (timeDiff=[min=%d,sec=%d],count=%d,list=%s)",
min, sec, outList.size(), gson().toJson(outList)); min, sec, outList.size(), gson().toJson(outList)));
} }
} }
} }
@ -960,9 +962,9 @@ public class MedtronicHistoryData {
} }
if (doubleBolusDebug) if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: filterOutAlreadyAddedEntries: PumpHistory=%s, Treatments=%s", aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: filterOutAlreadyAddedEntries: PumpHistory=%s, Treatments=%s",
gson().toJson(removeTreatmentsFromPH), gson().toJson(removeTreatmentsFromPH),
gsonCore().toJson(removeTreatmentsFromHistory)); gsonCore().toJson(removeTreatmentsFromHistory)));
treatmentsFromHistory.removeAll(removeTreatmentsFromHistory); treatmentsFromHistory.removeAll(removeTreatmentsFromHistory);
} }
@ -974,7 +976,7 @@ public class MedtronicHistoryData {
if (treatment == null) { if (treatment == null) {
if (doubleBolusDebug) if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: addBolus(tretament==null): Bolus=%s", bolusDTO); aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: addBolus(tretament==null): Bolus=" + bolusDTO);
switch (bolusDTO.getBolusType()) { switch (bolusDTO.getBolusType()) {
case Normal: { case Normal: {
@ -988,14 +990,14 @@ public class MedtronicHistoryData {
addCarbsFromEstimate(detailedBolusInfo, bolus); addCarbsFromEstimate(detailedBolusInfo, bolus);
if (doubleBolusDebug) if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: addBolus(tretament==null): DetailedBolusInfo=%s", detailedBolusInfo); aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: addBolus(tretament==null): DetailedBolusInfo=" + detailedBolusInfo);
boolean newRecord = activePlugin.getActiveTreatments().addToHistoryTreatment(detailedBolusInfo, false); boolean newRecord = activePlugin.getActiveTreatments().addToHistoryTreatment(detailedBolusInfo, false);
bolus.setLinkedObject(detailedBolusInfo); bolus.setLinkedObject(detailedBolusInfo);
aapsLogger.debug(LTag.PUMP, "addBolus - [date=%d,pumpId=%d, insulin=%.2f, newRecord=%b]", detailedBolusInfo.date, aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "addBolus - [date=%d,pumpId=%d, insulin=%.2f, newRecord=%b]", detailedBolusInfo.date,
detailedBolusInfo.pumpId, detailedBolusInfo.insulin, newRecord); detailedBolusInfo.pumpId, detailedBolusInfo.insulin, newRecord));
} }
break; break;
@ -1012,12 +1014,12 @@ public class MedtronicHistoryData {
bolus.setLinkedObject(extendedBolus); bolus.setLinkedObject(extendedBolus);
if (doubleBolusDebug) if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: addBolus(tretament==null): ExtendedBolus=%s", extendedBolus); aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: addBolus(tretament==null): ExtendedBolus=" + extendedBolus);
activePlugin.getActiveTreatments().addToHistoryExtendedBolus(extendedBolus); activePlugin.getActiveTreatments().addToHistoryExtendedBolus(extendedBolus);
aapsLogger.debug(LTag.PUMP, "addBolus - Extended [date=%d,pumpId=%d, insulin=%.3f, duration=%d]", extendedBolus.date, aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "addBolus - Extended [date=%d,pumpId=%d, insulin=%.3f, duration=%d]", extendedBolus.date,
extendedBolus.pumpId, extendedBolus.insulin, extendedBolus.durationInMinutes); extendedBolus.pumpId, extendedBolus.insulin, extendedBolus.durationInMinutes));
} }
break; break;
@ -1026,7 +1028,7 @@ public class MedtronicHistoryData {
} else { } else {
if (doubleBolusDebug) if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: addBolus(OldTreatment=%s): Bolus=%s", treatment, bolusDTO); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: addBolus(OldTreatment=%s): Bolus=%s", treatment, bolusDTO));
treatment.source = Source.PUMP; treatment.source = Source.PUMP;
treatment.pumpId = bolus.getPumpId(); treatment.pumpId = bolus.getPumpId();
@ -1035,10 +1037,10 @@ public class MedtronicHistoryData {
TreatmentUpdateReturn updateReturn = activePlugin.getActiveTreatments().createOrUpdateMedtronic(treatment, false); TreatmentUpdateReturn updateReturn = activePlugin.getActiveTreatments().createOrUpdateMedtronic(treatment, false);
if (doubleBolusDebug) if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: addBolus(tretament!=null): NewTreatment=%s, UpdateReturn=%s", treatment, updateReturn); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: addBolus(tretament!=null): NewTreatment=%s, UpdateReturn=%s", treatment, updateReturn));
aapsLogger.debug(LTag.PUMP, "editBolus - [date=%d,pumpId=%d, insulin=%.3f, newRecord=%s]", treatment.date, aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "editBolus - [date=%d,pumpId=%d, insulin=%.3f, newRecord=%s]", treatment.date,
treatment.pumpId, treatment.insulin, updateReturn.toString()); treatment.pumpId, treatment.insulin, updateReturn.toString()));
bolus.setLinkedObject(treatment); bolus.setLinkedObject(treatment);
@ -1053,7 +1055,7 @@ public class MedtronicHistoryData {
BolusWizardDTO bolusWizard = (BolusWizardDTO) bolus.getDecodedData().get("Estimate"); BolusWizardDTO bolusWizard = (BolusWizardDTO) bolus.getDecodedData().get("Estimate");
if (doubleBolusDebug) if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: addCarbsFromEstimate: Bolus=%s, BolusWizardDTO=%s", bolus, bolusWizard); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: addCarbsFromEstimate: Bolus=%s, BolusWizardDTO=%s", bolus, bolusWizard));
detailedBolusInfo.carbs = bolusWizard.carbs; detailedBolusInfo.carbs = bolusWizard.carbs;
} }
@ -1084,13 +1086,13 @@ public class MedtronicHistoryData {
databaseHelper.createOrUpdate(temporaryBasalDb); databaseHelper.createOrUpdate(temporaryBasalDb);
aapsLogger.debug(LTag.PUMP, operation + " - [date=%d,pumpId=%d, rate=%s %s, duration=%d]", // aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, operation + " - [date=%d,pumpId=%d, rate=%s %s, duration=%d]", //
temporaryBasalDb.date, // temporaryBasalDb.date, //
temporaryBasalDb.pumpId, // temporaryBasalDb.pumpId, //
temporaryBasalDb.isAbsolute ? String.format(Locale.ENGLISH, "%.2f", temporaryBasalDb.absoluteRate) : temporaryBasalDb.isAbsolute ? String.format(Locale.ENGLISH, "%.2f", temporaryBasalDb.absoluteRate) :
String.format(Locale.ENGLISH, "%d", temporaryBasalDb.percentRate), // String.format(Locale.ENGLISH, "%d", temporaryBasalDb.percentRate), //
temporaryBasalDb.isAbsolute ? "U/h" : "%", // temporaryBasalDb.isAbsolute ? "U/h" : "%", //
temporaryBasalDb.durationInMinutes); temporaryBasalDb.durationInMinutes));
} }
@ -1381,8 +1383,8 @@ public class MedtronicHistoryData {
Minutes minutes = Minutes.minutesBetween(oldestEntryTime, now); Minutes minutes = Minutes.minutesBetween(oldestEntryTime, now);
// returns oldest time in history, with calculated time difference between pump and phone, minus 5 minutes // returns oldest time in history, with calculated time difference between pump and phone, minus 5 minutes
aapsLogger.debug(LTag.PUMP, "Oldest entry: %d, pumpTimeDifference=%d, newDt=%s, currentTime=%s, differenceMin=%d", dt, aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "Oldest entry: %d, pumpTimeDifference=%d, newDt=%s, currentTime=%s, differenceMin=%d", dt,
this.pumpTime.timeDifference, oldestEntryTime, now, minutes.getMinutes()); this.pumpTime.timeDifference, oldestEntryTime, now, minutes.getMinutes()));
return minutes.getMinutes(); return minutes.getMinutes();
} }
@ -1402,22 +1404,22 @@ public class MedtronicHistoryData {
} }
if (doubleBolusDebug) if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: getOldestTimestamp. Oldest entry found: time=%d, object=%s", dt, currentTreatment); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: getOldestTimestamp. Oldest entry found: time=%d, object=%s", dt, currentTreatment));
try { try {
GregorianCalendar oldestEntryTime = DateTimeUtil.toGregorianCalendar(dt); GregorianCalendar oldestEntryTime = DateTimeUtil.toGregorianCalendar(dt);
if (doubleBolusDebug) if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: getOldestTimestamp. oldestEntryTime: %s", DateTimeUtil.toString(oldestEntryTime)); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: getOldestTimestamp. oldestEntryTime: %s", DateTimeUtil.toString(oldestEntryTime)));
oldestEntryTime.add(Calendar.MINUTE, -2); oldestEntryTime.add(Calendar.MINUTE, -2);
if (doubleBolusDebug) if (doubleBolusDebug)
aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: getOldestTimestamp. oldestEntryTime (-2m): %s, timeInMillis=%d", DateTimeUtil.toString(oldestEntryTime), oldestEntryTime.getTimeInMillis()); aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: getOldestTimestamp. oldestEntryTime (-2m): %s, timeInMillis=%d", DateTimeUtil.toString(oldestEntryTime), oldestEntryTime.getTimeInMillis()));
return oldestEntryTime.getTimeInMillis(); return oldestEntryTime.getTimeInMillis();
} catch (Exception ex) { } catch (Exception ex) {
aapsLogger.error("Problem decoding date from last record: %s", currentTreatment); aapsLogger.error("Problem decoding date from last record: " + currentTreatment);
return 8; // default return of 6 minutes return 8; // default return of 6 minutes
} }

View file

@ -8,6 +8,7 @@ import org.joda.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale;
import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.logging.LTag;
@ -123,8 +124,8 @@ public class BasalProfile {
BasalProfileEntry entry = entries.get(i); BasalProfileEntry entry = entries.get(i);
String startString = entry.startTime.toString("HH:mm"); String startString = entry.startTime.toString("HH:mm");
// this doesn't work // this doesn't work
aapsLogger.debug(LTag.PUMPCOMM, "Entry %d, rate=%.3f (0x%02X), start=%s (0x%02X)", i + 1, entry.rate, aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Entry %d, rate=%.3f (%s), start=%s (0x%02X)", i + 1, entry.rate,
entry.rate_raw, startString, entry.startTime_raw); ByteUtil.getHex(entry.rate_raw), startString, entry.startTime_raw));
} }
} }
@ -137,7 +138,7 @@ public class BasalProfile {
BasalProfileEntry entry = entries.get(i); BasalProfileEntry entry = entries.get(i);
String startString = entry.startTime.toString("HH:mm"); String startString = entry.startTime.toString("HH:mm");
sb.append(String.format("Entry %d, rate=%.3f, start=%s\n", i + 1, entry.rate, startString)); sb.append(String.format(Locale.ENGLISH, "Entry %d, rate=%.3f, start=%s\n", i + 1, entry.rate, startString));
} }
return sb.toString(); return sb.toString();
@ -155,7 +156,7 @@ public class BasalProfile {
BasalProfileEntry entry = entries.get(i); BasalProfileEntry entry = entries.get(i);
String startString = entry.startTime.toString("HH:mm"); String startString = entry.startTime.toString("HH:mm");
sb.append(String.format("%s=%.3f, ", startString, entry.rate)); sb.append(String.format(Locale.ENGLISH, "%s=%.3f, ", startString, entry.rate));
} }
sb.append("]"); sb.append("]");
@ -170,8 +171,8 @@ public class BasalProfile {
BasalProfileEntry rval = new BasalProfileEntry(); BasalProfileEntry rval = new BasalProfileEntry();
List<BasalProfileEntry> entries = getEntries(); List<BasalProfileEntry> entries = getEntries();
if (entries.size() == 0) { if (entries.size() == 0) {
aapsLogger.warn(LTag.PUMPCOMM, "getEntryForTime(%s): table is empty", aapsLogger.warn(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "getEntryForTime(%s): table is empty",
when.toDateTime().toLocalTime().toString("HH:mm")); when.toDateTime().toLocalTime().toString("HH:mm")));
return rval; return rval;
} }
// Log.w(TAG,"Assuming first entry"); // Log.w(TAG,"Assuming first entry");
@ -187,8 +188,8 @@ public class BasalProfile {
while (!done) { while (!done) {
BasalProfileEntry entry = entries.get(i); BasalProfileEntry entry = entries.get(i);
if (DEBUG_BASALPROFILE) { if (DEBUG_BASALPROFILE) {
aapsLogger.debug(LTag.PUMPCOMM, "Comparing 'now'=%s to entry 'start time'=%s", when.toDateTime().toLocalTime() aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Comparing 'now'=%s to entry 'start time'=%s", when.toDateTime().toLocalTime()
.toString("HH:mm"), entry.startTime.toString("HH:mm")); .toString("HH:mm"), entry.startTime.toString("HH:mm")));
} }
if (localMillis >= entry.startTime.getMillisOfDay()) { if (localMillis >= entry.startTime.getMillisOfDay()) {
rval = entry; rval = entry;
@ -206,9 +207,9 @@ public class BasalProfile {
} }
} }
if (DEBUG_BASALPROFILE) { if (DEBUG_BASALPROFILE) {
aapsLogger.debug(LTag.PUMPCOMM, "getEntryForTime(%s): Returning entry: rate=%.3f (%d), start=%s (%d)", when aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "getEntryForTime(%s): Returning entry: rate=%.3f (%s), start=%s (%d)", when
.toDateTime().toLocalTime().toString("HH:mm"), rval.rate, rval.rate_raw, .toDateTime().toLocalTime().toString("HH:mm"), rval.rate, ByteUtil.getHex(rval.rate_raw),
rval.startTime.toString("HH:mm"), rval.startTime_raw); rval.startTime.toString("HH:mm"), rval.startTime_raw));
} }
return rval; return rval;
} }
@ -237,7 +238,7 @@ public class BasalProfile {
try { try {
entries.add(new BasalProfileEntry(aapsLogger, r, st)); entries.add(new BasalProfileEntry(aapsLogger, r, st));
} catch (Exception ex) { } catch (Exception ex) {
aapsLogger.error(LTag.PUMPCOMM, "Error decoding basal profile from bytes: %s", ByteUtil.shortHexString(mRawData)); aapsLogger.error(LTag.PUMPCOMM, "Error decoding basal profile from bytes: " + ByteUtil.shortHexString(mRawData));
throw ex; throw ex;
} }

View file

@ -2,6 +2,8 @@ package info.nightscout.androidaps.plugins.pump.medtronic.data.dto;
import org.joda.time.LocalTime; import org.joda.time.LocalTime;
import java.util.Locale;
import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil; import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
@ -53,8 +55,8 @@ public class BasalProfileEntry {
startTime = new LocalTime(startTimeInterval / 2, (startTimeInterval % 2) * 30); startTime = new LocalTime(startTimeInterval / 2, (startTimeInterval % 2) * 30);
} catch (Exception ex) { } catch (Exception ex) {
aapsLogger.error(LTag.PUMPCOMM, aapsLogger.error(LTag.PUMPCOMM,
"Error creating BasalProfileEntry: startTimeInterval=%d, startTime_raw=%d, hours=%d, rateStrokes=%d", String.format(Locale.ENGLISH, "Error creating BasalProfileEntry: startTimeInterval=%d, startTime_raw=%d, hours=%d, rateStrokes=%d",
startTimeInterval, startTime_raw, startTimeInterval / 2, rateStrokes); startTimeInterval, startTime_raw, startTimeInterval / 2, rateStrokes));
throw ex; throw ex;
} }

View file

@ -1,5 +1,7 @@
package info.nightscout.androidaps.plugins.pump.medtronic.data.dto; package info.nightscout.androidaps.plugins.pump.medtronic.data.dto;
import java.util.Locale;
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil; import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
/** /**
@ -26,7 +28,7 @@ public class BolusWizardDTO extends PumpTimeStampedRecord {
// public long atechDateTime; // public long atechDateTime;
public String getValue() { public String getValue() {
return String.format("BG=%d;CH=%d;CH_UNIT=%s;CH_INS_RATIO=%5.3f;BG_INS_RATIO=%5.3f;" return String.format(Locale.ENGLISH, "BG=%d;CH=%d;CH_UNIT=%s;CH_INS_RATIO=%5.3f;BG_INS_RATIO=%5.3f;"
+ "BG_TARGET_LOW=%d;BG_TARGET_HIGH=%d;BOLUS_TOTAL=%5.3f;" + "BG_TARGET_LOW=%d;BG_TARGET_HIGH=%d;BOLUS_TOTAL=%5.3f;"
+ "BOLUS_CORRECTION=%5.3f;BOLUS_FOOD=%5.3f;UNABSORBED_INSULIN=%5.3f", // + "BOLUS_CORRECTION=%5.3f;BOLUS_FOOD=%5.3f;UNABSORBED_INSULIN=%5.3f", //
bloodGlucose, carbs, chUnit, carbRatio, insulinSensitivity, bgTargetLow, // bloodGlucose, carbs, chUnit, carbRatio, insulinSensitivity, bgTargetLow, //
@ -34,7 +36,7 @@ public class BolusWizardDTO extends PumpTimeStampedRecord {
} }
public String getDisplayableValue() { public String getDisplayableValue() {
return String.format("Bg=%d, CH=%d %s, Ch/Ins Ratio=%5.3f, Bg/Ins Ratio=%5.3f;" return String.format(Locale.ENGLISH, "Bg=%d, CH=%d %s, Ch/Ins Ratio=%5.3f, Bg/Ins Ratio=%5.3f;"
+ "Bg Target(L/H)=%d/%d, Bolus: Total=%5.3f, " + "Bg Target(L/H)=%d/%d, Bolus: Total=%5.3f, "
+ "Correction=%5.3f, Food=%5.3f, IOB=%5.3f", // + "Correction=%5.3f, Food=%5.3f, IOB=%5.3f", //
bloodGlucose, carbs, chUnit, carbRatio, insulinSensitivity, bgTargetLow, // bloodGlucose, carbs, chUnit, carbRatio, insulinSensitivity, bgTargetLow, //

View file

@ -6,6 +6,8 @@ import com.google.gson.annotations.Expose;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import java.util.Locale;
import info.nightscout.androidaps.db.TDD; import info.nightscout.androidaps.db.TDD;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil; import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
@ -128,11 +130,11 @@ public class DailyTotalsDTO {
int j1 = ByteUtil.toInt(body[i + 1], body[i]); int j1 = ByteUtil.toInt(body[i + 1], body[i]);
int k1 = ByteUtil.toInt(body[i + 2], body[i + 1], body[i]); int k1 = ByteUtil.toInt(body[i + 2], body[i + 1], body[i]);
System.out.println(String.format( System.out.println(String.format(Locale.ENGLISH,
"index: %d, number=%d, del/40=%.3f, del/10=%.3f, singular=%d, sing_hex=%s", i, j, j / 40.0d, j / 10.0d, "index: %d, number=%d, del/40=%.3f, del/10=%.3f, singular=%d, sing_hex=%s", i, j, j / 40.0d, j / 10.0d,
body[i], ByteUtil.shortHexString(body[i]))); body[i], ByteUtil.shortHexString(body[i])));
System.out.println(String.format(" number[k,j1,k1]=%d / %d /%d, del/40=%.3f, del/40=%.3f, del/40=%.3f", System.out.println(String.format(Locale.ENGLISH, " number[k,j1,k1]=%d / %d /%d, del/40=%.3f, del/40=%.3f, del/40=%.3f",
k, j1, k1, k / 40.0d, j1 / 40.0d, k1 / 40.0d)); k, j1, k1, k / 40.0d, j1 / 40.0d, k1 / 40.0d));
} }

View file

@ -76,7 +76,7 @@ public class TempBasalPair extends info.nightscout.androidaps.plugins.pump.commo
durationMinutes = MedtronicUtil.makeUnsignedShort(response[4], response[5]); durationMinutes = MedtronicUtil.makeUnsignedShort(response[4], response[5]);
} }
aapsLogger.warn(LTag.PUMPBTCOMM, "TempBasalPair (with %d byte response): %s", response.length, toString()); aapsLogger.warn(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "TempBasalPair (with %d byte response): %s", response.length, toString()));
} }

View file

@ -9,6 +9,7 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
@ -275,7 +276,7 @@ public class MedtronicUtil {
byte[] payload = sendPayloadBuffer.array(); byte[] payload = sendPayloadBuffer.array();
aapsLogger.debug(LTag.PUMPCOMM, "buildCommandPayload [%s]", ByteUtil.shortHexString(payload)); aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "buildCommandPayload [%s]", ByteUtil.shortHexString(payload)));
// int crc = computeCRC8WithPolynomial(payload, 0, payload.length - 1); // int crc = computeCRC8WithPolynomial(payload, 0, payload.length - 1);

View file

@ -1,14 +1,56 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump; package info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump;
import org.junit.Ignore; import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.powermock.modules.junit4.PowerMockRunner;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpHistoryEntryGroup; import java.util.List;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.AAPSLoggerTest;
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.RawHistoryPage;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.rx.TestAapsSchedulers;
import info.nightscout.androidaps.utils.sharedPreferences.SP;
/** /**
* Created by andy on 11/1/18. * Created by andy on 11/1/18.
*/ */
@Ignore @RunWith(PowerMockRunner.class)
public class MedtronicPumpHistoryDecoderUTest { public class MedtronicPumpHistoryDecoderUTest {
@Mock HasAndroidInjector injector;
AAPSLogger aapsLogger = new AAPSLoggerTest();
RxBusWrapper rxBusWrapper = new RxBusWrapper(new TestAapsSchedulers());
@Mock ResourceHelper resourceHelper;
@Mock(answer = Answers.RETURNS_DEEP_STUBS) ActivePluginProvider activePluginProvider;
@Mock RileyLinkUtil rileyLinkUtil;
@Mock SP sp;
MedtronicPumpStatus medtronicPumpStatus;
MedtronicUtil medtronicUtil;
MedtronicPumpHistoryDecoder decoder;
@Before
public void setup() {
medtronicPumpStatus = new MedtronicPumpStatus(resourceHelper, sp, rxBusWrapper, rileyLinkUtil);
medtronicUtil = new MedtronicUtil(aapsLogger, rxBusWrapper, rileyLinkUtil, medtronicPumpStatus);
decoder = new MedtronicPumpHistoryDecoder(aapsLogger, medtronicUtil);
}
/* /*
MedtronicPumpHistoryDecoder decoder = new MedtronicPumpHistoryDecoder(); MedtronicPumpHistoryDecoder decoder = new MedtronicPumpHistoryDecoder();
@ -151,4 +193,34 @@ public class MedtronicPumpHistoryDecoderUTest {
} }
*/ */
@Test
public void historyProblem_148_amunhateb() throws Exception {
byte[] historyPageData = ByteUtil.createByteArrayFromString(
"5A 0F 20 F4 0C 03 15 19 11 00 17 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1A 11 00 0F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 33 01 12 12 00 25 DE 2D 43 15 01 50 50 00 26 EA 2D 43 15 01 4B 4B 00 2C C9 34 43 15 62 00 2F CB 17 03 15 01 33 33 00 16 DE 37 43 15 07 00 00 07 FE 23 95 6D 23 95 0A 08 00 2B 00 00 00 00 07 FE 03 8E 2C 04 70 38 00 00 04 70 38 00 00 00 00 00 00 04 70 64 06 00 00 00 06 08 00 2B 00 00 00 2C A0 2F E3 01 04 15 33 00 2F E7 04 44 15 00 16 03 2F E7 04 44 15 33 28 3B C2 06 44 15 00 16 01 3B C2 06 44 15 08 08 17 DB 0B 44 15 00 26 00 06 26 00 0C 26 00 12 28 00 18 26 00 1E 26 00 24 24 00 2A 26 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 18 17 DB 0B 44 15 00 26 00 02 26 00 04 26 00 06 24 00 08 24 00 0A 24 00 0C 26 00 0E 26 00 10 26 00 12 28 00 14 28 00 16 28 00 18 26 00 1A 26 00 1C 26 00 1E 26 00 20 26 00 22 26 00 24 24 00 26 24 00 28 24 00 2A 26 00 2C 26 00 2E 26 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 45 45 00 28 E9 2B 44 15 19 00 00 C1 0D 04 15 1A 00 15 C3 0D 04 15 1A 01 33 C3 0D 04 15 01 28 28 00 07 CC 2E 44 15 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 2D");
System.out.println("HDP:" + historyPageData.length);
medtronicUtil.setMedtronicPumpModel(MedtronicDeviceType.Medtronic_522_722);
RawHistoryPage historyPage = new RawHistoryPage(aapsLogger);
historyPage.appendData(historyPageData);
List<PumpHistoryEntry> pumpHistoryEntries = decoder.processPageAndCreateRecords(historyPage);
System.out.println("PumpHistoryEntries: " + pumpHistoryEntries.size());
displayHistoryRecords(pumpHistoryEntries);
}
private void displayHistoryRecords(List<PumpHistoryEntry> pumpHistoryEntries) {
for (PumpHistoryEntry pumpHistoryEntry : pumpHistoryEntries) {
aapsLogger.debug(pumpHistoryEntry.toString());
}
}
} }

View file

@ -1,5 +1,7 @@
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink; package info.nightscout.androidaps.plugins.pump.common.hw.rileylink;
import java.util.Locale;
import javax.inject.Inject; import javax.inject.Inject;
import dagger.android.HasAndroidInjector; import dagger.android.HasAndroidInjector;
@ -85,8 +87,8 @@ public abstract class RileyLinkCommunicationManager<T extends RLMessage> {
// Mark this as the last time we heard from the pump. // Mark this as the last time we heard from the pump.
rememberLastGoodDeviceCommunicationTime(); rememberLastGoodDeviceCommunicationTime();
} else { } else {
aapsLogger.warn(LTag.PUMPBTCOMM, "isDeviceReachable. Response is invalid ! [noResponseFromRileyLink=%b, interrupted=%b, timeout=%b, unknownCommand=%b, invalidParam=%b]", aapsLogger.warn(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "isDeviceReachable. Response is invalid ! [noResponseFromRileyLink=%b, interrupted=%b, timeout=%b, unknownCommand=%b, invalidParam=%b]",
rfSpyResponse.wasNoResponseFromRileyLink(), rfSpyResponse.wasInterrupted(), rfSpyResponse.wasTimeout(), rfSpyResponse.isUnknownCommand(), rfSpyResponse.isInvalidParam()); rfSpyResponse.wasNoResponseFromRileyLink(), rfSpyResponse.wasInterrupted(), rfSpyResponse.wasTimeout(), rfSpyResponse.isUnknownCommand(), rfSpyResponse.isInvalidParam()));
if (rfSpyResponse.wasTimeout()) { if (rfSpyResponse.wasTimeout()) {
if (rileyLinkServiceData.targetDevice.isTuneUpEnabled()) { if (rileyLinkServiceData.targetDevice.isTuneUpEnabled()) {
@ -214,7 +216,7 @@ public abstract class RileyLinkCommunicationManager<T extends RLMessage> {
private double scanForDevice(double[] frequencies) { private double scanForDevice(double[] frequencies) {
aapsLogger.info(LTag.PUMPBTCOMM, "Scanning for receiver (%s)", receiverDeviceID); aapsLogger.info(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Scanning for receiver (%s)", receiverDeviceID));
wakeUp(receiverDeviceAwakeForMinutes, false); wakeUp(receiverDeviceAwakeForMinutes, false);
FrequencyScanResults results = new FrequencyScanResults(); FrequencyScanResults results = new FrequencyScanResults();
@ -231,7 +233,7 @@ public abstract class RileyLinkCommunicationManager<T extends RLMessage> {
RFSpyResponse resp = rfspy.transmitThenReceive(new RadioPacket(injector, pumpMsgContent), (byte) 0, (byte) 0, RFSpyResponse resp = rfspy.transmitThenReceive(new RadioPacket(injector, pumpMsgContent), (byte) 0, (byte) 0,
(byte) 0, (byte) 0, 1250, (byte) 0); (byte) 0, (byte) 0, 1250, (byte) 0);
if (resp.wasTimeout()) { if (resp.wasTimeout()) {
aapsLogger.error(LTag.PUMPBTCOMM, "scanForPump: Failed to find pump at frequency %.3f", frequencies[i]); aapsLogger.error(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "scanForPump: Failed to find pump at frequency %.3f", frequencies[i]));
} else if (resp.looksLikeRadioPacket()) { } else if (resp.looksLikeRadioPacket()) {
RadioResponse radioResponse = new RadioResponse(injector); RadioResponse radioResponse = new RadioResponse(injector);
@ -319,14 +321,14 @@ public abstract class RileyLinkCommunicationManager<T extends RLMessage> {
RadioPacket pkt = new RadioPacket(injector, pumpMsgContent); RadioPacket pkt = new RadioPacket(injector, pumpMsgContent);
RFSpyResponse resp = rfspy.transmitThenReceive(pkt, (byte) 0, (byte) 0, (byte) 0, (byte) 0, SCAN_TIMEOUT, (byte) 0); RFSpyResponse resp = rfspy.transmitThenReceive(pkt, (byte) 0, (byte) 0, (byte) 0, (byte) 0, SCAN_TIMEOUT, (byte) 0);
if (resp.wasTimeout()) { if (resp.wasTimeout()) {
aapsLogger.warn(LTag.PUMPBTCOMM, "tune_tryFrequency: no pump response at frequency %.3f", freqMHz); aapsLogger.warn(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "tune_tryFrequency: no pump response at frequency %.3f", freqMHz));
} else if (resp.looksLikeRadioPacket()) { } else if (resp.looksLikeRadioPacket()) {
RadioResponse radioResponse = new RadioResponse(injector); RadioResponse radioResponse = new RadioResponse(injector);
try { try {
radioResponse.init(resp.getRaw()); radioResponse.init(resp.getRaw());
if (radioResponse.isValid()) { if (radioResponse.isValid()) {
aapsLogger.warn(LTag.PUMPBTCOMM, "tune_tryFrequency: saw response level %d at frequency %.3f", radioResponse.rssi, freqMHz); aapsLogger.warn(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "tune_tryFrequency: saw response level %d at frequency %.3f", radioResponse.rssi, freqMHz));
return calculateRssi(radioResponse.rssi); return calculateRssi(radioResponse.rssi);
} else { } else {
aapsLogger.warn(LTag.PUMPBTCOMM, "tune_tryFrequency: invalid radio response:" aapsLogger.warn(LTag.PUMPBTCOMM, "tune_tryFrequency: invalid radio response:"
@ -365,9 +367,9 @@ public abstract class RileyLinkCommunicationManager<T extends RLMessage> {
} else { } else {
rfspy.setBaseFrequency(betterFrequency); rfspy.setBaseFrequency(betterFrequency);
if (betterFrequency != startFrequencyMHz) { if (betterFrequency != startFrequencyMHz) {
aapsLogger.info(LTag.PUMPBTCOMM, "quickTuneForPump: new frequency is %.3fMHz", betterFrequency); aapsLogger.info(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "quickTuneForPump: new frequency is %.3fMHz", betterFrequency));
} else { } else {
aapsLogger.info(LTag.PUMPBTCOMM, "quickTuneForPump: pump frequency is the same: %.3fMHz", startFrequencyMHz); aapsLogger.info(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "quickTuneForPump: pump frequency is the same: %.3fMHz", startFrequencyMHz));
} }
} }
return betterFrequency; return betterFrequency;
@ -375,7 +377,7 @@ public abstract class RileyLinkCommunicationManager<T extends RLMessage> {
private double quickTunePumpStep(double startFrequencyMHz, double stepSizeMHz) { private double quickTunePumpStep(double startFrequencyMHz, double stepSizeMHz) {
aapsLogger.info(LTag.PUMPBTCOMM, "Doing quick radio tune for receiver (%s)", receiverDeviceID); aapsLogger.info(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Doing quick radio tune for receiver (%s)", receiverDeviceID));
wakeUp(false); wakeUp(false);
int startRssi = tune_tryFrequency(startFrequencyMHz); int startRssi = tune_tryFrequency(startFrequencyMHz);
double lowerFrequency = startFrequencyMHz - stepSizeMHz; double lowerFrequency = startFrequencyMHz - stepSizeMHz;

View file

@ -4,6 +4,7 @@ import android.os.SystemClock;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import java.util.Locale;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
@ -115,7 +116,7 @@ public class RFSpy {
if (result.resultCode == BLECommOperationResult.RESULT_SUCCESS) { if (result.resultCode == BLECommOperationResult.RESULT_SUCCESS) {
if (ArrayUtils.isNotEmpty(result.value)) { if (ArrayUtils.isNotEmpty(result.value)) {
int value = result.value[0]; int value = result.value[0];
aapsLogger.debug(LTag.PUMPBTCOMM, "BLE battery level: %d", value); aapsLogger.debug(LTag.PUMPBTCOMM, "BLE battery level: " + value);
return value; return value;
} else { } else {
aapsLogger.error(LTag.PUMPBTCOMM, "getBatteryLevel received an empty result. Value: " + result.value); aapsLogger.error(LTag.PUMPBTCOMM, "getBatteryLevel received an empty result. Value: " + result.value);
@ -150,7 +151,7 @@ public class RFSpy {
byte[] getVersionRaw = getByteArray(RileyLinkCommandType.GetVersion.code); byte[] getVersionRaw = getByteArray(RileyLinkCommandType.GetVersion.code);
byte[] response = writeToDataRaw(getVersionRaw, 5000); byte[] response = writeToDataRaw(getVersionRaw, 5000);
aapsLogger.debug(LTag.PUMPBTCOMM, "Firmware Version. GetVersion [response=%s]", ByteUtil.shortHexString(response)); aapsLogger.debug(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Firmware Version. GetVersion [response=%s]", ByteUtil.shortHexString(response)));
if (response != null) { // && response[0] == (byte) 0xDD) { if (response != null) { // && response[0] == (byte) 0xDD) {
@ -171,14 +172,14 @@ public class RFSpy {
static RileyLinkFirmwareVersion getFirmwareVersion(AAPSLogger aapsLogger, String bleVersion, String cc1110Version) { static RileyLinkFirmwareVersion getFirmwareVersion(AAPSLogger aapsLogger, String bleVersion, String cc1110Version) {
if (cc1110Version != null) { if (cc1110Version != null) {
RileyLinkFirmwareVersion version = RileyLinkFirmwareVersion.getByVersionString(cc1110Version); RileyLinkFirmwareVersion version = RileyLinkFirmwareVersion.getByVersionString(cc1110Version);
aapsLogger.debug(LTag.PUMPBTCOMM, "Firmware Version string: %s, resolved to %s.", cc1110Version, version); aapsLogger.debug(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Firmware Version string: %s, resolved to %s.", cc1110Version, version));
if (version != RileyLinkFirmwareVersion.UnknownVersion) { if (version != RileyLinkFirmwareVersion.UnknownVersion) {
return version; return version;
} }
} }
aapsLogger.error(LTag.PUMPBTCOMM, "Firmware Version can't be determined. Checking with BLE Version [%s].", bleVersion); aapsLogger.error(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Firmware Version can't be determined. Checking with BLE Version [%s].", bleVersion));
if (bleVersion.contains(" 2.")) { if (bleVersion.contains(" 2.")) {
return RileyLinkFirmwareVersion.Version_2_0; return RileyLinkFirmwareVersion.Version_2_0;
@ -201,7 +202,7 @@ public class RFSpy {
// prepend length, and send it. // prepend length, and send it.
byte[] prepended = ByteUtil.concat(new byte[]{(byte) (bytes.length)}, bytes); byte[] prepended = ByteUtil.concat(new byte[]{(byte) (bytes.length)}, bytes);
aapsLogger.debug(LTag.PUMPBTCOMM, "writeToData (raw=%s)", ByteUtil.shortHexString(prepended)); aapsLogger.debug(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "writeToData (raw=%s)", ByteUtil.shortHexString(prepended)));
BLECommOperationResult writeCheck = rileyLinkBle.writeCharacteristic_blocking(radioServiceUUID, radioDataUUID, BLECommOperationResult writeCheck = rileyLinkBle.writeCharacteristic_blocking(radioServiceUUID, radioDataUUID,
prepended); prepended);
@ -292,7 +293,7 @@ public class RFSpy {
updateRegister(CC111XRegister.freq0, (byte) (value & 0xff)); updateRegister(CC111XRegister.freq0, (byte) (value & 0xff));
updateRegister(CC111XRegister.freq1, (byte) ((value >> 8) & 0xff)); updateRegister(CC111XRegister.freq1, (byte) ((value >> 8) & 0xff));
updateRegister(CC111XRegister.freq2, (byte) ((value >> 16) & 0xff)); updateRegister(CC111XRegister.freq2, (byte) ((value >> 16) & 0xff));
aapsLogger.info(LTag.PUMPBTCOMM, "Set frequency to %.3f MHz", freqMHz); aapsLogger.info(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Set frequency to %.3f MHz", freqMHz));
this.currentFrequencyMHz = freqMHz; this.currentFrequencyMHz = freqMHz;
@ -350,7 +351,7 @@ public class RFSpy {
setPreamble(0x6665); setPreamble(0x6665);
break; break;
default: default:
aapsLogger.warn(LTag.PUMPBTCOMM, "No region configuration for RfSpy and %s", frequency.name()); aapsLogger.warn(LTag.PUMPBTCOMM, "No region configuration for RfSpy and " + frequency.name());
break; break;
} }

View file

@ -14,6 +14,7 @@ import android.os.SystemClock;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.Semaphore; import java.util.concurrent.Semaphore;
@ -148,20 +149,20 @@ public class RileyLinkBLE {
if (status == BluetoothGatt.GATT_SUCCESS) { if (status == BluetoothGatt.GATT_SUCCESS) {
rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.BluetoothConnected, context); rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.BluetoothConnected, context);
} else { } else {
aapsLogger.debug(LTag.PUMPBTCOMM, "BT State connected, GATT status %d (%s)", status, getGattStatusMessage(status)); aapsLogger.debug(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "BT State connected, GATT status %d (%s)", status, getGattStatusMessage(status)));
} }
} else if ((newState == BluetoothProfile.STATE_CONNECTING) || // } else if ((newState == BluetoothProfile.STATE_CONNECTING) || //
(newState == BluetoothProfile.STATE_DISCONNECTING)) { (newState == BluetoothProfile.STATE_DISCONNECTING)) {
aapsLogger.debug(LTag.PUMPBTCOMM, "We are in %s state.", status == BluetoothProfile.STATE_CONNECTING ? "Connecting" : aapsLogger.debug(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "We are in %s state.", status == BluetoothProfile.STATE_CONNECTING ? "Connecting" :
"Disconnecting"); "Disconnecting"));
} else if (newState == BluetoothProfile.STATE_DISCONNECTED) { } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkDisconnected, context); rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkDisconnected, context);
if (manualDisconnect) if (manualDisconnect)
close(); close();
aapsLogger.warn(LTag.PUMPBTCOMM, "RileyLink Disconnected."); aapsLogger.warn(LTag.PUMPBTCOMM, "RileyLink Disconnected.");
} else { } else {
aapsLogger.warn(LTag.PUMPBTCOMM, "Some other state: (status=%d, newState=%d)", status, newState); aapsLogger.warn(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Some other state: (status=%d, newState=%d)", status, newState));
} }
} }

View file

@ -4,6 +4,7 @@ import org.slf4j.Logger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkCommunicationException; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkCommunicationException;
@ -121,7 +122,7 @@ public class Encoding4b6bGeoff extends Encoding4b6bAbstract {
*/ */
} else { } else {
// LOG.debug(String.format("i=%d,x=%08X, coding error: highcode=0x%02X, lowcode=0x%02X, %d bits remaining",i,x,highcode,lowcode,availableBits)); // LOG.debug(String.format("i=%d,x=%08X, coding error: highcode=0x%02X, lowcode=0x%02X, %d bits remaining",i,x,highcode,lowcode,availableBits));
errorMessageBuilder.append(String.format( errorMessageBuilder.append(String.format(Locale.ENGLISH,
"decode4b6b: i=%d,x=%08X, coding error: highcode=0x%02X, lowcode=0x%02X, %d bits remaining.\n", "decode4b6b: i=%d,x=%08X, coding error: highcode=0x%02X, lowcode=0x%02X, %d bits remaining.\n",
i, x, highcode, lowcode, availableBits)); i, x, highcode, lowcode, availableBits));
codingErrors++; codingErrors++;

View file

@ -6,6 +6,8 @@ import android.content.Intent;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import java.util.Locale;
import javax.inject.Inject; import javax.inject.Inject;
import dagger.android.DaggerService; import dagger.android.DaggerService;
@ -174,8 +176,8 @@ public abstract class RileyLinkService extends DaggerService {
if (rileyLinkServiceData.getRileyLinkServiceState() == RileyLinkServiceState.NotStarted) { if (rileyLinkServiceData.getRileyLinkServiceState() == RileyLinkServiceState.NotStarted) {
if (!bluetoothInit()) { if (!bluetoothInit()) {
aapsLogger.error("RileyLink can't get activated, Bluetooth is not functioning correctly. %s", aapsLogger.error("RileyLink can't get activated, Bluetooth is not functioning correctly. " +
getError() != null ? getError().name() : "Unknown error (null)"); (getError() != null ? getError().name() : "Unknown error (null)"));
return false; return false;
} }
} }
@ -205,7 +207,7 @@ public abstract class RileyLinkService extends DaggerService {
newFrequency = getDeviceCommunicationManager().tuneForDevice(); newFrequency = getDeviceCommunicationManager().tuneForDevice();
if ((newFrequency != 0.0) && (newFrequency != lastGoodFrequency)) { if ((newFrequency != 0.0) && (newFrequency != lastGoodFrequency)) {
aapsLogger.info(LTag.PUMPBTCOMM, "Saving new pump frequency of %.3f MHz", newFrequency); aapsLogger.info(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Saving new pump frequency of %.3f MHz", newFrequency));
sp.putDouble(RileyLinkConst.Prefs.LastGoodDeviceFrequency, newFrequency); sp.putDouble(RileyLinkConst.Prefs.LastGoodDeviceFrequency, newFrequency);
rileyLinkServiceData.lastGoodFrequency = newFrequency; rileyLinkServiceData.lastGoodFrequency = newFrequency;
rileyLinkServiceData.tuneUpDone = true; rileyLinkServiceData.tuneUpDone = true;

View file

@ -1,5 +1,7 @@
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service; package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service;
import java.util.Locale;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
@ -84,7 +86,7 @@ public class RileyLinkServiceData {
lastServiceStateChange = System.currentTimeMillis(); lastServiceStateChange = System.currentTimeMillis();
this.rileyLinkError = errorCode; this.rileyLinkError = errorCode;
aapsLogger.info(LTag.PUMP, "RileyLink State Changed: %s %s", newState, errorCode == null ? "" : " - Error State: " + errorCode.name()); aapsLogger.info(LTag.PUMP, String.format(Locale.ENGLISH, "RileyLink State Changed: %s %s", newState, errorCode == null ? "" : " - Error State: " + errorCode.name()));
rileyLinkUtil.getRileyLinkHistory().add(new RLHistoryItem(rileyLinkServiceState, errorCode, targetDevice)); rileyLinkUtil.getRileyLinkHistory().add(new RLHistoryItem(rileyLinkServiceState, errorCode, targetDevice));
rxBus.send(new EventRileyLinkDeviceStatusChange(targetDevice, newState, errorCode)); rxBus.send(new EventRileyLinkDeviceStatusChange(targetDevice, newState, errorCode));

Some files were not shown because too many files have changed in this diff Show more