code cleanup

This commit is contained in:
Milos Kozak 2021-06-01 22:51:16 +02:00
parent db95670be5
commit fedba23405
28 changed files with 56 additions and 103 deletions

View file

@ -48,7 +48,7 @@ data class TherapyEvent(
enum class GlucoseUnit {
MGDL,
MMOL;
companion object { }
companion object
}
enum class MeterType(val text: String) {

View file

@ -4,5 +4,4 @@ import dagger.Module
@Module
@Suppress("unused")
abstract class InsightCommModule {
}
abstract class InsightCommModule

View file

@ -322,7 +322,7 @@ class MedtronicFragment : DaggerFragment() {
val tbrRemainingTime: Int? = medtronicPumpStatus.tbrRemainingTime
if (tbrRemainingTime != null) {
tbrStr = resourceHelper.gs(R.string.mdt_tbr_remaining, medtronicPumpStatus.tempBasalAmount, tbrRemainingTime);
tbrStr = resourceHelper.gs(R.string.mdt_tbr_remaining, medtronicPumpStatus.tempBasalAmount, tbrRemainingTime)
}
binding.tempBasal.text = tbrStr

View file

@ -109,7 +109,7 @@ class MedtronicConverter @Inject constructor(
}
}
public fun decodeSettingsLoop(rd: ByteArray): Map<String, PumpSettingDTO> {
fun decodeSettingsLoop(rd: ByteArray): Map<String, PumpSettingDTO> {
val map: MutableMap<String, PumpSettingDTO> = HashMap()
addSettingToMap("PCFG_MAX_BOLUS", "" + decodeMaxBolus(rd), PumpConfigurationGroup.Bolus, map)
addSettingToMap(

View file

@ -92,7 +92,7 @@ abstract class MedtronicHistoryDecoder<T : MedtronicHistoryEntry?>(var aapsLogge
StringUtil.appendToStringBuilder(sb, key1, ", ")
}
val spaces = StringUtils.repeat(" ", 14 - key.name.length)
aapsLogger.info(LTag.PUMPCOMM, " ${key.name}$spaces - ${value.size}. Elements: ${sb.toString()}")
aapsLogger.info(LTag.PUMPCOMM, " ${key.name}$spaces - ${value.size}. Elements: $sb")
} else {
aapsLogger.info(LTag.PUMPCOMM, " ${key.name} - ${value.size}")
}

View file

@ -17,24 +17,18 @@ abstract class MedtronicHistoryEntry : MedtronicHistoryEntryInterface {
lateinit var rawData: List<Byte>
protected var sizes = IntArray(3)
get() = field
lateinit var head: ByteArray
lateinit var datetime: ByteArray
lateinit var body: ByteArray
var id: Long = 0
set(value) {
field = value
}
@Expose
var DT: String? = null
get() = field
@Expose
var atechDateTime: Long = 0L
get() = field
set(value) {
field = value
DT = DateTimeUtil.toString(value)
@ -43,7 +37,6 @@ abstract class MedtronicHistoryEntry : MedtronicHistoryEntryInterface {
@Expose
var decodedData: MutableMap<String, Any> = mutableMapOf()
get() = field
/**
* Pump id that will be used with AAPS object (time * 1000 + historyType (max is FF = 255)
@ -61,7 +54,6 @@ abstract class MedtronicHistoryEntry : MedtronicHistoryEntryInterface {
* Linked object, see linked
*/
var linkedObject: Any? = null
get() = field
set(value) {
linked = true
field = value

View file

@ -24,16 +24,9 @@ class PumpHistoryEntry : MedtronicHistoryEntry() {
override var opCode: Byte? = null
// this is set only when we have unknown entry...
get() = if (field == null) entryType.code else field
set(value) {
field = value
}
var offset = 0
var displayableValue = ""
get() = field
set(value) {
field = value
}
fun setEntryType(medtronicDeviceType: MedtronicDeviceType, entryType: PumpHistoryEntryType, opCode: Byte? = null) {
this.entryType = entryType
@ -57,17 +50,6 @@ class PumpHistoryEntry : MedtronicHistoryEntry() {
+ StringUtil.getStringInLength("" + opCode, 3) + ", 0x"
+ ByteUtil.shortHexString(opCode!!) + "]")
override fun toString(): String {
return super.toString()
// Object object = this.getDecodedDataEntry("Object");
//
// if (object == null) {
// return super.toString();
// } else {
// return super.toString() + "PumpHistoryEntry [type=" + StringUtil.getStringInLength(entryType.name(), 20) + ", DT: " + DT + ", Object=" + object.toString() + "]";
// }
}
override val entryTypeName: String
get() = entryType.name
@ -117,9 +99,6 @@ class PumpHistoryEntry : MedtronicHistoryEntry() {
}
return field
}
set(pumpId) {
field = pumpId
}
fun hasBolusChanged(entry: PumpHistoryEntry): Boolean {
if (entryType == PumpHistoryEntryType.Bolus) {

View file

@ -205,7 +205,6 @@ constructor(var code: Byte,
private var specialRulesHead: MutableList<SpecialRule>? = null
private var specialRulesBody: MutableList<SpecialRule>? = null
private var hasSpecialRules = false
get() = field
fun getTotalLength(medtronicDeviceType: MedtronicDeviceType): Int {
return if (hasSpecialRules) {

View file

@ -22,10 +22,6 @@ class GetHistoryPageCarelinkMessageBody : CarelinkLongMessageBody {
override val length: Int
get() = data!!.size
override fun init(rxData: ByteArray?) {
super.init(rxData)
}
fun init(pageNum: Int) {
val numArgs: Byte = 1
super.init(byteArrayOf(numArgs, pageNum.toByte()))

View file

@ -91,7 +91,7 @@ class MedtronicHistoryData @Inject constructor(
.filter { f -> f.pumpId == pumpId }
.findFirst()
return if (findFirst.isPresent()) findFirst.get() else null
return if (findFirst.isPresent) findFirst.get() else null
}
private fun showLogs(header: String?, data: String) {

View file

@ -314,7 +314,7 @@ class BasalProfile {
fun isBasalProfileByHourUndefined(basalByHour: DoubleArray): Boolean {
for (i in 0..23) {
if (basalByHour[i] > 0.0) {
return false;
return false
}
}
return true

View file

@ -15,16 +15,9 @@ class BasalProfileEntry {
var rate_raw: ByteArray
var rate = 0.0
set(value) {
field = value
}
var startTime_raw: Byte
var startTime : LocalTime? = null // Just a "time of day"
set(value) {
field = value
}
constructor() {
rate = -9.999E6

View file

@ -62,7 +62,7 @@ class TempBasalPair : TempBasalPair {
aapsLogger.warn(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "TempBasalPair (with %d byte response): %s", response.size, toString()))
}
constructor(insulinRate: Double, isPercent: Boolean, durationMinutes: Int) : super(insulinRate, isPercent, durationMinutes) {}
constructor(insulinRate: Double, isPercent: Boolean, durationMinutes: Int) : super(insulinRate, isPercent, durationMinutes)
// list.add((byte) 0); // ?

View file

@ -19,5 +19,5 @@ enum class MedtronicNotificationType(var notificationType: Int,
PumpWrongMaxBasalSet(R.string.medtronic_error_pump_wrong_max_basal_set, Notification.NORMAL), //
PumpWrongTimeUrgent(R.string.medtronic_notification_check_time_date, Notification.URGENT), PumpWrongTimeNormal(R.string.medtronic_notification_check_time_date, Notification.NORMAL), TimeChangeOver24h(Notification.OVER_24H_TIME_CHANGE_REQUESTED, R.string.medtronic_error_pump_24h_time_change_requested, Notification.URGENT);
constructor(resourceId: Int, notificationUrgency: Int) : this(Notification.MEDTRONIC_PUMP_ALARM, resourceId, notificationUrgency) {}
constructor(resourceId: Int, notificationUrgency: Int) : this(Notification.MEDTRONIC_PUMP_ALARM, resourceId, notificationUrgency)
}

View file

@ -30,6 +30,6 @@ abstract class MedtronicModule {
companion object {
@Provides
fun byteUtilProvider(): ByteUtil = ByteUtil();
fun byteUtilProvider(): ByteUtil = ByteUtil()
}
}

View file

@ -84,10 +84,6 @@ class MedtronicHistoryActivity : DaggerActivity() {
manualChange = false
}
override fun onPause() {
super.onPause()
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.medtronic_history_activity)
@ -96,17 +92,17 @@ class MedtronicHistoryActivity : DaggerActivity() {
recyclerView = findViewById(R.id.medtronic_history_recyclerview)
recyclerView.setHasFixedSize(true)
llm = LinearLayoutManager(this)
recyclerView.setLayoutManager(llm)
recyclerView.layoutManager = llm
recyclerViewAdapter = RecyclerViewAdapter(filteredHistoryList)
recyclerView.setAdapter(recyclerViewAdapter)
statusView.setVisibility(View.GONE)
recyclerView.adapter = recyclerViewAdapter
statusView.visibility = View.GONE
typeListFull = getTypeList(PumpHistoryEntryGroup.getTranslatedList(resourceHelper))
val spinnerAdapter = ArrayAdapter(this, R.layout.spinner_centered, typeListFull)
historyTypeSpinner.setAdapter(spinnerAdapter)
historyTypeSpinner.setOnItemSelectedListener(object : AdapterView.OnItemSelectedListener {
historyTypeSpinner.adapter = spinnerAdapter
historyTypeSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(parent: AdapterView<*>?, view: View, position: Int, id: Long) {
if (manualChange) return
val selected = historyTypeSpinner.getSelectedItem() as TypeList
val selected = historyTypeSpinner.selectedItem as TypeList
showingType = selected
selectedGroup = selected.entryGroup
filterHistory(selectedGroup)
@ -116,7 +112,7 @@ class MedtronicHistoryActivity : DaggerActivity() {
if (manualChange) return
filterHistory(PumpHistoryEntryGroup.All)
}
})
}
}
private fun getTypeList(list: List<PumpHistoryEntryGroup>): List<TypeList> {

View file

@ -4,5 +4,4 @@ import dagger.Module
@Module
@Suppress("unused")
abstract class OmnipodDashModule {
}
abstract class OmnipodDashModule

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.
import java.nio.ByteBuffer;
public class BolusShortInsulinProgramElement implements ShortInsulinProgramElement {
private short numberOfPulses;
private final short numberOfPulses;
public BolusShortInsulinProgramElement(short numberOfPulses) {
this.numberOfPulses = numberOfPulses;

View file

@ -157,7 +157,7 @@ public enum AlarmType {
ALARM_BLE_QN_CRIT_VAR_FAIL((byte) 0xc2),
UNKNOWN((byte) 0xff);
private byte value;
private final byte value;
AlarmType(byte value) {
this.value = value;

View file

@ -5,14 +5,14 @@ import androidx.annotation.NonNull;
import java.nio.ByteBuffer;
public class AlertConfiguration implements Encodable {
private AlertSlot slot;
private boolean enabled;
private short durationInMinutes;
private boolean autoOff;
private AlertTriggerType triggerType;
private short offsetInMinutesOrThresholdInMicroLiters;
private BeepType beepType;
private BeepRepetitionType beepRepetition;
private final AlertSlot slot;
private final boolean enabled;
private final short durationInMinutes;
private final boolean autoOff;
private final AlertTriggerType triggerType;
private final short offsetInMinutesOrThresholdInMicroLiters;
private final BeepType beepType;
private final BeepRepetitionType beepRepetition;
public AlertConfiguration(AlertSlot slot, boolean enabled, short durationInMinutes, boolean autoOff, AlertTriggerType triggerType, short offsetInMinutesOrThresholdInMicroLiters, BeepType beepType, BeepRepetitionType beepRepetition) {
this.slot = slot;

View file

@ -11,7 +11,7 @@ public enum AlertSlot {
EXPIRATION((byte) 0x07),
UNKNOWN((byte) 0xff);
private byte value;
private final byte value;
AlertSlot(byte value) {
this.value = value;

View file

@ -8,7 +8,7 @@ public enum BeepRepetitionType {
XXX4((byte) 0x06), // Used in imminent pod expiration alert
XXX5((byte) 0x08); // Used in lump of coal alert
private byte value;
private final byte value;
BeepRepetitionType(byte value) {
this.value = value;

View file

@ -5,7 +5,7 @@ public enum BeepType {
FOUR_TIMES_BIP_BEEP((byte) 0x02), // Used in low reservoir alert, user expiration alert, expiration alert, imminent expiration alert, lump of coal alert
LONG_SINGLE_BEEP((byte) 0x06); // Used in stop delivery command
private byte value;
private final byte value;
BeepType(byte value) {
this.value = value;

View file

@ -9,7 +9,7 @@ public enum DeliveryStatus {
BOLUS_AND_TEMP_BASAL_ACTIVE((byte) 0x06),
UNKNOWN((byte) 0xff);
private byte value;
private final byte value;
DeliveryStatus(byte value) {
this.value = value;

View file

@ -32,7 +32,7 @@ public enum NakErrorType {
INVALID_CRC((byte) 0x1d),
UNKNOWN((byte) 0xff);
private byte value;
private final byte value;
NakErrorType(byte value) {
this.value = value;

View file

@ -19,7 +19,7 @@ public enum PodStatus {
DEACTIVATED((byte) 0x0f),
UNKNOWN((byte) 0xff);
private byte value;
private final byte value;
PodStatus(byte value) {
this.value = value;

View file

@ -7,7 +7,7 @@ public enum ResponseType {
NAK_RESPONSE((byte) 0x06),
UNKNOWN((byte) 0xff);
private byte value;
private final byte value;
ResponseType(byte value) {
this.value = value;
@ -37,7 +37,7 @@ public enum ResponseType {
STATUS_RESPONSE_PAGE_81((byte) 0x51),
UNKNOWN((byte) 0xff);
private byte value;
private final byte value;
AdditionalStatusResponseType(byte value) {
this.value = value;
@ -62,7 +62,7 @@ public enum ResponseType {
SET_UNIQUE_ID_RESPONSE((byte) 0x1b),
UNKNOWN((byte) 0xff);
private byte length;
private final byte length;
ActivationResponseType(byte length) {
this.length = length;

View file

@ -6,25 +6,25 @@ import java.util.Arrays;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus;
public final class SetUniqueIdResponse extends ActivationResponseBase {
private byte messageType;
private short messageLength;
private short pulseVolumeInTenThousandthMicroLiter;
private short pumpRate;
private short primePumpRate;
private short numberOfEngagingClutchDrivePulses;
private short numberOfPrimePulses;
private short podExpirationTimeInHours;
private short firmwareVersionMajor;
private short firmwareVersionMinor;
private short firmwareVersionInterim;
private short bleVersionMajor;
private short bleVersionMinor;
private short bleVersionInterim;
private short productId;
private PodStatus podStatus;
private long lotNumber;
private long podSequenceNumber;
private long uniqueIdReceivedInCommand;
private final byte messageType;
private final short messageLength;
private final short pulseVolumeInTenThousandthMicroLiter;
private final short pumpRate;
private final short primePumpRate;
private final short numberOfEngagingClutchDrivePulses;
private final short numberOfPrimePulses;
private final short podExpirationTimeInHours;
private final short firmwareVersionMajor;
private final short firmwareVersionMinor;
private final short firmwareVersionInterim;
private final short bleVersionMajor;
private final short bleVersionMinor;
private final short bleVersionInterim;
private final short productId;
private final PodStatus podStatus;
private final long lotNumber;
private final long podSequenceNumber;
private final long uniqueIdReceivedInCommand;
public SetUniqueIdResponse(byte[] encoded) {
super(ResponseType.ActivationResponseType.SET_UNIQUE_ID_RESPONSE, encoded);