feat(realtime): 增加目标接收计数与频率计算支持
- 在 Target 结构体中新增 received_count 字段,用于跟踪每个目标在当前内存轨迹中的接收更新次数。 - 实现 ReceptionRate 结构体,计算目标更新频率,并在 State 中维护每个目标的接收率。 - 更新相关测试,确保接收计数和频率计算的准确性。 - 修改 Web UI 以显示目标的接收频率,提升用户体验。 - 升级协议版本至 4,确保后端、Worker 和前端的一致性。
This commit is contained in:
@@ -173,14 +173,14 @@ function markerCoordinate(id,index){
|
||||
if(id===selected&&rawFocus&&passesFilters(id))return {coordinate:rawFocus,unverified:true};
|
||||
return null;
|
||||
}
|
||||
function markerAge(value){if(!liveConnected)return '连接断开';if(!Number.isFinite(value)||value<0)return '—';if(value<1000)return `${Math.round(value)} ms`;if(value<10000)return `${(value/1000).toFixed(1)} 秒`;return `${Math.round(value/1000)} 秒`;}
|
||||
function markerFrequency(value){if(!liveConnected)return '连接断开';if(!Number.isFinite(value)||value<0)return '—';if(value===0)return '0 Hz';if(value<0.1)return `${value.toFixed(2)} Hz`;if(value<100)return `${value.toFixed(1)} Hz`;return `${Math.round(value)} Hz`;}
|
||||
function createTargetMarker(id,coordinate){
|
||||
const root=document.createElement('div');root.className='rt-target-pin';
|
||||
const card=document.createElement('div');card.className='rt-target-info';
|
||||
const header=document.createElement('div');header.className='rt-target-info-head';
|
||||
const name=document.createElement('span');name.className='rt-target-info-id';name.textContent=id;name.title=id;
|
||||
const age=document.createElement('span');age.className='rt-target-info-age';age.title='该目标最近一次接收数据到服务端生成推送数据的时间,不代表定位精度或完整传输延迟';
|
||||
header.append(name,age);
|
||||
const frequency=document.createElement('span');frequency.className='rt-target-info-frequency';frequency.title='服务端接受的目标数据更新频率;多个接收来源合计,5 秒无更新时显示 0 Hz';
|
||||
header.append(name,frequency);
|
||||
const coordinates=document.createElement('div');coordinates.className='rt-target-info-coordinates';
|
||||
const longitude=document.createElement('span');const latitude=document.createElement('span');coordinates.append(longitude,latitude);
|
||||
const height=document.createElement('div');height.className='rt-target-info-height';
|
||||
@@ -192,7 +192,7 @@ function createTargetMarker(id,coordinate){
|
||||
const point=document.createElement('i');point.className='rt-drone-point';
|
||||
root.append(card,icon,point);
|
||||
const marker=new maplibre.Marker({element:root,anchor:'bottom'}).setLngLat(coordinate).addTo(map);
|
||||
return {marker,root,card,name,age,longitude,latitude,height,verification,icon,coordinate:[...coordinate]};
|
||||
return {marker,root,card,name,frequency,longitude,latitude,height,verification,icon,coordinate:[...coordinate]};
|
||||
}
|
||||
function syncTargetMarkers(force=false){
|
||||
if(!map||!latest)return;
|
||||
@@ -225,7 +225,7 @@ function syncTargetMarkers(force=false){
|
||||
const value=markerInfos?.[index*3+1],heightKind=markerInfos?.[index*3+2];
|
||||
const label=({1:'高度',2:'几何高度',3:'离地高度',4:'相对高度(原始)',5:'气压高度'})[heightKind]||'高度';
|
||||
entry.height.textContent=`${label} ${Number.isFinite(value)?`${value.toFixed(1)} m`:'—'}`;
|
||||
entry.age.textContent=`数据年龄 ${markerAge(markerInfos?.[index*3])}`;
|
||||
entry.frequency.textContent=`数据频率 ${markerFrequency(markerInfos?.[index*3])}`;
|
||||
entry.verification.textContent=position.unverified?'坐标待核实':'';
|
||||
}
|
||||
if(updateText)lastMarkerText=now;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
.rt-target-info{box-sizing:border-box;width:100%;padding:7px 9px;border:1px solid #d6e9f04a;border-radius:6px;background:rgba(9,20,27,.38);backdrop-filter:blur(5px);-webkit-backdrop-filter:blur(5px);text-shadow:0 1px 3px #000,0 0 4px #000}
|
||||
.rt-target-info-head{display:flex;align-items:center;justify-content:space-between;gap:6px;padding-bottom:4px;border-bottom:1px solid #e0f2fa35}
|
||||
.rt-target-info-id{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;font-weight:600;letter-spacing:.01em}
|
||||
.rt-target-info-age{flex:none;white-space:nowrap;color:#d6e8ee;font-size:10px}
|
||||
.rt-target-info-frequency{flex:none;white-space:nowrap;color:#d6e8ee;font-size:10px}
|
||||
.rt-target-info-coordinates{display:flex;justify-content:space-between;gap:8px;margin-top:4px;font-size:11px;font-variant-numeric:tabular-nums;white-space:nowrap}
|
||||
.rt-target-info-height,.rt-target-info-verification{margin-top:2px;font-size:11px;font-variant-numeric:tabular-nums}
|
||||
.rt-target-info-verification{color:#ffe0a2}.rt-target-info-verification:empty{display:none}
|
||||
|
||||
Reference in New Issue
Block a user