feat: scan_id를 BLE 로그에도 추가 (CSV와 대조 가능)

- MEASUREMENT scan=3 vol=305.2ml lr=1.20 valid=4/6
- BV_SKIP scan=4 center=2/4 total=2/6
- BV_FAIL scan=5 no valid channels

AdcCsvLogger.lastScanId 공개 → BleDebugLogger에서 참조

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-27 11:24:57 +09:00
parent 099fcfaf97
commit 7125e79fb9
3 changed files with 8 additions and 3 deletions
@@ -16,6 +16,8 @@ object AdcCsvLogger {
private val dayFmt = SimpleDateFormat("yyyy-MM-dd", Locale.US)
private val timeFmt = SimpleDateFormat("HH:mm:ss.SSS", Locale.US)
var lastScanId: Int = 0
private set
private var scanCounter = 0
private fun getDir(): File {
@@ -47,6 +49,7 @@ object AdcCsvLogger {
val file = getTodayFile()
val isNew = !file.exists() || file.length() == 0L
scanCounter++
lastScanId = scanCounter
val timestamp = timeFmt.format(Date())
val volStr = volumeMl?.let { "%.1f".format(it) } ?: ""
@@ -156,8 +156,10 @@ class BleDebugLogger private constructor(private val context: Context) {
}
fun measurementResult(volumeMl: Double?, lrRatio: Double, validChannels: Int, urineLines: List<Int>) {
val scanId = AdcCsvLogger.lastScanId
val msg = buildString {
append("MEASUREMENT vol=${volumeMl?.let { "%.1f".format(it) } ?: "null"}ml")
append("MEASUREMENT scan=$scanId")
append(" vol=${volumeMl?.let { "%.1f".format(it) } ?: "null"}ml")
append(" lr=${"%.2f".format(lrRatio)}")
append(" valid=$validChannels/6")
append(" urine=[${urineLines.joinToString(",")}]")
@@ -158,7 +158,7 @@ fun PiezoMonitoringView(appState: AppState) {
}
} else if (centerWallCount > 0) {
Log.w("PiezoMonitor", "Insufficient center channels: $centerWallCount/4 (need 3+)")
bleManager.debugLogger.warn("BV_SKIP center=$centerWallCount/4 total=$totalWallCount/6")
bleManager.debugLogger.warn("BV_SKIP scan=${com.example.medilightv2android.services.AdcCsvLogger.lastScanId} center=$centerWallCount/4 total=$totalWallCount/6")
com.example.medilightv2android.services.AdcCsvLogger.log(rawADC, null)
android.widget.Toast.makeText(context,
"측정 부족 (${centerWallCount}/4채널) — 센서 위치를 조절해주세요",
@@ -166,7 +166,7 @@ fun PiezoMonitoringView(appState: AppState) {
}
} else {
Log.d("PiezoMonitor", "No valid channels — volume unchanged")
bleManager.debugLogger.warn("BV_FAIL no valid channels")
bleManager.debugLogger.warn("BV_FAIL scan=${com.example.medilightv2android.services.AdcCsvLogger.lastScanId} no valid channels")
val failADC = channels.sortedBy { it.channel }.map { it.buffer }
com.example.medilightv2android.services.AdcCsvLogger.log(failADC, null)
android.widget.Toast.makeText(context,