Display Dana model

This commit is contained in:
Milos Kozak 2020-03-28 22:40:56 +01:00
parent 5e50ca8793
commit a85ec262d3
9 changed files with 32 additions and 22 deletions

View file

@ -210,12 +210,7 @@ class DanaRFragment : DaggerFragment() {
danar_battery.text = "{fa-battery-" + pump.batteryRemaining / 25 + "}"
SetWarnColor.setColorInverse(danar_battery, pump.batteryRemaining.toDouble(), 51.0, 26.0)
danar_iob.text = resourceHelper.gs(R.string.formatinsulinunits, pump.iob)
if (pump.btModel != 0 || pump.protocol != 0 || pump.productCode != 0) {
danar_firmware.text = resourceHelper.gs(R.string.danar_model, pump.btModel, pump.protocol, pump.productCode)
} else {
@Suppress("SetTextI18n")
danar_firmware.text = "OLD"
}
danar_firmware.text = resourceHelper.gs(R.string.danar_model, pump.modelFriendlyName(), pump.hwModel, pump.protocol, pump.productCode)
danar_basalstep.text = pump.basalStep.toString()
danar_bolusstep.text = pump.bolusStep.toString()
danar_serialnumber.text = pump.serialNumber
@ -229,7 +224,7 @@ class DanaRFragment : DaggerFragment() {
//hide user options button if not an RS pump or old firmware
// also excludes pump with model 03 because of untested error
val isKorean = danaRKoreanPlugin.isEnabled(PluginType.PUMP)
if (isKorean || danar_firmware.text === "OLD" || pump.btModel == 3) {
if (isKorean || pump.hwModel == 0 || pump.hwModel == 3) {
danar_user_options.visibility = View.GONE
}
}

View file

@ -51,7 +51,7 @@ class DanaRPump @Inject constructor(
var isNewPump = true // R only , providing model info
var password = -1 // R, RSv1
var pumpTime: Long = 0
var btModel = 0
var hwModel = 0
var protocol = 0
var productCode = 0
var errorState: ErrorState = ErrorState.NONE
@ -227,6 +227,21 @@ class DanaRPump @Inject constructor(
lastSettingsRead = 0
}
fun modelFriendlyName(): String =
when (hwModel) {
0x01 -> "DanaR Korean"
0x03 ->
if (protocol == 0x00) "DanaR old"
else if (protocol == 0x02) "DanaR v2"
else "DanaR" // 0x01 and 0x03 known
0x05 ->
if (protocol < 10) "DanaRS"
else "DanaRS v3"
0x06 -> "DanaRS Korean"
0x07 -> "Dana-i"
else -> "Unknown Dana pump"
}
companion object {
const val UNITS_MGDL = 0
const val UNITS_MMOL = 1

View file

@ -19,14 +19,14 @@ class MsgCheckValue(
override fun handleMessage(bytes: ByteArray) {
danaRPump.isNewPump = true
aapsLogger.debug(LTag.PUMPCOMM, "New firmware confirmed")
danaRPump.btModel = intFromBuff(bytes, 0, 1)
danaRPump.hwModel = intFromBuff(bytes, 0, 1)
danaRPump.protocol = intFromBuff(bytes, 1, 1)
danaRPump.productCode = intFromBuff(bytes, 2, 1)
if (danaRPump.btModel != DanaRPump.EXPORT_MODEL) {
if (danaRPump.hwModel != DanaRPump.EXPORT_MODEL) {
danaRPlugin.disconnect("Wrong Model")
aapsLogger.debug(LTag.PUMPCOMM, "Wrong model selected")
}
aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.btModel))
aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.hwModel))
aapsLogger.debug(LTag.PUMPCOMM, "Protocol: " + String.format("%02X ", danaRPump.protocol))
aapsLogger.debug(LTag.PUMPCOMM, "Product Code: " + String.format("%02X ", danaRPump.productCode))
}

View file

@ -21,14 +21,14 @@ class MsgCheckValue_k(
override fun handleMessage(bytes: ByteArray) {
danaRPump.isNewPump = true
aapsLogger.debug(LTag.PUMPCOMM, "New firmware confirmed")
danaRPump.btModel = intFromBuff(bytes, 0, 1)
danaRPump.hwModel = intFromBuff(bytes, 0, 1)
danaRPump.protocol = intFromBuff(bytes, 1, 1)
danaRPump.productCode = intFromBuff(bytes, 2, 1)
if (danaRPump.btModel != DanaRPump.DOMESTIC_MODEL) {
if (danaRPump.hwModel != DanaRPump.DOMESTIC_MODEL) {
danaRKoreanPlugin.disconnect("Wrong Model")
aapsLogger.debug(LTag.PUMPCOMM, "Wrong model selected")
}
aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.btModel))
aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.hwModel))
aapsLogger.debug(LTag.PUMPCOMM, "Protocol: " + String.format("%02X ", danaRPump.protocol))
aapsLogger.debug(LTag.PUMPCOMM, "Product Code: " + String.format("%02X ", danaRPump.productCode))
}

View file

@ -30,14 +30,14 @@ class DanaRS_Packet_General_Get_Pump_Check(
failed = false
var dataIndex = DATA_START
var dataSize = 1
danaRPump.btModel = byteArrayToInt(getBytes(data, dataIndex, dataSize))
danaRPump.hwModel = byteArrayToInt(getBytes(data, dataIndex, dataSize))
dataIndex += dataSize
dataSize = 1
danaRPump.protocol = byteArrayToInt(getBytes(data, dataIndex, dataSize))
dataIndex += dataSize
dataSize = 1
danaRPump.productCode = byteArrayToInt(getBytes(data, dataIndex, dataSize))
aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.btModel))
aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.hwModel))
aapsLogger.debug(LTag.PUMPCOMM, "Protocol: " + String.format("%02X ", danaRPump.protocol))
aapsLogger.debug(LTag.PUMPCOMM, "Product Code: " + String.format("%02X ", danaRPump.productCode))
if (danaRPump.productCode < 2) {

View file

@ -38,10 +38,10 @@ class MsgCheckValue_v2(
override fun handleMessage(bytes: ByteArray) {
danaRPump.isNewPump = true
aapsLogger.debug(LTag.PUMPCOMM, "New firmware confirmed")
danaRPump.btModel = intFromBuff(bytes, 0, 1)
danaRPump.hwModel = intFromBuff(bytes, 0, 1)
danaRPump.protocol = intFromBuff(bytes, 1, 1)
danaRPump.productCode = intFromBuff(bytes, 2, 1)
if (danaRPump.btModel != DanaRPump.EXPORT_MODEL) {
if (danaRPump.hwModel != DanaRPump.EXPORT_MODEL) {
danaRPump.reset()
val notification = Notification(Notification.WRONG_DRIVER, resourceHelper.gs(R.string.pumpdrivercorrected), Notification.NORMAL)
rxBus.send(EventNewNotification(notification))
@ -74,7 +74,7 @@ class MsgCheckValue_v2(
commandQueue.readStatus("PumpDriverChange", null) // force new connection
return
}
aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.btModel))
aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.hwModel))
aapsLogger.debug(LTag.PUMPCOMM, "Protocol: " + String.format("%02X ", danaRPump.protocol))
aapsLogger.debug(LTag.PUMPCOMM, "Product Code: " + String.format("%02X ", danaRPump.productCode))
}

View file

@ -485,7 +485,7 @@
<string name="always_use_shortavg_summary">Useful when data from unfiltered sources like xDrip gets noisy.</string>
<string name="advancedsettings_title">Advanced Settings</string>
<string name="key_advancedsettings" translatable="false">key_advancedsettings</string>
<string name="danar_model">Model: %1$02X Protocol: %2$02X Code: %3$02X</string>
<string name="danar_model">%1$s\nModel: %2$02X\nProtocol: %3$02X\nCode: %4$02X</string>
<string name="profile">Profile</string>
<string name="openapsama_max_daily_safety_multiplier_summary">Default value: 3 This is a key OpenAPS safety cap. What this does is limit your basals to be 3x (in this people) your biggest basal rate. You likely will not need to change this, but you should be aware thats what is discussed about “3x max daily; 4x current” for safety caps.</string>
<string name="openapsama_current_basal_safety_multiplier_summary">Default value: 4 This is the other half of the key OpenAPS safety caps, and the other half of “3x max daily; 4x current” of the safety caps. This means your basal, regardless of max basal set on your pump, cannot be any higher than this number times the current level of your basal. This is to prevent people from getting into dangerous territory by setting excessively high max basals before understanding how the algorithm works. Again, the default is 4x; most people will never need to adjust this and are instead more likely to need to adjust other settings if they feel like they are “running into” this safety cap.</string>

View file

@ -20,6 +20,6 @@ class MsgCheckValueTest : DanaRTestBase() {
val array = ByteArray(100)
putByteToArray(array, 0, DanaRPump.EXPORT_MODEL.toByte())
packet.handleMessage(array)
Assert.assertEquals(DanaRPump.EXPORT_MODEL, danaRPump.btModel)
Assert.assertEquals(DanaRPump.EXPORT_MODEL, danaRPump.hwModel)
}
}

View file

@ -33,6 +33,6 @@ class MsgCheckValue_v2Test : DanaRTestBase() {
val packet = MsgCheckValue_v2(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, danaRv2Plugin, configBuilderPlugin, commandQueue)
// test message decoding
packet.handleMessage(createArray(34, 3.toByte()))
Assert.assertEquals(DanaRPump.EXPORT_MODEL, danaRPump.btModel)
Assert.assertEquals(DanaRPump.EXPORT_MODEL, danaRPump.hwModel)
}
}