generated from Grigo/AndroidTemplate
added refference point
This commit is contained in:
@@ -887,6 +887,26 @@ function metricCard(title, metric, suffix = '%') {
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function formatReferenceTxParams(params) {
|
||||
if (!params || !Object.keys(params).length) return 'TX параметры: —';
|
||||
const parts = [];
|
||||
if (params.frequency_hz != null) parts.push(`FQ ${(Number(params.frequency_hz) / 1e6).toFixed(3)} MHz`);
|
||||
if (params.power_dbm != null) parts.push(`PW ${params.power_dbm} dBm`);
|
||||
if (params.spreading_factor != null) parts.push(`SF ${params.spreading_factor}`);
|
||||
if (params.bandwidth_khz != null) parts.push(`BW ${params.bandwidth_khz} kHz`);
|
||||
if (params.code_rate != null) parts.push(`CR ${params.code_rate}`);
|
||||
if (params.preamble_length != null) parts.push(`PL ${params.preamble_length}`);
|
||||
if (params.tx_timeout_ms != null) parts.push(`TM ${params.tx_timeout_ms} ms`);
|
||||
if (params.crc_enabled != null) parts.push(`CRC ${params.crc_enabled ? 'On' : 'Off'}`);
|
||||
return parts.length ? `TX параметры: ${parts.join(' · ')}` : 'TX параметры: —';
|
||||
}
|
||||
|
||||
function formatReferenceRxPosition(pos) {
|
||||
if (!pos || pos.lat == null || pos.lon == null) return 'RX координаты: —';
|
||||
const device = pos.device_id ? `${deviceDisplayName(pos)} · ` : '';
|
||||
return `RX координаты: ${device}${Number(pos.lat).toFixed(6)}, ${Number(pos.lon).toFixed(6)}`;
|
||||
}
|
||||
|
||||
function drawReferencePointChart(samples) {
|
||||
const canvas = document.getElementById('referencePointChart');
|
||||
if (!canvas) return;
|
||||
@@ -991,9 +1011,15 @@ async function showReferencePoint(sessionId) {
|
||||
if (!res.ok) throw new Error('reference point ' + res.status);
|
||||
const data = await res.json();
|
||||
const stats = data.stats || {};
|
||||
const ctx = data.reference_context || {};
|
||||
if (summary) {
|
||||
summary.innerHTML = `<div><b>${escapeHtml(data.label || 'Реперная точка')} #${data.id}</b></div>
|
||||
<div>${escapeHtml(deviceDisplayName(data))} · samples: ${data.sample_count || 0} · ${escapeHtml(data.status || '')}</div>
|
||||
<div class="metric-card"><b>Контекст</b>
|
||||
<div>${escapeHtml(formatReferenceTxParams(ctx.tx_params))}</div>
|
||||
<div>${escapeHtml(formatReferenceRxPosition(ctx.rx_position))}</div>
|
||||
<div class="muted">Роли: ${escapeHtml((ctx.roles || []).join(', ') || '—')}</div>
|
||||
</div>
|
||||
${metricCard('PER', stats.per_percent)}
|
||||
${metricCard('RX Quality', stats.rx_quality_percent)}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user