From 2d0d1e6f970ccdf7a76a858cebc4aefee58b1a5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E7=AC=99=E6=AD=8C?= <2277317060@qq.com> Date: Wed, 30 Oct 2024 14:58:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B94F=20agv?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/cs/index2.vue | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/src/views/cs/index2.vue b/src/views/cs/index2.vue index 104b5dd..3190b23 100644 --- a/src/views/cs/index2.vue +++ b/src/views/cs/index2.vue @@ -101,7 +101,7 @@
+ :style="`${getLocation(i.x,i.y)}transform: rotate(${parseFloat(i.rotate )- 180}deg);`"> @@ -276,9 +276,9 @@ export default { hfData: [], equipmentData: [], agvData: [], - siteData:{ - x:250000, - y:200000 + siteData: { + x: 121000, + y: 82000 } } }, @@ -293,11 +293,12 @@ export default { getAgvLocation() { let agvArr = [] getAgvData().then(e => { + console.log(Math.max(...e.Data.map(v => v.X)), Math.max(...e.Data.map(v => v.Y))) e.Data.forEach(v => { agvArr.push({ id: v.AgvId, - x: Math.random() || v.X/this.siteData.x, - y: Math.random() || v.Y/this.siteData.y, + x: (v.X - 126000) / this.siteData.x, + y: (72000 - (v.Y - 116000)) / this.siteData.y, rotate: v.Angle, isGoods: false, }) @@ -305,16 +306,22 @@ export default { this.agvData = agvArr }) }, - updateAGVLocation(time){ + updateAGVLocation(time) { getAgvData().then(e => { e.Data.forEach(v => { - if(this.agvData.filter(r=>r.id===v.AgvId).length>=1){ - new TWEEN.Tween(this.agvData.find(r=>r.id===v.AgvId)).to({x:v.X/this.siteData.x, y: v.Y/this.siteData.y}, time).start() - }else{ + if (this.agvData.filter(r => r.id === v.AgvId).length >= 1) { + new TWEEN.Tween(this.agvData.find(r => r.id === v.AgvId)).to({ + rotate: v.Angle, + }, 100).start() + new TWEEN.Tween(this.agvData.find(r => r.id === v.AgvId)).to({ + x: (v.X - 126000) / this.siteData.x, + y: (72000 - (v.Y - 116000)) / this.siteData.y, + }, time - 100).start() + } else { this.agvData.push({ id: v.AgvId, - x: Math.random() || v.X/this.siteData.x, - y: Math.random() || v.Y/this.siteData.y, + x: (v.X - 126000) / this.siteData.x, + y: (72000 - (v.Y - 116000)) / this.siteData.y, rotate: v.Angle, isGoods: false, }) @@ -340,13 +347,15 @@ export default { mounted() { this.getData() this.getAgvLocation() - setInterval(()=>{ - this.updateAGVLocation(5*1000) - },5*1000) + let time = 2 * 1000 + setInterval(() => { + this.updateAGVLocation(time) + }, time) setInterval(() => { this.loopIndex = (this.loopIndex + 1) % 26 }, 1000 * 5) + function animate() { requestAnimationFrame(animate) TWEEN.update()