From 9efd4a80aae58cf36266e774d3c820cc8e115028 Mon Sep 17 00:00:00 2001
From: cuiqian2004 <cuiqian2004@163.com>
Date: 星期四, 25 九月 2025 17:33:45 +0800
Subject: [PATCH] test
---
pages/map/scene.vue | 297 +++++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 238 insertions(+), 59 deletions(-)
diff --git a/pages/map/scene.vue b/pages/map/scene.vue
index 74d3bfd..99fd981 100644
--- a/pages/map/scene.vue
+++ b/pages/map/scene.vue
@@ -1,15 +1,18 @@
<template>
<view class="pages-scene">
<view class="map-content" v-if="opSceneType =='' ">
- <image class="img" src="/images/image 25.png" alt=" 鍥剧墖" mode="aspectFit" />
- <view class="space">娌℃湁鎵惧埌绗﹀悎鏉′欢鐨勫湴鍥�/view>
-
+ <image v-if="opType != 'extend'" class="img" src="/images/image 25.png" alt=" 鍥剧墖" mode="aspectFit" />
+ <image v-else class="img" :src="extendBase64Img" alt=" 鍥剧墖" mode="aspectFit" />
+ <view v-if="opType != 'extend'" class="space">娌℃湁鎵惧埌绗﹀悎鏉′欢鐨勫湴鍥�/view>
+ <!-- <view class="loading-view">{{mapserverIsOk?"鏋勫浘绋嬪簭鍑嗗灏辩华":"绛夊緟鏋勫浘绋嬪簭灏辩华..."}}
+ <view v-if="!mapserverIsOk" class="auto-circle"></view>:disabled="!mapserverIsOk"
+ </view> -->
<view class="text-button-group">
<a-button type="primary" class="button" @click="clickStartConstructScene">
- 寮�鏋勫缓
+ {{opType == 'extend'?"寮�鎵╁睍":'寮�鏋勫缓'}}
</a-button>
- <a-button type="primary" class="button" :disabled="loading && localSceneList.length == 0"
- @click="clickDownloadScene" disabled>
+ <a-button v-if="opType != 'extend'" type="primary" class="button"
+ :disabled="loading && localSceneList.length == 0" @click="clickDownloadScene" disabled>
涓嬭浇鍦烘櫙
</a-button>
</view>
@@ -49,12 +52,12 @@
</view>
<view class="bottom-content" v-else-if="opSceneType =='finish'">
<view class="tip">鍦烘櫙鏋勫缓瀹屾垚</view>
- <view>
- 宸叉垚鍔熸瀯寤衡�{{sceneName}}鈥�- </view>
-
+ <view>宸叉垚鍔熸瀯寤衡�{{sceneName}}鈥�/view>
+ <!-- <view class="loading-view">{{saveMapIsOk?"鏋勫浘淇濆瓨瀹屾垚":"绛夊緟鏋勫浘淇濆瓨瀹屾垚..."}}
+ <view v-if="!saveMapIsOk" class="auto-circle"></view>
+ </view> !saveMapIsOk ||-->
<view class="text-button-group">
- <a-button type="primary" class="button" :disabled="loading" @click="clickFinish">鏋勫缓瀹屾垚</a-button>
+ <a-button type="primary" class="button" :disabled=" loading" @click="clickFinish">鏋勫缓瀹屾垚</a-button>
</view>
</view>
</view>
@@ -81,6 +84,11 @@
//getAgvState,
getMapLaserData,
saveDBData,
+ checkMapServerIsStart,
+ startOrStopMapServer,
+ checkMapServerIsOk,
+ checkSaveMapIsOk,
+ getMapUrl
} from "@/api/vehicle.js"
export default {
@@ -101,7 +109,11 @@
ctxDataStr: "[]",
localSceneList: [],
positioningAgv: true,
- robotPos: {}
+ robotPos: {},
+ mapserverIsOk: false,
+ extendBase64Img: "",
+ saveMapIsOk: false,
+ destroyFlag: false,
}
},
@@ -137,6 +149,7 @@
if (res) {
this.opSceneType = ""
if (this.opType != "") {
+
uni.navigateBack({
delta: 1, //杩斿洖灞傛暟锛�鍒欎笂涓婇〉
})
@@ -147,11 +160,27 @@
return true
} else if (this.opSceneType == "finish") {
- const eventChannel = this.getOpenerEventChannel();
- eventChannel.emit('create_finish', this.sceneName);
- return false
+ if (this.destroyFlag) {
+
+ const eventChannel = this.getOpenerEventChannel();
+ eventChannel.emit('create_finish', this.sceneName);
+ return false
+ } else {
+ this.ctxDataStr = JSON.stringify([{
+ method: "destroy",
+ }])
+ return true
+ }
+
} else {
- return false
+ if (this.destroyFlag)
+ return false
+ else {
+ this.ctxDataStr = JSON.stringify([{
+ method: "destroy",
+ }])
+ return true
+ }
}
},
@@ -180,6 +209,7 @@
async loadData() {
try {
+ // this.loadMapServerState()
if (this.opType == "") {
this.localSceneList = await this.loadLocalScene()
} else {
@@ -190,8 +220,19 @@
await addMap(this.ip, this.sceneName, "extend")
this.opSceneType = 'scan'
}
- }
+ // if (this.opType == "extend") {
+ // // const infoMap = await this.loadMapInfo(this.sceneName)
+ // // if (infoMap.filedata) {
+ // // var base64Image = infoMap.filedata
+ // // if (base64Image.indexOf("data:image/png;base64,") < 0) {
+ // // base64Image = "data:image/png;base64," + infoMap.filedata
+ // // }
+ // // this.extendBase64Img = base64Image
+ // // }
+ // }
+
+ }
this.refreshMapLaserData()
@@ -200,9 +241,81 @@
showError(ex)
}
},
+ async loadMapInfo(id) {
+ try {
+ const info = await getMapUrl(this.ip, id)
+ return info
+ } catch (ex) {
+
+ return {}
+ }
+ },
+ async loadMapServerState() {
+ try {
+
+ this.mapserverIsOk = false
+ const res = await checkMapServerIsStart(this.ip)
+ if (res) {
+ this.mapserverIsOk = true
+ } else {
+ this.mapserverIsOk = false
+ const res = await startOrStopMapServer(this.ip, 1)
+ if (res) {
+ this.checkMapServerState()
+ }
+ }
+ } catch (ex) {
+
+ showError(ex)
+ }
+ },
+
+ async checkMapServerState() {
+ try {
+
+ const res = await checkMapServerIsOk(this.ip)
+ if (res) {
+ this.mapserverIsOk = true
+ } else {
+ this.mapserverIsOk = false
+ setTimeout(this.checkMapServerState, 1000);
+ }
+
+ } catch (ex) {
+ showError(ex).then((res) => {
+ setTimeout(this.checkMapServerState, 1000);
+ })
+ }
+ },
+ async checkSaveMapState() {
+ try {
+
+ const res = await checkSaveMapIsOk(this.ip)
+ if (res) {
+ this.saveMapIsOk = true
+ } else {
+ this.saveMapIsOk = false
+ setTimeout(this.checkSaveMapState, 1000);
+ }
+
+ } catch (ex) {
+ showError(ex).then((res) => {
+ setTimeout(this.checkSaveMapState, 1000);
+ })
+ }
+ },
+
receiveRenderData(param) {
console.log('鎺ユ敹鍒拌鍥惧眰鐨勬暟鎹細', param);
- if (param.method == "set_backgroud_progress") {
+
+ if (param.method === "destroy_complete") {
+ if (param.param) {
+ this.destroyFlag = true
+ uni.navigateBack({
+ delta: 1
+ })
+ }
+ } else if (param.method == "set_backgroud_progress") {
if (param.type == "start") {
this.setData({
bgProgressPercent: 50,
@@ -224,14 +337,34 @@
}, 500)
} else if (param.type == "error") {
+ console.log("set_backgroud_progress error")
this.setData({
bgProgressPercent: 0,
bgLoading: false
})
+ const now = new Date()
+ const date = `${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`
+ showToast("鍔犺浇搴曞浘澶辫触")
+ const log = {
+ date,
+ method: `POST`,
+ url: "app/log/load_img",
+ param: param.msg,
+ statusCode: 100,
+ data: "鍔犺浇搴曞浘澶辫触"
+ }
+ const listLog = session.getValue("request_log") || []
+ listLog.unshift(log)
+ session.setValue("request_log", listLog)
+
}
} else if (param.method == "cancel_positioning_agv") {
this.positioningAgv = false
+ } else if (param.method == "show_log") {
+ const listLog = session.getValue("request_log") || []
+ listLog.unshift(param.data)
+ session.setValue("request_log", listLog)
}
},
@@ -244,8 +377,17 @@
return []
}
},
- clickStartConstructScene() {
- this.opSceneType = "add_name"
+ async clickStartConstructScene() {
+ try {
+ if (this.opType == "extend") {
+ await addMap(this.ip, this.sceneName, "extend")
+ this.opSceneType = 'scan'
+ } else {
+ this.opSceneType = "add_name"
+ }
+ } catch (ex) {
+ showError(ex)
+ }
},
async clickDownloadScene() {
try {
@@ -328,7 +470,10 @@
uni.setNavigationBarTitle({
title: this.sceneName
})
+ this.saveMapIsOk = false
await stopMap(this.ip, this.sceneName)
+ // await startOrStopMapServer(this.ip, 2)
+ // this.checkSaveMapState();
if (this.opType == "extend") {
this.opSceneType = ""
const eventChannel = this.getOpenerEventChannel();
@@ -339,14 +484,10 @@
}
} catch (ex) {
-
+ console.log(ex)
showModal("璇锋鏌ヨ溅杈嗚繛鎺ワ紝骞堕噸鏂板紑濮嬫瀯寤哄満鏅�, "鍦烘櫙鏋勫缓澶辫触", false, "纭畾").then((res) => {
this.opSceneType = ''
- if (this.opType != "") {
- uni.navigateBack({
- delta: 1, //杩斿洖灞傛暟锛�鍒欎笂涓婇〉
- })
- }
+ // this.loadMapServerState()
})
} finally {
this.loading = false
@@ -368,14 +509,7 @@
delta: 1, //杩斿洖灞傛暟锛�鍒欎笂涓婇〉
})
} catch (ex) {
- showModal("璇锋鏌ヨ溅杈嗚繛鎺ワ紝骞堕噸鏂板紑濮嬫瀯寤哄満鏅�, "鍦烘櫙鏋勫缓澶辫触", false, "纭畾").then((res) => {
- this.opSceneType = ''
- if (this.opType != "") {
- uni.navigateBack({
- delta: 1, //杩斿洖灞傛暟锛�鍒欎笂涓婇〉
- })
- }
- })
+ console.log(ex)
} finally {
this.loading = false
uni.hideLoading()
@@ -397,59 +531,77 @@
if (this.opSceneType === "scan") {
const data = await this.loadMapLaserData()
-
+
const listCtrData = []
+ let newMap = false
if (data.base_map?.image_base64) {
this.robotPos = {}
+ newMap = true
+ const mapData = data.base_map.image_base64 //this.mapId ?"terdy":
this.mapId = data.base_map.map_id
+
listCtrData.push({
method: "background",
param: {
proportion: 1,
img_proportion: 1,
- max_x: data.base_map.width,
- max_y: data.base_map.height,
+ max_x: data.base_map.width || 100,
+ max_y: data.base_map.height || 100,
min_x: 0,
min_y: 0,
- img_x: data.base_map.width,
- img_y: data.base_map.height,
- filedata: data.base_map.image_base64
+ img_x: data.base_map.width || 100,
+ img_y: data.base_map.height || 100,
+ filedata: mapData
}
})
}
- listCtrData.push({
- method: "agv_laser",
- param: data.robot_pose
- })
+
listCtrData.push({
method: "point_cloud",
param: data.point_cloud
})
- if (this.positioningAgv) {
+ if (data.robot_pose) {
listCtrData.push({
- method: "move_pt_visible",
- param: {
- x: data.robot_pose.x,
- y: data.robot_pose.y,
- width:50,
- height:50,
- }
+ method: "agv_laser",
+ param: data.robot_pose
})
+ if (newMap) {
+ listCtrData.push({
+ method: "move_pt_center",
+ param: {
+ x: data.robot_pose.x,
+ y: data.robot_pose.y,
+ }
+ })
+ } else {
+ if (this.positioningAgv) {
+ listCtrData.push({
+ method: "move_pt_visible",
+ param: {
+ x: data.robot_pose.x,
+ y: data.robot_pose.y,
+ width: 50,
+ height: 50,
+ }
+ })
+ }
+ }
}
-
+ // console.log("ctxDataStr",listCtrData.length)
this.ctxDataStr = JSON.stringify(listCtrData)
- this.robotPos = {
- x: data.robot_pose.x,
- y: data.robot_pose.y
+ if (data.robot_pose) {
+ this.robotPos = {
+ x: data.robot_pose.x,
+ y: data.robot_pose.y
+ }
}
}
setTimeout(this.refreshMapLaserData, 1000);
} catch (ex) {
- showError(ex).then((res) => {
- setTimeout(this.refreshMapLaserData, 1000);
- })
+ showToast(ex)
+ setTimeout(this.refreshMapLaserData, 1000);
}
},
async clickVehiclePosition() {
@@ -517,6 +669,7 @@
justify-content: center;
+
.text-button-group {
display: flex;
width: 100%;
@@ -533,6 +686,32 @@
}
+ .loading-view {
+ display: flex;
+ flex-direction: row;
+
+ .auto-circle {
+ margin-left: 20rpx;
+ width: 50rpx;
+ height: 50rpx;
+ border-radius: 50%;
+ border: 10rpx solid #1890FF;
+ border-top-color: transparent;
+ animation: drawCircle 1s infinite linear;
+ }
+
+ @keyframes drawCircle {
+ 0% {
+ transform: rotate(0deg);
+ }
+
+ 100% {
+ transform: rotate(360deg);
+ }
+ }
+
+ }
+
.bottom {
position: fixed;
--
Gitblit v1.9.1