提交 45236902 作者: 翁进城

fix:

1. 【机库】发送操作区域的控制指令飞控中心未收到,指令发送失败
2. 【机库】1、无人机飞行状态显示有误2、运行日志未显示出来
3. 【无人机控制面板】飞行时间需转换格式为时分秒
4. 【无人机飞行-监控日志】无人机飞行缺少监控日志
5. 【无人机飞行】-开始录屏和结束录屏按钮弄反了
上级 adb6adee
流水线 #9818 已失败 于阶段
......@@ -31,9 +31,8 @@
</div>
<div class="infoBox cf">
<div class="dib title">
{{ _uavData.flyTime }}
{{ flyTimeFormat }}
</div>
min
<div class="cf">飞行时间</div>
</div>
<div class="infoBox cf">
......@@ -80,6 +79,12 @@ export default {
velocityZ: Number(this.uavData?.velocityZ || 0).toFixed(0),
};
},
flyTimeFormat() {
const minutes = this._uavData.flyTime;
const hours = Math.floor(minutes / 60);
const mins = minutes % 60;
return `${hours}:${mins}`;
},
},
watch: {
uavData: function (val, old) {
......
<template>
<div class="qingliu" :class="classNames" id="qinglliu" ref="qingliu">
<div class="qingliu" id="qinglliu" ref="qingliu">
<div :id="'qingliu_' + name" class="qingcanvas" ref="qingcanvas">
</div>
</div>
......@@ -40,13 +40,13 @@ export default {
// 监听窗口大小变化事件
window.addEventListener("resize", this.handResize);
var canvas_qinliu = document.getElementById("qingliu_" + this.name);
/* var canvas_qinliu = document.getElementById("qingliu_" + this.name);
var resizeObserver = new ResizeObserver((e) => {
for (let i of e) {
window.kbt_player_resize("qingliu_" + this.name);
}
});
resizeObserver.observe(canvas_qinliu);
resizeObserver.observe(canvas_qinliu); */
},
handResize() {
// 获取 Canvas 元素
......@@ -78,7 +78,7 @@ export default {
<style scoped lang="scss">
.qingliu ::v-deep {
width: 100%;
height: calc(100% - 46px);
height: 200px;
.qingcanvas {
width: 100%;
height: 100%;
......
<template>
<div
class="cpt-nest-logger"
:class="{ chang: dakai == true, }"
>
<div class="cpt-nest-logger" :class="{ chang: dakai == true, }">
<div class="title-box" v-interact>
<div class="title">
<img src="../../../../../../../../assets/images/mount_head.png" />
<div class="font">运行监控日志</div>
<div effect="dark" class="status">
{{ getprocessStatus(hangarData.processStatus) }}
</div>
<div effect="dark" class="status">{{ getprocessStatus(hangarRealTimeData.processStatus) }}</div>
</div>
<div style="display: flex">
<div class="icon-box" @click="$emit('clearMsg')">
<div class="icon-box" @click="onClear">
<span class="iconfont icon-qingchushuju"></span>
<!-- <span class="icon-text pr20">清除数据</span> -->
</div>
<!-- <div class="icon-box" @click="$emit('step')">
<span class="icon-text">运行流程</span>
</div> -->
</div>-->
<div class="close" @click="$emit('exit')">关闭</div>
</div>
</div>
......@@ -50,14 +45,11 @@
<div class="time">时间</div>
</div>
<div class="list-box mt7">
<div class="item-box" v-for="(item, index) in _hangarMsgList" :key="index">
<div class="item-box" v-for="(item, index) in hangarMsgList" :key="index">
<div class="text-box">
<div
class="type-box"
:class="{ emerg: item.type === 1, ordinary: item.type === 8 }"
>
<span class="type" v-if="item.type === 1">紧急</span>
<span class="type" v-else-if="item.type === 8">普通</span>
<div class="type-box" :class="{ emerg: item.type == 1, ordinary: item.type == 8 }">
<span class="type" v-if="item.type == 1">紧急</span>
<span class="type" v-else-if="item.type == 8">普通</span>
<span class="type" v-else>未知</span>
</div>
<div class="text">{{ item.text }}</div>
......@@ -67,14 +59,17 @@
</div>
</div>
<div class="jiantou" @click="jiantou" :class="{ zhaun: dakai == true }">
<img :src="jian" style="width: 100%; height: 100%" alt="" />
<img :src="jian" style="width: 100%; height: 100%" alt />
</div>
</div>
</template>
<script>
import jiantouIMG from './assets/images/jiantou.png';
import jiantouIMG from "./assets/images/jiantou.png";
import { mapState } from "vuex";
export default {
name: "HangarLogger",
data() {
return {
jian: jiantouIMG,
......@@ -82,25 +77,9 @@ export default {
productType: false, // 产品类型
};
},
props: {
// 无人机消息type: 270的数据
uavMsg: {
type: Object,
default: () => ({}),
},
// 机库type为2063的日志消息
hangarMsgList: {
type: Array,
default: () => [],
},
// 机库mqtt实时数据
hangarData: {
type: Object,
default: () => ({}),
},
},
props: {},
watch: {
hangarData: function (val) {
hangarRealTimeData: function (val) {
// 产品类型 明达康机库:305 ,百胜将机库II(入云龙II换电式):304 ,百胜将机库II(入云龙II充电式):303 ,百胜将机库II翻盖式:302 ,百胜将机库I:301
if (val?.productType == 302 || val?.productType == 305) {
this.productType = false; //翻盖
......@@ -110,40 +89,67 @@ export default {
},
},
computed: {
// 消息反序显示
_hangarMsgList(){
return this.hangarMsgList.reverse();
...mapState("MMCFlightControlCenter/hangar", ["hangar", "hangarRealTimeData"]),
...mapState("MMCFlightControlCenter/uav", ["uavRealTimeData"]),
hangarMsgList() {
return this.hangarRealTimeData.msgList.slice().reverse();
},
// 无人机消息type: 270的数据
uavMsg() {
return (
this.uavRealTimeData.msgList[this.uavRealTimeData.length - 1] || {}
);
},
rtkPower() {
let { hangarData } = this;
if (hangarData.rtkPower) {
return hangarData.rtkPower;
let { hangarRealTimeData } = this;
if (hangarRealTimeData.rtkPower) {
return hangarRealTimeData.rtkPower;
}
return 0;
},
folder() {
let { hangarData } = this;
if (hangarData.folder) {
return hangarData.folder;
let { hangarRealTimeData } = this;
if (hangarRealTimeData.folder) {
return hangarRealTimeData.folder;
}
return 0;
},
lifts() {
let { hangarData } = this;
if (hangarData.lifts) {
return hangarData.lifts;
let { hangarRealTimeData } = this;
if (hangarRealTimeData.lifts) {
return hangarRealTimeData.lifts;
}
return 0;
},
cover() {
let { hangarData } = this;
if (hangarData.cover) {
return hangarData.cover;
let { hangarRealTimeData } = this;
if (hangarRealTimeData.cover) {
return hangarRealTimeData.cover;
}
return 0;
},
},
methods: {
/**
* 清理日志
*/
onClear() {
let dataSet = this.$store.state.MMCMQTT.dataSet;
dataSet[this.hangar.hardId][3] = null;
this.$store.commit("MMCMQTT/setState", {
key: "dataSet",
value: {
...dataSet,
},
});
this.$store.commit("MMCFlightControlCenter/hangar/setState", {
key: "hangarRealTimeData",
value: {
...this.hangarRealTimeData,
msgList: [],
},
});
},
getprocessStatus(val) {
let title = "";
if (val == 0) {
......
......@@ -39,12 +39,8 @@
</div>
</div>
<Logger
:uavMsg="uavRealTimeData.msg"
:hangarMsgList="hangarRealTimeData.msgList"
:hangarData="hangarRealTimeData"
class="logger"
@exit="showLogger = false"
@clearMsg="onClearMsg"
v-if="showLogger"
></Logger>
<HangarMonitor
......@@ -193,18 +189,7 @@ export default {
this.showHangar = false;
}
},
/**
* 清理日志
*/
onClearMsg() {
this.$store.commit("MMCFlightControlCenter/hangar/setState", {
key: "hangarRealTimeData",
value: {
...this.hangarRealTimeData,
msgList: [],
},
});
},
},
};
</script>
......
......@@ -31,13 +31,6 @@ export default {
key: 'listCollapse',
value: false
})
if (this.uav) {
this.$store.dispatch("MMCFlightControlCenter/uav/unsubscribe");
}
if (this.hangar) {
this.$store.dispatch("MMCFlightControlCenter/hangar/unsubscribe");
}
this.$store.dispatch('MMCFlightControlCenter/uav/end');
},
};
</script>
......
......@@ -19,7 +19,7 @@ export default {
}
},
},
async created() {
async mounted() {
// 启动mqtt服务
try {
this.$store
......@@ -33,4 +33,15 @@ export default {
console.log("mqtt失败", e);
}
},
beforeDestroy(){
console.log('断开mqtt连接');
if (this.uav) {
this.$store.dispatch("MMCFlightControlCenter/uav/unsubscribe");
}
if (this.hangar) {
this.$store.dispatch("MMCFlightControlCenter/hangar/unsubscribe");
}
this.$store.dispatch('MMCFlightControlCenter/uav/end');
}
};
......@@ -6,7 +6,7 @@
<div class="font">运行监控日志</div>
</div>
<div style="display: flex">
<div class="icon-box" @click="list = []">
<div class="icon-box" @click="onClear">
<span class="iconfont icon-qingchushuju"></span>
<!-- <span class="icon-text pr20">清除数据</span> -->
</div>
......@@ -15,24 +15,16 @@
</div>
<div class="ctx-box">
<div class="head mt7">
<div class="text">消息等级</div>
<div class="text">CODE</div>
<div class="text con">消息内容</div>
<div class="time">时间</div>
</div>
<div class="list-box mt7">
<div class="item-box" v-for="(item,index) in list" :key="index">
<div
class="text-box"
:style="item.id && item.id ==99 || item.id && item.id <= 2 ? 'color: #FF4040': item.id && item.id > 2 && item.id < 5 ? 'color: #FFFF40': item.id && item.id == 5 ? 'color: #8E1DB8':''"
>
<div v-if="item.id" class="type-box">
<span class="type">{{ item.id }}</span>
</div>
<div
class="text"
:style="item.id && item.id == 99 || item.id && item.id <= 2 ? 'color: #FF4040': item.id && item.id > 2 && item.id < 5 ? 'color: #FFFF40': item.id && item.id == 5 ? 'color: #8E1DB8':''"
>{{ item.cmd_title }}</div>
<div class="time">{{ item.time_strap }}</div>
<div class="item-box" v-for="(item,index) in msgList" :key="index">
<div class="text-box">
<span class="code">{{ item.code }}</span>
<div class="text">{{ item.text }}</div>
<div class="time">{{ item.time }}</div>
</div>
</div>
</div>
......@@ -48,43 +40,17 @@ import dayjs from "dayjs";
export default {
data() {
return {
list: [
// {
// id: 1,
// cmd_title: '测试数据1',
// time_strap: new Date().toLocaleString()
// },
// {
// id: 2,
// cmd_title: '测试数据2',
// time_strap: new Date().toLocaleString()
// },
// {
// id: 3,
// cmd_title: '测试数据3',
// time_strap: new Date().toLocaleString()
// },
],
Time: null,
};
},
computed: {
...mapState("MMCFlightControlCenter/uav", ["uav"]),
},
watch: {
async uav(newVal) {
if (newVal) {
this.list = [];
await this.getUavLog();
}
...mapState("MMCFlightControlCenter/uav", ["uav", "uavRealTimeData"]),
msgList() {
return this.uavRealTimeData.msgList.slice().reverse();
},
},
async created() {
await this.getUavLog();
this.Time = setInterval(() => {
this.getUavLog();
}, 1000);
},
watch: {},
async created() {},
beforeDestroy() {
if (this.Time) clearInterval(this.Time);
},
......@@ -92,24 +58,23 @@ export default {
onClose() {
this.$emit("onCloseOperationLog");
},
async getUavLog() {
const res = await Control_API.getUavAllLog({
page: 1,
pageSize: 999,
deviceId: this.uav.hardId,
startDateId: dayjs().format("YYYY-MM-DD"),
endDateId: dayjs().format("YYYY-MM-DD"),
onClear() {
let dataSet = this.$store.state.MMCMQTT.dataSet;
dataSet[this.uav.hardId][270] = null;
this.$store.commit("MMCMQTT/setState", {
key: "dataSet",
value: {
...dataSet,
},
});
this.$store.commit("MMCFlightControlCenter/uav/setState", {
key: "uavRealTimeData",
value: {
...this.uavRealTimeData,
msgList: [],
},
});
if (res.status === 1) {
this.list = res.data.data;
this.list = this.list.filter((item) => {
const current_date = new Date();
const difference =
current_date.getTime() - new Date(item.time_strap).getTime();
const hoursMilli = 1000 * 60 * 30; // 半个小时内
return Math.abs(difference) < hoursMilli;
});
}
},
},
};
......@@ -232,7 +197,7 @@ export default {
justify-content: space-between;
align-items: center;
.type-box {
.code {
width: 20%;
height: 20px;
text-align: center;
......@@ -245,21 +210,6 @@ export default {
display: flex;
justify-content: center;
align-items: center;
&.ordinary {
background-color: #298ad3;
}
&.emerg {
background-color: #ff3c3c;
}
.type {
width: 100px;
text-align: center;
font-size: 10px;
white-space: nowrap;
}
}
.text {
......
......@@ -127,6 +127,10 @@ export default {
type: String,
default: () => "",
},
isHangar: {
type: Boolean,
default: false
}
},
data() {
return {
......@@ -196,6 +200,14 @@ export default {
"routeControl",
"isTakeOver",
]),
async isTake(){
// 判断是否已接管
if (!this.isHangar && !(await this.isTakeOver())) {
this.$message.warning("请先接管无人机");
return false;
}
return true;
},
/**
* 显示隐藏航线
*/
......@@ -209,8 +221,7 @@ export default {
*/
async onPauseFly() {
// 判断是否已接管
if (!(await this.isTakeOver())) {
this.$message.warning("请先接管无人机");
if (!await this.isTake()) {
return;
}
this.pauseFly({
......@@ -224,8 +235,7 @@ export default {
*/
async onContinueFly() {
// 判断是否已接管
if (!(await this.isTakeOver())) {
this.$message.warning("请先接管无人机");
if (!await this.isTake()) {
return;
}
this.continueFly({
......@@ -239,8 +249,7 @@ export default {
*/
async onLand() {
// 判断是否已接管
if (!(await this.isTakeOver())) {
this.$message.warning("请先接管无人机");
if (!await this.isTake()) {
return;
}
this.safetyNotice = false;
......@@ -251,8 +260,7 @@ export default {
*/
async onInfieldControl() {
// 判断是否已接管
if (!(await this.isTakeOver())) {
this.$message.warning("请先接管无人机");
if (!await this.isTake()) {
return;
}
if (this.online === 0)
......@@ -294,8 +302,7 @@ export default {
*/
async guideFlight() {
// 判断是否已接管
if (!(await this.isTakeOver())) {
this.$message.warning("请先接管无人机");
if (!await this.isTake()) {
return;
}
if (this.uav.online === 0)
......@@ -339,8 +346,7 @@ export default {
*/
async onGuideFlightConfirm() {
// 判断是否已接管
if (!(await this.isTakeOver())) {
this.$message.warning("请先接管无人机");
if (!await this.isTake()) {
return;
}
console.log(
......
......@@ -91,6 +91,7 @@
@closeIconShow="iconShow = false"
@exit="showControlList = false"
v-if="showControlList"
:isHangar="isHangar"
></ControlList>
<Health v-if="showHealth" @exit="showHealth = false"></Health>
<Mount v-if="showMount"></Mount>
......
......@@ -2,6 +2,7 @@
<div class="livenvr pr" :class="className">
<!-- <video style="width:100%;height:100%" controls ref="video" src="./1.mp4"></video> -->
<LivePlayer
ref="livePlayer"
:dblclick-fullscreen="false"
aspect="fulllscreen"
:class="{
......@@ -10,11 +11,13 @@
vUrl: isStatus && !smallFPV,
vUrlDeffault: !isStatus && !smallFPV,
}"
ref="livePlayer"
:controls="false"
:videoUrl="data.vUrl"
live
/>
<LivePlayer
ref="fpvPlayer"
v-if="fpvUrl.vUrl"
:dblclick-fullscreen="false"
:class="{
......@@ -23,16 +26,19 @@
small: smallFPV,
'livenvr-player': !smallFPV,
}"
ref="fpvPlayer"
:controls="false"
:videoUrl="fpvUrl.vUrl"
live
/>
</div>
</template>
<script>
import LivePlayer from "@liveqing/liveplayer";
import { dataURLToBlob, canvasToDataURL } from "../../../../../../utils/image-tool";
import {
dataURLToBlob,
canvasToDataURL,
} from "../../../../../../utils/image-tool";
export default {
props: {
......
......@@ -96,4 +96,12 @@ export default {
object-fit: fill;
}
}
video::-webkit-media-controls-panel {
display:none !important;
}
video::-webkit-media-controls-timeline {
display: none !important;
}
</style>
\ No newline at end of file
......@@ -12,14 +12,14 @@
<div v-show="!isStatus" class="close" @click="close()">关闭</div>
</div>
<!-- <videoModelChange
<!-- <videoModelChange
:data="data"
v-if="streamSelect == 'QINGLIU' && !isStatus"
class="cp pa cf modelStyle"
@click="VideoModelChange"
:uavRealTimeData="uavRealTimeData"
:NXdata="NXdata"
></videoModelChange> -->
></videoModelChange>-->
<components
:is="playerCom"
......@@ -329,12 +329,12 @@
</div>
</el-tooltip>
<el-tooltip v-if="!screenRecordingStatus" content="开始录像" placement="bottom">
<div class="record menu-item" @click="getrecord">
<div class="record menu-item" @click="getRecord">
<img src="./assets/images/record.png" />
</div>
</el-tooltip>
<el-tooltip v-else content="停止录像" placement="bottom">
<div class="record menu-item" @click="getrecord">
<div class="record menu-item" @click="getRecord">
<img src="./assets/images/stop.png" />
</div>
</el-tooltip>
......@@ -428,7 +428,6 @@ import svg3 from "./assets/images/异物检测.svg";
import svg4 from "./assets/images/跌倒检测.svg";
import svg5 from "./assets/images/游泳检测.svg";
export default {
name: "Player",
components: {
......@@ -460,7 +459,7 @@ export default {
},
data() {
return {
backgroundStyle: {
backgroundStyle: {
"background-position-y": 0,
},
aiIdentifyList: [
......@@ -502,14 +501,14 @@ export default {
},
],
ygisCenterFlag: false,
ygValue: null,
ygValue: null,
showCenter: false, //开启瞄准
screenRecordingStatus: false, //是否录制中
showInfo: false, //清流视频信息展示
infoData: null, //清流信息
raw_msg: 0,
carList: [], //车牌识别结果
aiVisible: false, //打开ai
pid: null,
......@@ -836,23 +835,27 @@ export default {
/**
* 录像
*/
async getrecord() {
async getRecord() {
if (this.healthData.NX.code !== "0x2110000") {
return this.$message.error("录像失败,NX通信异常!");
}
this.screenRecordingStatus = !this.screenRecordingStatus;
this.$store.dispatch("MMCFlightControlCenter/uav/videoTranscribe", {
playerFormat: this.streamSelect,
videoID: 1, // 视频通道ID(需保持唯一)
dbID: "929", // 历史记录id
name: "z30Pro", // 挂载名称(如果知道挂载名称,将传名称即可,通道号可以不用传)
taskID: "", // 任务ID,可传可不传
recordControl: true, // 录制开关、true为开启
recordControl: this.screenRecordingStatus, // 录制开关、true为开启
callback: (isOk) => {
isOk &&
if (isOk) {
this.$message.success(
`${this.screenRecordingStatus ? "开始" : "结束"}录屏`
);
this.screenRecordingStatus = !this.screenRecordingStatus;
} else {
this.$message.error(`${this.screenRecordingStatus ? "开始" : "结束"}录屏失败`);
this.screenRecordingStatus = !this.screenRecordingStatus;
}
},
});
},
......
......@@ -59,10 +59,7 @@ export default {
key: 'listCollapse',
value: false
})
if(this.uav){
this.$store.dispatch('MMCFlightControlCenter/uav/unsubscribe');
}
this.$store.dispatch('MMCFlightControlCenter/uav/end');
},
methods: {
getcanvas(val, item) {
......
......@@ -35,7 +35,7 @@ export default {
}
},
},
async created() {
async mounted() {
// 模拟飞机数据上报
// this.$store.dispatch("MMCFlightControlCenter/uav/test", { open: true });
// 启动mqtt服务
......@@ -53,4 +53,11 @@ export default {
// 由于地面站是广播形式的数据传输, 非常消耗性能, 把连接地面站ws的操作挪到了订阅中去, 取消订阅时就断开ws
},
beforeDestroy(){
console.log('断开mqtt与ws连接');
if(this.uav){
this.$store.dispatch('MMCFlightControlCenter/uav/unsubscribe');
}
this.$store.dispatch('MMCFlightControlCenter/uav/end');
}
};
import Moment from "moment";
import moment from "moment";
import { Control_API } from "../api";
let hangarRealTimeData = {
......@@ -72,16 +72,30 @@ const actions = {
// mqtt链路
const type2065 = data[2065]?.data || {};
const type2063 = data[2063]?.data; //飞控应答消息
data[2063] && console.log("type2063", data[2063]);
const type3 = data[3]; //机库流程日志
const type2066 = data[2066]?.data || {}; //气象站数据
let msgList = state.hangarRealTimeData.msgList || [];
if (type2063) {
let moment = new Moment();
type2063.time = moment.format("yyyy-MM-DD hh:mm:ss");
msgList.push(type2063);
data[2063] = null;
type2063.timestamp = data[2063].timestamp;
let findMsg = msgList.find((item) => item.timestamp === type2063.timestamp);
if (!findMsg) {
msgList.push({
...type2063,
time: moment(type2063.timestamp).format("YYYY-MM-DD HH:mm:ss"),
});
}
}
if(type3){
let findMsg = msgList.find((item) => item.$time === type3.$time);
if (!findMsg) {
msgList.push({
...type3,
time: moment(type3.$time).format("YYYY-MM-DD HH:mm:ss"),
text: type3.body
});
}
}
commit("setState", {
......@@ -108,6 +122,13 @@ const actions = {
console.log("mqtt订阅主题", "APRON/RECEIVE/" + state.hangar.hardId);
},
});
window.$mmc.$store.dispatch("MMCMQTT/subscribe", {
topic: "PROCESS/RECEIVE/" + state.hangar.hardId,
callback(ok) {
ok &&
console.log("mqtt订阅主题", "PROCESS/RECEIVE/" + state.hangar.hardId);
},
});
},
/**
* 取消订阅
......@@ -124,6 +145,16 @@ const actions = {
);
},
});
window.$mmc.$store.dispatch("MMCMQTT/unsubscribe", {
topic: "PROCESS/RECEIVE/" + state.hangar.hardId,
callback(ok) {
ok &&
console.log(
"mqtt取消订阅主题",
"PROCESS/RECEIVE/" + state.hangar.hardId
);
},
});
dispatch("destroy");
},
......
import { Control_API } from "../api";
import mount from "../components/mount";
import moment from "moment";
let positions = []; // 飞机走过的点, 会一直累计, 每n秒减半一次, 防止爆内存
setInterval(() => {
......@@ -8,7 +9,7 @@ setInterval(() => {
}
}, 60000);
window.positions = () => {
console.log(positions)
console.log(positions);
};
const defaultPos = {
latitude: 22.433, // 纬度
......@@ -151,12 +152,13 @@ const uavRealTimeData = {
statusType: 3, // 电池状态 0无效值,1开机,2充电中,3关机
}, */
],
msg: { // 飞控应答消息
msg: {
// 飞控应答消息
code: 0,
cmd: 0,
text: "",
},
msgList: [], // 飞控应答消息记录
msgList: [], // 飞控应答消息记录
};
const state = {
......@@ -292,10 +294,20 @@ const actions = {
const type2017 = data[2017]?.data;
const type272 = data[272]?.data; // 避障信息
const type275 = data[275]?.data; // 健康管理
const type270 = data[270]?.data || {}; //飞控应答消息
const type270 = data[270]?.data; //飞控应答消息
let msgList = state.msgList || [];
msgList.push(type270);
let msgList = state.uavRealTimeData.msgList || [];
if (type270) {
type270.timestamp = data[270].timestamp;
let findMsg = msgList.find((item) => item.timestamp === type270.timestamp);
if (!findMsg) {
msgList.push({
...type270,
time: moment(type270.timestamp).format("YYYY-MM-DD HH:mm:ss"),
});
}
}
// gps 需要判断使用哪个
if (type258.rtk?.isMainSensor) {
......
......@@ -17,6 +17,18 @@ export default {
userInfo: {}, //用户信息
},
mutations: {
/**
* 单纯的给state赋值
* @param {*} param0
* @param {*} data {key: '', value}
*/
setState(state, data) {
try {
state[data.key] = data.value;
} catch (e) {
console.log("setDate err", e);
}
},
setWs(state, data) {
state.ws = data;
},
......
import mqtt from 'mqtt/dist/mqtt';
import mqtt from "mqtt/dist/mqtt";
import orders from "./orders";
function uint8array2json(uint8array) {
......@@ -24,6 +24,18 @@ export default {
orders, //所有指令
},
mutations: {
/**
* 单纯的给state赋值
* @param {*} param0
* @param {*} data {key: '', value}
*/
setState(state, data) {
try {
state[data.key] = data.value;
} catch (e) {
console.log("setDate err", e);
}
},
setClient(state, data) {
state.client = data;
},
......@@ -43,13 +55,12 @@ export default {
},
actions: {
init({ commit, state }, data) {
let protocol = data.url.replace(/(.+)\:\/\/.*/, "$1");
let clientId = Date.now();
let client = mqtt.connect(data.url, {
// protocol,
clientId,
});
console.log("MQTT client", client);
commit("setClient", client);
commit("setClientId", clientId);
......@@ -64,6 +75,8 @@ export default {
if (!state.dataSet[deviceHardId]) {
state.dataSet[deviceHardId] = {};
}
data.$time = Date.now(); // 打上时间戳
state.dataSet[deviceHardId][data.type] = data;
commit("setDataSet", state.dataSet);
});
......@@ -92,9 +105,10 @@ export default {
* @param {} param0
*/
end({ state, commit }) {
state.client.end();
commit('setClient', null);
commit("setClientId", '');
console.log('MMCMQTT: 断开mqtt连接')
state.client?.end();
commit("setClient", null);
commit("setClientId", "");
},
/**
* 订阅
......@@ -172,4 +186,4 @@ export default {
});
},
},
};
\ No newline at end of file
};
<template>
<div>
<el-form>
<el-form-item label="无人机id">
<el-form-item label="类型">
<el-switch v-model="isUav" inactive-text="机库" active-text="无人机"></el-switch>
</el-form-item>
<el-form-item label="设备id">
<el-input v-model="deviceHardId"></el-input>
</el-form-item>
<el-form-item label="操作">
......@@ -25,7 +28,8 @@ export default {
name: 'MQTT',
data(){
return {
deviceHardId: ''
deviceHardId: '',
isUav: true
}
},
computed: {
......@@ -36,7 +40,10 @@ export default {
return this.$store.state.MMCMQTT.orders;
},
topic(){
return `PX4/RECEIVE/${this.deviceHardId}`;
return `${this.preTopic}${this.deviceHardId}`;
},
preTopic(){
return this.isUav ? 'PX4/RECEIVE/' : 'APRON/RECEIVE/';
}
},
async created(){
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论