로드 부하 추가

This commit is contained in:
2026-01-19 20:17:05 +00:00
parent 6485a349d2
commit c6d42b87cb
2 changed files with 117 additions and 22 deletions

View File

@@ -2960,6 +2960,27 @@ void webUpdateTask(void *parameter) {
doc["sdReady"] = sdCardReady;
doc["totalMsg"] = totalMsgCount;
doc["msgPerSec"] = msgPerSecond;
// 🆕 CAN 버스 부하율 계산
// CAN 속도별 이론적 최대 메시지/초 (8바이트 데이터 기준)
// 125 Kbps: ~1,000 msg/s
// 250 Kbps: ~2,000 msg/s
// 500 Kbps: ~4,000 msg/s
// 1 Mbps: ~8,000 msg/s
uint32_t maxMsgPerSec;
switch(currentCanSpeed) {
case CAN_125KBPS: maxMsgPerSec = 1000; break;
case CAN_250KBPS: maxMsgPerSec = 2000; break;
case CAN_500KBPS: maxMsgPerSec = 4000; break;
case CAN_1000KBPS:
default: maxMsgPerSec = 8000; break;
}
// 부하율 계산 (0~100%)
float busLoad = (msgPerSecond * 100.0) / maxMsgPerSec;
if (busLoad > 100.0) busLoad = 100.0;
doc["busLoad"] = (int)busLoad; // 정수로 전송
doc["totalTx"] = totalTxCount;
doc["totalSerialRx"] = totalSerialRxCount;
doc["totalSerialTx"] = totalSerialTxCount;