Browse Source

信号曲线

master
xh 4 days ago
parent
commit
a792748d0f
  1. 3
      web/src/api/gas/tdengine/index.ts
  2. 234
      web/src/views/HandDevice/Home/components/HistoricalCurve.vue
  3. 1
      web/src/views/HandDevice/Home/index.vue

3
web/src/api/gas/tdengine/index.ts

@ -17,6 +17,9 @@ export interface tdStruct {
latitude?: number // 纬度 latitude?: number // 纬度
ts: number // 更新时间 ts: number // 更新时间
name?: string // 持有人姓名 name?: string // 持有人姓名
mem?: number|null,
sig?: string|null,
boot?: number|null,
} }
/** 原始数据 */ /** 原始数据 */

234
web/src/views/HandDevice/Home/components/HistoricalCurve.vue

@ -5,7 +5,7 @@
:before-close="handleClose" :before-close="handleClose"
:destroy-on-close="true" :destroy-on-close="true"
resizable resizable
size="550px"
size="480px"
> >
<template #header> <template #header>
<h4 <h4
@ -31,8 +31,11 @@
</div> </div>
</div> </div>
<div v-if="drawer && !loading"> <div v-if="drawer && !loading">
<Echart :options="gasLineOptions" :height="400" />
<Echart :options="gasLineOptions" :height="325" />
</div> </div>
<!-- <div v-if="drawer && !loading">
<Echart :options="gasSigLineOptions" :height="325" />
</div> -->
</div> </div>
<!-- <div> <!-- <div>
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
@ -138,6 +141,12 @@ const handleDateChange = () => {
const gas = computed(() => { const gas = computed(() => {
var value: (number | null)[] = [] var value: (number | null)[] = []
var battery: (number | null)[] = [] var battery: (number | null)[] = []
var mem: (number | null)[] = []
var rssi: (number | null)[] = []
var rsrp: (number | null)[] = []
var rsrq: (number | null)[] = []
var sinr: (number | null)[] = []
var time: string[] = [] var time: string[] = []
historicalData.value historicalData.value
// .filter((item) => typeof item.value === 'number') // .filter((item) => typeof item.value === 'number')
@ -152,6 +161,32 @@ const gas = computed(() => {
} else { } else {
value.push(null) value.push(null)
} }
if (item.mem) {
mem.push(item.mem / 1024)
} else {
mem.push(null)
}
if (item.sig) {
try {
let sig = JSON.parse(item.sig)
if (sig.length == 5) {
rssi.push(sig[0])
rsrp.push(sig[1])
rsrq.push(sig[2])
sinr.push(sig[4])
}
} catch {
rssi.push(null)
rsrp.push(null)
rsrq.push(null)
sinr.push(null)
}
} else {
rssi.push(null)
rsrp.push(null)
rsrq.push(null)
sinr.push(null)
}
time.push(item.timeStr) time.push(item.timeStr)
}) })
@ -159,6 +194,11 @@ const gas = computed(() => {
return { return {
value, value,
battery, battery,
mem,
rssi,
rsrp,
rsrq,
sinr,
time time
} }
}) })
@ -219,6 +259,64 @@ const gasLineOptions = computed<EChartsOption>(() => {
data: gas.value.battery, data: gas.value.battery,
animationDuration: 2800, animationDuration: 2800,
animationEasing: 'cubicInOut' animationEasing: 'cubicInOut'
},
{
name: '内存占用',
smooth: true,
type: 'line',
yAxisIndex: 1,
symbol: 'none',
data: gas.value.mem,
animationDuration: 2800,
animationEasing: 'cubicInOut',
tooltip: {
valueFormatter: function (value) {
if (value === null || value === undefined || isNaN(value)) {
return '-'
}
return Number(value).toFixed(3) + 'KB' //
}
}
},
{
name: 'RSSI',
smooth: true,
type: 'line',
yAxisIndex: 0,
symbol: 'none',
data: gas.value.rssi,
animationDuration: 2800,
animationEasing: 'cubicInOut'
},
{
name: 'RSRP',
smooth: true,
type: 'line',
yAxisIndex: 0,
symbol: 'none',
data: gas.value.rsrp,
animationDuration: 2800,
animationEasing: 'cubicInOut'
},
{
name: 'RSRQ',
smooth: true,
type: 'line',
yAxisIndex: 0,
symbol: 'none',
data: gas.value.rsrq,
animationDuration: 2800,
animationEasing: 'cubicInOut'
},
{
name: 'SINR',
smooth: true,
type: 'line',
yAxisIndex: 0,
symbol: 'none',
data: gas.value.sinr,
animationDuration: 2800,
animationEasing: 'cubicInOut'
} }
] ]
} }
@ -254,6 +352,138 @@ const gasLineOptions = computed<EChartsOption>(() => {
return option return option
}) })
// const gasSigLineOptions = computed<EChartsOption>(() => {
// const option: EChartsOption = {
// title: {
// text: '',
// left: 'center'
// },
// xAxis: {
// data: gas.value.time,
// boundaryGap: false,
// axisTick: {
// show: false
// }
// },
// tooltip: {
// trigger: 'axis',
// axisPointer: {
// type: 'cross'
// },
// padding: [5, 10]
// },
// yAxis: [
// {
// axisTick: {
// show: false
// }
// },
// {
// axisTick: {
// show: false
// }
// }
// ],
// legend: {
// // data: [],
// top: 50
// },
// series: [
// {
// name: '',
// smooth: true,
// type: 'line',
// yAxisIndex: 1,
// symbol: 'none',
// data: gas.value.battery,
// animationDuration: 2800,
// animationEasing: 'cubicInOut'
// },
// {
// name: '',
// smooth: true,
// type: 'line',
// yAxisIndex: 1,
// symbol: 'none',
// data: gas.value.mem,
// animationDuration: 2800,
// animationEasing: 'cubicInOut'
// },
// {
// name: 'RSSI',
// smooth: true,
// type: 'line',
// yAxisIndex: 0,
// symbol: 'none',
// data: gas.value.rssi,
// animationDuration: 2800,
// animationEasing: 'cubicInOut'
// },
// {
// name: 'RSRP',
// smooth: true,
// type: 'line',
// yAxisIndex: 0,
// symbol: 'none',
// data: gas.value.rsrp,
// animationDuration: 2800,
// animationEasing: 'cubicInOut'
// },
// {
// name: 'RSRQ',
// smooth: true,
// type: 'line',
// yAxisIndex: 0,
// symbol: 'none',
// data: gas.value.rsrq,
// animationDuration: 2800,
// animationEasing: 'cubicInOut'
// },
// {
// name: 'SINR',
// smooth: true,
// type: 'line',
// yAxisIndex: 0,
// symbol: 'none',
// data: gas.value.sinr,
// animationDuration: 2800,
// animationEasing: 'cubicInOut'
// }
// ]
// }
// const grid = {
// left: 20,
// right: 20,
// bottom: 10,
// top: 80,
// containLabel: true
// }
// if (gas.value.time.length >= 100) {
// grid.bottom = 50
// //
// option.dataZoom = [
// {
// type: 'slider',
// xAxisIndex: [0],
// bottom: 10,
// start: 0,
// end: 100
// },
// {
// type: 'inside',
// xAxisIndex: [0],
// start: 0,
// end: 100
// }
// ]
// } else {
// }
// option.grid = grid
// return option
// })
defineExpose({ defineExpose({
openDrawer openDrawer

1
web/src/views/HandDevice/Home/index.vue

@ -266,6 +266,7 @@ const getMarkers = async () => {
}) // }) //
return { return {
...i, ...i,
sig: i.sig?i.sig.replace(/,255/, ''):'',
coordinates: [i.longitude || 0, i.latitude || 0] as [number, number], coordinates: [i.longitude || 0, i.latitude || 0] as [number, number],
timeStr: i.time ? dayjs(i.time).format('YYYY-MM-DD HH:mm:ss') : '', timeStr: i.time ? dayjs(i.time).format('YYYY-MM-DD HH:mm:ss') : '',

Loading…
Cancel
Save