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