|
|
|
@ -1,12 +1,12 @@
|
|
|
|
|
<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>
|
|
|
|
@ -42,57 +42,15 @@
|
|
|
|
|
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';
|
|
|
|
|
|
|
|
|
|
const getData = () => {
|
|
|
|
|
const data = {
|
|
|
|
|
rtmp_url: 'rtmp://box.wisestcity.com:1935/live/7',
|
|
|
|
|
push_url: 'rtmp://box.wisestcity.com:1935/live/yolov8x',
|
|
|
|
|
imgsz: 640,
|
|
|
|
|
frame_skip: 1,
|
|
|
|
|
model_name: 'yolov8x.pt',
|
|
|
|
|
taskname: '兰山区火情监测日常任务20250828',
|
|
|
|
|
taskid: 'bbfc3789-92e2-4658-98e5-d218e77a981c',
|
|
|
|
|
tag: [0, 1, 2, 3, 4, 5, 7],
|
|
|
|
|
};
|
|
|
|
|
const url = 'sltest/start_detection';
|
|
|
|
|
|
|
|
|
|
axios
|
|
|
|
|
.post(url, data, {
|
|
|
|
|
headers: { 'Content-Type': 'application/json' },
|
|
|
|
|
})
|
|
|
|
|
.then((res) => {
|
|
|
|
|
console.log('helloworld', res);
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
console.log('err', err);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
let socket;
|
|
|
|
|
|
|
|
|
|
// const connectWebSocket = () => {
|
|
|
|
|
// const socket = new WebSocket('ws://192.168.10.131:9025/socket.io');
|
|
|
|
|
|
|
|
|
|
// // 同样可以使用 addEventListener 绑定事件
|
|
|
|
|
// // 监听连接建立事件
|
|
|
|
|
// socket.onopen = function () {
|
|
|
|
|
// console.log('WebSocket连接已建立');
|
|
|
|
|
|
|
|
|
|
// // 向服务器发送消息
|
|
|
|
|
// socket.send('Hello Server!');
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
// // 监听接收到消息事件
|
|
|
|
|
// socket.onmessage = function (event) {
|
|
|
|
|
// const message = event.data;
|
|
|
|
|
// console.log('接收到服务器消息:' + message);
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
// // 监听连接关闭事件
|
|
|
|
|
// socket.onclose = function () {
|
|
|
|
|
// console.log('WebSocket连接已关闭');
|
|
|
|
|
// };
|
|
|
|
|
// };
|
|
|
|
|
const airPortStoreVal = airPortStore();
|
|
|
|
|
const UAVinfo = airPortStoreVal.getUAV;
|
|
|
|
|
const socketData = ref();
|
|
|
|
|
const status = ref('未连接');
|
|
|
|
|
function connectWebSocket() {
|
|
|
|
|
console.log('connectWebSocket');
|
|
|
|
|
// 初始化Socket连接
|
|
|
|
@ -101,10 +59,12 @@
|
|
|
|
|
// 连接事件
|
|
|
|
|
socket.on('connect', () => {
|
|
|
|
|
console.log('服务连接成功');
|
|
|
|
|
status.value = '已连接';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
socket.on('disconnect', () => {
|
|
|
|
|
console.log('服务器断开');
|
|
|
|
|
status.value = '未连接';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 接收检测结果
|
|
|
|
@ -125,8 +85,18 @@
|
|
|
|
|
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>
|
|
|
|
|