feat: add live Gen5W telemetry dashboard

This commit is contained in:
seo-amugae committed 2026-10-18 16:20:34 +09:00
1 parent 46d95fd395
commit d006fed6db
4 files changed
+1083

No files matched your search

+59
View File
@@ -0,0 +1,59 @@
<?php
declare(strict_types=1);
if (PHP_SAPI !== 'cli') {
http_response_code(404);
exit;
}
require_once dirname(__DIR__) . '/NiroTelemetrySnapshot.php';
function check(bool $condition, string $message): void
{
if (!$condition) {
fwrite(STDERR, "FAIL: {$message}\n");
exit(1);
}
}
$now = time();
$summary = NiroTelemetrySnapshot::summarize([
'received_at' => $now,
'availability' => 'online',
'state' => [
'_sample_epoch' => $now - 3,
'meta_system_dumpsys_ok' => 'true',
'meta_hscan_dumpsys_ok' => 'false',
'system_root_ign' => 'true',
'system_individualdrivemode_vehicle_speed' => '27',
'system_individualdrivemode_gear_status' => 'D(0x5)',
'system_root_mbatterysoc' => '93',
'hev_micom_hevstatus_mdisplaysoc' => '255',
'hev_micom_hevstatus_odometer' => '2596537',
'bcm_micom_bcmstatus_mdrvopenedstate' => '0',
'datc_micom_datcstatus_mambienttempc' => '25.0',
'mode_root_current_mode_real' => 'BLUETOOTH STREAMING (0x36)',
],
], ['stale_after' => 20]);
check($summary['available'] === true, 'snapshot is available');
check($summary['online'] === true, 'availability topic is respected');
check($summary['stale'] === false, 'fresh sample is not stale');
check($summary['metric_count'] === 11, 'metric count excludes sample epoch');
check($summary['services'] === ['available' => 1, 'total' => 2], 'service health is counted');
check($summary['metrics']['speed']['value'] === '27', 'speed mapping');
check($summary['metrics']['gear']['value'] === 'D(0x5)', 'gear mapping');
check($summary['metrics']['outside_temperature']['value'] === '25.0', 'climate mapping');
check($summary['metrics']['driver_door']['supported'] === true, 'zero is supported');
check($summary['metrics']['distance_to_empty']['supported'] === false, 'missing value is unsupported');
check(!array_key_exists('state', $summary), 'raw snapshot is not exposed');
$stale = NiroTelemetrySnapshot::summarize([
'received_at' => $now - 90,
'availability' => 'offline',
'state' => ['_sample_epoch' => $now - 90],
], ['stale_after' => 20]);
check($stale['online'] === false, 'offline state is exposed');
check($stale['stale'] === true, 'old sample is stale');
echo "PASS\n";