Compare commits
4 Commits
20f55808e2
...
4d46c3cdac
Author | SHA1 | Date | |
---|---|---|---|
4d46c3cdac | |||
300a107ae6 | |||
36a427f43d | |||
24fac6cc27 |
@ -57,7 +57,8 @@
|
||||
<!-- 内容 -->
|
||||
<el-form label-position="left" ref="questForm" :model="questForm" label-width="80px">
|
||||
<el-form-item label="订单选择" v-if="!executeOrder">
|
||||
<el-select v-model="questForm.id" :filterable="isMobile" placeholder="请选择,也可输入搜索" :disabled="executeOrder">
|
||||
<el-select v-model="questForm.id" :filterable="isMobile" placeholder="请选择,也可输入搜索"
|
||||
:disabled="executeOrder">
|
||||
<el-option v-for="item in questList" :key="item.id" :label="item.id" :value="item.id"
|
||||
:class="isWaring(item) ? 'danger-color' : ''">
|
||||
<span class="l">{{ item.id }}</span>
|
||||
@ -409,8 +410,7 @@ export default {
|
||||
*/
|
||||
publishFun (jsonData) {
|
||||
if (this.plane) {
|
||||
const val = jsonData
|
||||
mqtt.publishFun(`cmd/${this.plane.macadd}`, val)
|
||||
mqtt.publishFun(`cmd/${this.plane.macadd}`, jsonData)
|
||||
} else {
|
||||
this.$message.warning('与飞机通信未接通,请稍后')
|
||||
}
|
||||
@ -742,12 +742,14 @@ export default {
|
||||
return isOverWaight || isQuestIng
|
||||
}
|
||||
},
|
||||
created () {
|
||||
mounted () {
|
||||
// 初始化
|
||||
if (this.executeOrder) { // 有正在执行单点
|
||||
this.makeRouteForMap()// 绘制地图
|
||||
} else { // 没有执行订单
|
||||
this.publishFun('{"resetState":1}')// 发送设置飞机状态主题 状态设为闲置
|
||||
if (this.plane) {
|
||||
this.publishFun('{"resetState":1}')// 发送设置飞机状态主题 状态设为闲置
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
@ -27,14 +27,14 @@
|
||||
<PublicTag icon="icon-gaodu" :val="plane.planeState.currentBattery" unit="安" state="danger" />
|
||||
</el-col>
|
||||
<el-col :span="2">
|
||||
<PublicTag icon="icon-gaodu" :val="plane.planeState.batteryRemaining" unit="%" state="danger" />
|
||||
<PublicTag icon="icon-gaodu" :val="plane.planeState.battCapacity" unit="%" state="danger" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<div class="batteryBox">
|
||||
<el-progress :percentage="plane.planeState.batteryRemaining" :show-text="false" stroke-width="2"></el-progress>
|
||||
<!-- <el-progress :percentage="plane.planeState.batteryRemaining" :show-text="false" stroke-width="2"></el-progress>
|
||||
<tooltip :horizontalPosition="'80%'" backgroundColor="#ff3333">
|
||||
H
|
||||
</tooltip>
|
||||
</tooltip> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
<script>
|
||||
import HeartTag from '@/components/Tag/HeartTag'
|
||||
import PublicTag from '@/components/Tag/PublicTag'
|
||||
import Tooltip from '@/components/Tag/Tooltip'
|
||||
// import Tooltip from '@/components/Tag/Tooltip'
|
||||
import geodist from 'geodist'
|
||||
|
||||
export default {
|
||||
@ -61,8 +61,8 @@ export default {
|
||||
},
|
||||
components: {
|
||||
HeartTag,
|
||||
PublicTag,
|
||||
Tooltip
|
||||
PublicTag
|
||||
// Tooltip
|
||||
},
|
||||
computed: {
|
||||
},
|
||||
|
@ -285,7 +285,8 @@ const store = new Vuex.Store({
|
||||
getPlaneMode: null, // 飞机模式
|
||||
loadweight: null, // 重量
|
||||
hookstatus: null, // 钩子状态
|
||||
position: []// [[经度,维度,海拔高度]]累计数组
|
||||
position: [], // [[经度,维度,海拔高度]]累计数组
|
||||
battCapacity: null// 电池容量
|
||||
}
|
||||
})
|
||||
if (res.data.status === 1) {
|
||||
|
@ -10,6 +10,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import mqtt from '@/utils/mqtt'
|
||||
import MapBox from '@/components/MapBox'
|
||||
import ControllerTabs from '@/components/ControllerTabs'
|
||||
import PlaneStatus from '@/components/PlaneStatus'
|
||||
@ -100,6 +101,10 @@ export default {
|
||||
plane: {
|
||||
handler (val) {
|
||||
this.makePlane(val)// 有飞机数据之后 在地图上创建飞机
|
||||
if (val.planeState.battCapacity === null) {
|
||||
console.log(val.planeState.battCapacity)
|
||||
mqtt.publishFun(`cmd/${this.plane.macadd}`, '{"getBattCapacity":1}')// 发送设置飞机状态主题 请求飞控返回 电池总容量
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
|
@ -81,24 +81,36 @@ export default {
|
||||
mqtt.doSubscribe('planeState/+', (mqttRes) => {
|
||||
res.forEach(plane => {
|
||||
if (mqttRes.topic.indexOf(plane.macadd) > -1) {
|
||||
// 反序列化 mqtt信息
|
||||
const jsonData = JSON.parse(mqttRes.msg.trim())
|
||||
// 更新mqtt信息 选择性更新状态
|
||||
for (const key in jsonData) {
|
||||
if (key === 'heartBeat') { // 每次接收到心跳 heartRandom属性 创建一个随机数 用于watch监听
|
||||
plane.planeState.heartRandom = Math.random()
|
||||
}
|
||||
if (key === 'position') { // 如果是飞机位置信息 则不是直接刷新状态 而是累计 到数组 以便于画出飞机路径
|
||||
let position = jsonData.position
|
||||
position = position.replace(/([a-zA-Z0-9]+):/g, '"$1":')// mcu过来的json格式修正一下 键没有引号 改成"lng":
|
||||
position = JSON.parse(position)
|
||||
plane.planeState.position.push([position.lng / 10e6, position.lat / 10e6, Number(position.alt)])
|
||||
if (plane.planeState.position.length > 1000) {
|
||||
plane.planeState.position.shift()// 删除最早的经纬度
|
||||
try {
|
||||
// 反序列化 mqtt信息
|
||||
const jsonData = JSON.parse(mqttRes.msg.trim())
|
||||
|
||||
// 更新mqtt信息 选择性更新状态
|
||||
for (const key in jsonData) {
|
||||
if (key === 'heartBeat') {
|
||||
// 每次接收到心跳 heartRandom属性 创建一个随机数 用于watch监听
|
||||
plane.planeState.heartRandom = Math.random()
|
||||
} else if (key === 'position') {
|
||||
// 如果是飞机位置信息 则不是直接刷新状态 而是累计 到数组 以便于画出飞机路径
|
||||
const position = JSON.parse(jsonData.position)
|
||||
plane.planeState.position.push([position.lng / 10e6, position.lat / 10e6, Number(position.alt)])
|
||||
if (plane.planeState.position.length > 1000) {
|
||||
plane.planeState.position.shift() // 删除最早的经纬度
|
||||
}
|
||||
} else if (key === 'parameter') {
|
||||
// 如果是 get飞控参数 判断设置对应值
|
||||
const parameter = JSON.parse(jsonData.parameter.trim())
|
||||
for (const k in parameter) {
|
||||
if (k === 'BATT_CAPACITY') {
|
||||
plane.planeState.battCapacity = parameter.BATT_CAPACITY
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plane.planeState[key] = jsonData[key] // 按订阅信息 刷新飞机状态
|
||||
}
|
||||
} else {
|
||||
plane.planeState[key] = jsonData[key]// 按订阅信息 刷新飞机状态
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error parsing JSON or processing message:', error)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user