fix: BV 측정 최소 center 3채널 이상 요구 + 실패 시 사용자 안내

- center 채널 3개 미만이면 BV 계산 스킵 (신뢰도 부족 방지)
- 1~2채널: "측정 부족 (N/4채널) — 센서 위치를 조절해주세요"
- 0채널: "방광이 감지되지 않았습니다. 센서 접촉을 확인해주세요."
- BleDebugLogger에 BV_SKIP/BV_FAIL 기록

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-23 12:08:52 +09:00
parent f220cca187
commit 6f4488f1ae
@@ -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