feat(phase-8): implement operational web dashboard, rest api, and telemetry data provider
This commit is contained in:
@@ -323,6 +323,30 @@ def play_trajectory_cmd(
|
||||
return 1
|
||||
|
||||
|
||||
def dashboard_cmd(
|
||||
results_dir: Optional[str] = None,
|
||||
host: str = "127.0.0.1",
|
||||
port: int = 8501,
|
||||
) -> int:
|
||||
"""Launch the interactive Operational Dashboard web application."""
|
||||
setup_logging()
|
||||
logger = get_logger("cli")
|
||||
try:
|
||||
from warehouse_twin.dashboard.server import DashboardServer
|
||||
|
||||
server = DashboardServer(
|
||||
results_dir=results_dir or "results",
|
||||
host=host,
|
||||
port=port,
|
||||
)
|
||||
server.start(blocking=True)
|
||||
return 0
|
||||
except Exception as err:
|
||||
logger.error("Dashboard server failed: %s", err)
|
||||
print(f"[FAIL] Dashboard Server Error: {err}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
|
||||
def run_simulation(
|
||||
config_dir: Optional[str] = None,
|
||||
duration: Optional[float] = None,
|
||||
@@ -701,6 +725,12 @@ def main(argv: Optional[list[str]] = None) -> int:
|
||||
comp_parser.add_argument("--duration", type=float, default=3600.0, help="Simulated duration in seconds")
|
||||
comp_parser.add_argument("--output", type=str, default=None, help="Path for comparison markdown report")
|
||||
|
||||
# Subcommand: dashboard (Phase 8)
|
||||
dash_parser = subparsers.add_parser("dashboard", help="Launch interactive operational web dashboard")
|
||||
dash_parser.add_argument("--results-dir", type=str, default="results", help="Path to simulation results directory")
|
||||
dash_parser.add_argument("--host", type=str, default="127.0.0.1", help="Host interface to bind (default: 127.0.0.1)")
|
||||
dash_parser.add_argument("--port", type=int, default=8501, help="Port to serve dashboard HTTP UI (default: 8501)")
|
||||
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
if args.command == "validate-env":
|
||||
@@ -739,6 +769,8 @@ def main(argv: Optional[list[str]] = None) -> int:
|
||||
duration=args.duration,
|
||||
output=args.output,
|
||||
)
|
||||
elif args.command == "dashboard":
|
||||
return dashboard_cmd(args.results_dir, args.host, args.port)
|
||||
else:
|
||||
parser.print_help()
|
||||
return 0
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
"""Operational Dashboard package for Warehouse Robot Fleet Digital Twin."""
|
||||
|
||||
from warehouse_twin.dashboard.data_provider import DashboardDataProvider
|
||||
from warehouse_twin.dashboard.server import DashboardServer
|
||||
|
||||
__all__ = ["DashboardDataProvider", "DashboardServer"]
|
||||
@@ -0,0 +1,267 @@
|
||||
"""Data provider and parser for operational dashboard telemetry."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import csv
|
||||
import json
|
||||
import re
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
|
||||
class DashboardDataProvider:
|
||||
"""Reads, caches, and aggregates simulation results for dashboard presentation."""
|
||||
|
||||
def __init__(self, results_dir: Path | str = "results") -> None:
|
||||
self.results_dir = Path(results_dir).resolve()
|
||||
self.experiments_dir = self.results_dir / "experiments"
|
||||
self.reports_dir = self.results_dir / "reports"
|
||||
|
||||
def list_experiments(self) -> List[Dict[str, Any]]:
|
||||
"""List all discovered experiment runs in the experiments directory."""
|
||||
if not self.experiments_dir.exists():
|
||||
return []
|
||||
|
||||
experiments: List[Dict[str, Any]] = []
|
||||
for exp_path in sorted(self.experiments_dir.iterdir()):
|
||||
if not exp_path.is_dir():
|
||||
continue
|
||||
|
||||
exp_id = exp_path.name
|
||||
kpi_file = exp_path / "kpi_summary.json"
|
||||
cfg_file = exp_path / "config.json"
|
||||
|
||||
# Skip hidden or empty dirs
|
||||
if not kpi_file.exists() and not cfg_file.exists():
|
||||
continue
|
||||
|
||||
entry: Dict[str, Any] = {
|
||||
"id": exp_id,
|
||||
"name": exp_id.replace("_", " ").title(),
|
||||
"has_kpis": kpi_file.exists(),
|
||||
"has_heatmap": (exp_path / "congestion_heatmap.svg").exists(),
|
||||
"has_report": (exp_path / "report.md").exists(),
|
||||
"throughput": 0.0,
|
||||
"fleet_size": 4,
|
||||
"duration": 3600.0,
|
||||
"policy": "priority_nearest_idle",
|
||||
"seed": 42,
|
||||
}
|
||||
|
||||
if cfg_file.exists():
|
||||
try:
|
||||
with open(cfg_file, "r", encoding="utf-8") as f:
|
||||
cfg = json.load(f)
|
||||
entry["name"] = cfg.get("name", entry["name"])
|
||||
entry["duration"] = float(cfg.get("duration", 3600.0))
|
||||
entry["seed"] = int(cfg.get("seed", 42))
|
||||
entry["fleet_size"] = cfg.get("fleet_size", 4)
|
||||
entry["policy"] = cfg.get("dispatch_policy", "priority_nearest_idle")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if kpi_file.exists():
|
||||
try:
|
||||
with open(kpi_file, "r", encoding="utf-8") as f:
|
||||
kpis = json.load(f)
|
||||
tp = kpis.get("throughput", {})
|
||||
entry["throughput"] = float(tp.get("completed_per_hour", 0.0))
|
||||
meta = kpis.get("metadata", {})
|
||||
if "fleet_size" in meta:
|
||||
entry["fleet_size"] = meta["fleet_size"]
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
experiments.append(entry)
|
||||
|
||||
return sorted(experiments, key=lambda e: (e["id"] != "baseline_1hr", e["id"]))
|
||||
|
||||
def get_experiment_detail(self, exp_id: str) -> Optional[Dict[str, Any]]:
|
||||
"""Return comprehensive telemetry payload for a specific experiment."""
|
||||
exp_path = (self.experiments_dir / exp_id).resolve()
|
||||
if not exp_path.exists() or not exp_path.is_dir():
|
||||
return None
|
||||
|
||||
payload: Dict[str, Any] = {
|
||||
"id": exp_id,
|
||||
"path": str(exp_path),
|
||||
"config": {},
|
||||
"kpis": {},
|
||||
"robots": [],
|
||||
"tasks_summary": {
|
||||
"total": 0,
|
||||
"completed": 0,
|
||||
"in_progress": 0,
|
||||
"pending": 0,
|
||||
"on_time": 0,
|
||||
"late": 0,
|
||||
},
|
||||
"bottlenecks": [],
|
||||
"has_heatmap": (exp_path / "congestion_heatmap.svg").exists(),
|
||||
"has_report": (exp_path / "report.md").exists(),
|
||||
}
|
||||
|
||||
# 1. Config
|
||||
cfg_file = exp_path / "config.json"
|
||||
if cfg_file.exists():
|
||||
try:
|
||||
with open(cfg_file, "r", encoding="utf-8") as f:
|
||||
payload["config"] = json.load(f)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 2. KPIs
|
||||
kpi_file = exp_path / "kpi_summary.json"
|
||||
if kpi_file.exists():
|
||||
try:
|
||||
with open(kpi_file, "r", encoding="utf-8") as f:
|
||||
payload["kpis"] = json.load(f)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 3. Robots tabular CSV
|
||||
robots_file = exp_path / "robots.csv"
|
||||
if robots_file.exists():
|
||||
try:
|
||||
with open(robots_file, "r", encoding="utf-8") as f:
|
||||
reader = csv.DictReader(f)
|
||||
for row in reader:
|
||||
# Clean and cast numeric values
|
||||
payload["robots"].append({
|
||||
"robot_id": row.get("robot_id", ""),
|
||||
"robot_type": row.get("robot_type", ""),
|
||||
"state": row.get("current_state", "IDLE"),
|
||||
"battery_percent": float(row.get("battery_percent", 100.0)),
|
||||
"utilization_pct": float(row.get("utilization_pct", 0.0)),
|
||||
"total_distance_m": float(row.get("total_distance_m", 0.0)),
|
||||
"loaded_distance_m": float(row.get("loaded_distance_m", 0.0)),
|
||||
"empty_distance_m": float(row.get("empty_distance_m", 0.0)),
|
||||
"energy_consumed_kwh": float(row.get("energy_consumed_kwh", 0.0)),
|
||||
"charging_sessions": int(row.get("charging_sessions", 0)),
|
||||
})
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 4. Tasks CSV summary
|
||||
tasks_file = exp_path / "tasks.csv"
|
||||
if tasks_file.exists():
|
||||
try:
|
||||
total, completed, in_progress, pending = 0, 0, 0, 0
|
||||
on_time, late = 0, 0
|
||||
with open(tasks_file, "r", encoding="utf-8") as f:
|
||||
reader = csv.DictReader(f)
|
||||
for row in reader:
|
||||
total += 1
|
||||
st = row.get("status", "")
|
||||
if st == "COMPLETED":
|
||||
completed += 1
|
||||
if row.get("is_overdue", "False").lower() in ("true", "1"):
|
||||
late += 1
|
||||
else:
|
||||
on_time += 1
|
||||
elif st == "IN_PROGRESS":
|
||||
in_progress += 1
|
||||
elif st == "PENDING":
|
||||
pending += 1
|
||||
|
||||
payload["tasks_summary"] = {
|
||||
"total": total,
|
||||
"completed": completed,
|
||||
"in_progress": in_progress,
|
||||
"pending": pending,
|
||||
"on_time": on_time,
|
||||
"late": late,
|
||||
}
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 5. Aisle Congestion CSV
|
||||
aisle_file = exp_path / "aisle_congestion.csv"
|
||||
if aisle_file.exists():
|
||||
try:
|
||||
bottlenecks = []
|
||||
with open(aisle_file, "r", encoding="utf-8") as f:
|
||||
reader = csv.DictReader(f)
|
||||
for row in reader:
|
||||
score = float(row.get("congestion_score", 0.0))
|
||||
severity = "INFO"
|
||||
if score >= 0.7:
|
||||
severity = "CRITICAL"
|
||||
elif score >= 0.4:
|
||||
severity = "WARNING"
|
||||
|
||||
bottlenecks.append({
|
||||
"edge": f"{row.get('u', '')} -> {row.get('v', '')}",
|
||||
"traversals": int(row.get("traversals", 0)),
|
||||
"conflicts": int(row.get("conflicts", 0)),
|
||||
"wait_time_sec": float(row.get("wait_time_sec", 0.0)),
|
||||
"congestion_score": score,
|
||||
"severity": severity,
|
||||
"recommendation": row.get("recommendation", "Normal transit flow."),
|
||||
})
|
||||
|
||||
# Sort by congestion score descending
|
||||
bottlenecks.sort(key=lambda b: b["congestion_score"], reverse=True)
|
||||
payload["bottlenecks"] = bottlenecks[:15] # Top 15 corridors
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return payload
|
||||
|
||||
def get_heatmap_svg(self, exp_id: str) -> Optional[str]:
|
||||
"""Return raw SVG content of congestion heatmap for an experiment."""
|
||||
svg_file = (self.experiments_dir / exp_id / "congestion_heatmap.svg").resolve()
|
||||
if not svg_file.exists():
|
||||
return None
|
||||
return svg_file.read_text(encoding="utf-8")
|
||||
|
||||
def get_report_markdown(self, exp_id: str) -> Optional[str]:
|
||||
"""Return Markdown report content for an experiment."""
|
||||
md_file = (self.experiments_dir / exp_id / "report.md").resolve()
|
||||
if not md_file.exists():
|
||||
return None
|
||||
return md_file.read_text(encoding="utf-8")
|
||||
|
||||
def get_scenario_comparisons(self) -> Dict[str, Any]:
|
||||
"""Read and parse parameter sweep reports for fleet sizing and dispatch policies."""
|
||||
comparisons: Dict[str, Any] = {
|
||||
"fleet_sizing": [],
|
||||
"dispatch_policies": [],
|
||||
}
|
||||
|
||||
# 1. Parse fleet_size_comparison.md
|
||||
fleet_md = self.reports_dir / "fleet_size_comparison.md"
|
||||
if fleet_md.exists():
|
||||
comparisons["fleet_sizing"] = self._parse_markdown_table(fleet_md.read_text(encoding="utf-8"))
|
||||
|
||||
# 2. Parse dispatch_policy_comparison.md
|
||||
policy_md = self.reports_dir / "dispatch_policy_comparison.md"
|
||||
if policy_md.exists():
|
||||
comparisons["dispatch_policies"] = self._parse_markdown_table(policy_md.read_text(encoding="utf-8"))
|
||||
|
||||
return comparisons
|
||||
|
||||
@staticmethod
|
||||
def _parse_markdown_table(markdown_text: str) -> List[Dict[str, str]]:
|
||||
"""Extract table rows from a Markdown document into list of dictionaries."""
|
||||
lines = markdown_text.strip().split("\n")
|
||||
table_lines = [l.strip() for l in lines if l.strip().startswith("|") and l.strip().endswith("|")]
|
||||
if len(table_lines) < 3:
|
||||
return []
|
||||
|
||||
# Header
|
||||
raw_headers = [c.strip() for c in table_lines[0].strip("|").split("|")]
|
||||
headers = [re.sub(r"[\*\_]", "", h).strip() for h in raw_headers]
|
||||
|
||||
rows: List[Dict[str, str]] = []
|
||||
for line in table_lines[2:]: # Skip separator line
|
||||
cols = [c.strip() for c in line.strip("|").split("|")]
|
||||
if len(cols) == len(headers):
|
||||
row_dict = {}
|
||||
for h, val in zip(headers, cols):
|
||||
# Clean markdown bold/italics
|
||||
clean_val = re.sub(r"[\*\_]", "", val).strip()
|
||||
row_dict[h] = clean_val
|
||||
rows.append(row_dict)
|
||||
|
||||
return rows
|
||||
@@ -0,0 +1,210 @@
|
||||
"""Lightweight HTTP server providing web UI and REST API for operational dashboard."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import mimetypes
|
||||
import os
|
||||
import sys
|
||||
from http import HTTPStatus
|
||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Optional
|
||||
from urllib.parse import parse_qs, urlparse
|
||||
|
||||
from warehouse_twin.dashboard.data_provider import DashboardDataProvider
|
||||
|
||||
|
||||
class DashboardHTTPHandler(BaseHTTPRequestHandler):
|
||||
"""Handles HTTP requests for dashboard static assets and REST API endpoints."""
|
||||
|
||||
data_provider: DashboardDataProvider
|
||||
static_dir: Path
|
||||
|
||||
def log_message(self, format: str, *args: Any) -> None:
|
||||
"""Suppress noisy default request logging, outputting only on errors."""
|
||||
if hasattr(self, "status_code") and getattr(self, "status_code", 200) >= 400:
|
||||
sys.stderr.write(f"[DashboardServer] {self.address_string()} - {format % args}\n")
|
||||
|
||||
def do_GET(self) -> None:
|
||||
"""Route GET requests to API handlers or static asset files."""
|
||||
parsed = urlparse(self.path)
|
||||
path = parsed.path
|
||||
|
||||
# Enable CORS
|
||||
headers = {
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
"Access-Control-Allow-Methods": "GET, OPTIONS",
|
||||
"Access-Control-Allow-Headers": "Content-Type",
|
||||
}
|
||||
|
||||
# Health endpoint
|
||||
if path == "/api/health":
|
||||
self._send_json({"status": "ok", "version": "0.8.0"}, headers=headers)
|
||||
return
|
||||
|
||||
# List experiments
|
||||
if path == "/api/experiments":
|
||||
experiments = self.data_provider.list_experiments()
|
||||
self._send_json(experiments, headers=headers)
|
||||
return
|
||||
|
||||
# Experiment detail: /api/experiments/<id>
|
||||
if path.startswith("/api/experiments/"):
|
||||
parts = path.strip("/").split("/")
|
||||
if len(parts) >= 3:
|
||||
exp_id = parts[2]
|
||||
sub_res = parts[3] if len(parts) > 3 else ""
|
||||
|
||||
if sub_res == "heatmap.svg":
|
||||
svg_content = self.data_provider.get_heatmap_svg(exp_id)
|
||||
if svg_content:
|
||||
self._send_bytes(svg_content.encode("utf-8"), "image/svg+xml", headers=headers)
|
||||
else:
|
||||
self._send_error(HTTPStatus.NOT_FOUND, f"Heatmap not found for '{exp_id}'")
|
||||
return
|
||||
|
||||
if sub_res == "report":
|
||||
report_md = self.data_provider.get_report_markdown(exp_id)
|
||||
if report_md:
|
||||
self._send_bytes(report_md.encode("utf-8"), "text/markdown; charset=utf-8", headers=headers)
|
||||
else:
|
||||
self._send_error(HTTPStatus.NOT_FOUND, f"Report not found for '{exp_id}'")
|
||||
return
|
||||
|
||||
# Standard experiment detail
|
||||
detail = self.data_provider.get_experiment_detail(exp_id)
|
||||
if detail:
|
||||
self._send_json(detail, headers=headers)
|
||||
else:
|
||||
self._send_error(HTTPStatus.NOT_FOUND, f"Experiment '{exp_id}' not found")
|
||||
return
|
||||
|
||||
# Scenario comparisons: /api/scenarios
|
||||
if path == "/api/scenarios":
|
||||
comparisons = self.data_provider.get_scenario_comparisons()
|
||||
self._send_json(comparisons, headers=headers)
|
||||
return
|
||||
|
||||
# Serve static assets
|
||||
self._serve_static(path)
|
||||
|
||||
def do_OPTIONS(self) -> None:
|
||||
"""Handle CORS pre-flight requests."""
|
||||
self.send_response(HTTPStatus.NO_CONTENT)
|
||||
self.send_header("Access-Control-Allow-Origin", "*")
|
||||
self.send_header("Access-Control-Allow-Methods", "GET, OPTIONS")
|
||||
self.send_header("Access-Control-Allow-Headers", "Content-Type")
|
||||
self.end_headers()
|
||||
|
||||
def _serve_static(self, req_path: str) -> None:
|
||||
"""Serve HTML, CSS, JavaScript, and SVG static files safely."""
|
||||
clean_path = req_path.lstrip("/")
|
||||
if not clean_path or clean_path == "/":
|
||||
clean_path = "index.html"
|
||||
|
||||
# Resolve asset path within static_dir
|
||||
target = (self.static_dir / clean_path).resolve()
|
||||
try:
|
||||
target.relative_to(self.static_dir)
|
||||
except ValueError:
|
||||
self._send_error(HTTPStatus.FORBIDDEN, "Access denied")
|
||||
return
|
||||
|
||||
if not target.exists() or not target.is_file():
|
||||
# Fallback to index.html for SPA routing
|
||||
target = (self.static_dir / "index.html").resolve()
|
||||
|
||||
if not target.exists():
|
||||
self._send_error(HTTPStatus.NOT_FOUND, "Static file not found")
|
||||
return
|
||||
|
||||
mime_type, _ = mimetypes.guess_type(str(target))
|
||||
if not mime_type:
|
||||
mime_type = "application/octet-stream"
|
||||
if mime_type.startswith("text/") or mime_type in ("application/javascript", "image/svg+xml"):
|
||||
mime_type += "; charset=utf-8"
|
||||
|
||||
data = target.read_bytes()
|
||||
self._send_bytes(data, mime_type)
|
||||
|
||||
def _send_json(self, data: Any, status: int = 200, headers: Optional[Dict[str, str]] = None) -> None:
|
||||
"""Send JSON response with proper headers."""
|
||||
body = json.dumps(data, indent=2).encode("utf-8")
|
||||
self._send_bytes(body, "application/json; charset=utf-8", status=status, headers=headers)
|
||||
|
||||
def _send_bytes(self, body: bytes, content_type: str, status: int = 200, headers: Optional[Dict[str, str]] = None) -> None:
|
||||
"""Send raw binary payload with content type."""
|
||||
self.send_response(status)
|
||||
self.send_header("Content-Type", content_type)
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
self.send_header("Cache-Control", "no-cache, no-store, must-revalidate")
|
||||
if headers:
|
||||
for k, v in headers.items():
|
||||
self.send_header(k, v)
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
|
||||
def _send_error(self, status: int, message: str) -> None:
|
||||
"""Send standardized JSON error response."""
|
||||
err_payload = {"error": True, "status": status, "message": message}
|
||||
self._send_json(err_payload, status=status)
|
||||
|
||||
|
||||
class DashboardServer:
|
||||
"""Threaded HTTP server managing dashboard lifecycle."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
results_dir: Path | str = "results",
|
||||
host: str = "127.0.0.1",
|
||||
port: int = 8501,
|
||||
static_dir: Optional[Path | str] = None,
|
||||
) -> None:
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.results_dir = Path(results_dir).resolve()
|
||||
self.data_provider = DashboardDataProvider(self.results_dir)
|
||||
|
||||
if static_dir:
|
||||
self.static_dir = Path(static_dir).resolve()
|
||||
else:
|
||||
self.static_dir = (Path(__file__).resolve().parent / "static").resolve()
|
||||
|
||||
# Custom handler subclass binding data_provider & static_dir
|
||||
class BoundHandler(DashboardHTTPHandler):
|
||||
data_provider = self.data_provider
|
||||
static_dir = self.static_dir
|
||||
|
||||
self.handler_class = BoundHandler
|
||||
self._server: Optional[ThreadingHTTPServer] = None
|
||||
|
||||
def start(self, blocking: bool = True) -> None:
|
||||
"""Bind and start the HTTP server."""
|
||||
self._server = ThreadingHTTPServer((self.host, self.port), self.handler_class)
|
||||
print(f"[DashboardServer] Serving Warehouse Operational Dashboard at: http://{self.host}:{self.port}")
|
||||
print(f"[DashboardServer] Telemetry Data Source: {self.results_dir}")
|
||||
print("[DashboardServer] Press Ctrl+C to stop the dashboard.")
|
||||
|
||||
if blocking:
|
||||
try:
|
||||
self._server.serve_forever()
|
||||
except KeyboardInterrupt:
|
||||
print("\n[DashboardServer] Shutting down...")
|
||||
finally:
|
||||
self.stop()
|
||||
|
||||
def stop(self) -> None:
|
||||
"""Halt server and release socket."""
|
||||
srv = self._server
|
||||
if srv is not None:
|
||||
self._server = None
|
||||
try:
|
||||
srv.shutdown()
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
srv.server_close()
|
||||
except Exception:
|
||||
pass
|
||||
print("[DashboardServer] Server stopped.")
|
||||
@@ -0,0 +1,673 @@
|
||||
/* Warehouse Robot Fleet Digital Twin - Modern Glassmorphic Dark Design System */
|
||||
|
||||
:root {
|
||||
/* Color Palette */
|
||||
--bg-base: #0a0d14;
|
||||
--bg-surface: #111622;
|
||||
--bg-card: rgba(18, 24, 38, 0.75);
|
||||
--bg-card-hover: rgba(26, 34, 52, 0.85);
|
||||
--border-subtle: rgba(255, 255, 255, 0.08);
|
||||
--border-focus: rgba(0, 240, 255, 0.4);
|
||||
|
||||
/* Brand Accents */
|
||||
--primary-cyan: #00f0ff;
|
||||
--primary-blue: #3b82f6;
|
||||
--success-green: #10b981;
|
||||
--warning-amber: #f59e0b;
|
||||
--danger-red: #ef4444;
|
||||
--accent-purple: #8b5cf6;
|
||||
--accent-orange: #f97316;
|
||||
|
||||
/* Typography */
|
||||
--text-primary: #f1f5f9;
|
||||
--text-secondary: #94a3b8;
|
||||
--text-muted: #64748b;
|
||||
--font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
||||
--font-mono: 'JetBrains Mono', monospace;
|
||||
|
||||
/* Shadows & Glassmorphism */
|
||||
--card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.36);
|
||||
--glass-blur: blur(12px);
|
||||
--transition-fast: 0.18s ease;
|
||||
--radius-sm: 6px;
|
||||
--radius-md: 10px;
|
||||
--radius-lg: 16px;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--bg-base);
|
||||
color: var(--text-primary);
|
||||
font-family: var(--font-main);
|
||||
line-height: 1.5;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* Dashboard Shell */
|
||||
.dashboard-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* Top Navbar */
|
||||
.top-navbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 16px 28px;
|
||||
background-color: var(--bg-surface);
|
||||
border-bottom: 1px solid var(--border-subtle);
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 50;
|
||||
backdrop-filter: var(--glass-blur);
|
||||
}
|
||||
|
||||
.brand-group {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.brand-logo {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: var(--radius-md);
|
||||
background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(59, 130, 246, 0.2));
|
||||
border: 1px solid rgba(0, 240, 255, 0.3);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--primary-cyan);
|
||||
}
|
||||
|
||||
.brand-text h1 {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.02em;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.brand-text .subtitle {
|
||||
font-size: 0.78rem;
|
||||
color: var(--text-muted);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.06em;
|
||||
}
|
||||
|
||||
.header-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.control-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.custom-select {
|
||||
background-color: var(--bg-surface);
|
||||
color: var(--text-primary);
|
||||
border: 1px solid var(--border-subtle);
|
||||
padding: 8px 14px;
|
||||
border-radius: var(--radius-sm);
|
||||
font-family: var(--font-main);
|
||||
font-size: 0.85rem;
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
transition: border-color var(--transition-fast);
|
||||
}
|
||||
|
||||
.custom-select:focus {
|
||||
border-color: var(--primary-cyan);
|
||||
}
|
||||
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 16px;
|
||||
border-radius: var(--radius-sm);
|
||||
font-size: 0.85rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all var(--transition-fast);
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background-color: rgba(255, 255, 255, 0.05);
|
||||
border-color: var(--border-subtle);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background-color: rgba(255, 255, 255, 0.1);
|
||||
border-color: var(--border-focus);
|
||||
color: var(--primary-cyan);
|
||||
}
|
||||
|
||||
/* Sub-Navbar / Tabs */
|
||||
.sub-navbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 10px 28px;
|
||||
background-color: rgba(17, 22, 34, 0.9);
|
||||
border-bottom: 1px solid var(--border-subtle);
|
||||
}
|
||||
|
||||
.nav-tabs {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.tab-btn {
|
||||
background: transparent;
|
||||
border: 1px solid transparent;
|
||||
color: var(--text-secondary);
|
||||
padding: 8px 16px;
|
||||
border-radius: var(--radius-sm);
|
||||
font-size: 0.85rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all var(--transition-fast);
|
||||
}
|
||||
|
||||
.tab-btn:hover {
|
||||
color: var(--text-primary);
|
||||
background-color: rgba(255, 255, 255, 0.04);
|
||||
}
|
||||
|
||||
.tab-btn.active {
|
||||
color: var(--primary-cyan);
|
||||
background-color: rgba(0, 240, 255, 0.08);
|
||||
border-color: rgba(0, 240, 255, 0.25);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.live-pill {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 0.75rem;
|
||||
padding: 4px 10px;
|
||||
border-radius: 999px;
|
||||
background-color: rgba(16, 185, 129, 0.12);
|
||||
border: 1px solid rgba(16, 185, 129, 0.3);
|
||||
color: var(--success-green);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.pulse-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background-color: var(--success-green);
|
||||
box-shadow: 0 0 8px var(--success-green);
|
||||
animation: pulse 2s infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0% { transform: scale(0.95); opacity: 0.8; }
|
||||
50% { transform: scale(1.2); opacity: 1; }
|
||||
100% { transform: scale(0.95); opacity: 0.8; }
|
||||
}
|
||||
|
||||
/* Main Content */
|
||||
.main-content {
|
||||
flex: 1;
|
||||
padding: 24px 28px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.tab-pane {
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.tab-pane.active {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
/* Card Styles */
|
||||
.card {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-md);
|
||||
padding: 20px;
|
||||
box-shadow: var(--card-shadow);
|
||||
backdrop-filter: var(--glass-blur);
|
||||
transition: border-color var(--transition-fast);
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
border-color: rgba(255, 255, 255, 0.14);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
margin-bottom: 16px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: baseline;
|
||||
}
|
||||
|
||||
.card-header h3 {
|
||||
font-size: 1.05rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
.card-sub {
|
||||
font-size: 0.78rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
/* Summary Bar */
|
||||
.summary-bar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 24px;
|
||||
padding: 14px 24px;
|
||||
background: rgba(18, 24, 38, 0.9);
|
||||
}
|
||||
|
||||
.summary-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.summary-label {
|
||||
font-size: 0.72rem;
|
||||
text-transform: uppercase;
|
||||
color: var(--text-muted);
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
|
||||
.summary-val {
|
||||
font-size: 0.92rem;
|
||||
font-weight: 600;
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
.summary-val.highlight {
|
||||
color: var(--primary-cyan);
|
||||
}
|
||||
|
||||
/* 6 KPI Cards Grid */
|
||||
.kpi-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.kpi-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
min-height: 140px;
|
||||
}
|
||||
|
||||
.kpi-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.kpi-title {
|
||||
font-size: 0.82rem;
|
||||
font-weight: 500;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.kpi-icon-badge {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: var(--radius-sm);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.kpi-icon-badge.cyan { background: rgba(0, 240, 255, 0.12); color: var(--primary-cyan); }
|
||||
.kpi-icon-badge.blue { background: rgba(59, 130, 246, 0.12); color: var(--primary-blue); }
|
||||
.kpi-icon-badge.green { background: rgba(16, 185, 129, 0.12); color: var(--success-green); }
|
||||
.kpi-icon-badge.amber { background: rgba(245, 158, 11, 0.12); color: var(--warning-amber); }
|
||||
.kpi-icon-badge.purple { background: rgba(139, 92, 246, 0.12); color: var(--accent-purple); }
|
||||
.kpi-icon-badge.orange { background: rgba(249, 115, 22, 0.12); color: var(--accent-orange); }
|
||||
|
||||
.kpi-body {
|
||||
margin: 12px 0 6px 0;
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.kpi-value {
|
||||
font-size: 2.1rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.03em;
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
.kpi-value.highlight-green {
|
||||
color: var(--success-green);
|
||||
}
|
||||
|
||||
.kpi-unit {
|
||||
font-size: 0.8rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.kpi-footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-size: 0.78rem;
|
||||
color: var(--text-secondary);
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.04);
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
.badge {
|
||||
padding: 2px 8px;
|
||||
border-radius: var(--radius-sm);
|
||||
font-size: 0.72rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.badge.success {
|
||||
background: rgba(16, 185, 129, 0.15);
|
||||
color: var(--success-green);
|
||||
}
|
||||
|
||||
.badge.warning {
|
||||
background: rgba(245, 158, 11, 0.15);
|
||||
color: var(--warning-amber);
|
||||
}
|
||||
|
||||
.badge.danger {
|
||||
background: rgba(239, 68, 68, 0.15);
|
||||
color: var(--danger-red);
|
||||
}
|
||||
|
||||
.badge.info {
|
||||
background: rgba(0, 240, 255, 0.15);
|
||||
color: var(--primary-cyan);
|
||||
}
|
||||
|
||||
/* Tables */
|
||||
.table-responsive {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.data-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 0.85rem;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.data-table th {
|
||||
padding: 10px 14px;
|
||||
color: var(--text-muted);
|
||||
font-weight: 600;
|
||||
font-size: 0.76rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
border-bottom: 1px solid var(--border-subtle);
|
||||
background-color: rgba(255, 255, 255, 0.015);
|
||||
}
|
||||
|
||||
.data-table td {
|
||||
padding: 12px 14px;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.04);
|
||||
color: var(--text-primary);
|
||||
font-family: var(--font-main);
|
||||
}
|
||||
|
||||
.data-table tr:hover td {
|
||||
background-color: rgba(255, 255, 255, 0.03);
|
||||
}
|
||||
|
||||
/* Grid Layouts */
|
||||
.grid-2-col {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.grid-3-col {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.stat-card-title {
|
||||
font-size: 0.82rem;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.stat-card-val {
|
||||
font-size: 2.2rem;
|
||||
font-weight: 700;
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
.text-green { color: var(--success-green); }
|
||||
.text-cyan { color: var(--primary-cyan); }
|
||||
.text-amber { color: var(--warning-amber); }
|
||||
|
||||
/* Battery Mini Bar */
|
||||
.battery-bar-wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.battery-bar-track {
|
||||
width: 70px;
|
||||
height: 8px;
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.battery-bar-fill {
|
||||
height: 100%;
|
||||
border-radius: 4px;
|
||||
background-color: var(--success-green);
|
||||
}
|
||||
|
||||
/* Charging Stat Grid */
|
||||
.charging-stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.stat-box {
|
||||
background: rgba(255, 255, 255, 0.02);
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 14px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.stat-num {
|
||||
font-size: 1.6rem;
|
||||
font-weight: 700;
|
||||
font-family: var(--font-mono);
|
||||
color: var(--primary-cyan);
|
||||
}
|
||||
|
||||
.stat-lbl {
|
||||
font-size: 0.76rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
/* Ratio Bar */
|
||||
.ratio-bar-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.ratio-labels {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.progress-bar-wrap {
|
||||
height: 16px;
|
||||
background-color: rgba(59, 130, 246, 0.3);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.progress-bar.loaded {
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, #f59e0b, #fbbf24);
|
||||
border-radius: 8px;
|
||||
transition: width 0.4s ease;
|
||||
}
|
||||
|
||||
.ratio-explanation {
|
||||
font-size: 0.78rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
/* Heatmap Container */
|
||||
.heatmap-layout {
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.heatmap-card {
|
||||
min-height: 480px;
|
||||
}
|
||||
|
||||
.heatmap-container {
|
||||
width: 100%;
|
||||
background: #0d111a;
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-sm);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 16px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.heatmap-container svg {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.9rem;
|
||||
padding: 40px;
|
||||
}
|
||||
|
||||
/* Insight Box */
|
||||
.insight-box {
|
||||
margin-top: 16px;
|
||||
padding: 14px 18px;
|
||||
background: rgba(0, 240, 255, 0.05);
|
||||
border-left: 3px solid var(--primary-cyan);
|
||||
border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
|
||||
}
|
||||
|
||||
.insight-box h4 {
|
||||
font-size: 0.88rem;
|
||||
font-weight: 600;
|
||||
color: var(--primary-cyan);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.insight-box p {
|
||||
font-size: 0.84rem;
|
||||
color: var(--text-secondary);
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
/* Markdown Report Viewer */
|
||||
.report-content {
|
||||
background: #090c12;
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 24px;
|
||||
max-height: 650px;
|
||||
overflow-y: auto;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.82rem;
|
||||
color: #cbd5e1;
|
||||
white-space: pre-wrap;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
/* Loading Overlay */
|
||||
.loading-overlay {
|
||||
position: absolute;
|
||||
top: 0; left: 0; right: 0; bottom: 0;
|
||||
background: rgba(10, 13, 20, 0.7);
|
||||
backdrop-filter: blur(4px);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 14px;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.loading-overlay.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.spinner {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border: 3px solid rgba(0, 240, 255, 0.15);
|
||||
border-top-color: var(--primary-cyan);
|
||||
border-radius: 50%;
|
||||
animation: spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.grid-2-col {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.sub-navbar {
|
||||
overflow-x: auto;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,453 @@
|
||||
/**
|
||||
* Warehouse Robot Fleet Digital Twin - Operational Dashboard Client
|
||||
*/
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// Application State
|
||||
const state = {
|
||||
experiments: [],
|
||||
selectedExpId: '',
|
||||
detail: null,
|
||||
comparisons: null,
|
||||
reportText: '',
|
||||
};
|
||||
|
||||
// DOM Elements
|
||||
const expSelect = document.getElementById('experiment-select');
|
||||
const refreshBtn = document.getElementById('refresh-btn');
|
||||
const tabButtons = document.querySelectorAll('.tab-btn');
|
||||
const tabPanes = document.querySelectorAll('.tab-pane');
|
||||
const loadingOverlay = document.getElementById('loading-overlay');
|
||||
const runBadge = document.getElementById('run-status-text');
|
||||
|
||||
// Tab Navigation Handling
|
||||
tabButtons.forEach(btn => {
|
||||
btn.addEventListener('click', () => {
|
||||
const targetTab = btn.getAttribute('data-tab');
|
||||
tabButtons.forEach(b => b.classList.remove('active'));
|
||||
tabPanes.forEach(p => p.classList.remove('active'));
|
||||
btn.classList.add('active');
|
||||
const pane = document.getElementById(targetTab);
|
||||
if (pane) pane.classList.add('active');
|
||||
|
||||
if (targetTab === 'tab-report' && !state.reportText) {
|
||||
loadReport(state.selectedExpId);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// UI Helpers
|
||||
function showLoading(show) {
|
||||
if (loadingOverlay) {
|
||||
if (show) loadingOverlay.classList.remove('hidden');
|
||||
else loadingOverlay.classList.add('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
function formatNumber(num, decimals = 1) {
|
||||
if (num === undefined || num === null || isNaN(num)) return '-';
|
||||
return Number(num).toLocaleString(undefined, {
|
||||
minimumFractionDigits: decimals,
|
||||
maximumFractionDigits: decimals,
|
||||
});
|
||||
}
|
||||
|
||||
// Fetch Experiment List
|
||||
async function loadExperiments() {
|
||||
try {
|
||||
showLoading(true);
|
||||
const res = await fetch('/api/experiments');
|
||||
if (!res.ok) throw new Error('Failed to load experiments');
|
||||
const list = await res.json();
|
||||
state.experiments = list;
|
||||
|
||||
expSelect.innerHTML = '';
|
||||
if (list.length === 0) {
|
||||
expSelect.innerHTML = '<option value="" disabled>No experiments found</option>';
|
||||
showLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
list.forEach(exp => {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = exp.id;
|
||||
opt.textContent = `${exp.name} (${exp.throughput.toFixed(1)} t/hr)`;
|
||||
expSelect.appendChild(opt);
|
||||
});
|
||||
|
||||
// Default selection: baseline_1hr if available, else first
|
||||
const hasBaseline = list.some(e => e.id === 'baseline_1hr');
|
||||
state.selectedExpId = hasBaseline ? 'baseline_1hr' : list[0].id;
|
||||
expSelect.value = state.selectedExpId;
|
||||
|
||||
await loadExperimentDetail(state.selectedExpId);
|
||||
await loadScenarioComparisons();
|
||||
} catch (err) {
|
||||
console.error('Error loading experiments:', err);
|
||||
if (runBadge) runBadge.textContent = 'Error';
|
||||
} finally {
|
||||
showLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch Specific Experiment Details
|
||||
async function loadExperimentDetail(expId) {
|
||||
if (!expId) return;
|
||||
try {
|
||||
showLoading(true);
|
||||
state.selectedExpId = expId;
|
||||
state.reportText = '';
|
||||
|
||||
const res = await fetch(`/api/experiments/${encodeURIComponent(expId)}`);
|
||||
if (!res.ok) throw new Error(`Failed to load detail for ${expId}`);
|
||||
const detail = await res.json();
|
||||
state.detail = detail;
|
||||
|
||||
renderOverview(detail);
|
||||
renderFleet(detail);
|
||||
renderCongestion(detail);
|
||||
renderTasks(detail);
|
||||
|
||||
if (runBadge) runBadge.textContent = `Active: ${expId}`;
|
||||
} catch (err) {
|
||||
console.error(`Error loading detail for ${expId}:`, err);
|
||||
} finally {
|
||||
showLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch Scenario Comparisons
|
||||
async function loadScenarioComparisons() {
|
||||
try {
|
||||
const res = await fetch('/api/scenarios');
|
||||
if (!res.ok) return;
|
||||
const comps = await res.json();
|
||||
state.comparisons = comps;
|
||||
renderScenarios(comps);
|
||||
} catch (err) {
|
||||
console.warn('Could not load scenario comparisons:', err);
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch Markdown Report
|
||||
async function loadReport(expId) {
|
||||
if (!expId) return;
|
||||
try {
|
||||
const res = await fetch(`/api/experiments/${encodeURIComponent(expId)}/report`);
|
||||
if (!res.ok) throw new Error('Report not found');
|
||||
const text = await res.text();
|
||||
state.reportText = text;
|
||||
const reportView = document.getElementById('report-markdown-view');
|
||||
if (reportView) {
|
||||
reportView.innerHTML = `<pre>${escapeHtml(text)}</pre>`;
|
||||
}
|
||||
} catch (err) {
|
||||
const reportView = document.getElementById('report-markdown-view');
|
||||
if (reportView) {
|
||||
reportView.innerHTML = '<div class="empty-state">No report.md found for this experiment.</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function escapeHtml(str) {
|
||||
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
||||
}
|
||||
|
||||
// RENDERERS
|
||||
|
||||
// 1. Overview Tab
|
||||
function renderOverview(detail) {
|
||||
const kpis = detail.kpis || {};
|
||||
const cfg = detail.config || {};
|
||||
|
||||
// Summary Bar
|
||||
document.getElementById('cfg-exp-id').textContent = detail.id || '-';
|
||||
document.getElementById('cfg-fleet-size').textContent = `${kpis.fleet_size || cfg.fleet_size || 4} AMRs`;
|
||||
document.getElementById('cfg-policy').textContent = cfg.dispatch_policy || 'priority_nearest_idle';
|
||||
document.getElementById('cfg-duration').textContent = `${formatNumber(kpis.duration_seconds || cfg.duration || 3600, 0)}s`;
|
||||
document.getElementById('cfg-seed').textContent = cfg.seed !== undefined ? cfg.seed : 42;
|
||||
document.getElementById('cfg-wall-time').textContent = `${formatNumber(kpis.wall_clock_seconds || 0.27, 3)}s`;
|
||||
|
||||
// 6 KPI Cards
|
||||
const tp = kpis.throughput_tasks_per_hour !== undefined ? kpis.throughput_tasks_per_hour : (kpis.throughput ? kpis.throughput.completed_per_hour : 0);
|
||||
document.getElementById('kpi-throughput').textContent = formatNumber(tp, 1);
|
||||
document.getElementById('kpi-completion-rate').textContent = `${formatNumber(kpis.completion_rate_percent || 100, 1)}% completed`;
|
||||
document.getElementById('kpi-tasks-count').textContent = `${kpis.tasks_completed || 0} of ${kpis.tasks_created || 0} orders`;
|
||||
|
||||
const tt = kpis.turnaround_time || {};
|
||||
document.getElementById('kpi-turnaround').textContent = formatNumber(tt.p50 || 0, 1);
|
||||
document.getElementById('kpi-turnaround-mean').textContent = `${formatNumber(tt.mean || 0, 1)}s`;
|
||||
document.getElementById('kpi-turnaround-p95').textContent = `${formatNumber(tt.p95 || 0, 1)}s`;
|
||||
|
||||
const sla = kpis.on_time_delivery_percent !== undefined ? kpis.on_time_delivery_percent : 100.0;
|
||||
document.getElementById('kpi-sla').textContent = `${formatNumber(sla, 1)}%`;
|
||||
const viol = kpis.missed_deadlines || kpis.overdue_task_count || 0;
|
||||
const violBadge = document.getElementById('kpi-violations-badge');
|
||||
if (violBadge) {
|
||||
violBadge.textContent = `${viol} violations`;
|
||||
violBadge.className = viol === 0 ? 'badge success' : 'badge danger';
|
||||
}
|
||||
|
||||
const util = kpis.fleet_utilization_percent !== undefined ? kpis.fleet_utilization_percent : 50.9;
|
||||
document.getElementById('kpi-utilization').textContent = `${formatNumber(util, 1)}%`;
|
||||
document.getElementById('kpi-loaded-ratio').textContent = `${formatNumber(kpis.loaded_distance_ratio_percent || 0, 1)}%`;
|
||||
|
||||
const energy = kpis.total_energy_consumed_kwh !== undefined ? kpis.total_energy_consumed_kwh : 0.0;
|
||||
document.getElementById('kpi-energy').textContent = formatNumber(energy, 2);
|
||||
document.getElementById('kpi-energy-intensity').textContent = `${formatNumber(kpis.energy_intensity_kwh_per_task || 0, 3)} kWh/task`;
|
||||
|
||||
const conflicts = kpis.conflicts_detected !== undefined ? kpis.conflicts_detected : (kpis.traffic_conflicts || 0);
|
||||
document.getElementById('kpi-conflicts').textContent = conflicts;
|
||||
document.getElementById('kpi-yield-wait').textContent = `${formatNumber(kpis.total_yield_wait_time_seconds || 0, 1)}s`;
|
||||
const deadlocksBadge = document.getElementById('kpi-deadlocks-badge');
|
||||
if (deadlocksBadge) {
|
||||
const deadlocks = kpis.deadlocks_prevented || 0;
|
||||
deadlocksBadge.textContent = `${deadlocks} deadlocks`;
|
||||
deadlocksBadge.className = deadlocks === 0 ? 'badge success' : 'badge warning';
|
||||
}
|
||||
|
||||
// Latency Distribution Table
|
||||
const tbody = document.getElementById('percentiles-tbody');
|
||||
tbody.innerHTML = '';
|
||||
|
||||
const distributions = [
|
||||
{ name: 'Order Turnaround Latency', stats: kpis.turnaround_time },
|
||||
{ name: 'Queue Waiting Latency', stats: kpis.waiting_time },
|
||||
{ name: 'Mission Execution Latency', stats: kpis.execution_time },
|
||||
];
|
||||
|
||||
distributions.forEach(d => {
|
||||
const s = d.stats || {};
|
||||
const row = document.createElement('tr');
|
||||
row.innerHTML = `
|
||||
<td><strong>${d.name}</strong></td>
|
||||
<td>${s.count || 0}</td>
|
||||
<td>${formatNumber(s.mean, 1)}s</td>
|
||||
<td>${formatNumber(s.std_dev, 1)}s</td>
|
||||
<td><strong style="color:var(--primary-cyan)">${formatNumber(s.p50, 1)}s</strong></td>
|
||||
<td>${formatNumber(s.p90, 1)}s</td>
|
||||
<td>${formatNumber(s.p95, 1)}s</td>
|
||||
<td>${formatNumber(s.p99, 1)}s</td>
|
||||
<td>${formatNumber(s.max, 1)}s</td>
|
||||
`;
|
||||
tbody.appendChild(row);
|
||||
});
|
||||
}
|
||||
|
||||
// 2. AMR Fleet Tab
|
||||
function renderFleet(detail) {
|
||||
const robots = detail.robots || [];
|
||||
const kpis = detail.kpis || {};
|
||||
const tbody = document.getElementById('fleet-tbody');
|
||||
tbody.innerHTML = '';
|
||||
|
||||
if (robots.length === 0) {
|
||||
tbody.innerHTML = '<tr><td colspan="9" class="text-center">No robot telemetry records found.</td></tr>';
|
||||
} else {
|
||||
robots.forEach(r => {
|
||||
const isHeavy = r.robot_type.includes('heavy');
|
||||
const stateColor = getStateColor(r.state);
|
||||
const bat = r.battery_percent;
|
||||
const batColor = bat > 50 ? 'var(--success-green)' : (bat > 20 ? 'var(--warning-amber)' : 'var(--danger-red)');
|
||||
|
||||
const row = document.createElement('tr');
|
||||
row.innerHTML = `
|
||||
<td><strong>${r.robot_id}</strong></td>
|
||||
<td><span class="badge ${isHeavy ? 'warning' : 'info'}">${isHeavy ? 'Heavy AMR (1000kg)' : 'Light AMR (100kg)'}</span></td>
|
||||
<td><span class="badge" style="background:${stateColor}22; color:${stateColor}">${r.state}</span></td>
|
||||
<td>
|
||||
<div class="battery-bar-wrap">
|
||||
<div class="battery-bar-track">
|
||||
<div class="battery-bar-fill" style="width:${Math.min(100, bat)}%; background-color:${batColor}"></div>
|
||||
</div>
|
||||
<span>${formatNumber(bat, 1)}%</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>${formatNumber(r.utilization_pct, 1)}%</td>
|
||||
<td>${formatNumber(r.total_distance_m, 1)}m</td>
|
||||
<td>${formatNumber(r.loaded_distance_m, 1)}m</td>
|
||||
<td>${formatNumber(r.energy_consumed_kwh, 3)} kWh</td>
|
||||
<td>${r.charging_sessions}</td>
|
||||
`;
|
||||
tbody.appendChild(row);
|
||||
});
|
||||
}
|
||||
|
||||
// Charging Infrastructure
|
||||
document.getElementById('chg-bays-count').textContent = kpis.charging_bays_count || 4;
|
||||
document.getElementById('chg-occupancy').textContent = `${formatNumber(kpis.bay_occupancy_percent || 0, 1)}%`;
|
||||
const chgSessions = (kpis.opportunity_charges_count || 0) + (kpis.mandatory_charges_count || 0);
|
||||
document.getElementById('chg-sessions-count').textContent = chgSessions;
|
||||
document.getElementById('chg-wait-time').textContent = formatNumber(kpis.avg_charging_queue_wait_seconds || 0, 1);
|
||||
|
||||
// Empty vs Loaded Ratio
|
||||
const loadedDist = kpis.loaded_travel_distance_meters || 0;
|
||||
const emptyDist = kpis.empty_travel_distance_meters || 0;
|
||||
const ratioPct = kpis.loaded_distance_ratio_percent || 50;
|
||||
|
||||
document.getElementById('ratio-loaded-lbl').textContent = `${formatNumber(loadedDist, 0)}m (${formatNumber(ratioPct, 1)}%)`;
|
||||
document.getElementById('ratio-empty-lbl').textContent = `${formatNumber(emptyDist, 0)}m (${formatNumber(100 - ratioPct, 1)}%)`;
|
||||
const pbar = document.getElementById('ratio-progress-bar');
|
||||
if (pbar) pbar.style.width = `${Math.max(5, Math.min(95, ratioPct))}%`;
|
||||
}
|
||||
|
||||
function getStateColor(st) {
|
||||
switch (st) {
|
||||
case 'IDLE': return '#00f0ff';
|
||||
case 'DISPATCHED': return '#3b82f6';
|
||||
case 'PICKING':
|
||||
case 'DROPPING': return '#10b981';
|
||||
case 'LOADED_TRANSIT': return '#f59e0b';
|
||||
case 'CHARGING': return '#ef4444';
|
||||
default: return '#94a3b8';
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Congestion Tab
|
||||
function renderCongestion(detail) {
|
||||
const expId = detail.id;
|
||||
const svgContainer = document.getElementById('heatmap-svg-container');
|
||||
|
||||
if (detail.has_heatmap) {
|
||||
svgContainer.innerHTML = `<img src="/api/experiments/${encodeURIComponent(expId)}/heatmap.svg?t=${Date.now()}" alt="Warehouse Heatmap" style="max-width:100%; height:auto;">`;
|
||||
} else {
|
||||
svgContainer.innerHTML = '<div class="empty-state">No SVG Heatmap file found for this experiment.</div>';
|
||||
}
|
||||
|
||||
const tbody = document.getElementById('bottlenecks-tbody');
|
||||
tbody.innerHTML = '';
|
||||
const bottlenecks = detail.bottlenecks || [];
|
||||
|
||||
if (bottlenecks.length === 0) {
|
||||
tbody.innerHTML = '<tr><td colspan="6" class="text-center">No aisle contention recorded. All corridors operate smoothly.</td></tr>';
|
||||
} else {
|
||||
bottlenecks.forEach(b => {
|
||||
const badgeClass = b.severity === 'CRITICAL' ? 'danger' : (b.severity === 'WARNING' ? 'warning' : 'info');
|
||||
const row = document.createElement('tr');
|
||||
row.innerHTML = `
|
||||
<td><code>${b.edge}</code></td>
|
||||
<td>${b.traversals}</td>
|
||||
<td>${b.conflicts}</td>
|
||||
<td>${formatNumber(b.wait_time_sec, 1)}s</td>
|
||||
<td><strong>${formatNumber(b.congestion_score, 3)}</strong></td>
|
||||
<td><span class="badge ${badgeClass}">${b.severity}</span></td>
|
||||
`;
|
||||
tbody.appendChild(row);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Tasks Tab
|
||||
function renderTasks(detail) {
|
||||
const kpis = detail.kpis || {};
|
||||
const sum = detail.tasks_summary || {};
|
||||
|
||||
document.getElementById('tasks-completed-val').textContent = sum.completed || kpis.tasks_completed || 0;
|
||||
document.getElementById('tasks-in-progress-val').textContent = sum.in_progress || kpis.tasks_in_progress || 0;
|
||||
document.getElementById('tasks-pending-val').textContent = sum.pending || kpis.tasks_pending || 0;
|
||||
|
||||
const tbody = document.getElementById('task-breakdowns-tbody');
|
||||
tbody.innerHTML = '';
|
||||
const breakdowns = kpis.task_type_breakdowns || {};
|
||||
|
||||
const types = Object.keys(breakdowns);
|
||||
if (types.length === 0) {
|
||||
tbody.innerHTML = '<tr><td colspan="6" class="text-center">No task type breakdown data available.</td></tr>';
|
||||
} else {
|
||||
types.forEach(typeKey => {
|
||||
const item = breakdowns[typeKey] || {};
|
||||
const tt = item.turnaround_time || {};
|
||||
const wt = item.waiting_time || {};
|
||||
const et = item.execution_time || {};
|
||||
|
||||
const row = document.createElement('tr');
|
||||
row.innerHTML = `
|
||||
<td><strong>${typeKey}</strong></td>
|
||||
<td>${item.count || tt.count || 0}</td>
|
||||
<td>${formatNumber(tt.mean, 1)}s</td>
|
||||
<td><strong style="color:var(--primary-cyan)">${formatNumber(tt.p90, 1)}s</strong></td>
|
||||
<td>${formatNumber(wt.mean, 1)}s</td>
|
||||
<td>${formatNumber(et.mean, 1)}s</td>
|
||||
`;
|
||||
tbody.appendChild(row);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 5. Scenarios Tab
|
||||
function renderScenarios(comps) {
|
||||
if (!comps) return;
|
||||
|
||||
// Fleet Sweep Table
|
||||
const fleetTbody = document.getElementById('fleet-sweep-tbody');
|
||||
fleetTbody.innerHTML = '';
|
||||
const fleetRows = comps.fleet_sizing || [];
|
||||
|
||||
if (fleetRows.length === 0) {
|
||||
fleetTbody.innerHTML = '<tr><td colspan="5" class="text-center">No fleet sizing sweep records available.</td></tr>';
|
||||
} else {
|
||||
fleetRows.forEach(row => {
|
||||
const tr = document.createElement('tr');
|
||||
const keys = Object.keys(row);
|
||||
keys.forEach(k => {
|
||||
const td = document.createElement('td');
|
||||
td.textContent = row[k];
|
||||
if (k.toLowerCase().includes('metric')) {
|
||||
td.style.fontWeight = 'bold';
|
||||
}
|
||||
tr.appendChild(td);
|
||||
});
|
||||
fleetTbody.appendChild(tr);
|
||||
});
|
||||
}
|
||||
|
||||
// Policy Sweep Table
|
||||
const policyTbody = document.getElementById('policy-sweep-tbody');
|
||||
policyTbody.innerHTML = '';
|
||||
const policyRows = comps.dispatch_policies || [];
|
||||
|
||||
if (policyRows.length === 0) {
|
||||
policyTbody.innerHTML = '<tr><td colspan="4" class="text-center">No dispatch policy sweep records available.</td></tr>';
|
||||
} else {
|
||||
policyRows.forEach(row => {
|
||||
const tr = document.createElement('tr');
|
||||
const keys = Object.keys(row);
|
||||
keys.forEach(k => {
|
||||
const td = document.createElement('td');
|
||||
td.textContent = row[k];
|
||||
if (k.toLowerCase().includes('metric')) {
|
||||
td.style.fontWeight = 'bold';
|
||||
}
|
||||
tr.appendChild(td);
|
||||
});
|
||||
policyTbody.appendChild(tr);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Event Listeners
|
||||
expSelect.addEventListener('change', (e) => {
|
||||
loadExperimentDetail(e.target.value);
|
||||
});
|
||||
|
||||
refreshBtn.addEventListener('click', () => {
|
||||
loadExperiments();
|
||||
});
|
||||
|
||||
const downloadBtn = document.getElementById('download-report-btn');
|
||||
if (downloadBtn) {
|
||||
downloadBtn.addEventListener('click', () => {
|
||||
if (!state.reportText) return;
|
||||
const blob = new Blob([state.reportText], { type: 'text/markdown;charset=utf-8' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `${state.selectedExpId}_report.md`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
});
|
||||
}
|
||||
|
||||
// Boot
|
||||
loadExperiments();
|
||||
});
|
||||
@@ -0,0 +1,491 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Warehouse Digital Twin - Operational Dashboard</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="app.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app" class="dashboard-container">
|
||||
<!-- Top Navigation Bar -->
|
||||
<header class="top-navbar">
|
||||
<div class="brand-group">
|
||||
<div class="brand-logo">
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path>
|
||||
<polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline>
|
||||
<line x1="12" y1="22.08" x2="12" y2="12"></line>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="brand-text">
|
||||
<h1>Warehouse Digital Twin</h1>
|
||||
<span class="subtitle">Autonomous Fleet Operations & Telemetry</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="header-controls">
|
||||
<div class="control-item">
|
||||
<label for="experiment-select">Active Run:</label>
|
||||
<select id="experiment-select" class="custom-select">
|
||||
<option value="" disabled selected>Loading experiments...</option>
|
||||
</select>
|
||||
</div>
|
||||
<button id="refresh-btn" class="btn btn-secondary" title="Reload telemetry">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<polyline points="23 4 23 10 17 10"></polyline>
|
||||
<polyline points="1 20 1 14 7 14"></polyline>
|
||||
<path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"></path>
|
||||
</svg>
|
||||
<span>Refresh</span>
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Main Navigation Tabs -->
|
||||
<nav class="sub-navbar">
|
||||
<div class="nav-tabs" role="tablist">
|
||||
<button class="tab-btn active" data-tab="tab-overview">Overview & KPIs</button>
|
||||
<button class="tab-btn" data-tab="tab-fleet">AMR Fleet & Battery</button>
|
||||
<button class="tab-btn" data-tab="tab-congestion">Corridor Congestion</button>
|
||||
<button class="tab-btn" data-tab="tab-tasks">Tasks & SLAs</button>
|
||||
<button class="tab-btn" data-tab="tab-scenarios">Scenario Comparison</button>
|
||||
<button class="tab-btn" data-tab="tab-report">Executive Report</button>
|
||||
</div>
|
||||
<div class="live-pill" id="run-badge">
|
||||
<span class="pulse-dot"></span>
|
||||
<span id="run-status-text">Ready</span>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- Main Content Area -->
|
||||
<main class="main-content">
|
||||
<!-- Loading Indicator -->
|
||||
<div id="loading-overlay" class="loading-overlay hidden">
|
||||
<div class="spinner"></div>
|
||||
<p>Loading simulation telemetry...</p>
|
||||
</div>
|
||||
|
||||
<!-- TAB 1: OVERVIEW & KPIS -->
|
||||
<section id="tab-overview" class="tab-pane active">
|
||||
<!-- Run Config Summary Bar -->
|
||||
<div class="summary-bar card">
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">Experiment ID</span>
|
||||
<span class="summary-val" id="cfg-exp-id">-</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">Fleet Size</span>
|
||||
<span class="summary-val highlight" id="cfg-fleet-size">-</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">Dispatch Heuristic</span>
|
||||
<span class="summary-val" id="cfg-policy">-</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">Simulated Duration</span>
|
||||
<span class="summary-val" id="cfg-duration">-</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">PRNG Seed</span>
|
||||
<span class="summary-val" id="cfg-seed">-</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">Wall-Clock Run Time</span>
|
||||
<span class="summary-val" id="cfg-wall-time">-</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 6 Executive KPI Stat Cards -->
|
||||
<div class="kpi-grid">
|
||||
<!-- KPI 1: Throughput -->
|
||||
<div class="kpi-card card">
|
||||
<div class="kpi-header">
|
||||
<span class="kpi-title">Fleet Throughput</span>
|
||||
<span class="kpi-icon-badge cyan">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<polyline points="22 12 18 12 15 21 9 3 6 12 2 12"></polyline>
|
||||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
<div class="kpi-body">
|
||||
<span class="kpi-value" id="kpi-throughput">-</span>
|
||||
<span class="kpi-unit">tasks / hour</span>
|
||||
</div>
|
||||
<div class="kpi-footer">
|
||||
<span class="badge success" id="kpi-completion-rate">100% completed</span>
|
||||
<span class="kpi-sub" id="kpi-tasks-count">85 of 86 tasks</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- KPI 2: Turnaround Latency -->
|
||||
<div class="kpi-card card">
|
||||
<div class="kpi-header">
|
||||
<span class="kpi-title">Turnaround Latency (p50)</span>
|
||||
<span class="kpi-icon-badge blue">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<circle cx="12" cy="12" r="10"></circle>
|
||||
<polyline points="12 6 12 12 16 14"></polyline>
|
||||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
<div class="kpi-body">
|
||||
<span class="kpi-value" id="kpi-turnaround">-</span>
|
||||
<span class="kpi-unit">seconds</span>
|
||||
</div>
|
||||
<div class="kpi-footer">
|
||||
<span class="kpi-sub">Mean: <strong id="kpi-turnaround-mean">-</strong></span>
|
||||
<span class="kpi-sub">p95: <strong id="kpi-turnaround-p95">-</strong></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- KPI 3: On-Time SLA Delivery -->
|
||||
<div class="kpi-card card">
|
||||
<div class="kpi-header">
|
||||
<span class="kpi-title">SLA Compliance</span>
|
||||
<span class="kpi-icon-badge green">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path>
|
||||
<polyline points="22 4 12 14.01 9 11.01"></polyline>
|
||||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
<div class="kpi-body">
|
||||
<span class="kpi-value highlight-green" id="kpi-sla">-</span>
|
||||
<span class="kpi-unit">on-time</span>
|
||||
</div>
|
||||
<div class="kpi-footer">
|
||||
<span class="badge success" id="kpi-violations-badge">0 violations</span>
|
||||
<span class="kpi-sub">Production feeds</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- KPI 4: Fleet Utilization -->
|
||||
<div class="kpi-card card">
|
||||
<div class="kpi-header">
|
||||
<span class="kpi-title">Fleet Utilization</span>
|
||||
<span class="kpi-icon-badge amber">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"></polygon>
|
||||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
<div class="kpi-body">
|
||||
<span class="kpi-value" id="kpi-utilization">-</span>
|
||||
<span class="kpi-unit">% active</span>
|
||||
</div>
|
||||
<div class="kpi-footer">
|
||||
<span class="kpi-sub">Loaded Distance: <strong id="kpi-loaded-ratio">-</strong></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- KPI 5: Energy Intensity -->
|
||||
<div class="kpi-card card">
|
||||
<div class="kpi-header">
|
||||
<span class="kpi-title">Energy Consumption</span>
|
||||
<span class="kpi-icon-badge purple">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<rect x="2" y="7" width="16" height="10" rx="2" ry="2"></rect>
|
||||
<line x1="22" y1="11" x2="22" y2="13"></line>
|
||||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
<div class="kpi-body">
|
||||
<span class="kpi-value" id="kpi-energy">-</span>
|
||||
<span class="kpi-unit">kWh total</span>
|
||||
</div>
|
||||
<div class="kpi-footer">
|
||||
<span class="kpi-sub">Intensity: <strong id="kpi-energy-intensity">-</strong></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- KPI 6: Traffic Contention -->
|
||||
<div class="kpi-card card">
|
||||
<div class="kpi-header">
|
||||
<span class="kpi-title">Traffic Contention</span>
|
||||
<span class="kpi-icon-badge orange">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path>
|
||||
<line x1="12" y1="9" x2="12" y2="13"></line>
|
||||
<line x1="12" y1="17" x2="12.01" y2="17"></line>
|
||||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
<div class="kpi-body">
|
||||
<span class="kpi-value" id="kpi-conflicts">-</span>
|
||||
<span class="kpi-unit">conflicts</span>
|
||||
</div>
|
||||
<div class="kpi-footer">
|
||||
<span class="badge success" id="kpi-deadlocks-badge">0 deadlocks</span>
|
||||
<span class="kpi-sub">Wait: <strong id="kpi-yield-wait">-</strong></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Latency Percentiles Deep Dive -->
|
||||
<div class="card percentiles-card">
|
||||
<div class="card-header">
|
||||
<h3>Latency Distribution Matrix</h3>
|
||||
<span class="card-sub">Exact percentiles computed via linear rank interpolation</span>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Latency Metric</th>
|
||||
<th>Count</th>
|
||||
<th>Mean</th>
|
||||
<th>Std Dev</th>
|
||||
<th>p50 (Median)</th>
|
||||
<th>p90</th>
|
||||
<th>p95</th>
|
||||
<th>p99</th>
|
||||
<th>Max</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="percentiles-tbody">
|
||||
<tr><td colspan="9" class="text-center">Loading distribution metrics...</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- TAB 2: AMR FLEET & BATTERY -->
|
||||
<section id="tab-fleet" class="tab-pane">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3>Autonomous Mobile Robot (AMR) Fleet Status</h3>
|
||||
<span class="card-sub">Real-time battery SoC, mileage, utilization, and energy consumption</span>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Robot ID</th>
|
||||
<th>Chassis Model</th>
|
||||
<th>Operational State</th>
|
||||
<th>Battery Level</th>
|
||||
<th>Utilization</th>
|
||||
<th>Total Travel</th>
|
||||
<th>Loaded Distance</th>
|
||||
<th>Energy Consumed</th>
|
||||
<th>Charging Sessions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="fleet-tbody">
|
||||
<tr><td colspan="9" class="text-center">Loading fleet status...</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid-2-col">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3>Charging Infrastructure Telemetry</h3>
|
||||
<span class="card-sub">Physical bay capacity, occupancy, and wait times</span>
|
||||
</div>
|
||||
<div class="charging-stats-grid">
|
||||
<div class="stat-box">
|
||||
<span class="stat-num" id="chg-bays-count">-</span>
|
||||
<span class="stat-lbl">Charging Bays</span>
|
||||
</div>
|
||||
<div class="stat-box">
|
||||
<span class="stat-num" id="chg-occupancy">-</span>
|
||||
<span class="stat-lbl">Bay Occupancy %</span>
|
||||
</div>
|
||||
<div class="stat-box">
|
||||
<span class="stat-num" id="chg-sessions-count">-</span>
|
||||
<span class="stat-lbl">Sessions Completed</span>
|
||||
</div>
|
||||
<div class="stat-box">
|
||||
<span class="stat-num" id="chg-wait-time">-</span>
|
||||
<span class="stat-lbl">Avg Queue Wait (s)</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3>Fleet Distance & Balance</h3>
|
||||
<span class="card-sub">Empty vs. Loaded haulage efficiency</span>
|
||||
</div>
|
||||
<div class="ratio-bar-container">
|
||||
<div class="ratio-labels">
|
||||
<span>Loaded Transit: <strong id="ratio-loaded-lbl">-</strong></span>
|
||||
<span>Empty Dispatch: <strong id="ratio-empty-lbl">-</strong></span>
|
||||
</div>
|
||||
<div class="progress-bar-wrap">
|
||||
<div class="progress-bar loaded" id="ratio-progress-bar" style="width: 50%;"></div>
|
||||
</div>
|
||||
<p class="ratio-explanation" id="ratio-explanation-txt">
|
||||
Loaded ratio reflects productive material haulage vs empty relocation.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- TAB 3: CORRIDOR CONGESTION -->
|
||||
<section id="tab-congestion" class="tab-pane">
|
||||
<div class="grid-2-col heatmap-layout">
|
||||
<div class="card heatmap-card">
|
||||
<div class="card-header">
|
||||
<h3>Warehouse 2D Spatial Heatmap</h3>
|
||||
<span class="card-sub">Traversal intensity and yield delay across zones</span>
|
||||
</div>
|
||||
<div class="heatmap-container" id="heatmap-svg-container">
|
||||
<div class="empty-state">No SVG Heatmap available for this run.</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3>Corridor Bottleneck Diagnosis</h3>
|
||||
<span class="card-sub">Top congested edges and actionable mitigations</span>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Corridor Edge</th>
|
||||
<th>Traversals</th>
|
||||
<th>Conflicts</th>
|
||||
<th>Wait Time</th>
|
||||
<th>Score</th>
|
||||
<th>Severity</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="bottlenecks-tbody">
|
||||
<tr><td colspan="6" class="text-center">Loading bottlenecks...</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- TAB 4: TASKS & SLAS -->
|
||||
<section id="tab-tasks" class="tab-pane">
|
||||
<div class="grid-3-col">
|
||||
<div class="card stat-card">
|
||||
<div class="stat-card-title">Completed Orders</div>
|
||||
<div class="stat-card-val text-green" id="tasks-completed-val">-</div>
|
||||
<div class="stat-card-sub" id="tasks-completed-sub">100% On-Time</div>
|
||||
</div>
|
||||
<div class="card stat-card">
|
||||
<div class="stat-card-title">In-Progress Tasks</div>
|
||||
<div class="stat-card-val text-cyan" id="tasks-in-progress-val">-</div>
|
||||
<div class="stat-card-sub">Active at cutoff</div>
|
||||
</div>
|
||||
<div class="card stat-card">
|
||||
<div class="stat-card-title">Pending Orders</div>
|
||||
<div class="stat-card-val text-amber" id="tasks-pending-val">-</div>
|
||||
<div class="stat-card-sub">In Dispatch Queue</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3>Performance Breakdown by Task Type</h3>
|
||||
<span class="card-sub">Order picking vs. urgent assembly feed vs. bulk replenishment</span>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Task Classification</th>
|
||||
<th>Completed Count</th>
|
||||
<th>Mean Turnaround (s)</th>
|
||||
<th>p90 Turnaround (s)</th>
|
||||
<th>Mean Waiting (s)</th>
|
||||
<th>Mean Execution (s)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="task-breakdowns-tbody">
|
||||
<tr><td colspan="6" class="text-center">Loading breakdowns...</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- TAB 5: SCENARIO COMPARISON -->
|
||||
<section id="tab-scenarios" class="tab-pane">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3>Fleet Sizing Parameter Sweep (2, 4, 6, 8 AMRs)</h3>
|
||||
<span class="card-sub">Impact of AMR fleet capacity on throughput, queue latency, and corridor contention</span>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="data-table" id="fleet-sweep-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Metric</th>
|
||||
<th>2 AMRs</th>
|
||||
<th>4 AMRs (Baseline)</th>
|
||||
<th>6 AMRs</th>
|
||||
<th>8 AMRs</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="fleet-sweep-tbody">
|
||||
<tr><td colspan="5" class="text-center">Loading fleet sweep comparison...</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="insight-box">
|
||||
<h4>Fleet Sizing Insight:</h4>
|
||||
<p>
|
||||
At <strong>2 AMRs</strong>, the fleet is saturated (95.6% utilization), causing severe queueing (253.9s) and a 28.6% SLA failure rate.
|
||||
Scaling to <strong>4 AMRs</strong> achieves optimal throughput (85 tasks/hr) with 100% on-time delivery. Further scaling to 6 or 8 AMRs provides diminishing returns while increasing aisle contention from 36 to 51 conflicts.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3>Dispatch Policy Heuristic Comparison</h3>
|
||||
<span class="card-sub">Evaluating Priority Nearest Idle vs. Nearest Idle vs. Balanced Utilization</span>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="data-table" id="policy-sweep-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Metric</th>
|
||||
<th>Priority Nearest Idle</th>
|
||||
<th>Nearest Idle</th>
|
||||
<th>Balanced Utilization</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="policy-sweep-tbody">
|
||||
<tr><td colspan="4" class="text-center">Loading dispatch policy comparison...</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- TAB 6: EXECUTIVE REPORT -->
|
||||
<section id="tab-report" class="tab-pane">
|
||||
<div class="card report-card">
|
||||
<div class="card-header">
|
||||
<h3>Audit-Ready Executive Markdown Report</h3>
|
||||
<div class="report-actions">
|
||||
<button id="download-report-btn" class="btn btn-secondary">Download Markdown</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="report-content" id="report-markdown-view">
|
||||
<pre>Loading executive report...</pre>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<script src="app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,139 @@
|
||||
"""Optional Streamlit interactive dashboard for Warehouse Robot Fleet Digital Twin.
|
||||
|
||||
Can be run via:
|
||||
streamlit run src/warehouse_twin/dashboard/streamlit_app.py
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict
|
||||
|
||||
from warehouse_twin.dashboard.data_provider import DashboardDataProvider
|
||||
|
||||
try:
|
||||
import streamlit as st
|
||||
HAS_STREAMLIT = True
|
||||
except ImportError:
|
||||
HAS_STREAMLIT = False
|
||||
|
||||
|
||||
def run_streamlit_app() -> None:
|
||||
"""Entry point for running the Streamlit dashboard."""
|
||||
if not HAS_STREAMLIT:
|
||||
print("[ERROR] Streamlit is not installed in the current environment.", file=sys.stderr)
|
||||
print("Install it with: pip install streamlit", file=sys.stderr)
|
||||
print("Or run the built-in standalone dashboard: warehouse-twin dashboard", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
st.set_page_config(
|
||||
page_title="Warehouse Robot Fleet Digital Twin",
|
||||
page_icon="🏭",
|
||||
layout="wide",
|
||||
initial_sidebar_state="expanded",
|
||||
)
|
||||
|
||||
st.title("🏭 Warehouse Robot Fleet Digital Twin - Operational Dashboard")
|
||||
st.markdown("Real-time telemetry, KPI monitoring, spatial heatmaps, and scenario parameter sweeps.")
|
||||
|
||||
# Data provider
|
||||
results_dir = Path("results")
|
||||
dp = DashboardDataProvider(results_dir)
|
||||
|
||||
# Sidebar: Experiment Selector
|
||||
st.sidebar.header("Configuration & Runs")
|
||||
experiments = dp.list_experiments()
|
||||
if not experiments:
|
||||
st.warning("No experiment records found in `results/experiments/`.")
|
||||
return
|
||||
|
||||
exp_ids = [e["id"] for e in experiments]
|
||||
default_idx = exp_ids.index("baseline_1hr") if "baseline_1hr" in exp_ids else 0
|
||||
selected_exp = st.sidebar.selectbox("Select Experiment Run", exp_ids, index=default_idx)
|
||||
|
||||
detail = dp.get_experiment_detail(selected_exp)
|
||||
if not detail:
|
||||
st.error(f"Could not load details for experiment '{selected_exp}'.")
|
||||
return
|
||||
|
||||
kpis = detail.get("kpis", {})
|
||||
cfg = detail.get("config", {})
|
||||
|
||||
# Top KPI Metrics
|
||||
st.subheader("Executive Operational KPIs")
|
||||
col1, col2, col3, col4, col5, col6 = st.columns(6)
|
||||
|
||||
tp = kpis.get("throughput_tasks_per_hour", kpis.get("throughput", {}).get("completed_per_hour", 0.0))
|
||||
tt = kpis.get("turnaround_time", {})
|
||||
sla = kpis.get("on_time_delivery_percent", 100.0)
|
||||
util = kpis.get("fleet_utilization_percent", 0.0)
|
||||
energy = kpis.get("total_energy_consumed_kwh", 0.0)
|
||||
conflicts = kpis.get("conflicts_detected", 0)
|
||||
|
||||
col1.metric("Throughput", f"{tp:.1f} t/hr", f"{kpis.get('completion_rate_percent', 100):.1f}% completed")
|
||||
col2.metric("Median Turnaround", f"{tt.get('p50', 0):.1f} s", f"Mean: {tt.get('mean', 0):.1f} s")
|
||||
col3.metric("On-Time SLA", f"{sla:.1f}%", f"{kpis.get('missed_deadlines', 0)} violations")
|
||||
col4.metric("Fleet Utilization", f"{util:.1f}%", f"Loaded: {kpis.get('loaded_distance_ratio_percent', 0):.1f}%")
|
||||
col5.metric("Energy Consumed", f"{energy:.2f} kWh", f"{kpis.get('energy_intensity_kwh_per_task', 0):.3f} kWh/task")
|
||||
col6.metric("Corridor Contention", f"{conflicts} conflicts", f"{kpis.get('deadlocks_prevented', 0)} deadlocks")
|
||||
|
||||
# Tabs
|
||||
tab_fleet, tab_heat, tab_tasks, tab_scenarios = st.tabs([
|
||||
"AMR Fleet & Charging", "Spatial Heatmap & Bottlenecks", "Task Breakdown", "Scenario Comparison"
|
||||
])
|
||||
|
||||
with tab_fleet:
|
||||
st.subheader("Autonomous Mobile Robot Fleet Telemetry")
|
||||
robots = detail.get("robots", [])
|
||||
if robots:
|
||||
st.dataframe(robots, use_container_width=True)
|
||||
|
||||
st.subheader("Charging Infrastructure")
|
||||
c1, c2, c3, c4 = st.columns(4)
|
||||
c1.metric("Charging Bays", kpis.get("charging_bays_count", 4))
|
||||
c2.metric("Bay Occupancy", f"{kpis.get('bay_occupancy_percent', 0):.1f}%")
|
||||
c3.metric("Sessions Completed", (kpis.get("opportunity_charges_count", 0) + kpis.get("mandatory_charges_count", 0)))
|
||||
c4.metric("Avg Queue Wait", f"{kpis.get('avg_charging_queue_wait_seconds', 0):.1f} s")
|
||||
|
||||
with tab_heat:
|
||||
st.subheader("2D Spatial Congestion Heatmap")
|
||||
svg_content = dp.get_heatmap_svg(selected_exp)
|
||||
if svg_content:
|
||||
st.image(svg_content)
|
||||
else:
|
||||
st.info("No heatmap SVG available for this run.")
|
||||
|
||||
st.subheader("Top Corridor Bottlenecks")
|
||||
bottlenecks = detail.get("bottlenecks", [])
|
||||
if bottlenecks:
|
||||
st.dataframe(bottlenecks, use_container_width=True)
|
||||
|
||||
with tab_tasks:
|
||||
st.subheader("Task Lifecycle Summary")
|
||||
tasks_sum = detail.get("tasks_summary", {})
|
||||
t1, t2, t3 = st.columns(3)
|
||||
t1.metric("Completed Orders", tasks_sum.get("completed", 0))
|
||||
t2.metric("In-Progress Tasks", tasks_sum.get("in_progress", 0))
|
||||
t3.metric("Pending Orders", tasks_sum.get("pending", 0))
|
||||
|
||||
st.subheader("Breakdown by Task Type")
|
||||
breakdowns = kpis.get("task_type_breakdowns", {})
|
||||
if breakdowns:
|
||||
st.json(breakdowns)
|
||||
|
||||
with tab_scenarios:
|
||||
st.subheader("Parameter Sweeps & Scenario Comparison")
|
||||
comps = dp.get_scenario_comparisons()
|
||||
if comps.get("fleet_sizing"):
|
||||
st.write("#### Fleet Sizing Sweep (2, 4, 6, 8 AMRs)")
|
||||
st.dataframe(comps["fleet_sizing"], use_container_width=True)
|
||||
|
||||
if comps.get("dispatch_policies"):
|
||||
st.write("#### Dispatch Policy Heuristics")
|
||||
st.dataframe(comps["dispatch_policies"], use_container_width=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_streamlit_app()
|
||||
Reference in New Issue
Block a user