main
徐景良 2025-11-19 16:10:41 +08:00
parent fa6cb383c4
commit 13b17ba157
2 changed files with 115 additions and 49 deletions

View File

@ -101,7 +101,7 @@
</div>
<!-- 无人机操作 -->
<div class="monitor-video-container" v-drag v-if="uavControllerShow">
<div class="monitor-video-container" v-drag v-show="uavControllerShow">
<div class="left-panel">
<div class="title">无人机视频
@ -602,6 +602,70 @@
airPortStoreVal.setProject(res.projectId);
});
// mqtt
if (!getClient() || !getClient().connected) {
createConnection();
}
setTimeout(() => {
getClient().on('message', (topic, message) => {
const rs = JSON.parse(message);
if (rs.method === 'takeoff_to_point' && rs.bid == bid) {
if (rs.data.result == 0) {
createMessage.success('一键起飞成功');
} else {
createMessage.error('一键起飞失败,' + errorName(rs.data.result));
}
}
//
if (rs.method == 'fly_to_point' && rs.bid == bid) {
if (rs.data.result == 0) {
createMessage.success('指点飞行成功');
} else {
createMessage.error('指点飞行失败,' + errorName(rs.data.result));
}
}
if (rs.method == 'live_start_push' && rs.tid == startTid) {
if (rs.data.result == 0) {
createMessage.success('无人机开始直播成功');
player.src(live_info.url + liveCode.value + '.flv');
player.play();
isUAVLive.value = false;
} else if (rs.data.result == 513003) {
createMessage.success('无人机直播已开启');
playVideo();
return null;
player.src(live_info.url + liveCode.value + '.flv');
player.play();
isUAVLive.value = false;
} else {
createMessage.error('开始直播失败,' + errorName(rs.data.result));
isUAVLive.value = true;
}
}
console.log("message995",rs.method);
console.log("message996",topic,rs.data.longitude);
console.log("message998",airPortStoreVal.getUAV.sn);
//
// && topic=='thing/product/' + airPortStoreVal.getUAV.sn + '/osd'
if (rs.data.latitude && rs.data.longitude && topic == 'thing/product/' + airPortStoreVal.getUAV.sn + '/osd') {
console.log("messge999",rs.data.latitude,rs.data.longitude);
handlerUpdateUavPostion(rs.data.longitude,rs.data.latitude)
}
});
}, 5000);
//
EventBus.on(props.chartConfig.id + 'dataupdate', (data) => {
return null;
@ -778,7 +842,7 @@
break;
case "uav":
handlerUavVerify(item);
createUavConnection();
break;
case "helicopter":
@ -1230,55 +1294,59 @@
const uavControllerShow = ref(false);
const flyControlShow = ref(false);
function createUavConnection(){
//
async function createUavConnection(){
clueInfo.value.lng = clueInfo.value.lng;
clueInfo.value.lat = clueInfo.value.lat;
listDronePort({
await listDronePort({
lng: clueInfo.value.lng,
lat: clueInfo.value.lat
}).then((res) => {
console.log("res1123",res);
//
if(res.length == 0){
return null;
ElMessage({
message:"周边没有机场!",
type: 'error',
})
return false;
}
airPortStoreVal.setAirPort('sn', res[0].droneportsn);
airPortStoreVal.setUAV('sn', res[0].Sn);
airPortStoreVal.setGateway(res[0].GateWay);
//
clientSubscribe("thing/product/"+res[0].Sn+"/osd",{ qos: 1 });
applyDroneControl({ dronePortSn: res[0].droneportsn }).then((res) => {
//
if(res.code == 400){
ElMessage({
message:"无人机已被锁定!",
type: 'error',
})
return false;
}
droneData.value = res;
//
handlerUavVerify();
});
//
setTimeout(() => {
if (!getClient()) {
createConnection();
}
setTimeout(() => {
//
getClient().on("message",(topic,message)=>{
console.log("连接成功!");
})
getClient().on('message', (topic, message) => {
const rs = JSON.parse(message);
if (rs.method === 'takeoff_to_point' && rs.bid == bid) {
if (rs.data.result == 0) {
createMessage.success('一键起飞成功');
//
saveHandFlyTask({
flightId: airPortStoreVal.getFlightId,
workspaceId: airPortStoreVal.getProject,
}).then((res) => {
if (res) {
setTimeout(() => {
airPortStoreVal.setTaskId(res.taskId);
}, 1000);
}
});
} else {
createMessage.error('一键起飞失败,' + errorName(rs.data.result));
}
@ -1293,7 +1361,8 @@
}
//
if (rs.data.latitude && rs.data.longitude) {
// && topic=='thing/product/' + airPortStoreVal.getUAV.sn + '/osd'
if (rs.data.latitude && rs.data.longitude && topic=='thing/product/' + airPortStoreVal.getUAV.sn + '/osd') {
console.log("messge9998",JSON.stringify(rs.data));
handlerUpdateUavPostion(rs.data.longitude,rs.data.latitude)
}
@ -1301,12 +1370,14 @@
});
}, 5000);
}, 500);
});
return true;
}).catch((res)=>{
return false;
})
}
function handlerUavVerify(item){
//
createUavConnection();
function handlerUavVerify(){
clueInfo.value.lng = clueInfo.value.lng
clueInfo.value.lat = clueInfo.value.lat;
@ -1318,13 +1389,9 @@
_alt:window.globalMap.getHeight([parseFloat(clueInfo.value.lng),parseFloat(clueInfo.value.lat)])+100
}
if(!droneData.value?.droneInDock){
ElMessage({
message:"周边没有机场!",
type: 'error',
})
return null;
}
// if(!droneData.value?.droneInDock){
// return null;
// }
//
if (droneData.value.droneInDock == 1) {
@ -1398,7 +1465,6 @@
});
}
}
//
let uavGraphicLayer:mars3d.layer.GraphicLayer;
@ -1442,13 +1508,8 @@
//
graphic.on(mars3d.EventType.click, function (event: any) {
var data = event.graphic.options.attr;
//
uavControllerShow.value = true;
isUAVLive.value = false;
setTimeout(function(){
playVideo();
},500);
// startLiveFun();
});
uavGraphicLayer.addGraphic(graphic);
@ -2102,10 +2163,10 @@
tid: startTid,
timestamp: new Date().getTime(),
data: {
url_type: 1, // 0 = RTMP 1GB28181 3WebRTC 4
url: live_info.rtmp + liveCode.value,
url_type: 1,
url: live_info.rtmp + uav.sn,
video_id: uav.video_id,
video_quality: 3, // 0=1=2=3=4=
video_quality: 3,
},
};
servicesTopic(querys);
@ -2115,6 +2176,11 @@
const liveCode = ref('7');
const playVideo = () => {
//
uavControllerShow.value = true;
isUAVLive.value = false;
alert(live_info.url + uav.sn + '.flv')
player = TCPlayer('player-container-id-live', {
sources: [