Add Clear alarms, new overview layout
This commit is contained in:
parent
cbc5a51f2c
commit
7b53630947
|
@ -7,4 +7,5 @@ interface Medtrum {
|
||||||
|
|
||||||
fun loadEvents(): PumpEnactResult // events history to build treatments from
|
fun loadEvents(): PumpEnactResult // events history to build treatments from
|
||||||
fun setUserOptions(): PumpEnactResult // set user settings
|
fun setUserOptions(): PumpEnactResult // set user settings
|
||||||
|
fun clearAlarms(): PumpEnactResult // clear alarms
|
||||||
}
|
}
|
|
@ -23,11 +23,12 @@ abstract class Command(
|
||||||
BASAL_PROFILE,
|
BASAL_PROFILE,
|
||||||
READSTATUS,
|
READSTATUS,
|
||||||
LOAD_HISTORY, // TDDs and so far only Dana specific
|
LOAD_HISTORY, // TDDs and so far only Dana specific
|
||||||
LOAD_EVENTS, // so far only Dana specific
|
LOAD_EVENTS,
|
||||||
LOAD_TDD,
|
LOAD_TDD,
|
||||||
SET_USER_SETTINGS, // so far only Dana specific,
|
SET_USER_SETTINGS, // so far only Dana specific,
|
||||||
START_PUMP,
|
START_PUMP,
|
||||||
STOP_PUMP,
|
STOP_PUMP,
|
||||||
|
CLEAR_ALARMS, // so far only Medtrum specific
|
||||||
INSIGHT_SET_TBR_OVER_ALARM, // insight only
|
INSIGHT_SET_TBR_OVER_ALARM, // insight only
|
||||||
CUSTOM_COMMAND
|
CUSTOM_COMMAND
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ interface CommandQueue {
|
||||||
fun setUserOptions(callback: Callback?): Boolean
|
fun setUserOptions(callback: Callback?): Boolean
|
||||||
fun loadTDDs(callback: Callback?): Boolean
|
fun loadTDDs(callback: Callback?): Boolean
|
||||||
fun loadEvents(callback: Callback?): Boolean
|
fun loadEvents(callback: Callback?): Boolean
|
||||||
|
fun clearAlarms(callback: Callback?): Boolean
|
||||||
fun customCommand(customCommand: CustomCommand, callback: Callback?): Boolean
|
fun customCommand(customCommand: CustomCommand, callback: Callback?): Boolean
|
||||||
fun isCustomCommandRunning(customCommandType: Class<out CustomCommand>): Boolean
|
fun isCustomCommandRunning(customCommandType: Class<out CustomCommand>): Boolean
|
||||||
fun isCustomCommandInQueue(customCommandType: Class<out CustomCommand>): Boolean
|
fun isCustomCommandInQueue(customCommandType: Class<out CustomCommand>): Boolean
|
||||||
|
|
|
@ -393,6 +393,7 @@
|
||||||
<string name="carbs_g">CARBS %1$d g</string>
|
<string name="carbs_g">CARBS %1$d g</string>
|
||||||
<string name="extended_bolus_u_min">EXTENDED BOLUS %1$.2f U %2$d min</string>
|
<string name="extended_bolus_u_min">EXTENDED BOLUS %1$.2f U %2$d min</string>
|
||||||
<string name="load_events">LOAD EVENTS</string>
|
<string name="load_events">LOAD EVENTS</string>
|
||||||
|
<string name="clear_alarms">CLEAR_ALARMS</string>
|
||||||
<string name="load_history">LOAD HISTORY %1$d</string>
|
<string name="load_history">LOAD HISTORY %1$d</string>
|
||||||
<string name="load_tdds">LOAD TDDs</string>
|
<string name="load_tdds">LOAD TDDs</string>
|
||||||
<string name="set_profile">SET PROFILE</string>
|
<string name="set_profile">SET PROFILE</string>
|
||||||
|
|
|
@ -14,6 +14,7 @@ import info.nightscout.implementation.queue.commands.CommandTempBasalPercent
|
||||||
import info.nightscout.implementation.queue.commands.CommandBolus
|
import info.nightscout.implementation.queue.commands.CommandBolus
|
||||||
import info.nightscout.implementation.queue.commands.CommandCancelExtendedBolus
|
import info.nightscout.implementation.queue.commands.CommandCancelExtendedBolus
|
||||||
import info.nightscout.implementation.queue.commands.CommandCancelTempBasal
|
import info.nightscout.implementation.queue.commands.CommandCancelTempBasal
|
||||||
|
import info.nightscout.implementation.queue.commands.CommandClearAlarms
|
||||||
import info.nightscout.implementation.queue.commands.CommandCustomCommand
|
import info.nightscout.implementation.queue.commands.CommandCustomCommand
|
||||||
import info.nightscout.implementation.queue.commands.CommandExtendedBolus
|
import info.nightscout.implementation.queue.commands.CommandExtendedBolus
|
||||||
import info.nightscout.implementation.queue.commands.CommandInsightSetTBROverNotification
|
import info.nightscout.implementation.queue.commands.CommandInsightSetTBROverNotification
|
||||||
|
@ -32,6 +33,7 @@ abstract class CommandQueueModule {
|
||||||
@ContributesAndroidInjector abstract fun commandExtendedBolusInjector(): CommandExtendedBolus
|
@ContributesAndroidInjector abstract fun commandExtendedBolusInjector(): CommandExtendedBolus
|
||||||
@ContributesAndroidInjector abstract fun commandInsightSetTBROverNotificationInjector(): CommandInsightSetTBROverNotification
|
@ContributesAndroidInjector abstract fun commandInsightSetTBROverNotificationInjector(): CommandInsightSetTBROverNotification
|
||||||
@ContributesAndroidInjector abstract fun commandLoadEventsInjector(): CommandLoadEvents
|
@ContributesAndroidInjector abstract fun commandLoadEventsInjector(): CommandLoadEvents
|
||||||
|
@ContributesAndroidInjector abstract fun commandClearAlarmsInjector(): CommandClearAlarms
|
||||||
@ContributesAndroidInjector abstract fun commandLoadHistoryInjector(): CommandLoadHistory
|
@ContributesAndroidInjector abstract fun commandLoadHistoryInjector(): CommandLoadHistory
|
||||||
@ContributesAndroidInjector abstract fun commandLoadTDDsInjector(): CommandLoadTDDs
|
@ContributesAndroidInjector abstract fun commandLoadTDDsInjector(): CommandLoadTDDs
|
||||||
@ContributesAndroidInjector abstract fun commandReadStatusInjector(): CommandReadStatus
|
@ContributesAndroidInjector abstract fun commandReadStatusInjector(): CommandReadStatus
|
||||||
|
|
|
@ -22,6 +22,7 @@ import info.nightscout.implementation.R
|
||||||
import info.nightscout.implementation.queue.commands.CommandBolus
|
import info.nightscout.implementation.queue.commands.CommandBolus
|
||||||
import info.nightscout.implementation.queue.commands.CommandCancelExtendedBolus
|
import info.nightscout.implementation.queue.commands.CommandCancelExtendedBolus
|
||||||
import info.nightscout.implementation.queue.commands.CommandCancelTempBasal
|
import info.nightscout.implementation.queue.commands.CommandCancelTempBasal
|
||||||
|
import info.nightscout.implementation.queue.commands.CommandClearAlarms
|
||||||
import info.nightscout.implementation.queue.commands.CommandCustomCommand
|
import info.nightscout.implementation.queue.commands.CommandCustomCommand
|
||||||
import info.nightscout.implementation.queue.commands.CommandExtendedBolus
|
import info.nightscout.implementation.queue.commands.CommandExtendedBolus
|
||||||
import info.nightscout.implementation.queue.commands.CommandInsightSetTBROverNotification
|
import info.nightscout.implementation.queue.commands.CommandInsightSetTBROverNotification
|
||||||
|
@ -535,6 +536,20 @@ class CommandQueueImplementation @Inject constructor(
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// returns true if command is queued
|
||||||
|
override fun clearAlarms(callback: Callback?): Boolean {
|
||||||
|
if (isRunning(CommandType.CLEAR_ALARMS)) {
|
||||||
|
callback?.result(executingNowError())?.run()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
// remove all unfinished
|
||||||
|
removeAll(CommandType.CLEAR_ALARMS)
|
||||||
|
// add new command to queue
|
||||||
|
add(CommandClearAlarms(injector, callback))
|
||||||
|
notifyAboutNewCommand()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
override fun customCommand(customCommand: CustomCommand, callback: Callback?): Boolean {
|
override fun customCommand(customCommand: CustomCommand, callback: Callback?): Boolean {
|
||||||
if (isCustomCommandInQueue(customCommand.javaClass)) {
|
if (isCustomCommandInQueue(customCommand.javaClass)) {
|
||||||
callback?.result(executingNowError())?.run()
|
callback?.result(executingNowError())?.run()
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package info.nightscout.implementation.queue.commands
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
|
import info.nightscout.interfaces.pump.Dana
|
||||||
|
import info.nightscout.interfaces.pump.Diaconn
|
||||||
|
import info.nightscout.interfaces.pump.Medtrum
|
||||||
|
import info.nightscout.interfaces.pump.PumpEnactResult
|
||||||
|
import info.nightscout.interfaces.queue.Callback
|
||||||
|
import info.nightscout.interfaces.queue.Command
|
||||||
|
import info.nightscout.rx.logging.LTag
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class CommandClearAlarms(
|
||||||
|
injector: HasAndroidInjector,
|
||||||
|
callback: Callback?
|
||||||
|
) : Command(injector, CommandType.CLEAR_ALARMS, callback) {
|
||||||
|
|
||||||
|
@Inject lateinit var activePlugin: ActivePlugin
|
||||||
|
|
||||||
|
override fun execute() {
|
||||||
|
val pump = activePlugin.activePump
|
||||||
|
|
||||||
|
if (pump is Medtrum) {
|
||||||
|
val medtrumPump = pump as Medtrum
|
||||||
|
val r = medtrumPump.clearAlarms()
|
||||||
|
aapsLogger.debug(LTag.PUMPQUEUE, "Result success: ${r.success} enacted: ${r.enacted}")
|
||||||
|
callback?.result(r)?.run()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun status(): String = rh.gs(info.nightscout.core.ui.R.string.clear_alarms)
|
||||||
|
|
||||||
|
override fun log(): String = "CLEAR ALAMRS"
|
||||||
|
override fun cancel() {
|
||||||
|
aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel")
|
||||||
|
callback?.result(PumpEnactResult(injector).success(false).comment(info.nightscout.core.ui.R.string.connectiontimedout))?.run()
|
||||||
|
}
|
||||||
|
}
|
|
@ -238,6 +238,11 @@ class CommandQueueImplementationTest : TestBaseWithProfile() {
|
||||||
// add loadEvents
|
// add loadEvents
|
||||||
commandQueue.loadEvents(null)
|
commandQueue.loadEvents(null)
|
||||||
Assertions.assertEquals(4, commandQueue.size())
|
Assertions.assertEquals(4, commandQueue.size())
|
||||||
|
|
||||||
|
// add clearAlarms
|
||||||
|
commandQueue.clearAlarms(null)
|
||||||
|
Assertions.assertEquals(5, commandQueue.size())
|
||||||
|
|
||||||
commandQueue.clear()
|
commandQueue.clear()
|
||||||
commandQueue.tempBasalAbsolute(0.0, 30, true, validProfile, PumpSync.TemporaryBasalType.NORMAL, null)
|
commandQueue.tempBasalAbsolute(0.0, 30, true, validProfile, PumpSync.TemporaryBasalType.NORMAL, null)
|
||||||
commandQueue.pickup()
|
commandQueue.pickup()
|
||||||
|
@ -354,6 +359,22 @@ class CommandQueueImplementationTest : TestBaseWithProfile() {
|
||||||
Assertions.assertEquals(1, commandQueue.size())
|
Assertions.assertEquals(1, commandQueue.size())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun isClearAlarmsCommandInQueue() {
|
||||||
|
// given
|
||||||
|
Assertions.assertEquals(0, commandQueue.size())
|
||||||
|
|
||||||
|
// when
|
||||||
|
commandQueue.clearAlarms(null)
|
||||||
|
|
||||||
|
// then
|
||||||
|
Assertions.assertTrue(commandQueue.isLastScheduled(Command.CommandType.CLEAR_ALARMS))
|
||||||
|
Assertions.assertEquals(1, commandQueue.size())
|
||||||
|
// next should be ignored
|
||||||
|
commandQueue.clearAlarms(null)
|
||||||
|
Assertions.assertEquals(1, commandQueue.size())
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun isLoadTDDsCommandInQueue() {
|
fun isLoadTDDsCommandInQueue() {
|
||||||
// given
|
// given
|
||||||
|
|
|
@ -383,4 +383,14 @@ import kotlin.math.round
|
||||||
val connectionOK = medtrumService?.setUserSettings() ?: false
|
val connectionOK = medtrumService?.setUserSettings() ?: false
|
||||||
return PumpEnactResult(injector).success(connectionOK)
|
return PumpEnactResult(injector).success(connectionOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun clearAlarms(): PumpEnactResult {
|
||||||
|
if (!isInitialized()) {
|
||||||
|
val result = PumpEnactResult(injector).success(false)
|
||||||
|
result.comment = "pump not initialized"
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
val connectionOK = medtrumService?.clearAlarms() ?: false
|
||||||
|
return PumpEnactResult(injector).success(connectionOK)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
package info.nightscout.pump.medtrum.code
|
package info.nightscout.pump.medtrum.code
|
||||||
|
|
||||||
enum class EventType {
|
enum class EventType {
|
||||||
ACTIVATION_CLICKED,
|
CHANGE_PATCH_CLICKED,
|
||||||
DEACTIVATION_CLICKED,
|
|
||||||
INVALID_BASAL_RATE,
|
INVALID_BASAL_RATE,
|
||||||
PROFILE_NOT_SET,
|
PROFILE_NOT_SET,
|
||||||
FINISH_ACTIVITY,
|
FINISH_ACTIVITY,
|
||||||
|
|
|
@ -15,10 +15,12 @@ enum class CommandType(val code: Byte) {
|
||||||
SET_BASAL_PROFILE(21),
|
SET_BASAL_PROFILE(21),
|
||||||
SET_TEMP_BASAL(24),
|
SET_TEMP_BASAL(24),
|
||||||
CANCEL_TEMP_BASAL(25),
|
CANCEL_TEMP_BASAL(25),
|
||||||
|
RESUME_PUMP(29),
|
||||||
POLL_PATCH(30),
|
POLL_PATCH(30),
|
||||||
STOP_PATCH(31),
|
STOP_PATCH(31),
|
||||||
READ_BOLUS_STATE(34),
|
READ_BOLUS_STATE(34),
|
||||||
SET_PATCH(35),
|
SET_PATCH(35),
|
||||||
SET_BOLUS_MOTOR(36),
|
SET_BOLUS_MOTOR(36),
|
||||||
GET_RECORD(99)
|
GET_RECORD(99),
|
||||||
|
CLEAR_ALARM(115)
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.pump.medtrum.comm.enums.CommandType.CLEAR_ALARM
|
||||||
|
import info.nightscout.pump.medtrum.extension.toByteArray
|
||||||
|
|
||||||
|
class ClearPumpAlarmPacket(injector: HasAndroidInjector, val clearType: Int) : MedtrumPacket(injector) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
opCode = CLEAR_ALARM.code
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getRequest(): ByteArray {
|
||||||
|
return byteArrayOf(opCode) + clearType.toByteArray(2)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.pump.medtrum.comm.enums.CommandType.RESUME_PUMP
|
||||||
|
import info.nightscout.pump.medtrum.extension.toByteArray
|
||||||
|
|
||||||
|
class ResumePumpPacket(injector: HasAndroidInjector) : MedtrumPacket(injector) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
opCode = RESUME_PUMP.code
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getRequest(): ByteArray {
|
||||||
|
return byteArrayOf(opCode)
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ import info.nightscout.pump.medtrum.comm.packets.ActivatePacket
|
||||||
import info.nightscout.pump.medtrum.comm.packets.AuthorizePacket
|
import info.nightscout.pump.medtrum.comm.packets.AuthorizePacket
|
||||||
import info.nightscout.pump.medtrum.comm.packets.CancelBolusPacket
|
import info.nightscout.pump.medtrum.comm.packets.CancelBolusPacket
|
||||||
import info.nightscout.pump.medtrum.comm.packets.CancelTempBasalPacket
|
import info.nightscout.pump.medtrum.comm.packets.CancelTempBasalPacket
|
||||||
|
import info.nightscout.pump.medtrum.comm.packets.ClearPumpAlarmPacket
|
||||||
import info.nightscout.pump.medtrum.comm.packets.GetDeviceTypePacket
|
import info.nightscout.pump.medtrum.comm.packets.GetDeviceTypePacket
|
||||||
import info.nightscout.pump.medtrum.comm.packets.GetRecordPacket
|
import info.nightscout.pump.medtrum.comm.packets.GetRecordPacket
|
||||||
import info.nightscout.pump.medtrum.comm.packets.GetTimePacket
|
import info.nightscout.pump.medtrum.comm.packets.GetTimePacket
|
||||||
|
@ -14,6 +15,7 @@ import info.nightscout.pump.medtrum.comm.packets.NotificationPacket
|
||||||
import info.nightscout.pump.medtrum.comm.packets.PollPatchPacket
|
import info.nightscout.pump.medtrum.comm.packets.PollPatchPacket
|
||||||
import info.nightscout.pump.medtrum.comm.packets.PrimePacket
|
import info.nightscout.pump.medtrum.comm.packets.PrimePacket
|
||||||
import info.nightscout.pump.medtrum.comm.packets.ReadBolusStatePacket
|
import info.nightscout.pump.medtrum.comm.packets.ReadBolusStatePacket
|
||||||
|
import info.nightscout.pump.medtrum.comm.packets.ResumePumpPacket
|
||||||
import info.nightscout.pump.medtrum.comm.packets.SetBasalProfilePacket
|
import info.nightscout.pump.medtrum.comm.packets.SetBasalProfilePacket
|
||||||
import info.nightscout.pump.medtrum.comm.packets.SetBolusMotorPacket
|
import info.nightscout.pump.medtrum.comm.packets.SetBolusMotorPacket
|
||||||
import info.nightscout.pump.medtrum.comm.packets.SetBolusPacket
|
import info.nightscout.pump.medtrum.comm.packets.SetBolusPacket
|
||||||
|
@ -32,6 +34,7 @@ abstract class MedtrumCommModule {
|
||||||
@ContributesAndroidInjector abstract fun contributesAuthorizePacket(): AuthorizePacket
|
@ContributesAndroidInjector abstract fun contributesAuthorizePacket(): AuthorizePacket
|
||||||
@ContributesAndroidInjector abstract fun contributesCancelBolusPacket(): CancelBolusPacket
|
@ContributesAndroidInjector abstract fun contributesCancelBolusPacket(): CancelBolusPacket
|
||||||
@ContributesAndroidInjector abstract fun contributesCancelTempBasalPacket(): CancelTempBasalPacket
|
@ContributesAndroidInjector abstract fun contributesCancelTempBasalPacket(): CancelTempBasalPacket
|
||||||
|
@ContributesAndroidInjector abstract fun contributesClearPumpAlarmPacket(): ClearPumpAlarmPacket
|
||||||
@ContributesAndroidInjector abstract fun contributesGetDeviceTypePacket(): GetDeviceTypePacket
|
@ContributesAndroidInjector abstract fun contributesGetDeviceTypePacket(): GetDeviceTypePacket
|
||||||
@ContributesAndroidInjector abstract fun contributesGetRecordPacket(): GetRecordPacket
|
@ContributesAndroidInjector abstract fun contributesGetRecordPacket(): GetRecordPacket
|
||||||
@ContributesAndroidInjector abstract fun contributesGetTimePacket(): GetTimePacket
|
@ContributesAndroidInjector abstract fun contributesGetTimePacket(): GetTimePacket
|
||||||
|
@ -40,6 +43,7 @@ abstract class MedtrumCommModule {
|
||||||
@ContributesAndroidInjector abstract fun contributesPollPatchPacket(): PollPatchPacket
|
@ContributesAndroidInjector abstract fun contributesPollPatchPacket(): PollPatchPacket
|
||||||
@ContributesAndroidInjector abstract fun contributesPrimePacket(): PrimePacket
|
@ContributesAndroidInjector abstract fun contributesPrimePacket(): PrimePacket
|
||||||
@ContributesAndroidInjector abstract fun contributesReadBolusStatePacket(): ReadBolusStatePacket
|
@ContributesAndroidInjector abstract fun contributesReadBolusStatePacket(): ReadBolusStatePacket
|
||||||
|
@ContributesAndroidInjector abstract fun contributesResumePumpPacket(): ResumePumpPacket
|
||||||
@ContributesAndroidInjector abstract fun contributesSetBasalProfilePacket(): SetBasalProfilePacket
|
@ContributesAndroidInjector abstract fun contributesSetBasalProfilePacket(): SetBasalProfilePacket
|
||||||
@ContributesAndroidInjector abstract fun contributesSetBolusMotorPacket(): SetBolusMotorPacket
|
@ContributesAndroidInjector abstract fun contributesSetBolusMotorPacket(): SetBolusMotorPacket
|
||||||
@ContributesAndroidInjector abstract fun contributesSetBolusPacket(): SetBolusPacket
|
@ContributesAndroidInjector abstract fun contributesSetBolusPacket(): SetBolusPacket
|
||||||
|
|
|
@ -75,6 +75,8 @@ class MedtrumService : DaggerService(), BLECommCallback {
|
||||||
private const val COMMAND_DEFAULT_TIMEOUT_SEC: Long = 60
|
private const val COMMAND_DEFAULT_TIMEOUT_SEC: Long = 60
|
||||||
private const val COMMAND_SYNC_TIMEOUT_SEC: Long = 120
|
private const val COMMAND_SYNC_TIMEOUT_SEC: Long = 120
|
||||||
private const val COMMAND_CONNECTING_TIMEOUT_SEC: Long = 30
|
private const val COMMAND_CONNECTING_TIMEOUT_SEC: Long = 30
|
||||||
|
private const val ALARM_HOURLY_MAX_CLEAR_CODE = 4
|
||||||
|
private const val ALARM_DAILY_MAX_CLEAR_CODE = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
val timeUtil = MedtrumTimeUtil()
|
val timeUtil = MedtrumTimeUtil()
|
||||||
|
@ -155,11 +157,8 @@ class MedtrumService : DaggerService(), BLECommCallback {
|
||||||
MedtrumPumpState.LOWBG_SUSPENDED,
|
MedtrumPumpState.LOWBG_SUSPENDED,
|
||||||
MedtrumPumpState.LOWBG_SUSPENDED2,
|
MedtrumPumpState.LOWBG_SUSPENDED2,
|
||||||
MedtrumPumpState.AUTO_SUSPENDED,
|
MedtrumPumpState.AUTO_SUSPENDED,
|
||||||
MedtrumPumpState.HMAX_SUSPENDED,
|
|
||||||
MedtrumPumpState.DMAX_SUSPENDED,
|
|
||||||
MedtrumPumpState.SUSPENDED,
|
MedtrumPumpState.SUSPENDED,
|
||||||
MedtrumPumpState.PAUSED -> {
|
MedtrumPumpState.PAUSED -> {
|
||||||
// TODO: Message with reason
|
|
||||||
uiInteraction.addNotification(
|
uiInteraction.addNotification(
|
||||||
Notification.PUMP_SUSPENDED,
|
Notification.PUMP_SUSPENDED,
|
||||||
rh.gs(R.string.pump_is_suspended),
|
rh.gs(R.string.pump_is_suspended),
|
||||||
|
@ -168,6 +167,23 @@ class MedtrumService : DaggerService(), BLECommCallback {
|
||||||
// Pump will report proper TBR for this
|
// Pump will report proper TBR for this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MedtrumPumpState.HMAX_SUSPENDED -> {
|
||||||
|
uiInteraction.addNotification(
|
||||||
|
Notification.PUMP_SUSPENDED,
|
||||||
|
rh.gs(R.string.pump_is_suspended_hour_max),
|
||||||
|
Notification.NORMAL,
|
||||||
|
)
|
||||||
|
// Pump will report proper TBR for this
|
||||||
|
}
|
||||||
|
MedtrumPumpState.DMAX_SUSPENDED -> {
|
||||||
|
uiInteraction.addNotification(
|
||||||
|
Notification.PUMP_SUSPENDED,
|
||||||
|
rh.gs(R.string.pump_is_suspended_day_max),
|
||||||
|
Notification.NORMAL,
|
||||||
|
)
|
||||||
|
// Pump will report proper TBR for this
|
||||||
|
}
|
||||||
|
|
||||||
MedtrumPumpState.OCCLUSION,
|
MedtrumPumpState.OCCLUSION,
|
||||||
MedtrumPumpState.EXPIRED,
|
MedtrumPumpState.EXPIRED,
|
||||||
MedtrumPumpState.RESERVOIR_EMPTY,
|
MedtrumPumpState.RESERVOIR_EMPTY,
|
||||||
|
@ -250,18 +266,49 @@ class MedtrumService : DaggerService(), BLECommCallback {
|
||||||
|
|
||||||
fun loadEvents(): Boolean {
|
fun loadEvents(): Boolean {
|
||||||
// Send a poll patch, to workaround connection losses?
|
// Send a poll patch, to workaround connection losses?
|
||||||
|
rxBus.send(EventPumpStatusChanged(rh.gs(info.nightscout.pump.medtrum.R.string.gettingpumpstatus)))
|
||||||
var result = sendPacketAndGetResponse(PollPatchPacket(injector))
|
var result = sendPacketAndGetResponse(PollPatchPacket(injector))
|
||||||
// So just do a syncronize to make sure we have the latest data
|
// So just do a syncronize to make sure we have the latest data
|
||||||
if (result) result = sendPacketAndGetResponse(SynchronizePacket(injector))
|
if (result) result = sendPacketAndGetResponse(SynchronizePacket(injector))
|
||||||
|
|
||||||
// Sync records (based on the info we have from the sync)
|
// Sync records (based on the info we have from the sync)
|
||||||
if (result) result = syncRecords()
|
if (result) result = syncRecords()
|
||||||
if (!result) {
|
if (result) {
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "Events loaded")
|
||||||
|
medtrumPump.lastConnection = System.currentTimeMillis()
|
||||||
|
} else {
|
||||||
aapsLogger.error(LTag.PUMPCOMM, "Failed to sync records")
|
aapsLogger.error(LTag.PUMPCOMM, "Failed to sync records")
|
||||||
}
|
}
|
||||||
if (result) medtrumPump.lastConnection = System.currentTimeMillis()
|
return result
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Events loaded")
|
}
|
||||||
rxBus.send(EventPumpStatusChanged(rh.gs(info.nightscout.pump.medtrum.R.string.gettingpumpstatus)))
|
|
||||||
|
fun clearAlarms(): Boolean {
|
||||||
|
var result = true
|
||||||
|
when (medtrumPump.pumpState) {
|
||||||
|
MedtrumPumpState.HMAX_SUSPENDED -> {
|
||||||
|
result = sendPacketAndGetResponse(ClearPumpAlarmPacket(injector, ALARM_HOURLY_MAX_CLEAR_CODE))
|
||||||
|
}
|
||||||
|
MedtrumPumpState.DMAX_SUSPENDED -> {
|
||||||
|
result = sendPacketAndGetResponse(ClearPumpAlarmPacket(injector, ALARM_DAILY_MAX_CLEAR_CODE))
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
// Do nothing
|
||||||
|
// TODO: Remove me before release!!!
|
||||||
|
// Try to brute force the commands
|
||||||
|
aapsLogger.warn(LTag.PUMPCOMM, "Trying to clear alarms brutus!")
|
||||||
|
for (i in 0..100) {
|
||||||
|
result = sendPacketAndGetResponse(ClearPumpAlarmPacket(injector, i))
|
||||||
|
if (result) {
|
||||||
|
aapsLogger.warn(LTag.PUMPCOMM, "Alarm cleared: $i")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Resume suspended pump
|
||||||
|
// TODO: We might not want to do this for alarms which don't suspend the pump
|
||||||
|
if (result) result = sendPacketAndGetResponse(ResumePumpPacket(injector))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import info.nightscout.pump.medtrum.ui.viewmodel.MedtrumOverviewViewModel
|
||||||
import info.nightscout.pump.medtrum.R
|
import info.nightscout.pump.medtrum.R
|
||||||
import info.nightscout.pump.medtrum.code.EventType
|
import info.nightscout.pump.medtrum.code.EventType
|
||||||
import info.nightscout.pump.medtrum.code.PatchStep
|
import info.nightscout.pump.medtrum.code.PatchStep
|
||||||
|
import info.nightscout.pump.medtrum.comm.enums.MedtrumPumpState
|
||||||
import info.nightscout.rx.AapsSchedulers
|
import info.nightscout.rx.AapsSchedulers
|
||||||
import info.nightscout.rx.logging.AAPSLogger
|
import info.nightscout.rx.logging.AAPSLogger
|
||||||
import info.nightscout.rx.logging.LTag
|
import info.nightscout.rx.logging.LTag
|
||||||
|
@ -43,18 +44,12 @@ class MedtrumOverviewFragment : MedtrumBaseFragment<FragmentMedtrumOverviewBindi
|
||||||
viewmodel?.apply {
|
viewmodel?.apply {
|
||||||
eventHandler.observe(viewLifecycleOwner) { evt ->
|
eventHandler.observe(viewLifecycleOwner) { evt ->
|
||||||
when (evt.peekContent()) {
|
when (evt.peekContent()) {
|
||||||
EventType.ACTIVATION_CLICKED -> requireContext().apply {
|
EventType.CHANGE_PATCH_CLICKED -> requireContext().apply {
|
||||||
// TODO: Check what to do with this, and if we need this, it currently messes up patch is last registered as priming
|
if (medtrumPump.pumpState > MedtrumPumpState.EJECTED && medtrumPump.pumpState < MedtrumPumpState.STOPPED) {
|
||||||
// var step = convertToPatchStep(medtrumPump.pumpState)
|
startActivity(MedtrumActivity.createIntentFromMenu(this, PatchStep.START_DEACTIVATION))
|
||||||
// if (step == PatchStep.DEACTIVATION_COMPLETE) {
|
} else {
|
||||||
// // Reset
|
|
||||||
// step = PatchStep.PREPARE_PATCH
|
|
||||||
// }
|
|
||||||
startActivity(MedtrumActivity.createIntentFromMenu(this, PatchStep.PREPARE_PATCH))
|
startActivity(MedtrumActivity.createIntentFromMenu(this, PatchStep.PREPARE_PATCH))
|
||||||
}
|
}
|
||||||
|
|
||||||
EventType.DEACTIVATION_CLICKED -> requireContext().apply {
|
|
||||||
startActivity(MedtrumActivity.createIntentFromMenu(this, PatchStep.START_DEACTIVATION))
|
|
||||||
}
|
}
|
||||||
else -> Unit
|
else -> Unit
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import info.nightscout.pump.medtrum.ui.event.SingleLiveEvent
|
||||||
import info.nightscout.pump.medtrum.ui.event.UIEvent
|
import info.nightscout.pump.medtrum.ui.event.UIEvent
|
||||||
import info.nightscout.pump.medtrum.ui.viewmodel.BaseViewModel
|
import info.nightscout.pump.medtrum.ui.viewmodel.BaseViewModel
|
||||||
import info.nightscout.interfaces.profile.ProfileFunction
|
import info.nightscout.interfaces.profile.ProfileFunction
|
||||||
|
import info.nightscout.interfaces.queue.CommandQueue
|
||||||
import info.nightscout.pump.medtrum.MedtrumPump
|
import info.nightscout.pump.medtrum.MedtrumPump
|
||||||
import info.nightscout.pump.medtrum.R
|
import info.nightscout.pump.medtrum.R
|
||||||
import info.nightscout.pump.medtrum.code.ConnectionState
|
import info.nightscout.pump.medtrum.code.ConnectionState
|
||||||
|
@ -34,7 +35,8 @@ class MedtrumOverviewViewModel @Inject constructor(
|
||||||
private val aapsSchedulers: AapsSchedulers,
|
private val aapsSchedulers: AapsSchedulers,
|
||||||
private val fabricPrivacy: FabricPrivacy,
|
private val fabricPrivacy: FabricPrivacy,
|
||||||
private val profileFunction: ProfileFunction,
|
private val profileFunction: ProfileFunction,
|
||||||
private val medtrumPump: MedtrumPump
|
private val commandQueue: CommandQueue,
|
||||||
|
val medtrumPump: MedtrumPump
|
||||||
) : BaseViewModel<MedtrumBaseNavigator>() {
|
) : BaseViewModel<MedtrumBaseNavigator>() {
|
||||||
|
|
||||||
private val scope = CoroutineScope(Dispatchers.Default)
|
private val scope = CoroutineScope(Dispatchers.Default)
|
||||||
|
@ -43,29 +45,41 @@ class MedtrumOverviewViewModel @Inject constructor(
|
||||||
val eventHandler: LiveData<UIEvent<EventType>>
|
val eventHandler: LiveData<UIEvent<EventType>>
|
||||||
get() = _eventHandler
|
get() = _eventHandler
|
||||||
|
|
||||||
|
private val _canDoRefresh = SingleLiveEvent<Boolean>()
|
||||||
|
val canDoRefresh: LiveData<Boolean>
|
||||||
|
get() = _canDoRefresh
|
||||||
|
|
||||||
|
private val _canDoResetAlarms = SingleLiveEvent<Boolean>()
|
||||||
|
val canDoResetAlarms: LiveData<Boolean>
|
||||||
|
get() = _canDoResetAlarms
|
||||||
|
|
||||||
private val _bleStatus = SingleLiveEvent<String>()
|
private val _bleStatus = SingleLiveEvent<String>()
|
||||||
val bleStatus: LiveData<String>
|
val bleStatus: LiveData<String>
|
||||||
get() = _bleStatus
|
get() = _bleStatus
|
||||||
|
|
||||||
private val _isPatchActivated = SingleLiveEvent<Boolean>()
|
private val _lastConnected = SingleLiveEvent<String>()
|
||||||
val isPatchActivated: LiveData<Boolean>
|
val lastConnected: LiveData<String>
|
||||||
get() = _isPatchActivated
|
get() = _lastConnected
|
||||||
|
|
||||||
private val _pumpState = SingleLiveEvent<String>()
|
private val _activeAlarms = SingleLiveEvent<String>()
|
||||||
val pumpState: LiveData<String>
|
val activeAlarms: LiveData<String>
|
||||||
get() = _pumpState
|
get() = _activeAlarms
|
||||||
|
|
||||||
private val _basalType = SingleLiveEvent<String>()
|
private val _pumpType = SingleLiveEvent<String>()
|
||||||
val basalType: LiveData<String>
|
val pumpType: LiveData<String>
|
||||||
get() = _basalType
|
get() = _pumpType
|
||||||
|
|
||||||
private val _runningBasalRate = SingleLiveEvent<String>()
|
private val _fwVersion = SingleLiveEvent<String>()
|
||||||
val runningBasalRate: LiveData<String>
|
val fwVersion: LiveData<String>
|
||||||
get() = _runningBasalRate
|
get() = _fwVersion
|
||||||
|
|
||||||
private val _reservoir = SingleLiveEvent<String>()
|
private val _patchNo = SingleLiveEvent<String>()
|
||||||
val reservoir: LiveData<String>
|
val patchNo: LiveData<String>
|
||||||
get() = _reservoir
|
get() = _patchNo
|
||||||
|
|
||||||
|
private val _patchExpiry = SingleLiveEvent<String>()
|
||||||
|
val patchExpiry: LiveData<String>
|
||||||
|
get() = _patchExpiry
|
||||||
|
|
||||||
init {
|
init {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
|
@ -74,51 +88,34 @@ class MedtrumOverviewViewModel @Inject constructor(
|
||||||
when (state) {
|
when (state) {
|
||||||
ConnectionState.CONNECTING -> {
|
ConnectionState.CONNECTING -> {
|
||||||
_bleStatus.postValue("{fa-bluetooth-b spin}")
|
_bleStatus.postValue("{fa-bluetooth-b spin}")
|
||||||
|
_canDoRefresh.postValue(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectionState.CONNECTED -> {
|
ConnectionState.CONNECTED -> {
|
||||||
_bleStatus.postValue("{fa-bluetooth}")
|
_bleStatus.postValue("{fa-bluetooth}")
|
||||||
|
_canDoRefresh.postValue(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectionState.DISCONNECTED -> {
|
ConnectionState.DISCONNECTED -> {
|
||||||
_bleStatus.postValue("{fa-bluetooth-b}")
|
_bleStatus.postValue("{fa-bluetooth-b}")
|
||||||
}
|
if (medtrumPump.pumpState > MedtrumPumpState.EJECTED && medtrumPump.pumpState < MedtrumPumpState.STOPPED) {
|
||||||
}
|
_canDoRefresh.postValue(true)
|
||||||
}
|
|
||||||
}
|
|
||||||
scope.launch {
|
|
||||||
medtrumPump.pumpStateFlow.collect { state ->
|
|
||||||
aapsLogger.debug(LTag.PUMP, "MedtrumViewModel pumpStateFlow: $state")
|
|
||||||
if (state > MedtrumPumpState.EJECTED && state < MedtrumPumpState.STOPPED) {
|
|
||||||
_isPatchActivated.postValue(true)
|
|
||||||
} else {
|
} else {
|
||||||
_isPatchActivated.postValue(false)
|
_canDoRefresh.postValue(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scope.launch {
|
|
||||||
medtrumPump.lastBasalRateFlow.collect { rate ->
|
|
||||||
aapsLogger.debug(LTag.PUMP, "MedtrumViewModel runningBasalRateFlow: $rate")
|
|
||||||
_runningBasalRate.postValue(String.format(rh.gs(R.string.current_basal_rate), rate))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scope.launch {
|
scope.launch {
|
||||||
medtrumPump.pumpStateFlow.collect { state ->
|
medtrumPump.pumpStateFlow.collect { state ->
|
||||||
aapsLogger.debug(LTag.PUMP, "MedtrumViewModel pumpStateFlow: $state")
|
aapsLogger.debug(LTag.PUMP, "MedtrumViewModel pumpStateFlow: $state")
|
||||||
_pumpState.postValue(state.toString())
|
if (medtrumPump.pumpState > MedtrumPumpState.EJECTED && medtrumPump.pumpState < MedtrumPumpState.STOPPED) {
|
||||||
|
_canDoResetAlarms.postValue(true)
|
||||||
|
} else {
|
||||||
|
_canDoResetAlarms.postValue(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scope.launch {
|
|
||||||
medtrumPump.reservoirFlow.collect { reservoir ->
|
|
||||||
aapsLogger.debug(LTag.PUMP, "MedtrumViewModel reservoirFlow: $reservoir")
|
|
||||||
_reservoir.postValue(String.format(rh.gs(R.string.reservoir_level), reservoir))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
scope.launch {
|
|
||||||
medtrumPump.lastBasalTypeFlow.collect { basalType ->
|
|
||||||
aapsLogger.debug(LTag.PUMP, "MedtrumViewModel basalTypeFlow: $basalType")
|
|
||||||
_basalType.postValue(basalType.toString())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,18 +124,22 @@ class MedtrumOverviewViewModel @Inject constructor(
|
||||||
scope.cancel()
|
scope.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onClickActivation() {
|
fun onClickRefresh() {
|
||||||
aapsLogger.debug(LTag.PUMP, "Start Patch clicked!")
|
commandQueue.readStatus(rh.gs(R.string.requested_by_user), null)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onClickResetAlarms() {
|
||||||
|
commandQueue.clearAlarms(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onClickChangePatch() {
|
||||||
|
aapsLogger.debug(LTag.PUMP, "ChangePatch Patch clicked!")
|
||||||
val profile = profileFunction.getProfile()
|
val profile = profileFunction.getProfile()
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
_eventHandler.postValue(UIEvent(EventType.PROFILE_NOT_SET))
|
_eventHandler.postValue(UIEvent(EventType.PROFILE_NOT_SET))
|
||||||
} else {
|
} else {
|
||||||
_eventHandler.postValue(UIEvent(EventType.ACTIVATION_CLICKED))
|
_eventHandler.postValue(UIEvent(EventType.CHANGE_PATCH_CLICKED))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onClickDeactivation() {
|
|
||||||
aapsLogger.debug(LTag.PUMP, "Stop Patch clicked!")
|
|
||||||
_eventHandler.postValue(UIEvent(EventType.DEACTIVATION_CLICKED))
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -27,31 +27,11 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="vertical"
|
||||||
android:paddingTop="2dp"
|
android:paddingTop="2dp"
|
||||||
android:paddingBottom="5dp"
|
android:paddingBottom="5dp">
|
||||||
android:visibility="gone">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/text1"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_marginRight="5dp"
|
|
||||||
android:gravity="center_vertical|center_horizontal"
|
|
||||||
android:text="@string/initializing"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="2dip"
|
|
||||||
android:layout_marginLeft="20dp"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:layout_marginRight="20dp"
|
|
||||||
android:layout_marginBottom="5dp"
|
|
||||||
android:background="@color/list_delimiter" />
|
|
||||||
|
|
||||||
|
<!-- BLE Status -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -64,8 +44,8 @@
|
||||||
android:gravity="end"
|
android:gravity="end"
|
||||||
android:paddingStart="5dp"
|
android:paddingStart="5dp"
|
||||||
android:paddingEnd="5dp"
|
android:paddingEnd="5dp"
|
||||||
android:text="@string/medtrum_ble_status"
|
android:text="@string/ble_status_label"
|
||||||
android:textSize="16sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="5dp"
|
android:layout_width="5dp"
|
||||||
|
@ -75,10 +55,10 @@
|
||||||
android:paddingStart="2dp"
|
android:paddingStart="2dp"
|
||||||
android:paddingEnd="2dp"
|
android:paddingEnd="2dp"
|
||||||
android:text=":"
|
android:text=":"
|
||||||
android:textSize="16sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<com.joanzapata.iconify.widget.IconTextView
|
<com.joanzapata.iconify.widget.IconTextView
|
||||||
android:id="@+id/medtrum_ble_status"
|
android:id="@+id/ble_status"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
@ -86,20 +66,56 @@
|
||||||
android:paddingStart="5dp"
|
android:paddingStart="5dp"
|
||||||
android:paddingEnd="5dp"
|
android:paddingEnd="5dp"
|
||||||
android:text="@{viewmodel.bleStatus}"
|
android:text="@{viewmodel.bleStatus}"
|
||||||
android:textColor="@android:color/white"
|
android:textSize="14sp" />
|
||||||
android:textSize="16sp" />
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Last Connected -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1.5"
|
||||||
|
android:gravity="end"
|
||||||
|
android:paddingStart="5dp"
|
||||||
|
android:paddingEnd="5dp"
|
||||||
|
android:text="@string/last_connected_label"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="5dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:paddingStart="2dp"
|
||||||
|
android:paddingEnd="2dp"
|
||||||
|
android:text=":"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/last_connected"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="start"
|
||||||
|
android:paddingStart="5dp"
|
||||||
|
android:paddingEnd="5dp"
|
||||||
|
android:text="@{viewmodel.lastConnected}"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="14sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="2dip"
|
android:layout_height="2dip"
|
||||||
android:layout_marginLeft="20dp"
|
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:layout_marginRight="20dp"
|
|
||||||
android:layout_marginBottom="5dp"
|
android:layout_marginBottom="5dp"
|
||||||
android:background="@color/list_delimiter" />
|
android:background="@color/list_delimiter" />
|
||||||
|
|
||||||
|
<!-- Pump State -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -114,7 +130,7 @@
|
||||||
android:paddingStart="5dp"
|
android:paddingStart="5dp"
|
||||||
android:paddingEnd="5dp"
|
android:paddingEnd="5dp"
|
||||||
android:text="@string/pump_state_label"
|
android:text="@string/pump_state_label"
|
||||||
android:textSize="16sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="5dp"
|
android:layout_width="5dp"
|
||||||
|
@ -124,7 +140,7 @@
|
||||||
android:paddingStart="2dp"
|
android:paddingStart="2dp"
|
||||||
android:paddingEnd="2dp"
|
android:paddingEnd="2dp"
|
||||||
android:text=":"
|
android:text=":"
|
||||||
android:textSize="16sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/pump_state"
|
android:id="@+id/pump_state"
|
||||||
|
@ -134,11 +150,12 @@
|
||||||
android:gravity="start"
|
android:gravity="start"
|
||||||
android:paddingStart="5dp"
|
android:paddingStart="5dp"
|
||||||
android:paddingEnd="5dp"
|
android:paddingEnd="5dp"
|
||||||
android:text="@{viewmodel.pumpState}"
|
android:text="@{viewmodel.medtrumPump.pumpStateFlow.toString()}"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:textSize="16sp" />
|
android:textSize="14sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Basal Type -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -152,8 +169,8 @@
|
||||||
android:gravity="end"
|
android:gravity="end"
|
||||||
android:paddingStart="5dp"
|
android:paddingStart="5dp"
|
||||||
android:paddingEnd="5dp"
|
android:paddingEnd="5dp"
|
||||||
android:text="@string/current_basal_type_label"
|
android:text="@string/basal_type_label"
|
||||||
android:textSize="16sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="5dp"
|
android:layout_width="5dp"
|
||||||
|
@ -163,21 +180,22 @@
|
||||||
android:paddingStart="2dp"
|
android:paddingStart="2dp"
|
||||||
android:paddingEnd="2dp"
|
android:paddingEnd="2dp"
|
||||||
android:text=":"
|
android:text=":"
|
||||||
android:textSize="16sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/current_basal_type"
|
android:id="@+id/basal_type"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:gravity="start"
|
android:gravity="start"
|
||||||
android:paddingStart="5dp"
|
android:paddingStart="5dp"
|
||||||
android:paddingEnd="5dp"
|
android:paddingEnd="5dp"
|
||||||
android:text="@{viewmodel.basalType}"
|
android:text="@{viewmodel.medtrumPump.lastBasalTypeFlow.toString()}"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:textSize="16sp" />
|
android:textSize="14sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Basal Rate -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -191,8 +209,8 @@
|
||||||
android:gravity="end"
|
android:gravity="end"
|
||||||
android:paddingStart="5dp"
|
android:paddingStart="5dp"
|
||||||
android:paddingEnd="5dp"
|
android:paddingEnd="5dp"
|
||||||
android:text="@string/current_basal_label"
|
android:text="@string/basal_rate_label"
|
||||||
android:textSize="16sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="5dp"
|
android:layout_width="5dp"
|
||||||
|
@ -202,21 +220,22 @@
|
||||||
android:paddingStart="2dp"
|
android:paddingStart="2dp"
|
||||||
android:paddingEnd="2dp"
|
android:paddingEnd="2dp"
|
||||||
android:text=":"
|
android:text=":"
|
||||||
android:textSize="16sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/current_basal"
|
android:id="@+id/basal_rate"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:gravity="start"
|
android:gravity="start"
|
||||||
android:paddingStart="5dp"
|
android:paddingStart="5dp"
|
||||||
android:paddingEnd="5dp"
|
android:paddingEnd="5dp"
|
||||||
android:text="@{viewmodel.runningBasalRate}"
|
android:text='@{@string/current_basal_rate(viewmodel.medtrumPump.lastBasalRateFlow)}'
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:textSize="16sp" />
|
android:textSize="14sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Reservoir -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -231,7 +250,7 @@
|
||||||
android:paddingStart="5dp"
|
android:paddingStart="5dp"
|
||||||
android:paddingEnd="5dp"
|
android:paddingEnd="5dp"
|
||||||
android:text="@string/reservoir_label"
|
android:text="@string/reservoir_label"
|
||||||
android:textSize="16sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="5dp"
|
android:layout_width="5dp"
|
||||||
|
@ -241,21 +260,241 @@
|
||||||
android:paddingStart="2dp"
|
android:paddingStart="2dp"
|
||||||
android:paddingEnd="2dp"
|
android:paddingEnd="2dp"
|
||||||
android:text=":"
|
android:text=":"
|
||||||
android:textSize="16sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/reservoir_level"
|
android:id="@+id/reservoir"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:gravity="start"
|
android:gravity="start"
|
||||||
android:paddingStart="5dp"
|
android:paddingStart="5dp"
|
||||||
android:paddingEnd="5dp"
|
android:paddingEnd="5dp"
|
||||||
android:text="@{viewmodel.reservoir}"
|
android:text='@{@string/reservoir_level(viewmodel.medtrumPump.reservoirFlow)}'
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:textSize="16sp" />
|
android:textSize="14sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Active Alarms -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginVertical="3dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1.5"
|
||||||
|
android:gravity="end"
|
||||||
|
android:paddingStart="5dp"
|
||||||
|
android:paddingEnd="5dp"
|
||||||
|
android:text="@string/active_alarms_label"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="5dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:paddingStart="2dp"
|
||||||
|
android:paddingEnd="2dp"
|
||||||
|
android:text=":"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/active_alarms"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="start"
|
||||||
|
android:paddingStart="5dp"
|
||||||
|
android:paddingEnd="5dp"
|
||||||
|
android:text="@{viewmodel.activeAlarms}"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="2dip"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:background="@color/list_delimiter" />
|
||||||
|
|
||||||
|
<!-- PumpType -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginVertical="3dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1.5"
|
||||||
|
android:gravity="end"
|
||||||
|
android:paddingStart="5dp"
|
||||||
|
android:paddingEnd="5dp"
|
||||||
|
android:text="@string/pump_type_label"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="5dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:paddingStart="2dp"
|
||||||
|
android:paddingEnd="2dp"
|
||||||
|
android:text=":"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/pump_type"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="start"
|
||||||
|
android:paddingStart="5dp"
|
||||||
|
android:paddingEnd="5dp"
|
||||||
|
android:text="@{viewmodel.pumpType}"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- FW Version -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginVertical="3dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1.5"
|
||||||
|
android:gravity="end"
|
||||||
|
android:paddingStart="5dp"
|
||||||
|
android:paddingEnd="5dp"
|
||||||
|
android:text="@string/fw_version_label"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="5dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:paddingStart="2dp"
|
||||||
|
android:paddingEnd="2dp"
|
||||||
|
android:text=":"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/fw_version"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="start"
|
||||||
|
android:paddingStart="5dp"
|
||||||
|
android:paddingEnd="5dp"
|
||||||
|
android:text="@{viewmodel.fwVersion}"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Patch No -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginVertical="3dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1.5"
|
||||||
|
android:gravity="end"
|
||||||
|
android:paddingStart="5dp"
|
||||||
|
android:paddingEnd="5dp"
|
||||||
|
android:text="@string/patch_no_label"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="5dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:paddingStart="2dp"
|
||||||
|
android:paddingEnd="2dp"
|
||||||
|
android:text=":"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/patch_no"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="start"
|
||||||
|
android:paddingStart="5dp"
|
||||||
|
android:paddingEnd="5dp"
|
||||||
|
android:text="@{viewmodel.patchNo}"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
<!-- Expiry? -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginVertical="3dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1.5"
|
||||||
|
android:gravity="end"
|
||||||
|
android:paddingStart="5dp"
|
||||||
|
android:paddingEnd="5dp"
|
||||||
|
android:text="@string/patch_expiry_label"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="5dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:paddingStart="2dp"
|
||||||
|
android:paddingEnd="2dp"
|
||||||
|
android:text=":"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/patch_expiry"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="start"
|
||||||
|
android:paddingStart="5dp"
|
||||||
|
android:paddingEnd="5dp"
|
||||||
|
android:text="@{viewmodel.patchExpiry}"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="2dip"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:background="@color/list_delimiter" />
|
||||||
|
|
||||||
|
<!-- Add other fields here as needed, like the ones above -->
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
@ -267,25 +506,37 @@
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<!-- Refresh button -->
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/button1"
|
android:id="@+id/refreshButton"
|
||||||
style="@style/ButtonMediumFontStyle"
|
style="@style/ButtonMediumFontStyle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:enabled="@{!viewmodel.isPatchActivated}"
|
android:enabled="@{viewmodel.canDoRefresh}"
|
||||||
android:text="@string/string_new_patch"
|
android:text="@string/refresh_label"
|
||||||
app:onSafeClick="@{() -> viewmodel.onClickActivation()}" />
|
app:onSafeClick="@{() -> viewmodel.onClickRefresh()}" />
|
||||||
|
|
||||||
|
<!-- Reset Alarms button -->
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/button2"
|
android:id="@+id/resetAlarmsButton"
|
||||||
style="@style/ButtonMediumFontStyle"
|
style="@style/ButtonMediumFontStyle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:enabled="@{viewmodel.isPatchActivated}"
|
android:text="@string/reset_alarms_label"
|
||||||
android:text="@string/string_stop_patch"
|
android:enabled="@{viewmodel.canDoResetAlarms}"
|
||||||
app:onSafeClick="@{() -> viewmodel.onClickDeactivation()}" />
|
app:onSafeClick="@{() -> viewmodel.onClickResetAlarms()}" />
|
||||||
|
|
||||||
|
<!-- Change Patch button -->
|
||||||
|
<Button
|
||||||
|
android:id="@+id/changePatchButton"
|
||||||
|
style="@style/ButtonMediumFontStyle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/change_patch_label"
|
||||||
|
app:onSafeClick="@{() -> viewmodel.onClickChangePatch()}" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
|
@ -21,19 +21,29 @@
|
||||||
<string name="medtrumpump_settings">Medtrum pump settings</string>
|
<string name="medtrumpump_settings">Medtrum pump settings</string>
|
||||||
<string name="pump_error">Pump error: %1$s !! </string>
|
<string name="pump_error">Pump error: %1$s !! </string>
|
||||||
<string name="pump_is_suspended">Pump is suspended</string>
|
<string name="pump_is_suspended">Pump is suspended</string>
|
||||||
|
<string name="pump_is_suspended_hour_max">Pump is suspended due to hourly max insulin exceeded</string>
|
||||||
|
<string name="pump_is_suspended_day_max">Pump is suspended due to daily max insulin exceeded</string>
|
||||||
<string name="patch_not_active">Patch not activated</string>
|
<string name="patch_not_active">Patch not activated</string>
|
||||||
<string name="pump_setting_failed">Setting user settings to pump failed!</string>
|
<string name="pump_setting_failed">Setting user settings to pump failed!</string>
|
||||||
|
|
||||||
<!-- overview fragment -->
|
<!-- overview fragment -->
|
||||||
<string name="medtrum_ble_status">BLE Status</string>
|
<string name="ble_status_label">BLE Status</string>
|
||||||
|
<string name="last_connected_label">Last connected</string>
|
||||||
<string name="pump_state_label">Pump state</string>
|
<string name="pump_state_label">Pump state</string>
|
||||||
|
<string name="active_alarms_label">Active alarms</string>
|
||||||
<string name="reservoir_label"> Reservoir</string>
|
<string name="reservoir_label"> Reservoir</string>
|
||||||
<string name="reservoir_level"> %.2f U</string>
|
<string name="reservoir_level"> %.2f U</string>
|
||||||
<string name="current_basal_type_label">Basal type</string>
|
<string name="basal_type_label">Basal type</string>
|
||||||
<string name="current_basal_label">Basal rate</string>
|
<string name="basal_rate_label">Basal rate</string>
|
||||||
<string name="current_basal_rate"> %.2f U/h</string>
|
<string name="current_basal_rate"> %.2f U/h</string>
|
||||||
<string name="string_new_patch">Start new patch</string>
|
<string name="pump_type_label">Pump type</string>
|
||||||
<string name="string_stop_patch">Stop patch</string>
|
<string name="fw_version_label">FW version</string>
|
||||||
|
<string name="patch_no_label">Patch no</string>
|
||||||
|
<string name="patch_expiry_label">Patch expires</string>
|
||||||
|
<string name="refresh_label">Refresh</string>
|
||||||
|
<string name="reset_alarms_label">Reset alarms</string>
|
||||||
|
<string name="change_patch_label">Change patch</string>
|
||||||
|
<string name="requested_by_user" comment="26 characters max for translation">Requested by user</string>
|
||||||
|
|
||||||
<!-- wizard-->
|
<!-- wizard-->
|
||||||
<string name="string_change_patch">Discard/Change Patch</string> <!-- TODO check-->
|
<string name="string_change_patch">Discard/Change Patch</string> <!-- TODO check-->
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import dagger.android.AndroidInjector
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
|
import info.nightscout.pump.medtrum.extension.toInt
|
||||||
|
import org.junit.jupiter.api.Test
|
||||||
|
import org.junit.Assert.*
|
||||||
|
|
||||||
|
class ClearPumpAlarmPacketTest : MedtrumTestBase() {
|
||||||
|
|
||||||
|
/** Test packet specific behavoir */
|
||||||
|
|
||||||
|
private val packetInjector = HasAndroidInjector {
|
||||||
|
AndroidInjector {
|
||||||
|
if (it is MedtrumPacket) {
|
||||||
|
it.aapsLogger = aapsLogger
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun getRequestGivenPacketWhenCalledThenReturnOpCode() {
|
||||||
|
// Inputs
|
||||||
|
val opCode = 115
|
||||||
|
val clearCode = 4
|
||||||
|
|
||||||
|
// Call
|
||||||
|
val packet = ClearPumpAlarmPacket(packetInjector, clearCode)
|
||||||
|
val result = packet.getRequest()
|
||||||
|
|
||||||
|
// Expected values
|
||||||
|
assertEquals(3, result.size)
|
||||||
|
assertEquals(opCode.toByte(), result[0])
|
||||||
|
assertEquals(clearCode, result.copyOfRange(1, 3).toInt())
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import dagger.android.AndroidInjector
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
|
import org.junit.jupiter.api.Test
|
||||||
|
import org.junit.Assert.*
|
||||||
|
|
||||||
|
class ResumePumpPacketTest : MedtrumTestBase() {
|
||||||
|
|
||||||
|
/** Test packet specific behavoir */
|
||||||
|
|
||||||
|
private val packetInjector = HasAndroidInjector {
|
||||||
|
AndroidInjector {
|
||||||
|
if (it is MedtrumPacket) {
|
||||||
|
it.aapsLogger = aapsLogger
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun getRequestGivenPacketWhenCalledThenReturnOpCode() {
|
||||||
|
// Inputs
|
||||||
|
val opCode = 29
|
||||||
|
|
||||||
|
// Call
|
||||||
|
val packet = ResumePumpPacket(packetInjector)
|
||||||
|
val result = packet.getRequest()
|
||||||
|
|
||||||
|
// Expected values
|
||||||
|
assertEquals(1, result.size)
|
||||||
|
assertEquals(opCode.toByte(), result[0])
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue