Compare commits

..

4 Commits

Author SHA1 Message Date
4d46c3cdac 【类 型】:feat 向飞机请求返回 电池容量
【原  因】:
【过  程】:监测飞机状态 电池容量null 时 向飞机请求 返回电池容量
【影  响】:

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
2024-07-20 18:42:47 +08:00
300a107ae6 【类 型】:refactor 飞机状态里 添加电池容量字段
【原  因】:
【过  程】:
【影  响】:

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
2024-07-20 18:41:10 +08:00
36a427f43d 【类 型】:test
【原  因】:
【过  程】:
【影  响】:

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
2024-07-20 18:40:12 +08:00
24fac6cc27 【类 型】:fix
【原  因】:在没有加载飞机之前 向飞机发送mqtt信息
【过  程】:
【影  响】:

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
2024-07-20 18:38:44 +08:00
5 changed files with 48 additions and 28 deletions

View File

@ -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: {

View File

@ -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: {
},

View File

@ -285,7 +285,8 @@ const store = new Vuex.Store({
getPlaneMode: null, // 飞机模式
loadweight: null, // 重量
hookstatus: null, // 钩子状态
position: []// [[经度,维度,海拔高度]]累计数组
position: [], // [[经度,维度,海拔高度]]累计数组
battCapacity: null// 电池容量
}
})
if (res.data.status === 1) {

View File

@ -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
},

View File

@ -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":')// mcujson "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)
}
}
})