diff --git a/core/ui/src/main/java/info/nightscout/core/ui/extensions/RadioGroupExtension.kt b/core/ui/src/main/java/info/nightscout/core/ui/extensions/RadioGroupExtension.kt index 0bf51f656f..54b61b97db 100644 --- a/core/ui/src/main/java/info/nightscout/core/ui/extensions/RadioGroupExtension.kt +++ b/core/ui/src/main/java/info/nightscout/core/ui/extensions/RadioGroupExtension.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.utils.extensions +package info.nightscout.core.ui.extensions import android.widget.RadioGroup import androidx.appcompat.widget.AppCompatRadioButton diff --git a/core/utils/src/main/java/info/nightscout/core/utils/extensions/JSONObjectExt.kt b/core/utils/src/main/java/info/nightscout/core/utils/extensions/JSONObjectExt.kt index bfcf039497..8f38aab753 100644 --- a/core/utils/src/main/java/info/nightscout/core/utils/extensions/JSONObjectExt.kt +++ b/core/utils/src/main/java/info/nightscout/core/utils/extensions/JSONObjectExt.kt @@ -1,4 +1,4 @@ -package info.nightscout.core.extensions +package info.nightscout.core.utils.extensions import androidx.annotation.StringRes import info.nightscout.shared.interfaces.ResourceHelper diff --git a/plugins/aps/src/main/java/info/nightscout/plugins/general/autotune/AutotuneCore.kt b/plugins/aps/src/main/java/info/nightscout/plugins/general/autotune/AutotuneCore.kt index 3c0de91b51..a173b54a22 100644 --- a/plugins/aps/src/main/java/info/nightscout/plugins/general/autotune/AutotuneCore.kt +++ b/plugins/aps/src/main/java/info/nightscout/plugins/general/autotune/AutotuneCore.kt @@ -165,7 +165,7 @@ class AutotuneCore @Inject constructor( for (i in 0..23) { newHourlyBasalProfile[i] = hourlyBasalProfile[i] } - val basalUnTuned = previousAutotune.basalUntuned + val basalUnTuned = previousAutotune.basalUnTuned //autotune-core (lib/autotune/index.js) #210-#266 // look at net deviations for each hour @@ -484,7 +484,7 @@ class AutotuneCore @Inject constructor( previousAutotune.basal = basalProfile previousAutotune.isf = isf previousAutotune.ic = Round.roundTo(carbRatio, 0.001) - previousAutotune.basalUntuned = basalUnTuned + previousAutotune.basalUnTuned = basalUnTuned previousAutotune.dia = newDia previousAutotune.peak = newPeak val localInsulin = LocalInsulin("Ins_$newPeak-$newDia", newPeak, newDia) diff --git a/plugins/aps/src/main/java/info/nightscout/plugins/general/autotune/AutotuneFS.kt b/plugins/aps/src/main/java/info/nightscout/plugins/general/autotune/AutotuneFS.kt index fb32c8bb6f..69d655462d 100644 --- a/plugins/aps/src/main/java/info/nightscout/plugins/general/autotune/AutotuneFS.kt +++ b/plugins/aps/src/main/java/info/nightscout/plugins/general/autotune/AutotuneFS.kt @@ -89,14 +89,14 @@ class AutotuneFS @Inject constructor( } fun exportPumpProfile(profile: ATProfile) { - createAutotunefile(PUMPPROFILE, profile.profiletoOrefJSON(), true) - createAutotunefile(PUMPPROFILE, profile.profiletoOrefJSON()) + createAutotunefile(PUMPPROFILE, profile.profileToOrefJSON(), true) + createAutotunefile(PUMPPROFILE, profile.profileToOrefJSON()) } fun exportTunedProfile(tunedProfile: ATProfile) { - createAutotunefile(TUNEDPROFILE + formatDate(tunedProfile.from) + ".json", tunedProfile.profiletoOrefJSON()) + createAutotunefile(TUNEDPROFILE + formatDate(tunedProfile.from) + ".json", tunedProfile.profileToOrefJSON()) try { - createAutotunefile(rh.gs(info.nightscout.core.ui.R.string.autotune_tunedprofile_name) + ".json", tunedProfile.profiletoOrefJSON(), true) + createAutotunefile(rh.gs(info.nightscout.core.ui.R.string.autotune_tunedprofile_name) + ".json", tunedProfile.profileToOrefJSON(), true) } catch (e: JSONException) { } } diff --git a/plugins/aps/src/main/java/info/nightscout/plugins/general/autotune/AutotuneFragment.kt b/plugins/aps/src/main/java/info/nightscout/plugins/general/autotune/AutotuneFragment.kt index 2bfd3b5e14..be1c6f5f76 100644 --- a/plugins/aps/src/main/java/info/nightscout/plugins/general/autotune/AutotuneFragment.kt +++ b/plugins/aps/src/main/java/info/nightscout/plugins/general/autotune/AutotuneFragment.kt @@ -28,9 +28,9 @@ import info.nightscout.interfaces.Constants import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.logging.UserEntryLogger import info.nightscout.interfaces.plugin.ActivePlugin +import info.nightscout.interfaces.profile.Instantiator import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.ProfileFunction -import info.nightscout.interfaces.profile.Instantiator import info.nightscout.interfaces.profile.ProfileStore import info.nightscout.interfaces.ui.UiInteraction import info.nightscout.interfaces.utils.MidnightTime @@ -149,12 +149,12 @@ class AutotuneFragment : DaggerFragment() { } binding.autotuneUpdateProfile.setOnClickListener { - val localName = autotunePlugin.pumpProfile.profilename + val localName = autotunePlugin.pumpProfile.profileName OKDialog.showConfirmation(requireContext(), rh.gs(info.nightscout.core.ui.R.string.autotune_update_input_profile_button), rh.gs(info.nightscout.core.ui.R.string.autotune_update_local_profile_message, localName), Runnable { - autotunePlugin.tunedProfile?.profilename = localName + autotunePlugin.tunedProfile?.profileName = localName autotunePlugin.updateProfile(autotunePlugin.tunedProfile) autotunePlugin.updateButtonVisibility = View.GONE autotunePlugin.saveLastRun() @@ -169,12 +169,12 @@ class AutotuneFragment : DaggerFragment() { } binding.autotuneRevertProfile.setOnClickListener { - val localName = autotunePlugin.pumpProfile.profilename + val localName = autotunePlugin.pumpProfile.profileName OKDialog.showConfirmation(requireContext(), rh.gs(info.nightscout.core.ui.R.string.autotune_revert_input_profile_button), rh.gs(info.nightscout.core.ui.R.string.autotune_revert_local_profile_message, localName), Runnable { - autotunePlugin.tunedProfile?.profilename = "" + autotunePlugin.tunedProfile?.profileName = "" autotunePlugin.updateProfile(autotunePlugin.pumpProfile) autotunePlugin.updateButtonVisibility = View.VISIBLE autotunePlugin.saveLastRun() @@ -192,11 +192,11 @@ class AutotuneFragment : DaggerFragment() { val pumpProfile = profileFunction.getProfile()?.let { currentProfile -> profileStore.getSpecificProfile(profileName)?.let { specificProfile -> ATProfile(ProfileSealed.Pure(specificProfile), LocalInsulin(""), injector).also { - it.profilename = profileName + it.profileName = profileName } } ?: ATProfile(currentProfile, LocalInsulin(""), injector).also { - it.profilename = profileFunction.getProfileName() + it.profileName = profileFunction.getProfileName() } } pumpProfile?.let { @@ -205,7 +205,7 @@ class AutotuneFragment : DaggerFragment() { time = dateUtil.now(), mode = UiInteraction.Mode.CUSTOM_PROFILE, customProfile = pumpProfile.profile.toPureNsJson(dateUtil).toString(), - customProfileName = pumpProfile.profilename + customProfileName = pumpProfile.profileName ) } } @@ -219,7 +219,7 @@ class AutotuneFragment : DaggerFragment() { time = dateUtil.now(), mode = UiInteraction.Mode.PROFILE_COMPARE, customProfile = pumpProfile.profile.toPureNsJson(dateUtil).toString(), - customProfileName = pumpProfile.profilename + "\n" + rh.gs(info.nightscout.core.ui.R.string.autotune_tunedprofile_name), + customProfileName = pumpProfile.profileName + "\n" + rh.gs(info.nightscout.core.ui.R.string.autotune_tunedprofile_name), customProfile2 = tunedProfile?.toPureNsJson(dateUtil).toString() ) } @@ -231,17 +231,17 @@ class AutotuneFragment : DaggerFragment() { tunedProfile?.let { tunedP -> tunedP.profileStore(circadian)?.let { OKDialog.showConfirmation(requireContext(), - rh.gs(info.nightscout.core.ui.R.string.activate_profile) + ": " + tunedP.profilename + " ?", + rh.gs(info.nightscout.core.ui.R.string.activate_profile) + ": " + tunedP.profileName + " ?", { uel.log( UserEntry.Action.STORE_PROFILE, UserEntry.Sources.Autotune, - ValueWithUnit.SimpleString(tunedP.profilename) + ValueWithUnit.SimpleString(tunedP.profileName) ) val now = dateUtil.now() if (profileFunction.createProfileSwitch( it, - profileName = tunedP.profilename, + profileName = tunedP.profileName, durationInMinutes = 0, percentage = 100, timeShiftInHours = 0, @@ -252,7 +252,7 @@ class AutotuneFragment : DaggerFragment() { UserEntry.Action.PROFILE_SWITCH, UserEntry.Sources.Autotune, "Autotune AutoSwitch", - ValueWithUnit.SimpleString(autotunePlugin.tunedProfile!!.profilename) + ValueWithUnit.SimpleString(autotunePlugin.tunedProfile!!.profileName) ) } rxBus.send(EventLocalProfileChanged()) @@ -472,7 +472,7 @@ class AutotuneFragment : DaggerFragment() { val time = df.format(h.toLong()) + ":00" totalPump += autotunePlugin.pumpProfile.basal[h] totalTuned += tuned.basal[h] - layout.addView(toTableRowValue(context, time, autotunePlugin.pumpProfile.basal[h], tuned.basal[h], "%.3f", tuned.basalUntuned[h].toString())) + layout.addView(toTableRowValue(context, time, autotunePlugin.pumpProfile.basal[h], tuned.basal[h], "%.3f", tuned.basalUnTuned[h].toString())) } layout.addView(toTableRowValue(context, "∑", totalPump, totalTuned, "%.3f", " ")) } diff --git a/plugins/aps/src/main/java/info/nightscout/plugins/general/autotune/AutotunePlugin.kt b/plugins/aps/src/main/java/info/nightscout/plugins/general/autotune/AutotunePlugin.kt index 50c4ab61c2..461797ea48 100644 --- a/plugins/aps/src/main/java/info/nightscout/plugins/general/autotune/AutotunePlugin.kt +++ b/plugins/aps/src/main/java/info/nightscout/plugins/general/autotune/AutotunePlugin.kt @@ -14,9 +14,9 @@ import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginDescription import info.nightscout.interfaces.plugin.PluginType +import info.nightscout.interfaces.profile.Instantiator import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.ProfileFunction -import info.nightscout.interfaces.profile.Instantiator import info.nightscout.interfaces.utils.JsonHelper import info.nightscout.interfaces.utils.MidnightTime import info.nightscout.plugins.aps.R @@ -131,10 +131,10 @@ class AutotunePlugin @Inject constructor( val starttime = endTime - daysBack * 24 * 60 * 60 * 1000L autotuneFS.exportSettings(settings(lastRun, daysBack, starttime, endTime)) tunedProfile = ATProfile(profile, localInsulin, injector).also { - it.profilename = rh.gs(info.nightscout.core.ui.R.string.autotune_tunedprofile_name) + it.profileName = rh.gs(info.nightscout.core.ui.R.string.autotune_tunedprofile_name) } pumpProfile = ATProfile(profile, localInsulin, injector).also { - it.profilename = selectedProfile + it.profileName = selectedProfile } autotuneFS.exportPumpProfile(pumpProfile) @@ -195,31 +195,31 @@ class AutotunePlugin @Inject constructor( if (autoSwitch) { val circadian = sp.getBoolean(info.nightscout.core.utils.R.string.key_autotune_circadian_ic_isf, false) tunedProfile?.let { tunedP -> - tunedP.profilename = pumpProfile.profilename + tunedP.profileName = pumpProfile.profileName updateProfile(tunedP) uel.log( UserEntry.Action.STORE_PROFILE, UserEntry.Sources.Automation, rh.gs(info.nightscout.core.ui.R.string.autotune), - ValueWithUnit.SimpleString(tunedP.profilename) + ValueWithUnit.SimpleString(tunedP.profileName) ) updateButtonVisibility = View.GONE tunedP.profileStore(circadian)?.let { profilestore -> if (profileFunction.createProfileSwitch( profilestore, - profileName = tunedP.profilename, + profileName = tunedP.profileName, durationInMinutes = 0, percentage = 100, timeShiftInHours = 0, timestamp = dateUtil.now() ) ) { - log("Profile Switch succeed ${tunedP.profilename}") + log("Profile Switch succeed ${tunedP.profileName}") uel.log( UserEntry.Action.PROFILE_SWITCH, UserEntry.Sources.Automation, rh.gs(info.nightscout.core.ui.R.string.autotune), - ValueWithUnit.SimpleString(tunedP.profilename) + ValueWithUnit.SimpleString(tunedP.profileName) ) } rxBus.send(EventLocalProfileChanged()) @@ -262,7 +262,7 @@ class AutotunePlugin @Inject constructor( totalBasal += pumpProfile.basal[i] totalTuned += tunedProfile.basal[i] val percentageChangeValue = tunedProfile.basal[i] / pumpProfile.basal[i] * 100 - 100 - strResult += rh.gs(info.nightscout.core.ui.R.string.autotune_log_basal, i.toDouble(), pumpProfile.basal[i], tunedProfile.basal[i], tunedProfile.basalUntuned[i], percentageChangeValue) + strResult += rh.gs(info.nightscout.core.ui.R.string.autotune_log_basal, i.toDouble(), pumpProfile.basal[i], tunedProfile.basal[i], tunedProfile.basalUnTuned[i], percentageChangeValue) } strResult += line strResult += rh.gs(info.nightscout.core.ui.R.string.autotune_log_sum_basal, totalBasal, totalTuned) @@ -329,10 +329,10 @@ class AutotunePlugin @Inject constructor( val profileList: ArrayList = profileStore.getProfileList() var indexLocalProfile = -1 for (p in profileList.indices) - if (profileList[p] == newProfile.profilename) + if (profileList[p] == newProfile.profileName) indexLocalProfile = p if (indexLocalProfile == -1) { - profilePlugin.addProfile(profilePlugin.copyFrom(newProfile.getProfile(circadian), newProfile.profilename)) + profilePlugin.addProfile(profilePlugin.copyFrom(newProfile.getProfile(circadian), newProfile.profileName)) return } profilePlugin.currentProfileIndex = indexLocalProfile @@ -348,17 +348,17 @@ class AutotunePlugin @Inject constructor( json.put("lastNbDays", lastNbDays) json.put("lastRun", lastRun) json.put("pumpProfile", pumpProfile.profile.toPureNsJson(dateUtil)) - json.put("pumpProfileName", pumpProfile.profilename) + json.put("pumpProfileName", pumpProfile.profileName) json.put("pumpPeak", pumpProfile.peak) json.put("pumpDia", pumpProfile.dia) tunedProfile?.let { atProfile -> json.put("tunedProfile", atProfile.profile.toPureNsJson(dateUtil)) json.put("tunedCircadianProfile", atProfile.circadianProfile.toPureNsJson(dateUtil)) - json.put("tunedProfileName", atProfile.profilename) + json.put("tunedProfileName", atProfile.profileName) json.put("tunedPeak", atProfile.peak) json.put("tunedDia", atProfile.dia) for (i in 0..23) { - json.put("missingDays_$i", atProfile.basalUntuned[i]) + json.put("missingDays_$i", atProfile.basalUnTuned[i]) } } json.put("result", result) @@ -379,7 +379,7 @@ class AutotunePlugin @Inject constructor( selectedProfile = JsonHelper.safeGetString(json, "pumpProfileName", "") val profile = JsonHelper.safeGetJSONObject(json, "pumpProfile", null)?.let { pureProfileFromJson(it, dateUtil) } ?: return - pumpProfile = ATProfile(ProfileSealed.Pure(profile), localInsulin, injector).also { it.profilename = selectedProfile } + pumpProfile = ATProfile(ProfileSealed.Pure(profile), localInsulin, injector).also { it.profileName = selectedProfile } val tunedPeak = JsonHelper.safeGetInt(json, "tunedPeak") val tunedDia = JsonHelper.safeGetDouble(json, "tunedDia") localInsulin = LocalInsulin("PumpInsulin", tunedPeak, tunedDia) @@ -389,10 +389,10 @@ class AutotunePlugin @Inject constructor( val circadianTuned = JsonHelper.safeGetJSONObject(json, "tunedCircadianProfile", null)?.let { pureProfileFromJson(it, dateUtil) } ?: return tunedProfile = ATProfile(ProfileSealed.Pure(tuned), localInsulin, injector).also { atProfile -> - atProfile.profilename = tunedProfileName + atProfile.profileName = tunedProfileName atProfile.circadianProfile = ProfileSealed.Pure(circadianTuned) for (i in 0..23) { - atProfile.basalUntuned[i] = JsonHelper.safeGetInt(json, "missingDays_$i") + atProfile.basalUnTuned[i] = JsonHelper.safeGetInt(json, "missingDays_$i") } } result = JsonHelper.safeGetString(json, "result", "") diff --git a/plugins/aps/src/main/java/info/nightscout/plugins/general/autotune/data/ATProfile.kt b/plugins/aps/src/main/java/info/nightscout/plugins/general/autotune/data/ATProfile.kt index f8b139736a..e8861d37ef 100644 --- a/plugins/aps/src/main/java/info/nightscout/plugins/general/autotune/data/ATProfile.kt +++ b/plugins/aps/src/main/java/info/nightscout/plugins/general/autotune/data/ATProfile.kt @@ -10,13 +10,15 @@ import info.nightscout.interfaces.Config import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.insulin.Insulin import info.nightscout.interfaces.plugin.ActivePlugin +import info.nightscout.interfaces.profile.Instantiator import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.ProfileFunction -import info.nightscout.interfaces.profile.Instantiator import info.nightscout.interfaces.profile.ProfileStore import info.nightscout.interfaces.profile.PureProfile import info.nightscout.interfaces.utils.Round import info.nightscout.rx.bus.RxBus +import info.nightscout.rx.logging.AAPSLogger +import info.nightscout.rx.logging.LTag import info.nightscout.shared.SafeParse import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.sharedPreferences.SP @@ -28,6 +30,7 @@ import org.json.JSONObject import java.text.DecimalFormat import java.util.TimeZone import javax.inject.Inject +import kotlin.math.min class ATProfile(profile: Profile, var localInsulin: LocalInsulin, val injector: HasAndroidInjector) { @@ -39,30 +42,31 @@ class ATProfile(profile: Profile, var localInsulin: LocalInsulin, val injector: @Inject lateinit var rxBus: RxBus @Inject lateinit var rh: ResourceHelper @Inject lateinit var instantiator: Instantiator + @Inject lateinit var aapsLogger: AAPSLogger var profile: ProfileSealed var circadianProfile: ProfileSealed - lateinit var pumpProfile: ProfileSealed - var profilename: String = "" + private lateinit var pumpProfile: ProfileSealed + var profileName: String = "" var basal = DoubleArray(24) - var basalUntuned = IntArray(24) + var basalUnTuned = IntArray(24) var ic = 0.0 var isf = 0.0 var dia = 0.0 var peak = 0 var isValid: Boolean = false var from: Long = 0 - var pumpProfileAvgISF = 0.0 - var pumpProfileAvgIC = 0.0 + private var pumpProfileAvgISF = 0.0 + private var pumpProfileAvgIC = 0.0 val icSize: Int get() = profile.getIcsValues().size val isfSize: Int get() = profile.getIsfsMgdlValues().size - val avgISF: Double - get() = if (profile.getIsfsMgdlValues().size == 1) profile.getIsfsMgdlValues().get(0).value else Round.roundTo(averageProfileValue(profile.getIsfsMgdlValues()), 0.01) - val avgIC: Double - get() = if (profile.getIcsValues().size == 1) profile.getIcsValues().get(0).value else Round.roundTo(averageProfileValue(profile.getIcsValues()), 0.01) + private val avgISF: Double + get() = if (profile.getIsfsMgdlValues().size == 1) profile.getIsfsMgdlValues()[0].value else Round.roundTo(averageProfileValue(profile.getIsfsMgdlValues()), 0.01) + private val avgIC: Double + get() = if (profile.getIcsValues().size == 1) profile.getIcsValues()[0].value else Round.roundTo(averageProfileValue(profile.getIcsValues()), 0.01) fun getBasal(timestamp: Long): Double = basal[MidnightUtils.secondsFromMidnight(timestamp) / 3600] @@ -94,12 +98,12 @@ class ATProfile(profile: Profile, var localInsulin: LocalInsulin, val injector: //Export json string with oref0 format used for autotune // Include min_5m_carbimpact, insulin type, single value for carb_ratio and isf - fun profiletoOrefJSON(): String { + fun profileToOrefJSON(): String { var jsonString = "" val json = JSONObject() val insulinInterface: Insulin = activePlugin.activeInsulin try { - json.put("name", profilename) + json.put("name", profileName) json.put("min_5m_carbimpact", sp.getDouble("openapsama_min_5m_carbimpact", 3.0)) json.put("dia", dia) if (insulinInterface.id === Insulin.InsulinType.OREF_ULTRA_RAPID_ACTING) json.put( @@ -110,32 +114,31 @@ class ATProfile(profile: Profile, var localInsulin: LocalInsulin, val injector: json.put("useCustomPeakTime", true) json.put("insulinPeakTime", 45) } else if (insulinInterface.id === Insulin.InsulinType.OREF_FREE_PEAK) { - val peaktime: Int = sp.getInt(rh.gs(info.nightscout.core.utils.R.string.key_insulin_oref_peak), 75) - json.put("curve", if (peaktime > 50) "rapid-acting" else "ultra-rapid") + val peakTime: Int = sp.getInt(rh.gs(info.nightscout.core.utils.R.string.key_insulin_oref_peak), 75) + json.put("curve", if (peakTime > 50) "rapid-acting" else "ultra-rapid") json.put("useCustomPeakTime", true) - json.put("insulinPeakTime", peaktime) + json.put("insulinPeakTime", peakTime) } val basals = JSONArray() for (h in 0..23) { - val secondfrommidnight = h * 60 * 60 - var time: String - time = DecimalFormat("00").format(h) + ":00:00" + val secondFromMidnight = h * 60 * 60 + val time: String = DecimalFormat("00").format(h) + ":00:00" basals.put( JSONObject() .put("start", time) .put("minutes", h * 60) .put( - "rate", profile.getBasalTimeFromMidnight(secondfrommidnight) + "rate", profile.getBasalTimeFromMidnight(secondFromMidnight) ) ) } json.put("basalprofile", basals) - val isfvalue = Round.roundTo(avgISF, 0.001) + val isfValue = Round.roundTo(avgISF, 0.001) json.put( "isfProfile", JSONObject().put( "sensitivities", - JSONArray().put(JSONObject().put("i", 0).put("start", "00:00:00").put("sensitivity", isfvalue).put("offset", 0).put("x", 0).put("endoffset", 1440)) + JSONArray().put(JSONObject().put("i", 0).put("start", "00:00:00").put("sensitivity", isfValue).put("offset", 0).put("x", 0).put("endoffset", 1440)) ) ) json.put("carb_ratio", avgIC) @@ -145,6 +148,7 @@ class ATProfile(profile: Profile, var localInsulin: LocalInsulin, val injector: json.put("timezone", TimeZone.getDefault().id) jsonString = json.toString(2).replace("\\/", "/") } catch (e: JSONException) { + aapsLogger.error(LTag.CORE, e.stackTraceToString()) } return jsonString @@ -163,6 +167,7 @@ class ATProfile(profile: Profile, var localInsulin: LocalInsulin, val injector: } json.put("basal", jsonArray(basal)) } catch (e: JSONException) { + aapsLogger.error(LTag.CORE, e.stackTraceToString()) } return pureProfileFromJson(json, dateUtil, profile.units.asText) } @@ -172,36 +177,37 @@ class ATProfile(profile: Profile, var localInsulin: LocalInsulin, val injector: val json = JSONObject() val store = JSONObject() val tunedProfile = if (circadian) circadianProfile else profile - if (profilename.isEmpty()) - profilename = rh.gs(info.nightscout.core.ui.R.string.autotune_tunedprofile_name) + if (profileName.isEmpty()) + profileName = rh.gs(info.nightscout.core.ui.R.string.autotune_tunedprofile_name) try { - store.put(profilename, tunedProfile.toPureNsJson(dateUtil)) - json.put("defaultProfile", profilename) + store.put(profileName, tunedProfile.toPureNsJson(dateUtil)) + json.put("defaultProfile", profileName) json.put("store", store) json.put("startDate", dateUtil.toISOAsUTC(dateUtil.now())) profileStore = instantiator.provideProfileStore(json) } catch (e: JSONException) { + aapsLogger.error(LTag.CORE, e.stackTraceToString()) } return profileStore } - fun jsonArray(values: DoubleArray): JSONArray { + private fun jsonArray(values: DoubleArray): JSONArray { val json = JSONArray() for (h in 0..23) { - val secondfrommidnight = h * 60 * 60 + val secondFromMidnight = h * 60 * 60 val df = DecimalFormat("00") val time = df.format(h.toLong()) + ":00" json.put( JSONObject() .put("time", time) - .put("timeAsSeconds", secondfrommidnight) + .put("timeAsSeconds", secondFromMidnight) .put("value", values[h]) ) } return json } - fun jsonArray(value: Double) = + private fun jsonArray(value: Double): JSONArray = JSONArray().put( JSONObject() .put("time", "00:00") @@ -209,7 +215,7 @@ class ATProfile(profile: Profile, var localInsulin: LocalInsulin, val injector: .put("value", value) ) - fun jsonArray(values: List, multiplier: Double = 1.0): JSONArray { + private fun jsonArray(values: List, multiplier: Double = 1.0): JSONArray { val json = JSONArray() var elapsedHours = 0L values.forEach { @@ -249,7 +255,7 @@ class ATProfile(profile: Profile, var localInsulin: LocalInsulin, val injector: var minBasal = 1.0 for (h in 0..23) { basal[h] = Round.roundTo(profile.basalBlocks.blockValueBySeconds(T.hours(h.toLong()).secs().toInt(), 1.0, 0), 0.001) - minBasal = Math.min(minBasal, basal[h]) + minBasal = min(minBasal, basal[h]) } ic = avgIC isf = avgISF diff --git a/plugins/constraints/src/main/java/info/nightscout/plugins/constraints/safety/SafetyPlugin.kt b/plugins/constraints/src/main/java/info/nightscout/plugins/constraints/safety/SafetyPlugin.kt index 7dfaa68fcb..c748fa957b 100644 --- a/plugins/constraints/src/main/java/info/nightscout/plugins/constraints/safety/SafetyPlugin.kt +++ b/plugins/constraints/src/main/java/info/nightscout/plugins/constraints/safety/SafetyPlugin.kt @@ -1,12 +1,12 @@ package info.nightscout.plugins.constraints.safety import dagger.android.HasAndroidInjector -import info.nightscout.core.extensions.putDouble -import info.nightscout.core.extensions.putInt -import info.nightscout.core.extensions.putString -import info.nightscout.core.extensions.storeDouble -import info.nightscout.core.extensions.storeInt -import info.nightscout.core.extensions.storeString +import info.nightscout.core.utils.extensions.putDouble +import info.nightscout.core.utils.extensions.putInt +import info.nightscout.core.utils.extensions.putString +import info.nightscout.core.utils.extensions.storeDouble +import info.nightscout.core.utils.extensions.storeInt +import info.nightscout.core.utils.extensions.storeString import info.nightscout.interfaces.Config import info.nightscout.interfaces.constraints.Constraint import info.nightscout.interfaces.constraints.Constraints diff --git a/plugins/insulin/src/main/java/info/nightscout/insulin/InsulinOrefFreePeakPlugin.kt b/plugins/insulin/src/main/java/info/nightscout/insulin/InsulinOrefFreePeakPlugin.kt index 30ed94d058..60582ac68f 100644 --- a/plugins/insulin/src/main/java/info/nightscout/insulin/InsulinOrefFreePeakPlugin.kt +++ b/plugins/insulin/src/main/java/info/nightscout/insulin/InsulinOrefFreePeakPlugin.kt @@ -1,8 +1,8 @@ package info.nightscout.insulin import dagger.android.HasAndroidInjector -import info.nightscout.core.extensions.putInt -import info.nightscout.core.extensions.storeInt +import info.nightscout.core.utils.extensions.putInt +import info.nightscout.core.utils.extensions.storeInt import info.nightscout.interfaces.Config import info.nightscout.interfaces.insulin.Insulin import info.nightscout.interfaces.profile.ProfileFunction diff --git a/plugins/main/src/main/java/info/nightscout/plugins/general/overview/OverviewPlugin.kt b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/OverviewPlugin.kt index be8198fd6c..09facd21a8 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/general/overview/OverviewPlugin.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/OverviewPlugin.kt @@ -7,14 +7,14 @@ import androidx.preference.SwitchPreference import dagger.android.HasAndroidInjector import info.nightscout.core.events.EventIobCalculationProgress import info.nightscout.core.events.EventNewNotification -import info.nightscout.core.extensions.putDouble -import info.nightscout.core.extensions.putInt -import info.nightscout.core.extensions.putString -import info.nightscout.core.extensions.storeDouble -import info.nightscout.core.extensions.storeInt -import info.nightscout.core.extensions.storeString import info.nightscout.core.graph.OverviewData import info.nightscout.core.ui.dialogs.OKDialog +import info.nightscout.core.utils.extensions.putDouble +import info.nightscout.core.utils.extensions.putInt +import info.nightscout.core.utils.extensions.putString +import info.nightscout.core.utils.extensions.storeDouble +import info.nightscout.core.utils.extensions.storeInt +import info.nightscout.core.utils.extensions.storeString import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.interfaces.Config import info.nightscout.interfaces.Overview diff --git a/plugins/main/src/main/java/info/nightscout/plugins/general/overview/dialogs/EditQuickWizardDialog.kt b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/dialogs/EditQuickWizardDialog.kt index 78e3fac0f1..217b5adc92 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/general/overview/dialogs/EditQuickWizardDialog.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/dialogs/EditQuickWizardDialog.kt @@ -10,9 +10,9 @@ import android.view.WindowManager import com.google.android.material.timepicker.MaterialTimePicker import com.google.android.material.timepicker.TimeFormat import dagger.android.support.DaggerDialogFragment -import info.nightscout.androidaps.utils.extensions.selectedItemPosition -import info.nightscout.androidaps.utils.extensions.setEnableForChildren -import info.nightscout.androidaps.utils.extensions.setSelection +import info.nightscout.core.ui.extensions.selectedItemPosition +import info.nightscout.core.ui.extensions.setEnableForChildren +import info.nightscout.core.ui.extensions.setSelection import info.nightscout.core.wizard.QuickWizard import info.nightscout.core.wizard.QuickWizardEntry import info.nightscout.plugins.R diff --git a/plugins/main/src/main/java/info/nightscout/plugins/general/wear/WearFragment.kt b/plugins/main/src/main/java/info/nightscout/plugins/general/wear/WearFragment.kt index 12d516917d..57cd89ec9d 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/general/wear/WearFragment.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/general/wear/WearFragment.kt @@ -5,9 +5,9 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import dagger.android.support.DaggerFragment -import info.nightscout.androidaps.plugins.general.wear.events.EventWearUpdateGui import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.plugins.databinding.WearFragmentBinding +import info.nightscout.plugins.general.wear.events.EventWearUpdateGui import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.bus.RxBus import info.nightscout.rx.events.EventMobileToWear diff --git a/plugins/main/src/main/java/info/nightscout/plugins/general/wear/events/EventWearUpdateGui.kt b/plugins/main/src/main/java/info/nightscout/plugins/general/wear/events/EventWearUpdateGui.kt index e7cb807f01..b8c4761358 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/general/wear/events/EventWearUpdateGui.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/general/wear/events/EventWearUpdateGui.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.general.wear.events +package info.nightscout.plugins.general.wear.events import info.nightscout.rx.events.Event diff --git a/plugins/main/src/main/java/info/nightscout/plugins/general/wear/wearintegration/DataLayerListenerServiceMobile.kt b/plugins/main/src/main/java/info/nightscout/plugins/general/wear/wearintegration/DataLayerListenerServiceMobile.kt index 8e9696e0f4..13a8ff47f9 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/general/wear/wearintegration/DataLayerListenerServiceMobile.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/general/wear/wearintegration/DataLayerListenerServiceMobile.kt @@ -15,7 +15,6 @@ import com.google.android.gms.wearable.PutDataMapRequest import com.google.android.gms.wearable.Wearable import com.google.android.gms.wearable.WearableListenerService import dagger.android.AndroidInjection -import info.nightscout.androidaps.plugins.general.wear.events.EventWearUpdateGui import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.database.impl.AppRepository import info.nightscout.interfaces.Config @@ -27,6 +26,7 @@ import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.receivers.ReceiverStatusStore import info.nightscout.plugins.R import info.nightscout.plugins.general.wear.WearPlugin +import info.nightscout.plugins.general.wear.events.EventWearUpdateGui import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.bus.RxBus import info.nightscout.rx.events.EventMobileToWear diff --git a/pump/combo/src/main/java/info/nightscout/pump/combo/di/ComboActivitiesModule.kt b/pump/combo/src/main/java/info/nightscout/pump/combo/di/ComboActivitiesModule.kt index ea71e7d0b1..832893dd2c 100644 --- a/pump/combo/src/main/java/info/nightscout/pump/combo/di/ComboActivitiesModule.kt +++ b/pump/combo/src/main/java/info/nightscout/pump/combo/di/ComboActivitiesModule.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.danars.di +package info.nightscout.pump.combo.di import dagger.Module import dagger.android.ContributesAndroidInjector diff --git a/pump/combo/src/main/java/info/nightscout/pump/combo/di/ComboModule.kt b/pump/combo/src/main/java/info/nightscout/pump/combo/di/ComboModule.kt index d31494715d..405589340f 100644 --- a/pump/combo/src/main/java/info/nightscout/pump/combo/di/ComboModule.kt +++ b/pump/combo/src/main/java/info/nightscout/pump/combo/di/ComboModule.kt @@ -1,7 +1,6 @@ package info.nightscout.pump.combo.di import dagger.Module -import info.nightscout.androidaps.danars.di.ComboActivitiesModule @Module(includes = [ ComboActivitiesModule::class diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/packet/BasalLimitInquireResponsePacket.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/packet/BasalLimitInquireResponsePacket.kt index 0d2f428178..0089294c28 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/packet/BasalLimitInquireResponsePacket.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/packet/BasalLimitInquireResponsePacket.kt @@ -3,7 +3,7 @@ package info.nightscout.pump.diaconn.packet import dagger.android.HasAndroidInjector import info.nightscout.pump.diaconn.DiaconnG8Pump import info.nightscout.pump.diaconn.R -import info.nightscout.pump.diaconn.pumplog.PumplogUtil +import info.nightscout.pump.diaconn.pumplog.PumpLogUtil import info.nightscout.rx.logging.LTag import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.sharedPreferences.SP @@ -39,7 +39,7 @@ class BasalLimitInquireResponsePacket(injector: HasAndroidInjector) : DiaconnG8P } diaconnG8Pump.maxBasalPerHours = getShortToInt(bufferData).toDouble() / 100.0 // not include tempbasal limit val pumpFirmwareVersion = sp.getString(rh.gs(R.string.pumpversion), "") - if(pumpFirmwareVersion.isNotEmpty() && PumplogUtil.isPumpVersionGe(pumpFirmwareVersion, 3, 0)) { + if(pumpFirmwareVersion.isNotEmpty() && PumpLogUtil.isPumpVersionGe(pumpFirmwareVersion, 3, 0)) { diaconnG8Pump.maxBasal = diaconnG8Pump.maxBasalPerHours * 2.5 // include tempbasal } else { diaconnG8Pump.maxBasal = diaconnG8Pump.maxBasalPerHours * 2.0 // include tempbasal diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/packet/BigAPSMainInfoInquireResponsePacket.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/packet/BigAPSMainInfoInquireResponsePacket.kt index 0408aa03a1..975e8edade 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/packet/BigAPSMainInfoInquireResponsePacket.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/packet/BigAPSMainInfoInquireResponsePacket.kt @@ -3,7 +3,7 @@ package info.nightscout.pump.diaconn.packet import dagger.android.HasAndroidInjector import info.nightscout.pump.diaconn.DiaconnG8Pump import info.nightscout.pump.diaconn.R -import info.nightscout.pump.diaconn.pumplog.PumplogUtil +import info.nightscout.pump.diaconn.pumplog.PumpLogUtil import info.nightscout.rx.logging.LTag import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.sharedPreferences.SP @@ -214,7 +214,7 @@ class BigAPSMainInfoInquireResponsePacket( diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][23] = diaconnG8Pump.baseAmount24 //incarnation no 처리 - diaconnG8Pump.isPumpVersionGe2_63 = PumplogUtil.isPumpVersionGe(sp.getString(rh.gs(R.string.pumpversion), ""), 2, 63) + diaconnG8Pump.isPumpVersionGe2_63 = PumpLogUtil.isPumpVersionGe(sp.getString(rh.gs(R.string.pumpversion), ""), 2, 63) aapsLogger.debug(LTag.PUMPCOMM, "result > " + diaconnG8Pump.result) aapsLogger.debug(LTag.PUMPCOMM, "systemRemainInsulin > " + diaconnG8Pump.systemRemainInsulin) diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/packet/BigLogInquireResponsePacket.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/packet/BigLogInquireResponsePacket.kt index cc99c8b9f8..23c00cf689 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/packet/BigLogInquireResponsePacket.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/packet/BigLogInquireResponsePacket.kt @@ -19,32 +19,32 @@ import info.nightscout.pump.diaconn.api.PumpLogDto import info.nightscout.pump.diaconn.common.RecordTypes import info.nightscout.pump.diaconn.database.DiaconnHistoryRecord import info.nightscout.pump.diaconn.database.DiaconnHistoryRecordDao -import info.nightscout.pump.diaconn.pumplog.LOG_ALARM_BATTERY -import info.nightscout.pump.diaconn.pumplog.LOG_ALARM_BLOCK -import info.nightscout.pump.diaconn.pumplog.LOG_ALARM_SHORTAGE -import info.nightscout.pump.diaconn.pumplog.LOG_CHANGE_INJECTOR_SUCCESS -import info.nightscout.pump.diaconn.pumplog.LOG_CHANGE_NEEDLE_SUCCESS -import info.nightscout.pump.diaconn.pumplog.LOG_CHANGE_TUBE_SUCCESS -import info.nightscout.pump.diaconn.pumplog.LOG_INJECTION_1DAY -import info.nightscout.pump.diaconn.pumplog.LOG_INJECTION_1DAY_BASAL -import info.nightscout.pump.diaconn.pumplog.LOG_INJECTION_1HOUR_BASAL -import info.nightscout.pump.diaconn.pumplog.LOG_INJECTION_DUAL_NORMAL -import info.nightscout.pump.diaconn.pumplog.LOG_INJECT_DUAL_FAIL -import info.nightscout.pump.diaconn.pumplog.LOG_INJECT_DUAL_SUCCESS -import info.nightscout.pump.diaconn.pumplog.LOG_INJECT_MEAL_FAIL -import info.nightscout.pump.diaconn.pumplog.LOG_INJECT_MEAL_SUCCESS -import info.nightscout.pump.diaconn.pumplog.LOG_INJECT_NORMAL_FAIL -import info.nightscout.pump.diaconn.pumplog.LOG_INJECT_NORMAL_SUCCESS -import info.nightscout.pump.diaconn.pumplog.LOG_INJECT_SQUARE_FAIL -import info.nightscout.pump.diaconn.pumplog.LOG_INJECT_SQUARE_SUCCESS -import info.nightscout.pump.diaconn.pumplog.LOG_RESET_SYS_V3 -import info.nightscout.pump.diaconn.pumplog.LOG_SET_DUAL_INJECTION -import info.nightscout.pump.diaconn.pumplog.LOG_SET_SQUARE_INJECTION -import info.nightscout.pump.diaconn.pumplog.LOG_SUSPEND_RELEASE_V2 -import info.nightscout.pump.diaconn.pumplog.LOG_SUSPEND_V2 -import info.nightscout.pump.diaconn.pumplog.LOG_TB_START_V3 -import info.nightscout.pump.diaconn.pumplog.LOG_TB_STOP_V3 -import info.nightscout.pump.diaconn.pumplog.PumplogUtil +import info.nightscout.pump.diaconn.pumplog.LogAlarmBattery +import info.nightscout.pump.diaconn.pumplog.LogAlarmBlock +import info.nightscout.pump.diaconn.pumplog.LogAlarmShortAge +import info.nightscout.pump.diaconn.pumplog.LogChangeInjectorSuccess +import info.nightscout.pump.diaconn.pumplog.LogChangeNeedleSuccess +import info.nightscout.pump.diaconn.pumplog.LogChangeTubeSuccess +import info.nightscout.pump.diaconn.pumplog.LogInjectDualFail +import info.nightscout.pump.diaconn.pumplog.LogInjectDualSuccess +import info.nightscout.pump.diaconn.pumplog.LogInjectMealFail +import info.nightscout.pump.diaconn.pumplog.LogInjectMealSuccess +import info.nightscout.pump.diaconn.pumplog.LogInjectNormalFail +import info.nightscout.pump.diaconn.pumplog.LogInjectNormalSuccess +import info.nightscout.pump.diaconn.pumplog.LogInjectSquareFail +import info.nightscout.pump.diaconn.pumplog.LogInjectSquareSuccess +import info.nightscout.pump.diaconn.pumplog.LogInjection1Day +import info.nightscout.pump.diaconn.pumplog.LogInjection1DayBasal +import info.nightscout.pump.diaconn.pumplog.LogInjection1HourBasal +import info.nightscout.pump.diaconn.pumplog.LogInjectionDualNormal +import info.nightscout.pump.diaconn.pumplog.LogResetSysV3 +import info.nightscout.pump.diaconn.pumplog.LogSetDualInjection +import info.nightscout.pump.diaconn.pumplog.LogSetSquareInjection +import info.nightscout.pump.diaconn.pumplog.LogSuspendReleaseV2 +import info.nightscout.pump.diaconn.pumplog.LogSuspendV2 +import info.nightscout.pump.diaconn.pumplog.LogTbStartV3 +import info.nightscout.pump.diaconn.pumplog.LogTbStopV3 +import info.nightscout.pump.diaconn.pumplog.PumpLogUtil import info.nightscout.rx.bus.RxBus import info.nightscout.rx.events.EventPumpStatusChanged import info.nightscout.rx.logging.LTag @@ -113,22 +113,22 @@ class BigLogInquireResponsePacket( val logNum = getShortToInt(bufferData) // 2byte // log Data Parsing val logData = byteArrayOf( - PumplogUtil.getByte(bufferData), - PumplogUtil.getByte(bufferData), - PumplogUtil.getByte(bufferData), - PumplogUtil.getByte(bufferData), - PumplogUtil.getByte(bufferData), - PumplogUtil.getByte(bufferData), - PumplogUtil.getByte(bufferData), - PumplogUtil.getByte(bufferData), - PumplogUtil.getByte(bufferData), - PumplogUtil.getByte(bufferData), - PumplogUtil.getByte(bufferData), - PumplogUtil.getByte(bufferData) + PumpLogUtil.getByte(bufferData), + PumpLogUtil.getByte(bufferData), + PumpLogUtil.getByte(bufferData), + PumpLogUtil.getByte(bufferData), + PumpLogUtil.getByte(bufferData), + PumpLogUtil.getByte(bufferData), + PumpLogUtil.getByte(bufferData), + PumpLogUtil.getByte(bufferData), + PumpLogUtil.getByte(bufferData), + PumpLogUtil.getByte(bufferData), + PumpLogUtil.getByte(bufferData), + PumpLogUtil.getByte(bufferData) ) // process Log to DB val logDataToHexString = toNarrowHex(logData) - val pumpLogKind: Byte = PumplogUtil.getKind(logDataToHexString) + val pumpLogKind: Byte = PumpLogUtil.getKind(logDataToHexString) var status: String val diaconnG8HistoryRecord = DiaconnHistoryRecord(0) @@ -151,8 +151,8 @@ class BigLogInquireResponsePacket( when (pumpLogKind) { - LOG_INJECT_MEAL_SUCCESS.LOG_KIND -> { - val logItem = LOG_INJECT_MEAL_SUCCESS.parse(logDataToHexString) + LogInjectMealSuccess.LOG_KIND -> { + val logItem = LogInjectMealSuccess.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") val logDateTime = logStartDate.time @@ -186,8 +186,8 @@ class BigLogInquireResponsePacket( status = "MEAL_BOLUS_SUCCESS" + dateUtil.timeString(logDateTime) } - LOG_INJECT_MEAL_FAIL.LOG_KIND -> { - val logItem = LOG_INJECT_MEAL_FAIL.parse(logDataToHexString) + LogInjectMealFail.LOG_KIND -> { + val logItem = LogInjectMealFail.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") val logDateTime = logStartDate.time @@ -221,8 +221,8 @@ class BigLogInquireResponsePacket( status = "MEAL_BOLUS_FAIL " + dateUtil.timeString(logDateTime) } - LOG_INJECT_NORMAL_SUCCESS.LOG_KIND -> { - val logItem = LOG_INJECT_NORMAL_SUCCESS.parse(logDataToHexString) + LogInjectNormalSuccess.LOG_KIND -> { + val logItem = LogInjectNormalSuccess.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") @@ -257,8 +257,8 @@ class BigLogInquireResponsePacket( status = "BOLUS_SUCCESS" + dateUtil.timeString(logDateTime) } - LOG_INJECT_NORMAL_FAIL.LOG_KIND -> { - val logItem = LOG_INJECT_NORMAL_FAIL.parse(logDataToHexString) + LogInjectNormalFail.LOG_KIND -> { + val logItem = LogInjectNormalFail.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") val logDateTime = logStartDate.time @@ -295,8 +295,8 @@ class BigLogInquireResponsePacket( status = "BOLUS_FAIL " + dateUtil.timeString(logDateTime) } - LOG_SET_SQUARE_INJECTION.LOG_KIND -> { - val logItem = LOG_SET_SQUARE_INJECTION.parse(logDataToHexString) + LogSetSquareInjection.LOG_KIND -> { + val logItem = LogSetSquareInjection.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") val logDateTime = logStartDate.time @@ -326,8 +326,8 @@ class BigLogInquireResponsePacket( status = "EXTENDED_BOLUS_START " + dateUtil.timeString(logDateTime) } - LOG_INJECT_SQUARE_SUCCESS.LOG_KIND -> { - val logItem = LOG_INJECT_SQUARE_SUCCESS.parse(logDataToHexString) + LogInjectSquareSuccess.LOG_KIND -> { + val logItem = LogInjectSquareSuccess.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") val logDateTime = logStartDate.time @@ -343,8 +343,8 @@ class BigLogInquireResponsePacket( status = "EXTENDED_BOLUS_END " + dateUtil.timeString(logDateTime) } - LOG_INJECT_SQUARE_FAIL.LOG_KIND -> { - val logItem = LOG_INJECT_SQUARE_FAIL.parse(logDataToHexString) + LogInjectSquareFail.LOG_KIND -> { + val logItem = LogInjectSquareFail.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") val logDateTime = logStartDate.time @@ -371,8 +371,8 @@ class BigLogInquireResponsePacket( status = "EXTENDED_BOLUS_FAIL " + dateUtil.timeString(logDateTime) } - LOG_SET_DUAL_INJECTION.LOG_KIND -> { - val logItem = LOG_SET_DUAL_INJECTION.parse(logDataToHexString) + LogSetDualInjection.LOG_KIND -> { + val logItem = LogSetDualInjection.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") val logDateTime = logStartDate.time @@ -405,8 +405,8 @@ class BigLogInquireResponsePacket( status = "DUAL_EXTENDED_START " + dateUtil.timeString(logDateTime) } - LOG_INJECTION_DUAL_NORMAL.LOG_KIND -> { - val logItem = LOG_INJECTION_DUAL_NORMAL.parse(logDataToHexString) + LogInjectionDualNormal.LOG_KIND -> { + val logItem = LogInjectionDualNormal.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") val logDateTime = logStartDate.time @@ -445,8 +445,8 @@ class BigLogInquireResponsePacket( status = "DUAL_BOLUS" + dateUtil.timeString(logDateTime) } - LOG_INJECT_DUAL_SUCCESS.LOG_KIND -> { - val logItem = LOG_INJECT_DUAL_SUCCESS.parse(logDataToHexString) + LogInjectDualSuccess.LOG_KIND -> { + val logItem = LogInjectDualSuccess.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") val logDateTime = logStartDate.time @@ -464,8 +464,8 @@ class BigLogInquireResponsePacket( status = "DUAL_BOLUS_SQUARE_SUCCESS " + dateUtil.timeString(logDateTime) } - LOG_INJECT_DUAL_FAIL.LOG_KIND -> { - val logItem = LOG_INJECT_DUAL_FAIL.parse(logDataToHexString) + LogInjectDualFail.LOG_KIND -> { + val logItem = LogInjectDualFail.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") val logDateTime = logStartDate.time @@ -493,8 +493,8 @@ class BigLogInquireResponsePacket( status = "DUAL_BOLUS FAIL " + dateUtil.timeString(logDateTime) } - LOG_INJECTION_1HOUR_BASAL.LOG_KIND -> { - val logItem = LOG_INJECTION_1HOUR_BASAL.parse(logDataToHexString) + LogInjection1HourBasal.LOG_KIND -> { + val logItem = LogInjection1HourBasal.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") val logDateTime = logStartDate.time @@ -509,8 +509,8 @@ class BigLogInquireResponsePacket( status = "1HOUR BASAL " + dateUtil.dateAndTimeString(logDateTime) } - LOG_SUSPEND_V2.LOG_KIND -> { - val logItem = LOG_SUSPEND_V2.parse(logDataToHexString) + LogSuspendV2.LOG_KIND -> { + val logItem = LogSuspendV2.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") val logDateTime = logStartDate.time @@ -524,8 +524,8 @@ class BigLogInquireResponsePacket( status = "SUSPEND " + dateUtil.timeString(logDateTime) } - LOG_SUSPEND_RELEASE_V2.LOG_KIND -> { - val logItem = LOG_SUSPEND_RELEASE_V2.parse(logDataToHexString) + LogSuspendReleaseV2.LOG_KIND -> { + val logItem = LogSuspendReleaseV2.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") val logDateTime = logStartDate.time @@ -539,8 +539,8 @@ class BigLogInquireResponsePacket( status = "SUSPEND_RELEASE " + dateUtil.timeString(logDateTime) } - LOG_CHANGE_INJECTOR_SUCCESS.LOG_KIND -> { - val logItem = LOG_CHANGE_INJECTOR_SUCCESS.parse(logDataToHexString) + LogChangeInjectorSuccess.LOG_KIND -> { + val logItem = LogChangeInjectorSuccess.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") val logDateTime = logStartDate.time @@ -568,8 +568,8 @@ class BigLogInquireResponsePacket( status = "INSULIN_CHANGE " + dateUtil.timeString(logDateTime) } - LOG_CHANGE_TUBE_SUCCESS.LOG_KIND -> { - val logItem = LOG_CHANGE_TUBE_SUCCESS.parse(logDataToHexString) + LogChangeTubeSuccess.LOG_KIND -> { + val logItem = LogChangeTubeSuccess.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") val logDateTime = logStartDate.time @@ -600,8 +600,8 @@ class BigLogInquireResponsePacket( status = "TUBE_CHANGE " + dateUtil.timeString(logDateTime) } - LOG_INJECTION_1DAY.LOG_KIND -> { // Daily Bolus Log - val logItem = LOG_INJECTION_1DAY.parse(logDataToHexString) + LogInjection1Day.LOG_KIND -> { // Daily Bolus Log + val logItem = LogInjection1Day.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") val logDateTime = logStartDate.time @@ -649,8 +649,8 @@ class BigLogInquireResponsePacket( status = "DAILY_BOLUS " + dateUtil.timeString(logDateTime) } - LOG_INJECTION_1DAY_BASAL.LOG_KIND -> { // Daily Basal Log - val logItem = LOG_INJECTION_1DAY_BASAL.parse(logDataToHexString) + LogInjection1DayBasal.LOG_KIND -> { // Daily Basal Log + val logItem = LogInjection1DayBasal.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") val logDateTime = logStartDate.time @@ -698,8 +698,8 @@ class BigLogInquireResponsePacket( status = "DAILY_BASAL " + dateUtil.timeString(logDateTime) } - LOG_CHANGE_NEEDLE_SUCCESS.LOG_KIND -> { - val logItem = LOG_CHANGE_NEEDLE_SUCCESS.parse(logDataToHexString) + LogChangeNeedleSuccess.LOG_KIND -> { + val logItem = LogChangeNeedleSuccess.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") val logDateTime = logStartDate.time @@ -728,8 +728,8 @@ class BigLogInquireResponsePacket( status = "NEEDLE_CHANGE " + dateUtil.timeString(logDateTime) } - LOG_TB_START_V3.LOG_KIND -> { - val logItem = LOG_TB_START_V3.parse(logDataToHexString) + LogTbStartV3.LOG_KIND -> { + val logItem = LogTbStartV3.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") @@ -772,8 +772,8 @@ class BigLogInquireResponsePacket( status = "TEMP_START " + dateUtil.timeString(logDateTime) } - LOG_TB_STOP_V3.LOG_KIND -> { - val logItem = LOG_TB_STOP_V3.parse(logDataToHexString) + LogTbStopV3.LOG_KIND -> { + val logItem = LogTbStopV3.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") val logDateTime = logStartDate.time @@ -806,8 +806,8 @@ class BigLogInquireResponsePacket( status = "TEMP_STOP " + dateUtil.timeString(logDateTime) } - LOG_ALARM_BATTERY.LOG_KIND -> { // BATTERY SHORTAGE ALARM - val logItem = LOG_ALARM_BATTERY.parse(logDataToHexString) + LogAlarmBattery.LOG_KIND -> { // BATTERY SHORTAGE ALARM + val logItem = LogAlarmBattery.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") val logDateTime = logStartDate.time @@ -822,8 +822,8 @@ class BigLogInquireResponsePacket( status = "BATTERY_ALARM " + dateUtil.timeString(logDateTime) } - LOG_ALARM_BLOCK.LOG_KIND -> { // INJECTION BLOCKED ALARM - val logItem = LOG_ALARM_BLOCK.parse(logDataToHexString) + LogAlarmBlock.LOG_KIND -> { // INJECTION BLOCKED ALARM + val logItem = LogAlarmBlock.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") @@ -840,8 +840,8 @@ class BigLogInquireResponsePacket( status = "BLOCK_ALARM " + dateUtil.timeString(logDateTime) } - LOG_ALARM_SHORTAGE.LOG_KIND -> { // INSULIN SHORTAGE ALARM - val logItem = LOG_ALARM_SHORTAGE.parse(logDataToHexString) + LogAlarmShortAge.LOG_KIND -> { // INSULIN SHORTAGE ALARM + val logItem = LogAlarmShortAge.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") @@ -858,8 +858,8 @@ class BigLogInquireResponsePacket( status = "SHORT_AGE_ALARM " + dateUtil.timeString(logDateTime) } - LOG_RESET_SYS_V3.LOG_KIND -> { - val logItem = LOG_RESET_SYS_V3.parse(logDataToHexString) + LogResetSysV3.LOG_KIND -> { + val logItem = LogResetSysV3.parse(logDataToHexString) aapsLogger.debug(LTag.PUMPCOMM, "$logItem ") val logStartDate = DateUtils.parseDate(logItem.dttm, "yyyy-MM-dd HH:mm:ss") diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/packet/BigMainInfoInquireResponsePacket.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/packet/BigMainInfoInquireResponsePacket.kt index 7ee93e9a1f..ce67dc789d 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/packet/BigMainInfoInquireResponsePacket.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/packet/BigMainInfoInquireResponsePacket.kt @@ -5,7 +5,7 @@ import info.nightscout.interfaces.pump.defs.PumpDescription import info.nightscout.interfaces.pump.defs.PumpType import info.nightscout.pump.diaconn.DiaconnG8Pump import info.nightscout.pump.diaconn.R -import info.nightscout.pump.diaconn.pumplog.PumplogUtil +import info.nightscout.pump.diaconn.pumplog.PumpLogUtil import info.nightscout.rx.logging.LTag import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.sharedPreferences.SP @@ -213,7 +213,7 @@ class BigMainInfoInquireResponsePacket( diaconnG8Pump.pumpProfiles!![diaconnG8Pump.activeProfile][23] = diaconnG8Pump.baseAmount24 //incarnation no 처리 - diaconnG8Pump.isPumpVersionGe2_63 = PumplogUtil.isPumpVersionGe(sp.getString(rh.gs(R.string.pumpversion), ""), 2, 63) + diaconnG8Pump.isPumpVersionGe2_63 = PumpLogUtil.isPumpVersionGe(sp.getString(rh.gs(R.string.pumpversion), ""), 2, 63) aapsLogger.debug(LTag.PUMPCOMM, "result > " + diaconnG8Pump.result) aapsLogger.debug(LTag.PUMPCOMM, "systemRemainInsulin > " + diaconnG8Pump.systemRemainInsulin) diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_ALARM_BATTERY.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogAlarmBattery.kt similarity index 68% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_ALARM_BATTERY.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogAlarmBattery.kt index faf98ff078..75ad61dce4 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_ALARM_BATTERY.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogAlarmBattery.kt @@ -6,7 +6,7 @@ import java.nio.ByteOrder /* * Battery Shortage Alarm Log */ -class LOG_ALARM_BATTERY private constructor( +class LogAlarmBattery private constructor( val data: String, val dttm: String, typeAndKind: Byte, // 1=INFO, 2=WARNING, 3=MAJOR, 4=CRITICAL @@ -15,8 +15,8 @@ class LOG_ALARM_BATTERY private constructor( val batteryRemain: Byte ) { - val type: Byte = PumplogUtil.getType(typeAndKind) - val kind: Byte = PumplogUtil.getKind(typeAndKind) + val type: Byte = PumpLogUtil.getType(typeAndKind) + val kind: Byte = PumpLogUtil.getKind(typeAndKind) override fun toString(): String { val sb = StringBuilder("LOG_ALARM_BATTERY{") @@ -35,17 +35,17 @@ class LOG_ALARM_BATTERY private constructor( companion object { const val LOG_KIND: Byte = 0x28 - fun parse(data: String): LOG_ALARM_BATTERY { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogAlarmBattery { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_ALARM_BATTERY( + return LogAlarmBattery( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer) ) } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_ALARM_BLOCK.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogAlarmBlock.kt similarity index 66% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_ALARM_BLOCK.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogAlarmBlock.kt index 5b794a8843..dcfc0b8397 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_ALARM_BLOCK.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogAlarmBlock.kt @@ -6,19 +6,19 @@ import java.nio.ByteOrder /* * Injection Blocked Alarm Log */ -class LOG_ALARM_BLOCK private constructor( +class LogAlarmBlock private constructor( val data: String, val dttm: String, typeAndKind: Byte, // 1=INFO, 2=WARNING, 3=MAJOR, 4=CRITICAL - val alarmLevel: Byte, // 1=OCCUR - val ack: Byte, + private val alarmLevel: Byte, // 1=OCCUR + private val ack: Byte, val amount: Short, // 1=BASE, 2=Meal, 3=snack , 4=square, 5=dual, 6=tube change, 7=needle change, 8=insulin change val reason: Byte, val batteryRemain: Byte ) { - val type: Byte = PumplogUtil.getType(typeAndKind) - val kind: Byte = PumplogUtil.getKind(typeAndKind) + val type: Byte = PumpLogUtil.getType(typeAndKind) + val kind: Byte = PumpLogUtil.getKind(typeAndKind) override fun toString(): String { val sb = StringBuilder("LOG_ALARM_BLOCK{") @@ -39,19 +39,19 @@ class LOG_ALARM_BLOCK private constructor( companion object { const val LOG_KIND: Byte = 0x29 - fun parse(data: String): LOG_ALARM_BLOCK { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogAlarmBlock { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_ALARM_BLOCK( + return LogAlarmBlock( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer) ) } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_ALARM_SHORTAGE.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogAlarmShortAge.kt similarity index 63% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_ALARM_SHORTAGE.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogAlarmShortAge.kt index 827d2a6622..89c6329332 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_ALARM_SHORTAGE.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogAlarmShortAge.kt @@ -6,18 +6,18 @@ import java.nio.ByteOrder /* * Insulin shortage alarm */ -class LOG_ALARM_SHORTAGE private constructor( +class LogAlarmShortAge private constructor( val data: String, val dttm: String, typeAndKind: Byte, // 1=INFO, 2=WARNING, 3=MAJOR, 4=CRITICAL - val alarmLevel: Byte, // 1=OCCUR, 2=STOP - val ack: Byte, // (1~100U) + private val alarmLevel: Byte, // 1=OCCUR, 2=STOP + private val ack: Byte, // (1~100U) val remain: Byte, val batteryRemain: Byte ) { - val type: Byte = PumplogUtil.getType(typeAndKind) - val kind: Byte = PumplogUtil.getKind(typeAndKind) + val type: Byte = PumpLogUtil.getType(typeAndKind) + val kind: Byte = PumpLogUtil.getKind(typeAndKind) override fun toString(): String { val sb = StringBuilder("LOG_ALARM_SHORTAGE{") @@ -37,18 +37,18 @@ class LOG_ALARM_SHORTAGE private constructor( companion object { const val LOG_KIND: Byte = 0x2A - fun parse(data: String): LOG_ALARM_SHORTAGE { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogAlarmShortAge { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_ALARM_SHORTAGE( + return LogAlarmShortAge( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer) ) } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_CHANGE_INJECTOR_SUCCESS.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogChangeInjectorSuccess.kt similarity index 67% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_CHANGE_INJECTOR_SUCCESS.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogChangeInjectorSuccess.kt index e0ae6a26c4..26ba1b3150 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_CHANGE_INJECTOR_SUCCESS.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogChangeInjectorSuccess.kt @@ -6,7 +6,7 @@ import java.nio.ByteOrder /* * 주사기 교체 성공 */ -class LOG_CHANGE_INJECTOR_SUCCESS private constructor( +class LogChangeInjectorSuccess private constructor( val data: String, val dttm: String, typeAndKind: Byte, // 47.5=4750 @@ -15,8 +15,8 @@ class LOG_CHANGE_INJECTOR_SUCCESS private constructor( val batteryRemain: Byte ) { - val type: Byte = PumplogUtil.getType(typeAndKind) - val kind: Byte = PumplogUtil.getKind(typeAndKind) + val type: Byte = PumpLogUtil.getType(typeAndKind) + val kind: Byte = PumpLogUtil.getKind(typeAndKind) override fun toString(): String { val sb = StringBuilder("LOG_CHANGE_INJECTOR_SUCCESS{") @@ -35,17 +35,17 @@ class LOG_CHANGE_INJECTOR_SUCCESS private constructor( companion object { const val LOG_KIND: Byte = 0x1A - fun parse(data: String): LOG_CHANGE_INJECTOR_SUCCESS { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogChangeInjectorSuccess { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_CHANGE_INJECTOR_SUCCESS( + return LogChangeInjectorSuccess( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getByte(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getByte(buffer) ) } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_CHANGE_NEEDLE_SUCCESS.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogChangeNeedleSuccess.kt similarity index 66% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_CHANGE_NEEDLE_SUCCESS.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogChangeNeedleSuccess.kt index 045a28e302..f69320fcc9 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_CHANGE_NEEDLE_SUCCESS.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogChangeNeedleSuccess.kt @@ -6,7 +6,8 @@ import java.nio.ByteOrder /* * 바늘 공기빼기 성공 */ -class LOG_CHANGE_NEEDLE_SUCCESS private constructor( +@Suppress("SpellCheckingInspection") +class LogChangeNeedleSuccess private constructor( val data: String, val dttm: String, typeAndKind: Byte, // 47.5=4750 @@ -15,8 +16,8 @@ class LOG_CHANGE_NEEDLE_SUCCESS private constructor( val batteryRemain: Byte ) { - val type: Byte = PumplogUtil.getType(typeAndKind) - val kind: Byte = PumplogUtil.getKind(typeAndKind) + val type: Byte = PumpLogUtil.getType(typeAndKind) + val kind: Byte = PumpLogUtil.getKind(typeAndKind) override fun toString(): String { val sb = StringBuilder("LOG_CHANGE_NEEDLE_SUCCESS{") @@ -35,17 +36,17 @@ class LOG_CHANGE_NEEDLE_SUCCESS private constructor( companion object { const val LOG_KIND: Byte = 0x1C - fun parse(data: String): LOG_CHANGE_NEEDLE_SUCCESS { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogChangeNeedleSuccess { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_CHANGE_NEEDLE_SUCCESS( + return LogChangeNeedleSuccess( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getByte(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getByte(buffer) ) } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_CHANGE_TUBE_SUCCESS.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogChangeTubeSuccess.kt similarity index 66% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_CHANGE_TUBE_SUCCESS.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogChangeTubeSuccess.kt index 84b57d3e87..d3a6025de9 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_CHANGE_TUBE_SUCCESS.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogChangeTubeSuccess.kt @@ -6,7 +6,8 @@ import java.nio.ByteOrder /* * 튜브 공기빼기 성공 */ -class LOG_CHANGE_TUBE_SUCCESS private constructor( +@Suppress("SpellCheckingInspection") +class LogChangeTubeSuccess private constructor( val data: String, val dttm: String, typeAndKind: Byte, // 47.5=4750 @@ -15,8 +16,8 @@ class LOG_CHANGE_TUBE_SUCCESS private constructor( val batteryRemain: Byte ) { - val type: Byte = PumplogUtil.getType(typeAndKind) - val kind: Byte = PumplogUtil.getKind(typeAndKind) + val type: Byte = PumpLogUtil.getType(typeAndKind) + val kind: Byte = PumpLogUtil.getKind(typeAndKind) override fun toString(): String { val sb = StringBuilder("LOG_CHANGE_TUBE_SUCCESS{") @@ -35,17 +36,17 @@ class LOG_CHANGE_TUBE_SUCCESS private constructor( companion object { const val LOG_KIND: Byte = 0x18 - fun parse(data: String): LOG_CHANGE_TUBE_SUCCESS { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogChangeTubeSuccess { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_CHANGE_TUBE_SUCCESS( + return LogChangeTubeSuccess( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getByte(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getByte(buffer) ) } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECT_DUAL_FAIL.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectDualFail.kt similarity index 71% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECT_DUAL_FAIL.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectDualFail.kt index 8aa28434d7..c9197f2854 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECT_DUAL_FAIL.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectDualFail.kt @@ -7,7 +7,8 @@ import java.nio.ByteOrder /* * Dual Injection Fail Log */ -class LOG_INJECT_DUAL_FAIL private constructor( +@Suppress("SpellCheckingInspection") +class LogInjectDualFail private constructor( val data: String, val dttm: String, typeAndKind: Byte, // 47.5=4750 @@ -18,8 +19,8 @@ class LOG_INJECT_DUAL_FAIL private constructor( val batteryRemain: Byte ) { - val type: Byte = PumplogUtil.getType(typeAndKind) - val kind: Byte = PumplogUtil.getKind(typeAndKind) + val type: Byte = PumpLogUtil.getType(typeAndKind) + val kind: Byte = PumpLogUtil.getKind(typeAndKind) fun getInjectTime(): Int { return injectTime and 0xff @@ -44,19 +45,19 @@ class LOG_INJECT_DUAL_FAIL private constructor( companion object { const val LOG_KIND: Byte = 0x11 - fun parse(data: String): LOG_INJECT_DUAL_FAIL { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogInjectDualFail { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_INJECT_DUAL_FAIL( + return LogInjectDualFail( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer) ) } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECT_DUAL_SUCCESS.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectDualSuccess.kt similarity index 67% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECT_DUAL_SUCCESS.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectDualSuccess.kt index f5dd9d1638..3e0acd0b80 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECT_DUAL_SUCCESS.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectDualSuccess.kt @@ -7,18 +7,19 @@ import java.nio.ByteOrder /* * 듀얼주입 성공 */ -class LOG_INJECT_DUAL_SUCCESS private constructor( +@Suppress("SpellCheckingInspection") +class LogInjectDualSuccess private constructor( val data: String, val dttm: String, typeAndKind: Byte, // 47.5=4750 - val injectNormAmount: Short, // 47.5=4750 + private val injectNormAmount: Short, // 47.5=4750 val injectSquareAmount: Short, // 1분단위 주입시간(124=124분=2시간4분) private val injectTime: Byte, val batteryRemain: Byte ) { - val type: Byte = PumplogUtil.getType(typeAndKind) - val kind: Byte = PumplogUtil.getKind(typeAndKind) + val type: Byte = PumpLogUtil.getType(typeAndKind) + val kind: Byte = PumpLogUtil.getKind(typeAndKind) fun getInjectTime(): Int { return injectTime and 0xff } @@ -41,18 +42,18 @@ class LOG_INJECT_DUAL_SUCCESS private constructor( companion object { const val LOG_KIND: Byte = 0x10 - fun parse(data: String): LOG_INJECT_DUAL_SUCCESS { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogInjectDualSuccess { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_INJECT_DUAL_SUCCESS( + return LogInjectDualSuccess( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer) ) } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECT_MEAL_FAIL.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectMealFail.kt similarity index 71% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECT_MEAL_FAIL.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectMealFail.kt index ab046f0e9f..a01640f6d1 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECT_MEAL_FAIL.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectMealFail.kt @@ -7,7 +7,8 @@ import java.nio.ByteOrder /* * 식사주입 실패 */ -class LOG_INJECT_MEAL_FAIL private constructor( +@Suppress("SpellCheckingInspection") +class LogInjectMealFail private constructor( val data: String, val dttm: String, typeAndKind: Byte, // 47.5=4750 @@ -18,8 +19,8 @@ class LOG_INJECT_MEAL_FAIL private constructor( val reason: Byte ) { - val type: Byte = PumplogUtil.getType(typeAndKind) - val kind: Byte = PumplogUtil.getKind(typeAndKind) + val type: Byte = PumpLogUtil.getType(typeAndKind) + val kind: Byte = PumpLogUtil.getKind(typeAndKind) fun getInjectTime(): Int { return injectTime and 0xff @@ -44,19 +45,19 @@ class LOG_INJECT_MEAL_FAIL private constructor( companion object { const val LOG_KIND: Byte = 0x09 - fun parse(data: String): LOG_INJECT_MEAL_FAIL { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogInjectMealFail { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_INJECT_MEAL_FAIL( + return LogInjectMealFail( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer) ) } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECT_MEAL_SUCCESS.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectMealSuccess.kt similarity index 67% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECT_MEAL_SUCCESS.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectMealSuccess.kt index e1292aae47..23cda27c74 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECT_MEAL_SUCCESS.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectMealSuccess.kt @@ -7,7 +7,8 @@ import java.nio.ByteOrder /* * 식사주입 성공 */ -class LOG_INJECT_MEAL_SUCCESS private constructor( +@Suppress("SpellCheckingInspection") +class LogInjectMealSuccess private constructor( val data: String, val dttm: String, typeAndKind: Byte, // 47.5=4750 @@ -15,12 +16,11 @@ class LOG_INJECT_MEAL_SUCCESS private constructor( val injectAmount: Short, // 1분단위 주입시간(124=124분=2시간4분) private val injectTime: Byte, // 아침=1, 점심=2, 저녁=3 val time: Byte, - batteryRemain: Byte + val batteryRemain: Byte ) { - val type: Byte = PumplogUtil.getType(typeAndKind) - val kind: Byte = PumplogUtil.getKind(typeAndKind) - val batteryRemain: Byte = batteryRemain + val type: Byte = PumpLogUtil.getType(typeAndKind) + val kind: Byte = PumpLogUtil.getKind(typeAndKind) fun getInjectTime(): Int { return injectTime and 0xff } @@ -44,19 +44,19 @@ class LOG_INJECT_MEAL_SUCCESS private constructor( companion object { const val LOG_KIND: Byte = 0x08 - fun parse(data: String): LOG_INJECT_MEAL_SUCCESS { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogInjectMealSuccess { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_INJECT_MEAL_SUCCESS( + return LogInjectMealSuccess( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer) ) } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECT_NORMAL_FAIL.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectNormalFail.kt similarity index 68% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECT_NORMAL_FAIL.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectNormalFail.kt index 71b0beb1d4..ca4e156085 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECT_NORMAL_FAIL.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectNormalFail.kt @@ -7,19 +7,20 @@ import java.nio.ByteOrder /* * 일반주입 실패 */ -class LOG_INJECT_NORMAL_FAIL private constructor( +@Suppress("SpellCheckingInspection") +class LogInjectNormalFail private constructor( val data: String, val dttm: String, typeAndKind: Byte, // 47.5=4750 - val setAmount: Short, // 47.5=4750 + private val setAmount: Short, // 47.5=4750 val injectAmount: Short, // 1분단위 주입시간(124=124분=2시간4분) val injectTime: Byte, // 1=주입막힘, 2=배터리잔량부족, 3=약물부족, 4=사용자중지, 5=시스템리셋, 6=기타, 7=긴급정지 val reason: Byte, val batteryRemain: Byte ) { - val type: Byte = PumplogUtil.getType(typeAndKind) - val kind: Byte = PumplogUtil.getKind(typeAndKind) + val type: Byte = PumpLogUtil.getType(typeAndKind) + val kind: Byte = PumpLogUtil.getKind(typeAndKind) fun getInjectTime(): Int { return injectTime and 0xff @@ -44,19 +45,19 @@ class LOG_INJECT_NORMAL_FAIL private constructor( companion object { const val LOG_KIND: Byte = 0x0B - fun parse(data: String): LOG_INJECT_NORMAL_FAIL { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogInjectNormalFail { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_INJECT_NORMAL_FAIL( + return LogInjectNormalFail( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer) ) } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECT_NORMAL_SUCCESS.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectNormalSuccess.kt similarity index 66% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECT_NORMAL_SUCCESS.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectNormalSuccess.kt index 4692b7b8a0..6725145414 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECT_NORMAL_SUCCESS.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectNormalSuccess.kt @@ -7,18 +7,19 @@ import java.nio.ByteOrder /* * 일반주입 성공 */ -class LOG_INJECT_NORMAL_SUCCESS private constructor( +@Suppress("SpellCheckingInspection") +class LogInjectNormalSuccess private constructor( val data: String, val dttm: String, typeAndKind: Byte, // 47.5=4750 - val setAmount: Short, // 47.5=4750 + private val setAmount: Short, // 47.5=4750 val injectAmount: Short, // 1분단위 주입시간(124=124분=2시간4분) val injectTime: Byte, val batteryRemain: Byte ) { - val type: Byte = PumplogUtil.getType(typeAndKind) - val kind: Byte = PumplogUtil.getKind(typeAndKind) + val type: Byte = PumpLogUtil.getType(typeAndKind) + val kind: Byte = PumpLogUtil.getKind(typeAndKind) fun getInjectTime(): Int { return injectTime and 0xff } @@ -41,18 +42,18 @@ class LOG_INJECT_NORMAL_SUCCESS private constructor( companion object { const val LOG_KIND: Byte = 0x0A - fun parse(data: String): LOG_INJECT_NORMAL_SUCCESS { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogInjectNormalSuccess { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_INJECT_NORMAL_SUCCESS( + return LogInjectNormalSuccess( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer) ) } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECT_SQUARE_FAIL.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectSquareFail.kt similarity index 70% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECT_SQUARE_FAIL.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectSquareFail.kt index c815dfec45..31c910307d 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECT_SQUARE_FAIL.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectSquareFail.kt @@ -7,7 +7,8 @@ import java.nio.ByteOrder /* * 스퀘어주입 실패 */ -class LOG_INJECT_SQUARE_FAIL private constructor( +@Suppress("SpellCheckingInspection") +class LogInjectSquareFail private constructor( val data: String, val dttm: String, typeAndKind: Byte, // 47.5=4750 @@ -17,8 +18,8 @@ class LOG_INJECT_SQUARE_FAIL private constructor( val batteryRemain: Byte ) { - val type: Byte = PumplogUtil.getType(typeAndKind) - val kind: Byte = PumplogUtil.getKind(typeAndKind) + val type: Byte = PumpLogUtil.getType(typeAndKind) + val kind: Byte = PumpLogUtil.getKind(typeAndKind) fun getInjectTime(): Int { return injectTime and 0xff @@ -42,18 +43,18 @@ class LOG_INJECT_SQUARE_FAIL private constructor( companion object { const val LOG_KIND: Byte = 0x0E - fun parse(data: String): LOG_INJECT_SQUARE_FAIL { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogInjectSquareFail { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_INJECT_SQUARE_FAIL( + return LogInjectSquareFail( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer) ) } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECT_SQUARE_SUCCESS.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectSquareSuccess.kt similarity index 64% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECT_SQUARE_SUCCESS.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectSquareSuccess.kt index e76fe57c06..0d1a2181e2 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECT_SQUARE_SUCCESS.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectSquareSuccess.kt @@ -7,17 +7,18 @@ import java.nio.ByteOrder /* * 스퀘어주입 성공 */ -class LOG_INJECT_SQUARE_SUCCESS private constructor( +@Suppress("SpellCheckingInspection") +class LogInjectSquareSuccess private constructor( val data: String, val dttm: String, typeAndKind: Byte, // 47.5=4750 - val injectAmount: Short, // 1분단위 주입시간(124=124분=2시간4분) + private val injectAmount: Short, // 1분단위 주입시간(124=124분=2시간4분) private val injectTime: Byte, val batteryRemain: Byte ) { - val type: Byte = PumplogUtil.getType(typeAndKind) - val kind: Byte = PumplogUtil.getKind(typeAndKind) + val type: Byte = PumpLogUtil.getType(typeAndKind) + val kind: Byte = PumpLogUtil.getKind(typeAndKind) fun getInjectTime(): Int { return injectTime and 0xff } @@ -39,17 +40,17 @@ class LOG_INJECT_SQUARE_SUCCESS private constructor( companion object { const val LOG_KIND: Byte = 0x0D - fun parse(data: String): LOG_INJECT_SQUARE_SUCCESS { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogInjectSquareSuccess { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_INJECT_SQUARE_SUCCESS( + return LogInjectSquareSuccess( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer) ) } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECTION_1DAY.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjection1Day.kt similarity index 68% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECTION_1DAY.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjection1Day.kt index 4d536a6194..2dc31d9e47 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECTION_1DAY.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjection1Day.kt @@ -6,7 +6,8 @@ import java.nio.ByteOrder /* * 당일 주입 총량 (식사, 추가) */ -class LOG_INJECTION_1DAY private constructor( +@Suppress("SpellCheckingInspection") +class LogInjection1Day private constructor( val data: String, val dttm: String, typeAndKind: Byte, // 당일 식사주입 총량 47.5=4750 @@ -15,8 +16,8 @@ class LOG_INJECTION_1DAY private constructor( val batteryRemain: Byte ) { - val type: Byte = PumplogUtil.getType(typeAndKind) - val kind: Byte = PumplogUtil.getKind(typeAndKind) + val type: Byte = PumpLogUtil.getType(typeAndKind) + val kind: Byte = PumpLogUtil.getKind(typeAndKind) override fun toString(): String { val sb = StringBuilder("LOG_INJECTION_1DAY{") @@ -35,17 +36,17 @@ class LOG_INJECTION_1DAY private constructor( companion object { const val LOG_KIND: Byte = 0x2F - fun parse(data: String): LOG_INJECTION_1DAY { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogInjection1Day { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_INJECTION_1DAY( + return LogInjection1Day( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getByte(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getByte(buffer) ) } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECTION_1DAY_BASAL.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjection1DayBasal.kt similarity index 66% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECTION_1DAY_BASAL.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjection1DayBasal.kt index 9c8a47fc37..2c90363850 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECTION_1DAY_BASAL.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjection1DayBasal.kt @@ -6,7 +6,8 @@ import java.nio.ByteOrder /* * 당일 주입 총량 (기저) */ -class LOG_INJECTION_1DAY_BASAL private constructor( +@Suppress("SpellCheckingInspection") +class LogInjection1DayBasal private constructor( val data: String, val dttm: String, typeAndKind: Byte, @@ -15,8 +16,8 @@ class LOG_INJECTION_1DAY_BASAL private constructor( val batteryRemain: Byte ) { - val type: Byte = PumplogUtil.getType(typeAndKind) - val kind: Byte = PumplogUtil.getKind(typeAndKind) + val type: Byte = PumpLogUtil.getType(typeAndKind) + val kind: Byte = PumpLogUtil.getKind(typeAndKind) override fun toString(): String { val sb = StringBuilder("LOG_INJECTION_1DAY_BASAL{") @@ -33,16 +34,16 @@ class LOG_INJECTION_1DAY_BASAL private constructor( companion object { const val LOG_KIND: Byte = 0x2E - fun parse(data: String): LOG_INJECTION_1DAY_BASAL { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogInjection1DayBasal { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_INJECTION_1DAY_BASAL( + return LogInjection1DayBasal( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getByte(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getByte(buffer) ) } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECTION_1HOUR_BASAL.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjection1HourBasal.kt similarity index 74% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECTION_1HOUR_BASAL.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjection1HourBasal.kt index ea0663d07b..c09820b992 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECTION_1HOUR_BASAL.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjection1HourBasal.kt @@ -6,7 +6,8 @@ import java.nio.ByteOrder /* * 1시간 단위 기저 주입량 */ -class LOG_INJECTION_1HOUR_BASAL private constructor( +@Suppress("SpellCheckingInspection") +class LogInjection1HourBasal private constructor( val data: String, val dttm: String, typeAndKind: Byte, @@ -17,8 +18,8 @@ class LOG_INJECTION_1HOUR_BASAL private constructor( private val remainTotalAmount: Short ) { - val type: Byte = PumplogUtil.getType(typeAndKind) - val kind: Byte = PumplogUtil.getKind(typeAndKind) + val type: Byte = PumpLogUtil.getType(typeAndKind) + val kind: Byte = PumpLogUtil.getKind(typeAndKind) val beforeAmount // 해당시간의 임시기저 계산 전 기저주입량: 기저주입막힘 발생 시 기저주입 막힘량 제외, 기저정지로 인해 주입되지 않은 량 제외, 리셋으로 인해 주입되지 않은 량 제외(47.5=4750) : Short = tbBeforeAmount val afterAmount // 해당시간의 임시기저 계산 후 기저주입량: 기저주입막힘 발생 시 기저주입 막힘량 제외, 기저정지로 인해 주입되지 않은 량 제외, 리셋으로 인해 주입되지 않은 량 제외(47.5=4750) @@ -42,18 +43,18 @@ class LOG_INJECTION_1HOUR_BASAL private constructor( companion object { const val LOG_KIND: Byte = 0x2C - fun parse(data: String): LOG_INJECTION_1HOUR_BASAL { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogInjection1HourBasal { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_INJECTION_1HOUR_BASAL( + return LogInjection1HourBasal( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getShort(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getShort(buffer) ) } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECTION_DUAL_NORMAL.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectionDualNormal.kt similarity index 67% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECTION_DUAL_NORMAL.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectionDualNormal.kt index ce46ea8bfd..95f9fb19b5 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_INJECTION_DUAL_NORMAL.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogInjectionDualNormal.kt @@ -7,18 +7,19 @@ import java.nio.ByteOrder /* * 듀얼(일반) 주입량: 듀얼(일반) 주입 완료 시 기록하는 방식 */ -class LOG_INJECTION_DUAL_NORMAL private constructor( +@Suppress("SpellCheckingInspection") +class LogInjectionDualNormal private constructor( val data: String, val dttm: String, typeAndKind: Byte, // 설정량 47.5=4750 - val setAmount: Short, // 주입량 47.5=4750 + private val setAmount: Short, // 주입량 47.5=4750 val injectAmount: Short, // 1분 단위 주입 시간 Ex) 124 = 124분 = 2시간 4분 private val injectTime: Byte, val batteryRemain: Byte ) { - val type: Byte = PumplogUtil.getType(typeAndKind) - val kind: Byte = PumplogUtil.getKind(typeAndKind) + val type: Byte = PumpLogUtil.getType(typeAndKind) + val kind: Byte = PumpLogUtil.getKind(typeAndKind) fun getInjectTime(): Int { return injectTime and 0xff } @@ -41,18 +42,18 @@ class LOG_INJECTION_DUAL_NORMAL private constructor( companion object { const val LOG_KIND: Byte = 0x35 - fun parse(data: String): LOG_INJECTION_DUAL_NORMAL { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogInjectionDualNormal { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_INJECTION_DUAL_NORMAL( + return LogInjectionDualNormal( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer) ) } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_RESET_SYS_V3.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogResetSysV3.kt similarity index 62% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_RESET_SYS_V3.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogResetSysV3.kt index 491fdf04bb..a47ba43e0d 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_RESET_SYS_V3.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogResetSysV3.kt @@ -6,18 +6,19 @@ import java.nio.ByteOrder /* * System Reset Log */ -class LOG_RESET_SYS_V3 private constructor( +@Suppress("SpellCheckingInspection") +class LogResetSysV3 private constructor( val data: String, val dttm: String, typeAndKind: Byte, val batteryRemain: Byte, val reason: Byte, // 사유(1:공장초기화 후 리셋, 2:긴급정지 해제 후 리셋, 3:사용자 배터리 교체 후 리셋, 4:캘리브레이션 후 리셋, 9:예상치 못한 시스템 리셋) - val rcon1: Short, // PIC 데이터 시트 내 정의된 2바이트 값 - val rcon2: Short // PIC 데이터 시트 내 정의된 2바이트 값 + private val rcon1: Short, // PIC 데이터 시트 내 정의된 2바이트 값 + private val rcon2: Short // PIC 데이터 시트 내 정의된 2바이트 값 ) { - val type: Byte = PumplogUtil.getType(typeAndKind) - val kind: Byte = PumplogUtil.getKind(typeAndKind) + val type: Byte = PumpLogUtil.getType(typeAndKind) + val kind: Byte = PumpLogUtil.getKind(typeAndKind) override fun toString(): String { val sb = StringBuilder("LOG_RESET_SYS_V3{") @@ -37,18 +38,18 @@ class LOG_RESET_SYS_V3 private constructor( companion object { const val LOG_KIND: Byte = 0x01 - fun parse(data: String): LOG_RESET_SYS_V3 { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogResetSysV3 { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_RESET_SYS_V3( + return LogResetSysV3( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getShort(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getShort(buffer) ) } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_SET_DUAL_INJECTION.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogSetDualInjection.kt similarity index 66% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_SET_DUAL_INJECTION.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogSetDualInjection.kt index c90acc008b..daedf5c04c 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_SET_DUAL_INJECTION.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogSetDualInjection.kt @@ -7,18 +7,19 @@ import java.nio.ByteOrder /* * 듀얼주입 설정(시작) */ -class LOG_SET_DUAL_INJECTION private constructor( +@Suppress("SpellCheckingInspection") +class LogSetDualInjection private constructor( val data: String, val dttm: String, typeAndKind: Byte, - val setNormAmount: Short, // 47.5=4750 + private val setNormAmount: Short, // 47.5=4750 val setSquareAmount: Short, // 47.5=4750 private val injectTime: Byte, // 1~30( 1: 10min ) val batteryRemain: Byte ) { - val type: Byte = PumplogUtil.getType(typeAndKind) - val kind: Byte = PumplogUtil.getKind(typeAndKind) + val type: Byte = PumpLogUtil.getType(typeAndKind) + val kind: Byte = PumpLogUtil.getKind(typeAndKind) fun getInjectTime(): Int { return injectTime and 0xff } @@ -41,18 +42,18 @@ class LOG_SET_DUAL_INJECTION private constructor( companion object { const val LOG_KIND: Byte = 0x0F - fun parse(data: String): LOG_SET_DUAL_INJECTION { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogSetDualInjection { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_SET_DUAL_INJECTION( + return LogSetDualInjection( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer) ) } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_SET_SQUARE_INJECTION.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogSetSquareInjection.kt similarity index 68% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_SET_SQUARE_INJECTION.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogSetSquareInjection.kt index 4c315da683..6ad23e0439 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_SET_SQUARE_INJECTION.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogSetSquareInjection.kt @@ -7,7 +7,8 @@ import java.nio.ByteOrder /* * 스퀘어주입 설정(시작) */ -class LOG_SET_SQUARE_INJECTION private constructor( +@Suppress("SpellCheckingInspection") +class LogSetSquareInjection private constructor( val data: String, val dttm: String, typeAndKind: Byte, // 47.5=4750 @@ -16,8 +17,8 @@ class LOG_SET_SQUARE_INJECTION private constructor( val batteryRemain: Byte ) { - val type: Byte = PumplogUtil.getType(typeAndKind) - val kind: Byte = PumplogUtil.getKind(typeAndKind) + val type: Byte = PumpLogUtil.getType(typeAndKind) + val kind: Byte = PumpLogUtil.getKind(typeAndKind) fun getInjectTime(): Int { return injectTime and 0xff } @@ -39,17 +40,17 @@ class LOG_SET_SQUARE_INJECTION private constructor( companion object { const val LOG_KIND: Byte = 0x0C - fun parse(data: String): LOG_SET_SQUARE_INJECTION { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogSetSquareInjection { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_SET_SQUARE_INJECTION( + return LogSetSquareInjection( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer) ) } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_SUSPEND_RELEASE_V2.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogSuspendReleaseV2.kt similarity index 73% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_SUSPEND_RELEASE_V2.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogSuspendReleaseV2.kt index b10961e883..e53445912c 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_SUSPEND_RELEASE_V2.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogSuspendReleaseV2.kt @@ -6,7 +6,8 @@ import java.nio.ByteOrder /* * 일시정지 중지 (기저정지 해제) */ -class LOG_SUSPEND_RELEASE_V2 private constructor( +@Suppress("SpellCheckingInspection") +class LogSuspendReleaseV2 private constructor( val data: String, val dttm: String, typeAndKind: Byte, @@ -17,7 +18,7 @@ class LOG_SUSPEND_RELEASE_V2 private constructor( val type: Byte val kind: Byte val batteryRemain: Byte - val patternType // 1=기본, 2=생활1, 3=생활2, 4=생활3, 5=닥터1, 6=닥터2 + private val patternType // 1=기본, 2=생활1, 3=생활2, 4=생활3, 5=닥터1, 6=닥터2 : Byte override fun toString(): String { @@ -48,23 +49,23 @@ class LOG_SUSPEND_RELEASE_V2 private constructor( companion object { const val LOG_KIND: Byte = 0x04 - fun parse(data: String): LOG_SUSPEND_RELEASE_V2 { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogSuspendReleaseV2 { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_SUSPEND_RELEASE_V2( + return LogSuspendReleaseV2( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer) ) } } init { - type = PumplogUtil.getType(typeAndKind) - kind = PumplogUtil.getKind(typeAndKind) + type = PumpLogUtil.getType(typeAndKind) + kind = PumpLogUtil.getKind(typeAndKind) this.batteryRemain = batteryRemain this.patternType = patternType } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_SUSPEND_V2.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogSuspendV2.kt similarity index 73% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_SUSPEND_V2.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogSuspendV2.kt index 7a1dc061c8..0daf0acaea 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_SUSPEND_V2.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogSuspendV2.kt @@ -6,16 +6,17 @@ import java.nio.ByteOrder /* * 일시정지 시작 (기저정지) */ -class LOG_SUSPEND_V2 private constructor( +@Suppress("SpellCheckingInspection") +class LogSuspendV2 private constructor( val data: String, val dttm: String, typeAndKind: Byte, val batteryRemain: Byte, // 1=기본, 2=생활1, 3=생활2, 4=생활3, 5=닥터1, 6=닥터2 - val patternType: Byte + private val patternType: Byte ) { - val type: Byte = PumplogUtil.getType(typeAndKind) - val kind: Byte = PumplogUtil.getKind(typeAndKind) + val type: Byte = PumpLogUtil.getType(typeAndKind) + val kind: Byte = PumpLogUtil.getKind(typeAndKind) override fun toString(): String { val sb = StringBuilder("LOG_SUSPEND_V2{") @@ -46,16 +47,16 @@ class LOG_SUSPEND_V2 private constructor( companion object { const val LOG_KIND: Byte = 0x03 - fun parse(data: String): LOG_SUSPEND_V2 { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogSuspendV2 { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_SUSPEND_V2( + return LogSuspendV2( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer) ) } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_TB_START_V3.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogTbStartV3.kt similarity index 72% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_TB_START_V3.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogTbStartV3.kt index 8f54222df8..09d3e7897f 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_TB_START_V3.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogTbStartV3.kt @@ -8,7 +8,8 @@ import java.nio.ByteOrder /* * 임시기저 설정(시작) */ -class LOG_TB_START_V3 private constructor( +@Suppress("SpellCheckingInspection") +class LogTbStartV3 private constructor( val data: String, val dttm: String, typeAndKind: Byte, // 임시기저 시간(30분 ~ 24시간, 2 ~ 96, 1당 15분 단위 증감) @@ -17,8 +18,8 @@ class LOG_TB_START_V3 private constructor( private val tbDttm: String // 앱에서 생성 전달한 임시기저 시작(요청) 시간 ) { - val type: Byte = PumplogUtil.getType(typeAndKind) - val kind: Byte = PumplogUtil.getKind(typeAndKind) + val type: Byte = PumpLogUtil.getType(typeAndKind) + val kind: Byte = PumpLogUtil.getKind(typeAndKind) fun getTbInjectRateRatio(): Int { return tbInjectRateRatio and 0xffff @@ -33,7 +34,7 @@ class LOG_TB_START_V3 private constructor( sb.append(", kind=").append(kind.toInt()) sb.append(", tbTime=").append(tbTime.toInt()) sb.append(", tbInjectRateRatio=").append(tbInjectRateRatio and 0xffff) - if (!StringUtils.equals(tbDttm, PumplogUtil.getDttm("ffffffff"))) { + if (!StringUtils.equals(tbDttm, PumpLogUtil.getDttm("ffffffff"))) { sb.append(", tbDttm=").append(tbDttm) } sb.append('}') @@ -43,17 +44,17 @@ class LOG_TB_START_V3 private constructor( companion object { const val LOG_KIND: Byte = 0x12 - fun parse(data: String): LOG_TB_START_V3 { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogTbStartV3 { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_TB_START_V3( + return LogTbStartV3( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getDttm(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getDttm(buffer) ) } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_TB_STOP_V3.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogTbStopV3.kt similarity index 72% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_TB_STOP_V3.kt rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogTbStopV3.kt index 51080f95bb..1b4bff1be5 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LOG_TB_STOP_V3.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/LogTbStopV3.kt @@ -8,7 +8,8 @@ import java.nio.ByteOrder /* * 임시기저 중지(완료) */ -class LOG_TB_STOP_V3 private constructor( +@Suppress("SpellCheckingInspection") +class LogTbStopV3 private constructor( val data: String, val dttm: String, typeAndKind: Byte, @@ -20,8 +21,8 @@ class LOG_TB_STOP_V3 private constructor( private val tbDttm: String ) { - val type: Byte = PumplogUtil.getType(typeAndKind) - val kind: Byte = PumplogUtil.getKind(typeAndKind) + val type: Byte = PumpLogUtil.getType(typeAndKind) + val kind: Byte = PumpLogUtil.getKind(typeAndKind) fun getTbInjectRateRatio(): Int { return tbInjectRateRatio and 0xffff @@ -36,7 +37,7 @@ class LOG_TB_STOP_V3 private constructor( sb.append(", kind=").append(kind.toInt()) sb.append(", tbInjectRateRatio=").append(tbInjectRateRatio and 0xffff) sb.append(", reason=").append(reason.toInt()) - if (!StringUtils.equals(tbDttm, PumplogUtil.getDttm("ffffffff"))) { + if (!StringUtils.equals(tbDttm, PumpLogUtil.getDttm("ffffffff"))) { sb.append(", tbDttm=").append(tbDttm) } sb.append('}') @@ -46,17 +47,17 @@ class LOG_TB_STOP_V3 private constructor( companion object { const val LOG_KIND: Byte = 0x13 - fun parse(data: String): LOG_TB_STOP_V3 { - val bytes = PumplogUtil.hexStringToByteArray(data) + fun parse(data: String): LogTbStopV3 { + val bytes = PumpLogUtil.hexStringToByteArray(data) val buffer = ByteBuffer.wrap(bytes) buffer.order(ByteOrder.LITTLE_ENDIAN) - return LOG_TB_STOP_V3( + return LogTbStopV3( data, - PumplogUtil.getDttm(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getShort(buffer), - PumplogUtil.getByte(buffer), - PumplogUtil.getDttm(buffer) + PumpLogUtil.getDttm(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getShort(buffer), + PumpLogUtil.getByte(buffer), + PumpLogUtil.getDttm(buffer) ) } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/PumplogUtil.java b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/PumpLogUtil.java similarity index 96% rename from pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/PumplogUtil.java rename to pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/PumpLogUtil.java index c458aba743..27ea305112 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/PumplogUtil.java +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/pumplog/PumpLogUtil.java @@ -13,7 +13,8 @@ import java.util.TimeZone; /* * 디아콘 G8 펌프 로그 유틸리티 클래스 */ -public class PumplogUtil { +@SuppressWarnings({"CommentedOutCode", "SpellCheckingInspection"}) +public class PumpLogUtil { /* * 바이트버퍼에서 4바이트 날짜를 구한다. * @param buffer 바이트버퍼 @@ -39,7 +40,7 @@ public class PumplogUtil { */ @SuppressLint("SimpleDateFormat") public static String getDttm(String data) { - byte[] bytes = PumplogUtil.hexStringToByteArray(data); + byte[] bytes = PumpLogUtil.hexStringToByteArray(data); byte b0 = bytes[0]; byte b1 = bytes[1]; byte b2 = bytes[2]; @@ -74,9 +75,11 @@ public class PumplogUtil { * @param buffer 바이트버퍼 * @return int */ + /* public static int getInt(ByteBuffer buffer) { return buffer.getInt(); } + */ /* * 로그데이터에서 로그 타입 바이트를 구한다. @@ -136,12 +139,14 @@ public class PumplogUtil { * @param data 1970.1.1이후 경과한 초 * @return 날짜(GMT기준) */ + /* public static Date pumpTimeToGMTDate(Integer data) { long epochTime = new Date(0).getTime(); // 1970-01-01 long pumpTime = data.longValue() * 1000; // 초를 밀리초 단위로 변환 int timeZoneOffset = TimeZone.getDefault().getRawOffset(); // GMT와 로컬 타임존 사이의 차이 return new Date(epochTime + pumpTime - timeZoneOffset); } + */ /* * 펌프 버전이 해당 버전보다 크거나 같은지 여부 확인(새로운 기능이 추가된 버전을 체크하기 위함) diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/service/DiaconnG8Service.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/service/DiaconnG8Service.kt index ca627bb3fd..d412ab138f 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/service/DiaconnG8Service.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/service/DiaconnG8Service.kt @@ -57,7 +57,7 @@ import info.nightscout.pump.diaconn.packet.TempBasalInquirePacket import info.nightscout.pump.diaconn.packet.TempBasalSettingPacket import info.nightscout.pump.diaconn.packet.TimeInquirePacket import info.nightscout.pump.diaconn.packet.TimeSettingPacket -import info.nightscout.pump.diaconn.pumplog.PumplogUtil +import info.nightscout.pump.diaconn.pumplog.PumpLogUtil import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.bus.RxBus import info.nightscout.rx.events.EventAppExit @@ -168,7 +168,7 @@ class DiaconnG8Service : DaggerService() { val pumpFirmwareVersion = sp.getString(rh.gs(R.string.pumpversion), "") - if (pumpFirmwareVersion.isNotEmpty() && PumplogUtil.isPumpVersionGe(pumpFirmwareVersion, 3, 0)) { + if (pumpFirmwareVersion.isNotEmpty() && PumpLogUtil.isPumpVersionGe(pumpFirmwareVersion, 3, 0)) { sendMessage(BigAPSMainInfoInquirePacket(injector)) // APS Pump Main Info } else { sendMessage(BasalLimitInquirePacket(injector)) // basal Limit diff --git a/pump/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.kt b/pump/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.kt index 5aa76055f7..defdbf9c45 100644 --- a/pump/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.kt +++ b/pump/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.kt @@ -216,10 +216,6 @@ class MedtronicPumpPlugin @Inject constructor( } } - override fun hasService(): Boolean { - return true - } - override fun onStartScheduledPumpActions() { // check status every minute (if any status needs refresh we send readStatus command) diff --git a/pump/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/util/MedtronicUtil.kt b/pump/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/util/MedtronicUtil.kt index 34fe0eafa5..2e53e74990 100644 --- a/pump/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/util/MedtronicUtil.kt +++ b/pump/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/util/MedtronicUtil.kt @@ -1,5 +1,6 @@ package info.nightscout.androidaps.plugins.pump.medtronic.util +import com.google.gson.Gson import com.google.gson.GsonBuilder import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil @@ -18,13 +19,13 @@ import info.nightscout.rx.events.EventDismissNotification import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.LTag import info.nightscout.shared.interfaces.ResourceHelper -import org.joda.time.LocalTime import java.nio.ByteBuffer import java.nio.ByteOrder import java.util.Locale import javax.inject.Inject import javax.inject.Singleton import kotlin.experimental.or +import kotlin.math.abs /** * Created by andy on 5/9/18. @@ -38,39 +39,41 @@ class MedtronicUtil @Inject constructor( private val uiInteraction: UiInteraction ) { + @Suppress("PrivatePropertyName") private val ENVELOPE_SIZE = 4 // 0xA7 S1 S2 S3 CMD PARAM_COUNT [PARAMS] //private MedtronicDeviceType medtronicPumpModel; private var currentCommand: MedtronicCommandType? = null var settings: Map? = null + @Suppress("PrivatePropertyName") private val BIG_FRAME_LENGTH = 65 - private val doneBit = 1 shl 7 + //private val doneBit = 1 shl 7 var pumpTime: ClockDTO? = null - var gsonInstance = GsonBuilder().excludeFieldsWithoutExposeAnnotation().create() + var gsonInstance: Gson = GsonBuilder().excludeFieldsWithoutExposeAnnotation().create() - fun getTimeFrom30MinInterval(interval: Int): LocalTime { - return if (interval % 2 == 0) { - LocalTime(interval / 2, 0) - } else { - LocalTime((interval - 1) / 2, 30) - } - } + // fun getTimeFrom30MinInterval(interval: Int): LocalTime { + // return if (interval % 2 == 0) { + // LocalTime(interval / 2, 0) + // } else { + // LocalTime((interval - 1) / 2, 30) + // } + // } - fun decodeBasalInsulin(i: Int, j: Int): Double { - return decodeBasalInsulin(makeUnsignedShort(i, j)) - } + // fun decodeBasalInsulin(i: Int, j: Int): Double { + // return decodeBasalInsulin(makeUnsignedShort(i, j)) + // } - fun decodeBasalInsulin(i: Int): Double { - return i.toDouble() / 40.0 - } + // fun decodeBasalInsulin(i: Int): Double { + // return i.toDouble() / 40.0 + // } - fun getBasalStrokes(amount: Double): ByteArray { - return getBasalStrokes(amount, false) - } + // fun getBasalStrokes(amount: Double): ByteArray { + // return getBasalStrokes(amount, false) + // } - fun getBasalStrokesInt(amount: Double): Int { - return getStrokesInt(amount, 40) - } + // fun getBasalStrokesInt(amount: Double): Int { + // return getStrokesInt(amount, 40) + // } fun getBolusStrokes(amount: Double): ByteArray { val strokesPerUnit = medtronicPumpStatus.medtronicDeviceType.bolusStrokes @@ -89,17 +92,17 @@ class MedtronicUtil @Inject constructor( return ByteUtil.fromHexString(String.format("%02x%0" + 2 * length + "x", length, strokes)) } - fun createCommandBody(input: ByteArray): ByteArray { - return ByteUtil.concat(input.size.toByte(), input) - } + // fun createCommandBody(input: ByteArray): ByteArray { + // return ByteUtil.concat(input.size.toByte(), input) + // } - fun sendNotification(notificationType: MedtronicNotificationType, rh: ResourceHelper) { - uiInteraction.addNotification( - notificationType.notificationType, - rh.gs(notificationType.resourceId), - notificationType.notificationUrgency - ) - } + // fun sendNotification(notificationType: MedtronicNotificationType, rh: ResourceHelper) { + // uiInteraction.addNotification( + // notificationType.notificationType, + // rh.gs(notificationType.resourceId), + // notificationType.notificationUrgency + // ) + // } fun sendNotification(notificationType: MedtronicNotificationType, rh: ResourceHelper, vararg parameters: Any?) { uiInteraction.addNotification( @@ -117,7 +120,7 @@ class MedtronicUtil @Inject constructor( return buildCommandPayload(rileyLinkServiceData, commandType.commandCode, parameters) } - fun buildCommandPayload(rileyLinkServiceData: RileyLinkServiceData, commandType: Byte, parameters: ByteArray?): ByteArray { + private fun buildCommandPayload(rileyLinkServiceData: RileyLinkServiceData, commandType: Byte, parameters: ByteArray?): ByteArray { // A7 31 65 51 C0 00 52 val commandLength = (if (parameters == null) 2 else 2 + parameters.size).toByte() val sendPayloadBuffer = ByteBuffer.allocate(ENVELOPE_SIZE + commandLength) // + CRC_SIZE @@ -283,12 +286,13 @@ class MedtronicUtil @Inject constructor( return getStrokes(amount, 40, returnFixedSize) } - fun getStrokes(amount: Double, strokesPerUnit: Int, returnFixedSize: Boolean): ByteArray { + @Suppress("SameParameterValue") + private fun getStrokes(amount: Double, strokesPerUnit: Int, returnFixedSize: Boolean): ByteArray { val strokes = getStrokesInt(amount, strokesPerUnit) return getByteArrayFromUnsignedShort(strokes, returnFixedSize) } - fun getStrokesInt(amount: Double, strokesPerUnit: Int): Int { + private fun getStrokesInt(amount: Double, strokesPerUnit: Int): Int { //var length = 1 var scrollRate = 1 if (strokesPerUnit >= 40) { @@ -304,7 +308,7 @@ class MedtronicUtil @Inject constructor( fun isSame(d1: Double, d2: Double): Boolean { val diff = d1 - d2 - return Math.abs(diff) <= 0.000001 + return abs(diff) <= 0.000001 } } diff --git a/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Milenage.kt b/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Milenage.kt index c06c5a3410..15e6477d15 100644 --- a/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Milenage.kt +++ b/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Milenage.kt @@ -1,5 +1,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session +import android.annotation.SuppressLint import info.nightscout.core.utils.toHex import info.nightscout.interfaces.Config import info.nightscout.rx.logging.AAPSLogger @@ -10,8 +11,8 @@ import javax.crypto.Cipher import javax.crypto.spec.SecretKeySpec class Milenage( - private val aapsLogger: AAPSLogger, - private val config: Config, + aapsLogger: AAPSLogger, + config: Config, private val k: ByteArray, val sqn: ByteArray, randParam: ByteArray? = null, @@ -30,6 +31,7 @@ class Milenage( } private val secretKeySpec = SecretKeySpec(k, "AES") + @SuppressLint("GetInstance") private val cipher: Cipher = Cipher.getInstance("AES/ECB/NoPadding") init { @@ -123,9 +125,10 @@ class Milenage( } } + @Suppress("SpellCheckingInspection") companion object { - val RESYNC_AMF = Hex.decode("0000") + val RESYNC_AMF: ByteArray = Hex.decode("0000") private val MILENAGE_OP = Hex.decode("cdc202d5123e20f62b6d676ac72cb318") private val MILENAGE_AMF = Hex.decode("b9b9") const val KEY_SIZE = 16 diff --git a/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt b/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt index b28bbc8036..9eef681ae6 100644 --- a/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt +++ b/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt @@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state import android.os.SystemClock import com.google.gson.Gson -import info.nightscout.interfaces.pump.DetailedBolusInfo import info.nightscout.androidaps.plugins.pump.omnipod.dash.EventOmnipodDashPumpValuesChanged import info.nightscout.androidaps.plugins.pump.omnipod.dash.R import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Id @@ -20,6 +19,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response. import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.DefaultStatusResponse import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.SetUniqueIdResponse import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.VersionResponse +import info.nightscout.interfaces.pump.DetailedBolusInfo import info.nightscout.interfaces.utils.Round import info.nightscout.rx.bus.RxBus import info.nightscout.rx.logging.AAPSLogger @@ -437,7 +437,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor( } @Synchronized - override fun updateActiveCommand() = Maybe.create { source -> + override fun updateActiveCommand(): Maybe = Maybe.create { source -> val activeCommand = podState.activeCommand if (activeCommand == null) { logger.error(LTag.PUMPCOMM, "No active command to update") @@ -515,6 +515,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor( "lastResponse=$lastStatusResponseReceived " + "$sequenceNumberOfLastProgrammingCommand $historyId" ) + @Suppress("KotlinConstantConditions") when { createdRealtime <= podState.lastStatusResponseReceived && sequence == podState.sequenceNumberOfLastProgrammingCommand -> diff --git a/pump/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/extensions/PumpStateExtension.kt b/pump/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/extensions/PumpStateExtension.kt index a12532c9de..001440a4f4 100644 --- a/pump/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/extensions/PumpStateExtension.kt +++ b/pump/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/extensions/PumpStateExtension.kt @@ -1,4 +1,4 @@ -package info.nightscout.core.pump +package info.nightscout.androidaps.plugins.pump.omnipod.eros.extensions import info.nightscout.interfaces.pump.PumpSync import kotlin.math.ceil diff --git a/pump/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/manager/AapsOmnipodErosManager.java b/pump/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/manager/AapsOmnipodErosManager.java index 8c1584c2c9..8af0a35161 100644 --- a/pump/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/manager/AapsOmnipodErosManager.java +++ b/pump/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/manager/AapsOmnipodErosManager.java @@ -56,12 +56,12 @@ import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.manager.ErosP import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.manager.OmnipodManager; import info.nightscout.androidaps.plugins.pump.omnipod.eros.event.EventOmnipodErosPumpValuesChanged; import info.nightscout.androidaps.plugins.pump.omnipod.eros.extensions.DetailedBolusInfoExtensionKt; +import info.nightscout.androidaps.plugins.pump.omnipod.eros.extensions.PumpStateExtensionKt; import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.ErosHistory; import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.database.ErosHistoryRecordEntity; import info.nightscout.androidaps.plugins.pump.omnipod.eros.rileylink.manager.OmnipodRileyLinkCommunicationManager; import info.nightscout.androidaps.plugins.pump.omnipod.eros.util.AapsOmnipodUtil; import info.nightscout.androidaps.plugins.pump.omnipod.eros.util.OmnipodAlertUtil; -import info.nightscout.core.pump.PumpStateExtensionKt; import info.nightscout.interfaces.notifications.Notification; import info.nightscout.interfaces.profile.Profile; import info.nightscout.interfaces.pump.DetailedBolusInfo; diff --git a/pump/pump-common/src/main/java/info/nightscout/pump/common/PumpPluginAbstract.kt b/pump/pump-common/src/main/java/info/nightscout/pump/common/PumpPluginAbstract.kt index 22a21e56df..25b3957678 100644 --- a/pump/pump-common/src/main/java/info/nightscout/pump/common/PumpPluginAbstract.kt +++ b/pump/pump-common/src/main/java/info/nightscout/pump/common/PumpPluginAbstract.kt @@ -4,6 +4,7 @@ import android.content.Context import android.content.Intent import android.content.ServiceConnection import android.text.format.DateFormat +import com.google.gson.Gson import com.google.gson.GsonBuilder import dagger.android.HasAndroidInjector import info.nightscout.core.utils.fabric.FabricPrivacy @@ -26,6 +27,7 @@ import info.nightscout.interfaces.utils.DecimalFormatter.to2Decimal import info.nightscout.pump.common.data.PumpStatus import info.nightscout.pump.common.defs.PumpDriverState import info.nightscout.pump.common.sync.PumpDbEntryCarbs +import info.nightscout.pump.common.sync.PumpSyncEntriesCreator import info.nightscout.pump.common.sync.PumpSyncStorage import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.bus.RxBus @@ -61,7 +63,7 @@ abstract class PumpPluginAbstract protected constructor( var aapsSchedulers: AapsSchedulers, var pumpSync: PumpSync, var pumpSyncStorage: PumpSyncStorage -) : PumpPluginBase(pluginDescription, injector, aapsLogger, rh, commandQueue), Pump, Constraints, info.nightscout.pump.common.sync.PumpSyncEntriesCreator { +) : PumpPluginBase(pluginDescription, injector, aapsLogger, rh, commandQueue), Pump, Constraints, PumpSyncEntriesCreator { protected val disposable = CompositeDisposable() @@ -80,24 +82,21 @@ abstract class PumpPluginAbstract protected constructor( pumpDescription.fillFor(value) } - protected var gson = GsonBuilder().excludeFieldsWithoutExposeAnnotation().create() + protected var gson: Gson = GsonBuilder().excludeFieldsWithoutExposeAnnotation().create() abstract fun initPumpStatusData() - open fun hasService(): Boolean { - return true - } - override fun onStart() { super.onStart() initPumpStatusData() - if (hasService()) { + serviceConnection?.let { serviceConnection -> val intent = Intent(context, serviceClass) - context.bindService(intent, serviceConnection!!, Context.BIND_AUTO_CREATE) - disposable.add(rxBus - .toObservable(EventAppExit::class.java) - .observeOn(aapsSchedulers.io) - .subscribe({ _ -> context.unbindService(serviceConnection!!) }) { throwable: Throwable? -> fabricPrivacy.logException(throwable!!) } + context.bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE) + disposable.add( + rxBus + .toObservable(EventAppExit::class.java) + .observeOn(aapsSchedulers.io) + .subscribe({ context.unbindService(serviceConnection) }, fabricPrivacy::logException) ) } serviceRunning = true @@ -106,8 +105,8 @@ abstract class PumpPluginAbstract protected constructor( override fun onStop() { aapsLogger.debug(LTag.PUMP, model().model + " onStop()") - if (hasService()) { - context.unbindService(serviceConnection!!) + serviceConnection?.let { serviceConnection -> + context.unbindService(serviceConnection) } serviceRunning = false disposable.clear() @@ -334,7 +333,7 @@ abstract class PumpPluginAbstract protected constructor( rxBus.send(EventCustomActionsChanged()) } - override fun manufacturer(): ManufacturerType = pumpType.manufacturer!! + override fun manufacturer(): ManufacturerType = pumpType.manufacturer ?: ManufacturerType.AAPS override fun model(): PumpType = pumpType override fun canHandleDST(): Boolean = false diff --git a/workflow/src/main/java/info/nightscout/workflow/iob/CarbsInPastExtension.kt b/workflow/src/main/java/info/nightscout/workflow/iob/CarbsInPastExtension.kt index 23e7a93780..d675ffa3a0 100644 --- a/workflow/src/main/java/info/nightscout/workflow/iob/CarbsInPastExtension.kt +++ b/workflow/src/main/java/info/nightscout/workflow/iob/CarbsInPastExtension.kt @@ -1,4 +1,4 @@ -package info.nightscout.plugins.iob.iobCobCalculator +package info.nightscout.workflow.iob import info.nightscout.database.entities.Carbs import info.nightscout.interfaces.Constants diff --git a/workflow/src/main/java/info/nightscout/workflow/iob/IobCobOref1Worker.kt b/workflow/src/main/java/info/nightscout/workflow/iob/IobCobOref1Worker.kt index 95657f8da3..9ce169cf21 100644 --- a/workflow/src/main/java/info/nightscout/workflow/iob/IobCobOref1Worker.kt +++ b/workflow/src/main/java/info/nightscout/workflow/iob/IobCobOref1Worker.kt @@ -23,7 +23,6 @@ import info.nightscout.interfaces.profile.Instantiator import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profiling.Profiler import info.nightscout.interfaces.utils.DecimalFormatter -import info.nightscout.plugins.iob.iobCobCalculator.fromCarbs import info.nightscout.rx.bus.RxBus import info.nightscout.rx.events.Event import info.nightscout.rx.events.EventAutosensCalculationFinished diff --git a/workflow/src/main/java/info/nightscout/workflow/iob/IobCobOrefWorker.kt b/workflow/src/main/java/info/nightscout/workflow/iob/IobCobOrefWorker.kt index 39b02048fe..538c179fe0 100644 --- a/workflow/src/main/java/info/nightscout/workflow/iob/IobCobOrefWorker.kt +++ b/workflow/src/main/java/info/nightscout/workflow/iob/IobCobOrefWorker.kt @@ -21,7 +21,6 @@ import info.nightscout.interfaces.profile.Instantiator import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profiling.Profiler import info.nightscout.interfaces.utils.DecimalFormatter -import info.nightscout.plugins.iob.iobCobCalculator.fromCarbs import info.nightscout.rx.bus.RxBus import info.nightscout.rx.events.Event import info.nightscout.rx.events.EventAutosensCalculationFinished