抢夺控制权优化

main
刘妍 2 months ago
parent 5820971d5c
commit 5a7ec0e1f0

@ -30,12 +30,14 @@
<a-button @click="emits('clickFlyTo')"></a-button>
<!-- <a-button>智能环绕</a-button> -->
<a-button @click="returnVoyage"></a-button>
<a-button @click="obtain" style="background-color: #1b71e8; border: none"
>获取飞行器控制权</a-button
>
<a-button @click="enterDRC" style="background-color: #24d365; border: none"
>进入飞行控制</a-button
>
<a-button @click="obtain" style="background-color: #1b71e8; border: none">
<template #icon v-if="flightGrab"><CheckOutlined /></template>
获取飞行器控制权
</a-button>
<a-button @click="enterDRC" style="background-color: #24d365; border: none">
<template #icon v-if="modeEnter"><CheckOutlined /></template>
进入飞行控制
</a-button>
<a-button @click="exitDRC" style="background-color: #e3150e; border: none"
>退出飞行控制</a-button
>
@ -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();

@ -17,7 +17,10 @@
</div>
<div class="content">
<div class="content-button">
<a-button @click="obtain"></a-button>
<a-button @click="obtain">
<template #icon v-if="grabBtn"><CheckOutlined /></template>
获取相机控制权
</a-button>
<a-button @click="singleShot"></a-button>
</div>
<div class="direction-controller">
@ -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));
}
}

Loading…
Cancel
Save