reset AS on PS instead of EPS
This commit is contained in:
parent
370b504d74
commit
102f73fbc9
5 changed files with 47 additions and 47 deletions
|
@ -6,7 +6,7 @@ import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.annotations.OpenForTesting
|
import info.nightscout.androidaps.annotations.OpenForTesting
|
||||||
import info.nightscout.androidaps.database.AppRepository
|
import info.nightscout.androidaps.database.AppRepository
|
||||||
import info.nightscout.androidaps.database.entities.TherapyEvent
|
import info.nightscout.androidaps.database.entities.TherapyEvent
|
||||||
import info.nightscout.androidaps.extensions.isEPSEvent5minBack
|
import info.nightscout.androidaps.extensions.isPSEvent5minBack
|
||||||
import info.nightscout.androidaps.extensions.isTherapyEventEvent5minBack
|
import info.nightscout.androidaps.extensions.isTherapyEventEvent5minBack
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
@ -38,13 +38,14 @@ class SensitivityAAPSPlugin @Inject constructor(
|
||||||
private val profileFunction: ProfileFunction,
|
private val profileFunction: ProfileFunction,
|
||||||
private val dateUtil: DateUtil,
|
private val dateUtil: DateUtil,
|
||||||
private val repository: AppRepository
|
private val repository: AppRepository
|
||||||
) : AbstractSensitivityPlugin(PluginDescription()
|
) : AbstractSensitivityPlugin(
|
||||||
.mainType(PluginType.SENSITIVITY)
|
PluginDescription()
|
||||||
.pluginIcon(R.drawable.ic_generic_icon)
|
.mainType(PluginType.SENSITIVITY)
|
||||||
.pluginName(R.string.sensitivityaaps)
|
.pluginIcon(R.drawable.ic_generic_icon)
|
||||||
.shortName(R.string.sensitivity_shortname)
|
.pluginName(R.string.sensitivityaaps)
|
||||||
.preferencesId(R.xml.pref_absorption_aaps)
|
.shortName(R.string.sensitivity_shortname)
|
||||||
.description(R.string.description_sensitivity_aaps),
|
.preferencesId(R.xml.pref_absorption_aaps)
|
||||||
|
.description(R.string.description_sensitivity_aaps),
|
||||||
injector, aapsLogger, rh, sp
|
injector, aapsLogger, rh, sp
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
@ -70,7 +71,7 @@ class SensitivityAAPSPlugin @Inject constructor(
|
||||||
return AutosensResult()
|
return AutosensResult()
|
||||||
}
|
}
|
||||||
val siteChanges = repository.getTherapyEventDataFromTime(fromTime, TherapyEvent.Type.CANNULA_CHANGE, true).blockingGet()
|
val siteChanges = repository.getTherapyEventDataFromTime(fromTime, TherapyEvent.Type.CANNULA_CHANGE, true).blockingGet()
|
||||||
val profileSwitches = repository.getEffectiveProfileSwitchDataFromTime(fromTime, true).blockingGet()
|
val profileSwitches = repository.getProfileSwitchDataFromTime(fromTime, true).blockingGet()
|
||||||
val deviationsArray: MutableList<Double> = ArrayList()
|
val deviationsArray: MutableList<Double> = ArrayList()
|
||||||
var pastSensitivity = ""
|
var pastSensitivity = ""
|
||||||
var index = 0
|
var index = 0
|
||||||
|
@ -92,7 +93,7 @@ class SensitivityAAPSPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset deviations after profile switch
|
// reset deviations after profile switch
|
||||||
if (profileSwitches.isEPSEvent5minBack(autosensData.time)) {
|
if (profileSwitches.isPSEvent5minBack(autosensData.time)) {
|
||||||
deviationsArray.clear()
|
deviationsArray.clear()
|
||||||
pastSensitivity += "(PROFILESWITCH)"
|
pastSensitivity += "(PROFILESWITCH)"
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.annotations.OpenForTesting
|
import info.nightscout.androidaps.annotations.OpenForTesting
|
||||||
import info.nightscout.androidaps.database.AppRepository
|
import info.nightscout.androidaps.database.AppRepository
|
||||||
import info.nightscout.androidaps.database.entities.TherapyEvent
|
import info.nightscout.androidaps.database.entities.TherapyEvent
|
||||||
import info.nightscout.androidaps.extensions.isEPSEvent5minBack
|
import info.nightscout.androidaps.extensions.isPSEvent5minBack
|
||||||
import info.nightscout.androidaps.extensions.isTherapyEventEvent5minBack
|
import info.nightscout.androidaps.extensions.isTherapyEventEvent5minBack
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
@ -39,15 +39,16 @@ class SensitivityOref1Plugin @Inject constructor(
|
||||||
private val profileFunction: ProfileFunction,
|
private val profileFunction: ProfileFunction,
|
||||||
private val dateUtil: DateUtil,
|
private val dateUtil: DateUtil,
|
||||||
private val repository: AppRepository
|
private val repository: AppRepository
|
||||||
) : AbstractSensitivityPlugin(PluginDescription()
|
) : AbstractSensitivityPlugin(
|
||||||
.mainType(PluginType.SENSITIVITY)
|
PluginDescription()
|
||||||
.pluginIcon(R.drawable.ic_generic_icon)
|
.mainType(PluginType.SENSITIVITY)
|
||||||
.pluginName(R.string.sensitivityoref1)
|
.pluginIcon(R.drawable.ic_generic_icon)
|
||||||
.shortName(R.string.sensitivity_shortname)
|
.pluginName(R.string.sensitivityoref1)
|
||||||
.enableByDefault(true)
|
.shortName(R.string.sensitivity_shortname)
|
||||||
.preferencesId(R.xml.pref_absorption_oref1)
|
.enableByDefault(true)
|
||||||
.description(R.string.description_sensitivity_oref1)
|
.preferencesId(R.xml.pref_absorption_oref1)
|
||||||
.setDefault(),
|
.description(R.string.description_sensitivity_oref1)
|
||||||
|
.setDefault(),
|
||||||
injector, aapsLogger, rh, sp
|
injector, aapsLogger, rh, sp
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
@ -71,7 +72,7 @@ class SensitivityOref1Plugin @Inject constructor(
|
||||||
return AutosensResult()
|
return AutosensResult()
|
||||||
}
|
}
|
||||||
val siteChanges = repository.getTherapyEventDataFromTime(fromTime, TherapyEvent.Type.CANNULA_CHANGE, true).blockingGet()
|
val siteChanges = repository.getTherapyEventDataFromTime(fromTime, TherapyEvent.Type.CANNULA_CHANGE, true).blockingGet()
|
||||||
val profileSwitches = repository.getEffectiveProfileSwitchDataFromTime(fromTime, true).blockingGet()
|
val profileSwitches = repository.getProfileSwitchDataFromTime(fromTime, true).blockingGet()
|
||||||
|
|
||||||
//[0] = 8 hour
|
//[0] = 8 hour
|
||||||
//[1] = 24 hour
|
//[1] = 24 hour
|
||||||
|
@ -108,7 +109,7 @@ class SensitivityOref1Plugin @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset deviations after profile switch
|
// reset deviations after profile switch
|
||||||
if (profileSwitches.isEPSEvent5minBack(autosensData.time)) {
|
if (profileSwitches.isPSEvent5minBack(autosensData.time)) {
|
||||||
deviationsArray.clear()
|
deviationsArray.clear()
|
||||||
pastSensitivity += "(PROFILESWITCH)"
|
pastSensitivity += "(PROFILESWITCH)"
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.annotations.OpenForTesting
|
import info.nightscout.androidaps.annotations.OpenForTesting
|
||||||
import info.nightscout.androidaps.database.AppRepository
|
import info.nightscout.androidaps.database.AppRepository
|
||||||
import info.nightscout.androidaps.database.entities.TherapyEvent
|
import info.nightscout.androidaps.database.entities.TherapyEvent
|
||||||
import info.nightscout.androidaps.extensions.isEPSEvent5minBack
|
import info.nightscout.androidaps.extensions.isPSEvent5minBack
|
||||||
import info.nightscout.androidaps.extensions.isTherapyEventEvent5minBack
|
import info.nightscout.androidaps.extensions.isTherapyEventEvent5minBack
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
@ -37,13 +37,14 @@ class SensitivityWeightedAveragePlugin @Inject constructor(
|
||||||
private val profileFunction: ProfileFunction,
|
private val profileFunction: ProfileFunction,
|
||||||
private val dateUtil: DateUtil,
|
private val dateUtil: DateUtil,
|
||||||
private val repository: AppRepository
|
private val repository: AppRepository
|
||||||
) : AbstractSensitivityPlugin(PluginDescription()
|
) : AbstractSensitivityPlugin(
|
||||||
.mainType(PluginType.SENSITIVITY)
|
PluginDescription()
|
||||||
.pluginIcon(R.drawable.ic_generic_icon)
|
.mainType(PluginType.SENSITIVITY)
|
||||||
.pluginName(R.string.sensitivityweightedaverage)
|
.pluginIcon(R.drawable.ic_generic_icon)
|
||||||
.shortName(R.string.sensitivity_shortname)
|
.pluginName(R.string.sensitivityweightedaverage)
|
||||||
.preferencesId(R.xml.pref_absorption_aaps)
|
.shortName(R.string.sensitivity_shortname)
|
||||||
.description(R.string.description_sensitivity_weighted_average),
|
.preferencesId(R.xml.pref_absorption_aaps)
|
||||||
|
.description(R.string.description_sensitivity_weighted_average),
|
||||||
injector, aapsLogger, rh, sp
|
injector, aapsLogger, rh, sp
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
@ -69,7 +70,7 @@ class SensitivityWeightedAveragePlugin @Inject constructor(
|
||||||
return AutosensResult()
|
return AutosensResult()
|
||||||
}
|
}
|
||||||
val siteChanges = repository.getTherapyEventDataFromTime(fromTime, TherapyEvent.Type.CANNULA_CHANGE, true).blockingGet()
|
val siteChanges = repository.getTherapyEventDataFromTime(fromTime, TherapyEvent.Type.CANNULA_CHANGE, true).blockingGet()
|
||||||
val profileSwitches = repository.getEffectiveProfileSwitchDataFromTime(fromTime, true).blockingGet()
|
val profileSwitches = repository.getProfileSwitchDataFromTime(fromTime, true).blockingGet()
|
||||||
var pastSensitivity = ""
|
var pastSensitivity = ""
|
||||||
var index = 0
|
var index = 0
|
||||||
val data = LongSparseArray<Double>()
|
val data = LongSparseArray<Double>()
|
||||||
|
@ -95,7 +96,7 @@ class SensitivityWeightedAveragePlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset deviations after profile switch
|
// reset deviations after profile switch
|
||||||
if (profileSwitches.isEPSEvent5minBack(autosensData.time)) {
|
if (profileSwitches.isPSEvent5minBack(autosensData.time)) {
|
||||||
data.clear()
|
data.clear()
|
||||||
pastSensitivity += "(PROFILESWITCH)"
|
pastSensitivity += "(PROFILESWITCH)"
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,21 +7,8 @@ import info.nightscout.androidaps.database.entities.TherapyEvent
|
||||||
import info.nightscout.androidaps.interfaces.GlucoseUnit
|
import info.nightscout.androidaps.interfaces.GlucoseUnit
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.JsonHelper
|
import info.nightscout.androidaps.utils.JsonHelper
|
||||||
import info.nightscout.androidaps.utils.T.Companion.mins
|
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
||||||
fun List<EffectiveProfileSwitch>.isEPSEvent5minBack(time: Long): Boolean {
|
|
||||||
for (event in this) {
|
|
||||||
if (event.timestamp <= time && event.timestamp > time - mins(5).msecs()) {
|
|
||||||
if (event.originalDuration == 0L) {
|
|
||||||
//aapsLogger.debug(LTag.DATABASE, "Found ProfileSwitch event for time: " + dateUtil.dateAndTimeString(time) + " " + event.toString())
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
fun EffectiveProfileSwitch.toJson(isAdd: Boolean, dateUtil: DateUtil): JSONObject =
|
fun EffectiveProfileSwitch.toJson(isAdd: Boolean, dateUtil: DateUtil): JSONObject =
|
||||||
JSONObject()
|
JSONObject()
|
||||||
.put("created_at", dateUtil.toISOString(timestamp))
|
.put("created_at", dateUtil.toISOString(timestamp))
|
||||||
|
|
|
@ -5,11 +5,9 @@ import info.nightscout.androidaps.data.ProfileSealed
|
||||||
import info.nightscout.androidaps.data.PureProfile
|
import info.nightscout.androidaps.data.PureProfile
|
||||||
import info.nightscout.androidaps.database.embedments.InterfaceIDs
|
import info.nightscout.androidaps.database.embedments.InterfaceIDs
|
||||||
import info.nightscout.androidaps.database.entities.ProfileSwitch
|
import info.nightscout.androidaps.database.entities.ProfileSwitch
|
||||||
import info.nightscout.androidaps.database.entities.TemporaryBasal
|
|
||||||
import info.nightscout.androidaps.database.entities.TherapyEvent
|
import info.nightscout.androidaps.database.entities.TherapyEvent
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
import info.nightscout.androidaps.interfaces.GlucoseUnit
|
import info.nightscout.androidaps.interfaces.GlucoseUnit
|
||||||
import info.nightscout.androidaps.interfaces.Profile
|
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter.to2Decimal
|
import info.nightscout.androidaps.utils.DecimalFormatter.to2Decimal
|
||||||
import info.nightscout.androidaps.utils.JsonHelper
|
import info.nightscout.androidaps.utils.JsonHelper
|
||||||
|
@ -17,6 +15,18 @@ import info.nightscout.androidaps.utils.T
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
fun List<ProfileSwitch>.isPSEvent5minBack(time: Long): Boolean {
|
||||||
|
for (event in this) {
|
||||||
|
if (event.timestamp <= time && event.timestamp > time - T.mins(5).msecs()) {
|
||||||
|
if (event.duration == 0L) {
|
||||||
|
//aapsLogger.debug(LTag.DATABASE, "Found ProfileSwitch event for time: " + dateUtil.dateAndTimeString(time) + " " + event.toString())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
fun ProfileSwitch.toJson(isAdd: Boolean, dateUtil: DateUtil): JSONObject =
|
fun ProfileSwitch.toJson(isAdd: Boolean, dateUtil: DateUtil): JSONObject =
|
||||||
JSONObject()
|
JSONObject()
|
||||||
.put("created_at", dateUtil.toISOString(timestamp))
|
.put("created_at", dateUtil.toISOString(timestamp))
|
||||||
|
|
Loading…
Reference in a new issue