// BMS Simulation useEffect(() => { const timer = setInterval(() => { setAgvState(s => { const isCharging = s.isCharging; let newLevel = s.batteryLevel; if (isCharging) { // Charge: 1% per min (faster than discharge) newLevel = Math.min(100, s.batteryLevel + (1.0 / 60)); } else { // Discharge: 5% per 10 min = 0.5% per min = 0.5 / 60 per sec newLevel = Math.max(0, s.batteryLevel - (0.5 / 60)); } // Fluctuate Voltages (+- 0.01V) const newVoltages = s.cellVoltages.map(v => { const delta = (Math.random() - 0.5) * 0.02; let val = v + delta; if (val < 2.8) val = 2.8; if (val > 3.6) val = 3.6; return val; }); return { ...s, batteryLevel: newLevel, cellVoltages: newVoltages }; }); }, 1000); return () => clearInterval(timer); }, []);