From 5a7ec0e1f09e00a05b6692f42e53b39b86ba91b8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=88=98=E5=A6=8D?= <1455167345@qq.com>
Date: Thu, 10 Jul 2025 17:20:04 +0800
Subject: [PATCH] =?UTF-8?q?=E6=8A=A2=E5=A4=BA=E6=8E=A7=E5=88=B6=E6=9D=83?=
=?UTF-8?q?=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../flightoperation/src/FlightControl.vue | 49 ++++++++++++-------
.../flightoperation/src/LoadControl.vue | 22 ++++++---
2 files changed, 46 insertions(+), 25 deletions(-)
diff --git a/src/views/demo/workmanagement/flightoperation/src/FlightControl.vue b/src/views/demo/workmanagement/flightoperation/src/FlightControl.vue
index 2883395..1c73d4b 100644
--- a/src/views/demo/workmanagement/flightoperation/src/FlightControl.vue
+++ b/src/views/demo/workmanagement/flightoperation/src/FlightControl.vue
@@ -30,12 +30,14 @@
指点飞行
一键返航
- 获取飞行器控制权
- 进入飞行控制
+
+
+ 获取飞行器控制权
+
+
+
+ 进入飞行控制
+
退出飞行控制
@@ -84,7 +86,7 @@
destroySeizeConnection,
connection,
} from '@/utils/mqtt';
- import { CloseOutlined } from '@ant-design/icons-vue';
+ import { CloseOutlined, CheckOutlined } from '@ant-design/icons-vue';
import { vDrag } from '@/utils/drag';
import { drcDownTopicReize, eventsTopicSubscribeReize } from '@/utils/debugging/events';
import {
@@ -127,7 +129,7 @@
const airportVal: any = ref({
mode_code: 0,
});
-
+ const bid = buildGUID();
//修改redis用户锁
const changeRedisUser = (val: boolean) => {
const querys = redisUser.value;
@@ -158,7 +160,6 @@
emits('clickTakeOff');
changeRedisUser(true);
};
-
// 获取
const obtain = () => {
// if (!getClient()) {
@@ -168,11 +169,15 @@
createMessage.success('当前有用户正在操作,请稍后再试');
return;
}
+ if (flightGrab.value) {
+ createMessage.warning('已经获取了飞行器控制权');
+ return;
+ }
createMessage.info('正在获取飞行器控制权,请稍候');
changeRedisUser(true);
// 飞行控制权抢夺
servicesTopic({
- bid: buildGUID(),
+ bid: bid,
method: 'flight_authority_grab',
tid: buildGUID(),
timestamp: new Date().getTime(),
@@ -180,7 +185,7 @@
});
// 负载控制权抢夺
servicesTopic({
- bid: buildGUID(),
+ bid: bid,
method: 'payload_authority_grab',
tid: buildGUID(),
timestamp: new Date().getTime(),
@@ -191,8 +196,13 @@
services_replyTopic();
};
// 一键返航
+ const returnBtn = ref(false);
const returnVoyage = () => {
- // 老的
+ if (returnBtn.value) {
+ createMessage.warning('正在返航或已返航,请勿重复操作');
+ return;
+ }
+ returnBtn.value = true;
servicesTopic({
bid: buildGUID(),
method: 'return_home',
@@ -200,7 +210,6 @@
timestamp: new Date().getTime(),
data: {},
});
- // 新的servicesTopicReize
};
const seq = ref(1);
const changeDRC = (type, value) => {
@@ -243,7 +252,7 @@
const { protocol, host, port, endpoint } = connection;
const connectUrl = `${protocol}://${host}:${port}${endpoint}`;
const querys = {
- bid: buildGUID(),
+ bid: bid,
data: {
hsi_frequency: 10,
mqtt_broker: {
@@ -289,7 +298,7 @@
const exitDRC = () => {
createMessage.info('正在退出飞行控制,请稍后');
const querys = {
- bid: buildGUID(),
+ bid: bid,
data: {},
tid: buildGUID(),
timestamp: new Date().getTime(),
@@ -311,7 +320,7 @@
if (rs.data.mode_code || rs.data.mode_code == 0) {
airportVal.value.mode_code = rs.data.mode_code;
}
- if (rs.method == 'flight_authority_grab') {
+ if (rs.method == 'flight_authority_grab' && rs.bid == bid) {
if (rs.data.result == 0) {
flightGrab.value = true;
createMessage.success('飞行控制权抢夺成功');
@@ -320,7 +329,7 @@
createMessage.error('飞行控制权抢夺失败,' + errorName(rs.data.result));
}
}
- if (rs.method == 'drc_mode_enter') {
+ if (rs.method == 'drc_mode_enter' && rs.bid == bid) {
if (rs.data.result == 0) {
modeEnter.value = true;
createMessage.success('进入指令飞行控制模式成功');
@@ -329,10 +338,11 @@
createMessage.error('进入指令飞行控制模式失败,' + errorName(rs.data.result));
}
}
- if (rs.method == 'drc_mode_exit') {
+ if (rs.method == 'drc_mode_exit' && rs.bid == bid) {
if (rs.data.result == 0) {
modeEnter.value = false;
createMessage.success('退出指令飞行控制模式成功');
+ changeRedisUser(false);
} else {
createMessage.error('退出指令飞行控制模式失败,' + errorName(rs.data.result));
}
@@ -342,8 +352,10 @@
if (rs.data.result == 0) {
createMessage.success('一键返航成功');
monitorDRC.value = false;
+ returnBtn.value = true;
} else {
createMessage.error('一键返航失败,' + errorName(rs.data.result));
+ returnBtn.value = false;
}
}
if (rs.method === 'takeoff_to_point') {
@@ -354,7 +366,6 @@
}
}
if (rs.method === 'drc_status_notify' && monitorDRC.value) {
- console.log('drc_status_notify', rs.data);
if (rs.data.result == 0) {
if (rs.data.drc_state == 0) {
drc_eart_beat();
diff --git a/src/views/demo/workmanagement/flightoperation/src/LoadControl.vue b/src/views/demo/workmanagement/flightoperation/src/LoadControl.vue
index 1d617ac..cfae880 100644
--- a/src/views/demo/workmanagement/flightoperation/src/LoadControl.vue
+++ b/src/views/demo/workmanagement/flightoperation/src/LoadControl.vue
@@ -17,7 +17,10 @@
-
获取相机控制权
+
+
+ 获取相机控制权
+
单拍
@@ -64,7 +67,7 @@
destroySeizeConnection,
connection,
} from '@/utils/mqtt';
- import { CloseOutlined } from '@ant-design/icons-vue';
+ import { CloseOutlined, CheckOutlined } from '@ant-design/icons-vue';
import { vDrag } from '@/utils/drag';
import { buildGUID } from '@/utils/uuid';
import { servicesTopic, services_replyTopic, errorName } from '@/utils/debugging/remote';
@@ -187,7 +190,7 @@
cameraZoom();
},
);
-
+ const bid = buildGUID();
// 变焦
const cameraZoom = () => {
if (!flightGrab.value) {
@@ -234,6 +237,7 @@
}
});
};
+ const grabBtn = ref(false);
const obtain = () => {
// if (!getClient()) {
// createConnection();
@@ -242,10 +246,14 @@
createMessage.success('当前有用户正在操作,请稍后再试');
return;
}
+ if (grabBtn.value) {
+ createMessage.warning('已经获取了飞行器控制权');
+ return;
+ }
changeRedisUser(true);
// 飞行控制权抢夺
servicesTopic({
- bid: buildGUID(),
+ bid: bid,
method: 'flight_authority_grab',
tid: buildGUID(),
timestamp: new Date().getTime(),
@@ -253,7 +261,7 @@
});
// 负载控制权抢夺
servicesTopic({
- bid: buildGUID(),
+ bid: bid,
method: 'payload_authority_grab',
tid: buildGUID(),
timestamp: new Date().getTime(),
@@ -329,12 +337,14 @@
createMessage.error('拍照失败,' + errorName(rs.data.result));
}
}
- if (rs.method == 'flight_authority_grab') {
+ if (rs.method == 'flight_authority_grab' && rs.bid == bid) {
if (rs.data.result == 0) {
flightGrab.value = true;
+ grabBtn.value = true;
createMessage.success('相机控制权获取成功');
} else {
flightGrab.value = false;
+ grabBtn.value = false;
createMessage.error('相机控制权获取失败,' + errorName(rs.data.result));
}
}