Merge remote-tracking branch 'Nightscout/dev' into Autotune/TuneWeekDaysClean
This commit is contained in:
commit
123f590722
|
@ -312,7 +312,7 @@ class ActionsFragment : DaggerFragment() {
|
|||
for (customAction in customActions) {
|
||||
if (!customAction.isEnabled) continue
|
||||
|
||||
val btn = SingleClickButton(currentContext, null, android.R.attr.buttonStyle)
|
||||
val btn = SingleClickButton(currentContext, null, R.attr.customBtnStyle)
|
||||
btn.text = rh.gs(customAction.name)
|
||||
|
||||
val layoutParams = LinearLayout.LayoutParams(
|
||||
|
|
|
@ -582,7 +582,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
for (event in events)
|
||||
if (event.isEnabled && event.trigger.shouldRun())
|
||||
context?.let { context ->
|
||||
SingleClickButton(context).also {
|
||||
SingleClickButton(context, null, R.attr.customBtnStyle).also {
|
||||
it.setTextColor(rh.gac(context, R.attr.treatmentButton))
|
||||
it.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10f)
|
||||
it.layoutParams = LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 0.5f).also { l ->
|
||||
|
|
|
@ -97,11 +97,11 @@ class IobCobOref1Worker(
|
|||
val bucketedData = ads.bucketedData
|
||||
val autosensDataTable = ads.autosensDataTable
|
||||
if (bucketedData == null || bucketedData.size < 3) {
|
||||
aapsLogger.debug(LTag.AUTOSENS, "Aborting calculation thread (No bucketed data available): ${data.from}")
|
||||
aapsLogger.debug(LTag.AUTOSENS, {"Aborting calculation thread (No bucketed data available): ${data.from}"})
|
||||
return Result.success(workDataOf("Error" to "Aborting calculation thread (No bucketed data available): ${data.from}"))
|
||||
}
|
||||
val prevDataTime = ads.roundUpTime(bucketedData[bucketedData.size - 3].timestamp)
|
||||
aapsLogger.debug(LTag.AUTOSENS, "Prev data time: " + dateUtil.dateAndTimeString(prevDataTime))
|
||||
aapsLogger.debug(LTag.AUTOSENS, {"Prev data time: " + dateUtil.dateAndTimeString(prevDataTime)})
|
||||
var previous = autosensDataTable[prevDataTime]
|
||||
// start from oldest to be able sub cob
|
||||
for (i in bucketedData.size - 4 downTo 0) {
|
||||
|
@ -156,15 +156,15 @@ class IobCobOref1Worker(
|
|||
val hourAgoData = ads.getAutosensDataAtTime(hourAgo)
|
||||
if (hourAgoData != null) {
|
||||
val initialIndex = autosensDataTable.indexOfKey(hourAgoData.time)
|
||||
aapsLogger.debug(LTag.AUTOSENS, ">>>>> bucketed_data.size()=" + bucketedData.size + " i=" + i + " hourAgoData=" + hourAgoData.toString())
|
||||
aapsLogger.debug(LTag.AUTOSENS, { ">>>>> bucketed_data.size()=" + bucketedData.size + " i=" + i + " hourAgoData=" + hourAgoData.toString()})
|
||||
var past = 1
|
||||
try {
|
||||
while (past < 12) {
|
||||
val ad = autosensDataTable.valueAt(initialIndex + past)
|
||||
aapsLogger.debug(LTag.AUTOSENS, ">>>>> past=" + past + " ad=" + ad?.toString())
|
||||
aapsLogger.debug(LTag.AUTOSENS, {">>>>> past=" + past + " ad=" + ad?.toString()})
|
||||
if (ad == null) {
|
||||
aapsLogger.debug(LTag.AUTOSENS, autosensDataTable.toString())
|
||||
aapsLogger.debug(LTag.AUTOSENS, bucketedData.toString())
|
||||
aapsLogger.debug(LTag.AUTOSENS, {autosensDataTable.toString()})
|
||||
aapsLogger.debug(LTag.AUTOSENS, {bucketedData.toString()})
|
||||
//aapsLogger.debug(LTag.AUTOSENS, iobCobCalculatorPlugin.getBgReadingsDataTable().toString())
|
||||
val notification = Notification(Notification.SEND_LOGFILES, rh.gs(R.string.sendlogfiles), Notification.LOW)
|
||||
rxBus.send(EventNewNotification(notification))
|
||||
|
@ -319,14 +319,12 @@ class IobCobOref1Worker(
|
|||
if (bgTime < dateUtil.now()) autosensDataTable.put(bgTime, autosensData)
|
||||
aapsLogger.debug(
|
||||
LTag.AUTOSENS,
|
||||
"Running detectSensitivity from: " + dateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + dateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + ads.lastDataTime(
|
||||
dateUtil
|
||||
)
|
||||
{"Running detectSensitivity from: " + dateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + dateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + ads.lastDataTime(dateUtil)}
|
||||
)
|
||||
val sensitivity = activePlugin.activeSensitivity.detectSensitivity(ads, oldestTimeWithData, bgTime)
|
||||
aapsLogger.debug(LTag.AUTOSENS, "Sensitivity result: $sensitivity")
|
||||
autosensData.autosensResult = sensitivity
|
||||
aapsLogger.debug(LTag.AUTOSENS, autosensData.toString())
|
||||
aapsLogger.debug(LTag.AUTOSENS, {autosensData.toString()})
|
||||
}
|
||||
data.iobCobCalculator.ads = ads
|
||||
Thread {
|
||||
|
@ -335,7 +333,7 @@ class IobCobOref1Worker(
|
|||
}.start()
|
||||
} finally {
|
||||
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.IOB_COB_OREF, 100, data.cause))
|
||||
aapsLogger.debug(LTag.AUTOSENS, "AUTOSENSDATA thread ended: ${data.from}")
|
||||
aapsLogger.debug(LTag.AUTOSENS, {"AUTOSENSDATA thread ended: ${data.from}"})
|
||||
profiler.log(LTag.AUTOSENS, "IobCobOref1Thread", start)
|
||||
}
|
||||
return Result.success()
|
||||
|
|
|
@ -7,9 +7,9 @@ buildscript {
|
|||
rxjava_version = '3.1.5'
|
||||
rxandroid_version = '3.0.0'
|
||||
rxkotlin_version = '3.0.1'
|
||||
room_version = '2.4.2'
|
||||
room_version = '2.4.3'
|
||||
lifecycle_version = '2.5.0'
|
||||
dagger_version = '2.42'
|
||||
dagger_version = '2.43'
|
||||
coroutines_version = '1.6.4'
|
||||
activity_version = '1.4.0'
|
||||
fragmentktx_version = '1.4.1'
|
||||
|
|
|
@ -57,7 +57,7 @@ class AutosensDataStore {
|
|||
synchronized(autosensDataTable) {
|
||||
for (index in autosensDataTable.size() - 1 downTo 0) {
|
||||
if (autosensDataTable.keyAt(index) > time) {
|
||||
aapsLogger.debug(LTag.AUTOSENS, "Removing from autosensDataTable: " + dateUtil.dateAndTimeAndSecondsString(autosensDataTable.keyAt(index)))
|
||||
aapsLogger.debug(LTag.AUTOSENS, {"Removing from autosensDataTable: " + dateUtil.dateAndTimeAndSecondsString(autosensDataTable.keyAt(index))})
|
||||
autosensDataTable.removeAt(index)
|
||||
} else {
|
||||
break
|
||||
|
@ -135,10 +135,10 @@ class AutosensDataStore {
|
|||
return null
|
||||
}
|
||||
return if (data.time < System.currentTimeMillis() - 11 * 60 * 1000) {
|
||||
aapsLogger.debug(LTag.AUTOSENS, "AUTOSENSDATA null: data is old (" + reason + ") size()=" + autosensDataTable.size() + " lastData=" + dateUtil.dateAndTimeAndSecondsString(data.time))
|
||||
aapsLogger.debug(LTag.AUTOSENS, {"AUTOSENSDATA null: data is old (" + reason + ") size()=" + autosensDataTable.size() + " lastData=" + dateUtil.dateAndTimeAndSecondsString(data.time)})
|
||||
null
|
||||
} else {
|
||||
aapsLogger.debug(LTag.AUTOSENS, "AUTOSENSDATA ($reason) $data")
|
||||
aapsLogger.debug(LTag.AUTOSENS, {"AUTOSENSDATA ($reason) $data"})
|
||||
data
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ class AutosensDataStore {
|
|||
.compatGetBgReadingsDataFromTime(start, to + T.mins(2).msecs(), false)
|
||||
.blockingGet()
|
||||
.filter { it.value >= 39 }
|
||||
aapsLogger.debug(LTag.AUTOSENS, "BG data loaded. Size: " + bgReadings.size + " Start date: " + dateUtil.dateAndTimeString(start) + " End date: " + dateUtil.dateAndTimeString(to))
|
||||
aapsLogger.debug(LTag.AUTOSENS, {"BG data loaded. Size: " + bgReadings.size + " Start date: " + dateUtil.dateAndTimeString(start) + " End date: " + dateUtil.dateAndTimeString(to)})
|
||||
createBucketedData(aapsLogger, dateUtil)
|
||||
rxBus.send(EventBucketedDataCreated())
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ class AutosensDataStore {
|
|||
}
|
||||
val bData: MutableList<InMemoryGlucoseValue> = ArrayList()
|
||||
bData.add(InMemoryGlucoseValue(bgReadings[0]))
|
||||
aapsLogger.debug(LTag.AUTOSENS, "Adding. bgTime: " + dateUtil.toISOString(bgReadings[0].timestamp) + " lastBgTime: " + "none-first-value" + " " + bgReadings[0].toString())
|
||||
aapsLogger.debug(LTag.AUTOSENS, {"Adding. bgTime: " + dateUtil.toISOString(bgReadings[0].timestamp) + " lastBgTime: " + "none-first-value" + " " + bgReadings[0].toString()})
|
||||
var j = 0
|
||||
for (i in 1 until bgReadings.size) {
|
||||
val bgTime = bgReadings[i].timestamp
|
||||
|
@ -293,7 +293,7 @@ class AutosensDataStore {
|
|||
val newBgReading = InMemoryGlucoseValue(nextBgTime, nextBg.roundToLong().toDouble(), true)
|
||||
//console.error("Interpolated", bData[j]);
|
||||
bData.add(newBgReading)
|
||||
aapsLogger.debug(LTag.AUTOSENS, "Adding. bgTime: " + dateUtil.toISOString(bgTime) + " lastBgTime: " + dateUtil.toISOString(lastBgTime) + " " + newBgReading.toString())
|
||||
aapsLogger.debug(LTag.AUTOSENS, {"Adding. bgTime: " + dateUtil.toISOString(bgTime) + " lastBgTime: " + dateUtil.toISOString(lastBgTime) + " " + newBgReading.toString()})
|
||||
elapsedMinutes -= 5
|
||||
lastBg = nextBg
|
||||
lastBgTime = nextBgTime
|
||||
|
@ -301,14 +301,14 @@ class AutosensDataStore {
|
|||
j++
|
||||
val newBgReading = InMemoryGlucoseValue(bgTime, bgReadings[i].value)
|
||||
bData.add(newBgReading)
|
||||
aapsLogger.debug(LTag.AUTOSENS, "Adding. bgTime: " + dateUtil.toISOString(bgTime) + " lastBgTime: " + dateUtil.toISOString(lastBgTime) + " " + newBgReading.toString())
|
||||
aapsLogger.debug(LTag.AUTOSENS, {"Adding. bgTime: " + dateUtil.toISOString(bgTime) + " lastBgTime: " + dateUtil.toISOString(lastBgTime) + " " + newBgReading.toString()})
|
||||
}
|
||||
|
||||
abs(elapsedMinutes) > 2 -> {
|
||||
j++
|
||||
val newBgReading = InMemoryGlucoseValue(bgTime, bgReadings[i].value)
|
||||
bData.add(newBgReading)
|
||||
aapsLogger.debug(LTag.AUTOSENS, "Adding. bgTime: " + dateUtil.toISOString(bgTime) + " lastBgTime: " + dateUtil.toISOString(lastBgTime) + " " + newBgReading.toString())
|
||||
aapsLogger.debug(LTag.AUTOSENS, {"Adding. bgTime: " + dateUtil.toISOString(bgTime) + " lastBgTime: " + dateUtil.toISOString(lastBgTime) + " " + newBgReading.toString()})
|
||||
}
|
||||
|
||||
else -> {
|
||||
|
@ -327,7 +327,7 @@ class AutosensDataStore {
|
|||
val previous = bData[i + 1]
|
||||
val mSecDiff = current.timestamp - previous.timestamp
|
||||
val adjusted = (mSecDiff - T.mins(5).msecs()) / 1000
|
||||
aapsLogger.debug(LTag.AUTOSENS, "Adjusting bucketed data time. Current: " + dateUtil.dateAndTimeAndSecondsString(current.timestamp) + " to: " + dateUtil.dateAndTimeAndSecondsString(previous.timestamp + T.mins(5).msecs()) + " by " + adjusted + " sec")
|
||||
aapsLogger.debug(LTag.AUTOSENS, {"Adjusting bucketed data time. Current: " + dateUtil.dateAndTimeAndSecondsString(current.timestamp) + " to: " + dateUtil.dateAndTimeAndSecondsString(previous.timestamp + T.mins(5).msecs()) + " by " + adjusted + " sec"})
|
||||
if (abs(adjusted) > 90) {
|
||||
// too big adjustment, fallback to non 5 min data
|
||||
aapsLogger.debug(LTag.AUTOSENS, "Fallback to non 5 min data")
|
||||
|
|
|
@ -248,6 +248,8 @@
|
|||
<item name="crossTargetColor">@color/white</item>
|
||||
<!---Spinner style from pump common-->
|
||||
<item name="android:spinnerItemStyle">@style/CommonSpinnerItemStyle</item>
|
||||
<!---Custom button -->
|
||||
<item name="customBtnStyle">@style/GrayButton</item>
|
||||
</style>
|
||||
|
||||
|
||||
|
|
|
@ -218,4 +218,6 @@
|
|||
<!---Icons in Loop area -->
|
||||
<attr name="profileColor" format="reference|color" />
|
||||
<attr name="crossTargetColor" format="reference|color" />
|
||||
<!---Custom button -->
|
||||
<attr name="customBtnStyle" format="reference"/>
|
||||
</resources>
|
|
@ -249,6 +249,8 @@
|
|||
<item name="crossTargetColor">@color/white</item>
|
||||
<!---Spinner style from pump common-->
|
||||
<item name="android:spinnerItemStyle">@style/CommonSpinnerItemStyle</item>
|
||||
<!---Custom button -->
|
||||
<item name="customBtnStyle">@style/GrayButton</item>
|
||||
</style>
|
||||
|
||||
<style name="CommonSpinnerItemStyle" parent="Widget.AppCompat.TextView.SpinnerItem">
|
||||
|
|
|
@ -7,6 +7,5 @@
|
|||
android:gravity="center_vertical"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="0dp"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp"
|
||||
tools:text="Test" />
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
android:gravity="start"
|
||||
android:paddingStart="5dp"
|
||||
android:paddingEnd="0dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="14sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -797,24 +797,68 @@ class MedtronicHistoryData @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
// see if rewind items, need to fix any of current tempBasalProcessDTO items (bug 1724)
|
||||
if (rewindList.isNotEmpty()) {
|
||||
for (rewindEntry in rewindList) {
|
||||
for (tempBasalProcessDTO in processList) {
|
||||
if (tempBasalProcessDTO.itemTwo==null) {
|
||||
val endTime: Long = DateTimeUtil.getATDWithAddedMinutes(tempBasalProcessDTO.itemOne.atechDateTime, tempBasalProcessDTO.itemOneTbr!!.durationMinutes)
|
||||
// TODO this solution needs to be overworked, commenting out for now
|
||||
// val suspendList = getFilteredItems(newHistory, //
|
||||
// setOf(PumpHistoryEntryType.SuspendPump))
|
||||
//
|
||||
// val stopList : MutableList<PumpHistoryEntry> = mutableListOf()
|
||||
// stopList.addAll(suspendList);
|
||||
// stopList.addAll(rewindList);
|
||||
//
|
||||
// // TODO remove see if rewind items, need to fix any of current tempBasalProcessDTO items (bug 1724)
|
||||
// if (rewindList.isNotEmpty()) {
|
||||
// for (rewindEntry in rewindList) {
|
||||
// for (tempBasalProcessDTO in processList) {
|
||||
// if (tempBasalProcessDTO.itemTwo==null) {
|
||||
// val endTime: Long = DateTimeUtil.getATDWithAddedMinutes(tempBasalProcessDTO.itemOne.atechDateTime, tempBasalProcessDTO.itemOneTbr!!.durationMinutes)
|
||||
//
|
||||
// if ((rewindEntry.atechDateTime > tempBasalProcessDTO.itemOne.atechDateTime) &&
|
||||
// (rewindEntry.atechDateTime < endTime)) {
|
||||
// tempBasalProcessDTO.itemTwo = rewindEntry
|
||||
// continue
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // see if have rewind/stop items that need to fix any of current tempBasalProcessDTO items (bug 1724)
|
||||
// if (stopList.isNotEmpty()) {
|
||||
// for (tempBasalProcessDTO in processList) {
|
||||
// if (tempBasalProcessDTO.itemTwo==null) {
|
||||
// val endTime: Long = DateTimeUtil.getATDWithAddedMinutes(tempBasalProcessDTO.itemOne.atechDateTime, tempBasalProcessDTO.itemOneTbr!!.durationMinutes)
|
||||
//
|
||||
// val findNearestEntry = findNearestEntry(tempBasalProcessDTO.itemOne.atechDateTime, endTime, stopList);
|
||||
//
|
||||
// if (findNearestEntry!=null) {
|
||||
// tempBasalProcessDTO.itemTwo = findNearestEntry
|
||||
// stopList.remove(findNearestEntry)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if ((rewindEntry.atechDateTime > tempBasalProcessDTO.itemOne.atechDateTime) &&
|
||||
(rewindEntry.atechDateTime < endTime)) {
|
||||
tempBasalProcessDTO.itemTwo = rewindEntry
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
return processList
|
||||
}
|
||||
|
||||
fun findNearestEntry(startTime: Long, endTime: Long, list: MutableList<PumpHistoryEntry>) : PumpHistoryEntry? {
|
||||
val outList: MutableList<PumpHistoryEntry> = mutableListOf()
|
||||
|
||||
for (pumpHistoryEntry in list) {
|
||||
if ((pumpHistoryEntry.atechDateTime > startTime) &&
|
||||
(pumpHistoryEntry.atechDateTime < endTime)) {
|
||||
outList.add(pumpHistoryEntry)
|
||||
}
|
||||
}
|
||||
|
||||
return processList
|
||||
if (outList.size == 0) {
|
||||
return null
|
||||
} else if (outList.size==1) {
|
||||
return outList[0]
|
||||
} else {
|
||||
// TODO
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
fun isTBRActive(dbEntry: PumpDbEntryTBR): Boolean {
|
||||
|
|
|
@ -9,6 +9,7 @@ interface AAPSLogger {
|
|||
fun debug(message: String)
|
||||
fun debug(enable: Boolean, tag: LTag, message: String)
|
||||
fun debug(tag: LTag, message: String)
|
||||
fun debug(tag: LTag, accessor: () -> String)
|
||||
fun debug(tag: LTag, format: String, vararg arguments: Any?)
|
||||
fun warn(tag: LTag, message: String)
|
||||
fun warn(tag: LTag, format: String, vararg arguments: Any?)
|
||||
|
|
|
@ -22,6 +22,11 @@ class AAPSLoggerProduction constructor(val l: L) : AAPSLogger {
|
|||
LoggerFactory.getLogger(tag.tag).debug(stackLogMarker() + message)
|
||||
}
|
||||
|
||||
override fun debug(tag: LTag, accessor: () -> String) {
|
||||
if (l.findByName(tag.tag).enabled)
|
||||
LoggerFactory.getLogger(tag.tag).debug(stackLogMarker() + accessor.invoke())
|
||||
}
|
||||
|
||||
override fun debug(tag: LTag, format: String, vararg arguments: Any?) {
|
||||
if (l.findByName(tag.tag).enabled)
|
||||
LoggerFactory.getLogger(tag.tag).debug(stackLogMarker() + format, arguments)
|
||||
|
|
|
@ -18,6 +18,10 @@ class AAPSLoggerTest : AAPSLogger {
|
|||
println("DEBUG: : " + tag.tag + " " + message)
|
||||
}
|
||||
|
||||
override fun debug(tag: LTag, accessor: () -> String) {
|
||||
println("DEBUG: : " + tag.tag + " " + accessor.invoke())
|
||||
}
|
||||
|
||||
override fun debug(tag: LTag, format: String, vararg arguments: Any?) {
|
||||
println("DEBUG: : " + tag.tag + " " + String.format(format, arguments))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue