import { useState } from 'react' import { useLiveData } from '../context/LiveDataContext' import { startSimulation, stopSimulation } from '../services/api' import { Play, Square, Siren, Loader2, RadioTower } from 'lucide-react' function formatTime(seconds) { if (seconds == null) return '00:00' const m = Math.floor(seconds / 60).toString().padStart(2, '0') const s = Math.floor(seconds % 60).toString().padStart(2, '0') return `${m}:${s}` } export default function TopBar() { const { wsStatus, status } = useLiveData() const [busy, setBusy] = useState(false) const sysStatus = status?.system_status ?? 'stopped' const isRunning = sysStatus === 'running' const simTime = status?.simulation_time ?? 0 const wsLabel = wsStatus === 'connected' ? 'Connected' : wsStatus === 'connecting' ? 'Connecting' : 'Disconnected' const wsColor = wsStatus === 'connected' ? 'text-emerald-400' : wsStatus === 'connecting' ? 'text-yellow-400' : 'text-red-400' const dotColor = wsStatus === 'connected' ? 'bg-emerald-400' : wsStatus === 'connecting' ? 'bg-yellow-400' : 'bg-red-400' const handleStart = async (emergency = false) => { setBusy(true) try { await startSimulation({ steps: 200, emergency, gui: false }) } catch (_) {} setBusy(false) } const handleStop = async () => { setBusy(true) try { await stopSimulation() } catch (_) {} setBusy(false) } return (

AI Traffic Adaptation

Real-time signal intelligence center

{isRunning ? ( ) : ( <> )}
SUMO: {isRunning ? 'Running' : sysStatus === 'stopped' ? 'Stopped' : sysStatus}
Sim Time: {formatTime(simTime)}
) }