From 6f4488f1ae543d8104e759319c6da4a12df969b8 Mon Sep 17 00:00:00 2001 From: jjangddu Date: Thu, 23 Apr 2026 12:08:52 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20BV=20=EC=B8=A1=EC=A0=95=20=EC=B5=9C?= =?UTF-8?q?=EC=86=8C=20center=203=EC=B1=84=EB=84=90=20=EC=9D=B4=EC=83=81?= =?UTF-8?q?=20=EC=9A=94=EA=B5=AC=20+=20=EC=8B=A4=ED=8C=A8=20=EC=8B=9C=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=EC=9E=90=20=EC=95=88=EB=82=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - center 채널 3개 미만이면 BV 계산 스킵 (신뢰도 부족 방지) - 1~2채널: "측정 부족 (N/4채널) — 센서 위치를 조절해주세요" - 0채널: "방광이 감지되지 않았습니다. 센서 접촉을 확인해주세요." - BleDebugLogger에 BV_SKIP/BV_FAIL 기록 Co-Authored-By: Claude Opus 4.6 (1M context) --- .../views/monitoring/PiezoMonitoringView.kt | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/example/medilightv2android/ui/views/monitoring/PiezoMonitoringView.kt b/app/src/main/java/com/example/medilightv2android/ui/views/monitoring/PiezoMonitoringView.kt index 8783e7e..38edc70 100644 --- a/app/src/main/java/com/example/medilightv2android/ui/views/monitoring/PiezoMonitoringView.kt +++ b/app/src/main/java/com/example/medilightv2android/ui/views/monitoring/PiezoMonitoringView.kt @@ -120,25 +120,39 @@ fun PiezoMonitoringView(appState: AppState) { } } - // 6ch BV estimation (center 4ch + lateral lr_ratio) - val bvResult = estimateBladderVolume6ch(allWalls) - if (bvResult != null) { - lastVolumeMl = bvResult.volumeMl - maxVolumeMl = maxOf(maxVolumeMl, bvResult.volumeMl) - Log.d("PiezoMonitor", "BV: ${"%.1f".format(bvResult.volumeMl)}ml (6ch, lr=${ - "%.2f".format(bvResult.lrRatio)}, ${bvResult.validChannels.size}ch)") - } else { - Log.d("PiezoMonitor", "BV: estimation failed (< 2 valid channels)") - } + // Count valid center channels (CH0~CH3) + val centerWallCount = (0..3).count { allWalls[it] != null } + val totalWallCount = allWalls.count { it != null } - // Log per-channel detail for (ch in analysisResult.channels) { if (ch.isValid && ch.result != null) { Log.d("PiezoMonitor", " CH${ch.channel}: ant=${ch.result.ant} post=${ch.result.post} urine=${ch.result.urineLen} score=${"%.1f".format(ch.result.score)}") } } + + if (centerWallCount >= 3) { + // 6ch BV estimation (center 4ch + lateral lr_ratio) + val bvResult = estimateBladderVolume6ch(allWalls) + if (bvResult != null) { + lastVolumeMl = bvResult.volumeMl + maxVolumeMl = maxOf(maxVolumeMl, bvResult.volumeMl) + Log.d("PiezoMonitor", "BV: ${"%.1f".format(bvResult.volumeMl)}ml (6ch, lr=${"%.2f".format(bvResult.lrRatio)}, center=${centerWallCount}/4)") + bleManager.debugLogger.measurementResult(bvResult.volumeMl, bvResult.lrRatio, totalWallCount, + (0..5).map { allWalls[it]?.let { w -> w.second - w.first } ?: 0 }) + } + } 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") + android.widget.Toast.makeText(context, + "측정 부족 (${centerWallCount}/4채널) — 센서 위치를 조절해주세요", + android.widget.Toast.LENGTH_SHORT).show() + } } else { Log.d("PiezoMonitor", "No valid channels — volume unchanged") + bleManager.debugLogger.warn("BV_FAIL no valid channels") + android.widget.Toast.makeText(context, + "방광이 감지되지 않았습니다. 센서 접촉을 확인해주세요.", + android.widget.Toast.LENGTH_SHORT).show() } // Update level based on measured volume