Skip to content

Diagnostic Test Debug Dashboard

A Laravel blade in the EMS frontend that lets an administrator activate each EMS diagnostic test from the browser and watch its result without using curl or the command line.

The dashboard is part of the SCADA frontend repository (GESS_SCADA2_V0.0.8_20.02.2025_git) and talks server-side to the Python EMS service (ems_settings_api.py) running in the ems-backend container.

Browser -> Laravel (ems-frontend) -> Python EMS (ems-backend:8080)

URL and access

Item Value
URL /diagnostic-test-debug-dashboard
Middleware auth + admin.or.superadmin
Access Admin / Super Admin only

Files

File (SCADA repo) Purpose
app/Http/Controllers/Admin/DiagnosticTestDebugController.php Renders the page, triggers tests, exposes JSON state/report endpoints
resources/views/admin/diagnosticTestDebugDashboard.blade.php The dashboard blade: buttons, state panel, result panel, auto-refresh
routes/web.php The four dashboard routes (appended at the end of the file)

Configuration

The controller reads its backend connection from the Laravel config ems.* (config/ems.php).

Env var Config key Default Purpose
EMS_BACKEND_URL ems.backend_url http://ems-backend:8080 Base URL of the Python EMS service
EMS_SETTINGS_API_TOKEN ems.settings_api_token (empty) Bearer token required by the EMS service when it is enabled
EMS_BACKEND_TOKEN ems.backend_token (empty) Fallback token if EMS_SETTINGS_API_TOKEN is not set

After changing the environment variables, run:

php artisan config:clear

The same EMS_SETTINGS_API_TOKEN value is used by the Python backend; when it is empty, the backend disables authentication (acceptable only on a closed network).

Routes

Method URI Route name Controller action
GET /diagnostic-test-debug-dashboard diagnostic-test-debug-dashboard.index index
POST /diagnostic-test-debug-dashboard/trigger diagnostic-test-debug-dashboard.trigger trigger
GET /diagnostic-test-debug-dashboard/state diagnostic-test-debug-dashboard.state state
GET /diagnostic-test-debug-dashboard/report diagnostic-test-debug-dashboard.report report

How it works

  1. On page load, the controller calls GET /api/v1/ems/diagnostic-tests for the current service state and test catalog, and GET /api/v1/ems/diagnostic-tests/report/latest for the latest XML report.
  2. Each test is rendered as a button. Clicking a button submits a POST form with mode_number to trigger, which forwards {"mode_number": N} to POST /api/v1/ems/diagnostic-tests.
  3. The backend returns 202 Accepted with a run_id; the dashboard shows the acceptance message and the raw response payload.
  4. While the page is open, JavaScript polls the state and report JSON endpoints every 5 seconds, so the result panel updates automatically once the run finishes. A manual Refresh button reloads the whole page.

UI sections

  • Diagnostic service state — current state (idle/running/queued), active flag and queued count.
  • Activate a test — one button per implemented test:
  • #1 State of Health (SOH) Estimation
  • #2 State of Charge (SOC) Validation
  • #3 Cell Balancing Test
  • #4 Internal Resistance (Impedance) Test
  • #5 Thermal Response Test
  • Trigger response — the JSON returned by the backend when a test was accepted.
  • Latest result — the most recent XML diagnostic report.

The button list is driven by the backend catalog when it is reachable; if not, the controller falls back to the five implemented tests above.

Backend API used

Method Path Purpose
POST /api/v1/ems/diagnostic-tests Trigger a test ({"mode_number": N})
GET /api/v1/ems/diagnostic-tests State, schedules and test catalog
GET /api/v1/ems/diagnostic-tests/report/latest Latest XML diagnostic report

See HTTP API Endpoints and Diagnostic Tests — Overview & API for the full request/response contract.

Failure behaviour

  • If the EMS backend is unreachable, the page still renders the buttons and shows an error banner with the connection error instead of failing with a blank page.
  • If no report exists yet, the result panel shows No report yet.
  • A failed trigger (for example a non-202 response) is reported as an error banner with the response status and body.

Troubleshooting

cURL error 7: Failed to connect to ems-backend port 8000

The Python EMS service listens on port 8080 by default (ems_settings_api.py server --port ${EMS_SETTINGS_API_PORT:-8080}). If the dashboard header shows http://ems-backend:8000, the frontend is configured with the wrong port.

Fix it by setting the correct URL and clearing the cached config:

# in the Laravel app .env
EMS_BACKEND_URL=http://ems-backend:8080

php artisan config:clear

In the Docker Compose stack the ems-frontend service must also pass EMS_BACKEND_URL: http://ems-backend:8080 (not 8000), and the ems-backend service must expose 8080.

If it still fails on 8080, check that the backend HTTP API is actually up:

docker logs ems-backend
docker exec ems-frontend curl -s http://ems-backend:8080/api/v1/ems/health

Verification

From the SCADA repository root:

php -l app/Http/Controllers/Admin/DiagnosticTestDebugController.php
php artisan route:list --name=diagnostic-test-debug-dashboard
php artisan view:cache