提交 a65eef25 作者: 翁进城

fix: 起飞前判断航线是否上传成功

上级 d6ba18b8
......@@ -173,6 +173,14 @@ function initUavRealTimeData() {
down45Link 4/5G下行速率,单位字节/秒 Long
} */
flightMode: "UNKNOWN",
uploadAirline: { //上传的航线
finishedAction: '', //航点任务完成后,飞机将采取的行动
headingMode: '', //飞机在航点之间移动时的航向模式
isExitMissionOnRCSignalLostEnabled: Boolean, //飞机在航点之间移动时的航向模式
maxFlightSpeed: 0, //航线飞行最大速度,px4无人机默认最大12m
autoFlightSpeed: 0, //航线飞行速度默认5m
waypointList: null
},
};
}
......@@ -197,6 +205,7 @@ const state = {
showPlayer: false, //显示播放器
showPanel: false, //显示数据面板
isQingLiu: null, // 当前视频播放的是否为清流
waitAirlineUpload: false, //是否正在等待航线上传
};
const mutations = {
......@@ -231,7 +240,10 @@ const actions = {
commit("setState", { key: "mountList", value: [] });
commit("setState", { key: "selectMount", value: null });
commit("setState", { key: "showVideo", value: false });
commit("setState", { key: "uavRealTimeData", value: initUavRealTimeData() });
commit("setState", {
key: "uavRealTimeData",
value: initUavRealTimeData(),
});
positions = [];
},
......@@ -298,6 +310,7 @@ const actions = {
const type275 = data[275]?.data; // 健康管理
const type270 = data[270]?.data; // 飞控应答消息
const type260 = data[260]?.data; // 无人机提示信息
const type261 = data[261]?.data; // 航线上传完成信息
let msgList = state.uavRealTimeData.msgList || [];
......@@ -308,10 +321,10 @@ const actions = {
);
if (!findMsg) {
msgList.push({
grade: 'AUTO',
grade: "AUTO",
text: type270.text,
time: moment(type270.timestamp).format("YYYY-MM-DD HH:mm:ss"),
timestamp: type270.timestamp
timestamp: type270.timestamp,
});
}
}
......@@ -322,10 +335,23 @@ const actions = {
);
if (!findMsg) {
msgList.push({
grade: type260.grade <= 2 ? "[危险]" : type260.grade == 3 ? "[错误]" : type260.grade ==4 ? "[警告]" : type260.grade == 5 ? "[通知]" : type260.grade == 6 ? "[正常]" : type260.grade == 7 ? "[调试]" : "AUTO",
grade:
type260.grade <= 2
? "[危险]"
: type260.grade == 3
? "[错误]"
: type260.grade == 4
? "[警告]"
: type260.grade == 5
? "[通知]"
: type260.grade == 6
? "[正常]"
: type260.grade == 7
? "[调试]"
: "AUTO",
text: type260.msg,
time: moment(type260.timestamp).format("YYYY-MM-DD HH:mm:ss"),
timestamp: type260.timestamp
timestamp: type260.timestamp,
});
}
}
......@@ -363,6 +389,7 @@ const actions = {
batteryList,
msg: type270,
msgList,
uploadAirline: type261,
},
});
......@@ -638,7 +665,7 @@ const actions = {
* 一键起飞
* @param {function} data.callback //完成回调
*/
async takeOff({ state }, data) {
async takeOff({ state, commit }, data) {
console.log(state.airlineData, data);
if (state.uav.network == 2) {
try {
......@@ -682,10 +709,14 @@ const actions = {
callback() {},
});
// 更改任务状态
// 起飞指令
setTimeout(() => {
commit("setState", {
key: "waitAirlineUpload",
value: true,
});
let time = setInterval(() => {
if (state.uavRealTimeData.uploadAirline) {
clearInterval(time);
window.$mmc.$store.dispatch("MMCMQTT/publish", {
topic: "PX4/OBTAIN/" + state.uav.deviceId,
data: {
......@@ -699,7 +730,28 @@ const actions = {
data?.callback && data.callback(true, flightSortieId.data);
},
});
}, 6000);
// 清空261数据
let dataSet = window.$mmc.$store.state.MMCMQTT.dataSet;
dataSet[state.uav.deviceId][261] = null;
window.$mmc.$store.commit('MMCMQTT/setSate', {
key: 'dataSet',
value: dataSet
})
commit('setState', {
key: 'uavRealTimeData',
value: {
...state.uavRealTimeData,
uploadAirline: null
}
})
}
}, 1000);
// 做个保险, 要是因为各种原因导致没飞起, 超过一分钟删除循环定时器
setTimeout(() => {
clearInterval(time);
}, 60000)
} catch (e) {
console.log("一键起飞失败", e);
data?.callback && data.callback(false);
......@@ -1272,17 +1324,17 @@ const actions = {
},
// 键盘控制
keyControl({ state }, data) {
console.log(data, '键盘控制');
console.log(data, "键盘控制");
if (state.uav.network == 2) {
window.$mmc.$store.dispatch('MMCMQTT/publish', {
topic: 'PX4/OBTAIN/' + state.uav.deviceId,
window.$mmc.$store.dispatch("MMCMQTT/publish", {
topic: "PX4/OBTAIN/" + state.uav.deviceId,
data: {
type: 538,
data: data
data: data,
},
callback() {
data.callback && data.callback(true);
}
},
});
}
},
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论