|
|
|
@ -1,30 +1,104 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div class="inspection-container">
|
|
|
|
|
<div class="inspection-header">
|
|
|
|
|
<SelectComponent />
|
|
|
|
|
<SelectComponent @selectChange="changeSelect" />
|
|
|
|
|
<div class="inspection-header-desc">
|
|
|
|
|
<div class="inspection-header-desc-item">
|
|
|
|
|
<!-- <a-badge status="success" text="Success" /> -->
|
|
|
|
|
<a-badge status="error" />
|
|
|
|
|
状态:<span>未连接</span>
|
|
|
|
|
<a-badge status="success" v-if="status === '已连接'" />
|
|
|
|
|
<a-badge status="error" v-else />
|
|
|
|
|
状态:<span>{{ status }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="inspection-header-desc-item">
|
|
|
|
|
FPS:<span>{{ socketData && socketData.fps ? socketData.fps : 0 }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="inspection-header-desc-item">
|
|
|
|
|
总帧数:<span>{{
|
|
|
|
|
socketData && socketData.frame_count ? socketData.frame_count : 0
|
|
|
|
|
}}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="inspection-header-desc-item">
|
|
|
|
|
监测目标数:<span>{{
|
|
|
|
|
socketData && socketData.detections.length ? socketData.detections.length : 0
|
|
|
|
|
}}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="inspection-header-desc-item"> FPS:<span>123</span> </div>
|
|
|
|
|
<div class="inspection-header-desc-item"> 总帧数:<span>123</span> </div>
|
|
|
|
|
<div class="inspection-header-desc-item"> 监测目标数:<span>123</span> </div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="inspection-content">
|
|
|
|
|
<div class="inspection-content-left">
|
|
|
|
|
<StatisticsComponent />
|
|
|
|
|
<StatisticsComponent
|
|
|
|
|
:statisData="socketData && socketData.detections ? socketData.detections : []"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="inspection-content-right">
|
|
|
|
|
<VideoStreamComponent />
|
|
|
|
|
<VideoStreamComponent
|
|
|
|
|
:statisData="socketData && socketData.detections ? socketData.detections : []"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import { SelectComponent, StatisticsComponent, VideoStreamComponent } from './index';
|
|
|
|
|
import axios from 'axios';
|
|
|
|
|
import { onMounted, ref } from 'vue';
|
|
|
|
|
import io from 'socket.io-client';
|
|
|
|
|
import { getClient, createConnection, clientSubscribe, destroyConnection } from '@/utils/mqtt';
|
|
|
|
|
import { airPortStore } from '@/store/modules/airport';
|
|
|
|
|
|
|
|
|
|
let socket;
|
|
|
|
|
|
|
|
|
|
const airPortStoreVal = airPortStore();
|
|
|
|
|
const UAVinfo = airPortStoreVal.getUAV;
|
|
|
|
|
const socketData = ref();
|
|
|
|
|
const status = ref('未连接');
|
|
|
|
|
function connectWebSocket() {
|
|
|
|
|
console.log('connectWebSocket');
|
|
|
|
|
// 初始化Socket连接
|
|
|
|
|
socket = io('http://192.168.10.131:9025');
|
|
|
|
|
|
|
|
|
|
// 连接事件
|
|
|
|
|
socket.on('connect', () => {
|
|
|
|
|
console.log('服务连接成功');
|
|
|
|
|
status.value = '已连接';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
socket.on('disconnect', () => {
|
|
|
|
|
console.log('服务器断开');
|
|
|
|
|
status.value = '未连接';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 接收检测结果
|
|
|
|
|
socket.on('detection_results', (data) => {
|
|
|
|
|
// console.log('收到检测结果:', data);
|
|
|
|
|
socketData.value = data;
|
|
|
|
|
// {
|
|
|
|
|
// "detections": [],
|
|
|
|
|
// "timestamp": 1756371710725,
|
|
|
|
|
// "fps": 18.2,
|
|
|
|
|
// "frame_count": 3269,
|
|
|
|
|
// "taskid": "03721e94-08da-42fc-aa0e-261ac0b4f2d9"
|
|
|
|
|
// }
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 错误处理
|
|
|
|
|
socket.on('error', (error) => {
|
|
|
|
|
console.log('WebSocket连接错误:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
const changeSelect = async (value?: any) => {
|
|
|
|
|
const topicUAVUrl = 'thing/product/' + UAVinfo.sn + '/osd';
|
|
|
|
|
// 订阅飞行器消息
|
|
|
|
|
clientSubscribe(topicUAVUrl, { qos: 1 });
|
|
|
|
|
};
|
|
|
|
|
const connected = ref(false);
|
|
|
|
|
const connectCallback = () => {
|
|
|
|
|
connected.value = true;
|
|
|
|
|
};
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
// getData();
|
|
|
|
|
createConnection(connectCallback);
|
|
|
|
|
connectWebSocket();
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.inspection-container {
|
|
|
|
|