From eee916d6160e36d8f3073b6cf0c8054a2409e3ac Mon Sep 17 00:00:00 2001 From: yuliang <398780299@qq.com> Date: Fri, 4 Jul 2025 16:14:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?cl2=20=E5=9F=BA=E4=BA=8E=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=92=8C=E4=BB=BB=E5=8A=A1=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=88=86=E6=AD=A5=E7=94=9F=E6=88=90=E8=AE=BE=E5=A4=87=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/manager/EnvManager.ts | 2 +- src/modules/amr/ptr/PtrObject.ts | 164 ++++++++++++++++++--------------- src/modules/amr/ptr/cl2/Cl23dObject.ts | 4 +- src/modules/amr/ptr/clx/Clx3dObject.ts | 5 +- 4 files changed, 94 insertions(+), 81 deletions(-) diff --git a/src/core/manager/EnvManager.ts b/src/core/manager/EnvManager.ts index bbb2703..fbfa78b 100644 --- a/src/core/manager/EnvManager.ts +++ b/src/core/manager/EnvManager.ts @@ -17,7 +17,7 @@ export default class EnvManager { } onMqttMessage = (topic: string, payload: Buffer, packet: IPublishPacket) => { - console.log(`[${topic}]-> ${payload.toString()}`) + // console.log(`[${topic}]-> ${payload.toString()}`) if (topic.startsWith('/wcs_server/')) { const message: AmrMsg = JSON.parse(payload.toString()) this.amrMessageManager.handleMessage(topic, message) diff --git a/src/modules/amr/ptr/PtrObject.ts b/src/modules/amr/ptr/PtrObject.ts index 59a90c6..51488d9 100644 --- a/src/modules/amr/ptr/PtrObject.ts +++ b/src/modules/amr/ptr/PtrObject.ts @@ -62,7 +62,12 @@ export default class PtrObject extends THREE.Object3D { private runningStepTask: StepTask = null public runningStepTaskList: StepTask[] = [] + // 移动动画 public travelAnimation: core.Tween = null + // 旋转动画 + public rotationAnimation: core.Tween = null + // 动作动画 + public actionAnimation: core.Tween = null // 心跳间隔 UInt32 单位: s private heartBeatInterval: number = 0 @@ -345,7 +350,7 @@ export default class PtrObject extends THREE.Object3D { if (!worldModel.state.runState.isVirtual) { return } - console.log('send message:', JSON.stringify(msg)) + // console.log('send message:', JSON.stringify(msg)) if (this.sendMessageQueue.indexOf(msg) < 0) { this.sendMessageQueue.push(msg) } @@ -428,17 +433,17 @@ export default class PtrObject extends THREE.Object3D { while (ra < 0) { ra += Math.PI * 2 } - const ddra = Math.PI / 8 - if (ra >= ddra * 7 || ra < ddra) { + const ddra = Math.PI / 180 + if (ra >= Math.PI * 2 - ddra || ra <= ddra) { this.currentDirection = 0; - } else if (ra >= ddra && ra < ddra * 3) { + } else if (ra >= Math.PI/2 - ddra && ra <= Math.PI/2 + ddra) { this.currentDirection = 3; - } else if (ra >= ddra * 3 && ra < ddra * 5) { + } else if (ra >= Math.PI - ddra && ra <= Math.PI + ddra) { this.currentDirection = 2; - } else if (ra >= ddra * 5 && ra < ddra * 7) { + } else if (ra >= Math.PI/2*3 - ddra && ra <= Math.PI/2*3 + ddra) { this.currentDirection = 1; } else { this.currentDirection = 15; @@ -477,11 +482,13 @@ export default class PtrObject extends THREE.Object3D { } let endDirection = currentStepTask.EndDirection - if (data.Link.length > 0) { + const linkCount = data.Link?.length || 0 + if (linkCount > 0) { for (let i = 0; i < data.Link.length; i++) { const link = data.Link[i] if ((currentStepTask.X == link.X && currentStepTask.Y == link.Y) || (currentStepTask.X != link.X && currentStepTask.Y != link.Y)) { + debugger continue } else if (currentStepTask.X < link.X) { if (link.Speed > 0) { @@ -547,75 +554,82 @@ export default class PtrObject extends THREE.Object3D { } } + // 如果没有link 或者当前link的XY是任务结束点位 + if (linkCount <= 0 + || (linkCount > 0 && data.Link[linkCount - 1].X == data.EndX && data.Link[linkCount - 1].Y == data.EndY)) { - if (data.OperationType == 0 && data.EndDirection >= 0 && data.EndDirection <= 3) { - endDirection = data.EndDirection; - } else if (data.OperationType == 3 && data.ChargeDirection >= 0 && data.ChargeDirection <= 3) { - endDirection = data.ChargeDirection - } else if (data.OperationType == 4 && data.GoodsSlotDirection >= 0 && data.GoodsSlotDirection <= 3) { - if (data.GoodsSlotDirection == 0) { - endDirection = 3 - } else { - endDirection = (data.GoodsSlotDirection - 1) as LogicDirection + if (data.OperationType == 0 && data.EndDirection >= 0 && data.EndDirection <= 3) { + endDirection = data.EndDirection; + } else if (data.OperationType == 3 && data.ChargeDirection >= 0 && data.ChargeDirection <= 3) { + endDirection = data.ChargeDirection + } else if (data.OperationType == 4 && data.GoodsSlotDirection >= 0 && data.GoodsSlotDirection <= 3) { + if (data.GoodsSlotDirection == 0) { + endDirection = 3 + } else { + endDirection = (data.GoodsSlotDirection - 1) as LogicDirection + } } - } - if (endDirection != currentStepTask.EndDirection) { - const stepTask: StepTask = { - SeqNo: data.SeqNo, - StepTaskType: "ROTATION", - OperationType: 0, - PickMode: 0, - X: data.EndX, - Y: data.EndY, - Speed: currentStepTask.Speed, - EndDirection: endDirection, - ChargeLocation: data.ChargeLocation, - GoodsSlotHeight: data.GoodsSlotHeight, - position: Model.getPositionByLogicXY(data.EndX, data.EndY) as THREE.Vector3, - isCompleted: false + if (endDirection != currentStepTask.EndDirection) { + const stepTask: StepTask = { + SeqNo: data.SeqNo, + StepTaskType: "ROTATION", + OperationType: 0, + PickMode: 0, + X: data.EndX, + Y: data.EndY, + Speed: currentStepTask.Speed, + EndDirection: endDirection, + ChargeLocation: data.ChargeLocation, + GoodsSlotHeight: data.GoodsSlotHeight, + position: Model.getPositionByLogicXY(data.EndX, data.EndY) as THREE.Vector3, + isCompleted: false + } + this.currentStepTaskList.push(stepTask) } - this.currentStepTaskList.push(stepTask) - } - if (data.OperationType == 3) { + if (data.OperationType == 3) { - const stepTask: StepTask = { - SeqNo: data.SeqNo, - StepTaskType: "CHARGE", - OperationType: 3, - PickMode: 0, - X: data.EndX, - Y: data.EndY, - Speed: currentStepTask.Speed, - EndDirection: endDirection, - ChargeLocation: data.ChargeLocation, - GoodsSlotHeight: data.GoodsSlotHeight, - position: Model.getPositionByLogicXY(data.EndX, data.EndY) as THREE.Vector3, - isCompleted: false - } - this.currentStepTaskList.push(stepTask) - - } else if (data.OperationType == 4) { - - const stepTask: StepTask = { - SeqNo: data.SeqNo, - StepTaskType: data.PickMode == 1 ? "LOAD" : "UNLOAD", - OperationType: 4, - PickMode: data.PickMode, - X: data.EndX, - Y: data.EndY, - Speed: currentStepTask.Speed, - EndDirection: endDirection, - ChargeLocation: data.ChargeLocation, - GoodsSlotHeight: data.GoodsSlotHeight, - position: Model.getPositionByLogicXY(data.EndX, data.EndY) as THREE.Vector3, - isCompleted: false - } - this.currentStepTaskList.push(stepTask) + const stepTask: StepTask = { + SeqNo: data.SeqNo, + StepTaskType: "CHARGE", + OperationType: 3, + PickMode: 0, + X: data.EndX, + Y: data.EndY, + Speed: currentStepTask.Speed, + EndDirection: endDirection, + ChargeLocation: data.ChargeLocation, + GoodsSlotHeight: data.GoodsSlotHeight, + position: Model.getPositionByLogicXY(data.EndX, data.EndY) as THREE.Vector3, + isCompleted: false + } + this.currentStepTaskList.push(stepTask) - } else { + } else if (data.OperationType == 4) { + + const stepTask: StepTask = { + SeqNo: data.SeqNo, + StepTaskType: data.PickMode == 1 ? "LOAD" : "UNLOAD", + OperationType: 4, + PickMode: data.PickMode, + X: data.EndX, + Y: data.EndY, + Speed: currentStepTask.Speed, + EndDirection: endDirection, + ChargeLocation: data.ChargeLocation, + GoodsSlotHeight: data.GoodsSlotHeight, + position: Model.getPositionByLogicXY(data.EndX, data.EndY) as THREE.Vector3, + isCompleted: false + } + this.currentStepTaskList.push(stepTask) + } else { + + } } + + console.log(JSON.stringify(this.currentStepTaskList)) + } executeTask() { @@ -624,6 +638,7 @@ export default class PtrObject extends THREE.Object3D { const stepTask = this.currentStepTaskList[0] if (this.runningStepTask) { if ((stepTask.StepTaskType == "MOVE" || stepTask.StepTaskType == "MOVE_BACKWARD") + && this.rotationAnimation == null && this.actionAnimation == null && stepTask.EndDirection == this.runningStepTask.EndDirection && (stepTask.Speed > 0) == (this.runningStepTask.Speed > 0)) { this.runningStepTask = stepTask @@ -693,12 +708,13 @@ export default class PtrObject extends THREE.Object3D { const duration = time return new Promise(resolve => { - gsap.to(this.rotation, { + this.rotationAnimation = gsap.to(this.rotation, { y: tr, duration, ease: 'none', onComplete: ()=>{ resolve() + this.rotationAnimation = null this.onActionCompleted() } }) @@ -718,11 +734,7 @@ export default class PtrObject extends THREE.Object3D { if (!this.travelAnimation) { return new Promise(resolve => { - this.travelAnimation = gsap.fromTo(this.position, { - x: fromPos.x, - y: fromPos.y, - z: fromPos.z, - }, { + this.travelAnimation = gsap.to(this.position, { x: toPos.x, y: toPos.y, z: toPos.z, @@ -776,6 +788,7 @@ export default class PtrObject extends THREE.Object3D { ()=>this.animationUpFork(height + 0.2).then( ()=>this.animationHideFork().then( ()=>this.animationDownFork().then(()=>{ + this.actionAnimation = null this.onActionCompleted() }) ) @@ -792,6 +805,7 @@ export default class PtrObject extends THREE.Object3D { ()=>this.animationUpFork(height).then( ()=>this.animationHideFork().then( ()=>this.animationDownFork().then(()=>{ + this.actionAnimation = null this.onActionCompleted() }) ) @@ -815,13 +829,13 @@ export default class PtrObject extends THREE.Object3D { //获取ptr的角度朝向 getAmrOrientation(radY: number) { - radY = radY + Math.PI while (radY < 0) { radY += Math.PI * 2 } while (radY > Math.PI * 2) { radY -= Math.PI * 2 } + radY = (Math.PI * 2 - radY)%(Math.PI * 2) return THREE.MathUtils.radToDeg(radY) } diff --git a/src/modules/amr/ptr/cl2/Cl23dObject.ts b/src/modules/amr/ptr/cl2/Cl23dObject.ts index 1ca81c4..affaecf 100644 --- a/src/modules/amr/ptr/cl2/Cl23dObject.ts +++ b/src/modules/amr/ptr/cl2/Cl23dObject.ts @@ -83,7 +83,7 @@ export default class Cl23dObject extends PtrObject { const ptrPillar = this.getObjectByName('ptrPillar') const time = 3 return new Promise(resolve => { - gsap.to(ptrPillar.position, { + this.actionAnimation = gsap.to(ptrPillar.position, { z: -z, duration: time, repeat: 0, @@ -106,7 +106,7 @@ export default class Cl23dObject extends PtrObject { const bh = 0.22 const children = ptrFork.children - gsap.to(ptrFork.position, { + this.actionAnimation = gsap.to(ptrFork.position, { y: y, duration: time, repeat: 0, diff --git a/src/modules/amr/ptr/clx/Clx3dObject.ts b/src/modules/amr/ptr/clx/Clx3dObject.ts index f1be300..ee8ed1a 100644 --- a/src/modules/amr/ptr/clx/Clx3dObject.ts +++ b/src/modules/amr/ptr/clx/Clx3dObject.ts @@ -184,7 +184,7 @@ export default class Clx3dObject extends PtrObject { }) return new Promise(resolve => { - gsap.to(clxFork.position, { + this.actionAnimation = gsap.to(clxFork.position, { z: -z, duration: time, repeat: 0, @@ -243,7 +243,7 @@ export default class Clx3dObject extends PtrObject { const bh = 0.22 const children = clxFork.children - gsap.to(clxFork.position, { + this.actionAnimation = gsap.to(clxFork.position, { y: y, duration: time, repeat: 0, @@ -252,7 +252,6 @@ export default class Clx3dObject extends PtrObject { onUpdate: function() { const a = this.targets()[0] if (a.y < bh) { - console.log(a.z) if (a.z > -1) { for (let i = 0; i < children.length; i++) { const child = children[i] From b4f92ef58bcb140624f92821e299336ad6852131 Mon Sep 17 00:00:00 2001 From: lizw-2015 <1183409807@qq.com> Date: Fri, 4 Jul 2025 17:20:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat(task):=20=E4=BC=98=E5=8C=96=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E8=A7=86=E5=9B=BE=E5=8A=9F=E8=83=BD=E5=92=8C=E5=B8=83?= =?UTF-8?q?=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加刷新按钮和自动追踪开关 - 增加任务进度显示 - 优化树形结构展示 - 调整样式和布局,提高可读性和易用性 --- src/editor/widgets/task/TaskView2.vue | 42 +++++++++++++++++++++++++++++------ src/router/index.ts | 2 +- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/editor/widgets/task/TaskView2.vue b/src/editor/widgets/task/TaskView2.vue index 198ecb3..eb5d5cd 100644 --- a/src/editor/widgets/task/TaskView2.vue +++ b/src/editor/widgets/task/TaskView2.vue @@ -5,6 +5,8 @@ import { localeText as localeTextCn } from "@/components/yvTable/yv-aggrid-cn.lo import { Request } from "@ease-forge/shared"; import type { GridOptions } from "ag-grid-enterprise"; import type { GridApi, GridReadyEvent } from "ag-grid-community"; +import { Refresh } from "@element-plus/icons-vue"; +import { ElButton, ElInput, ElSwitch } from "element-plus"; defineOptions({ name: 'TaskView', @@ -20,12 +22,14 @@ const props = withDefaults(defineProps(), {}); // 定义 State 类型 interface TaskViewState { loading: boolean; + automaticTracking: boolean; grid1Data: Array; } // state 属性 const state = reactive({ loading: false, + automaticTracking: false, grid1Data: [], }); @@ -50,6 +54,7 @@ const data: TaskViewData = { { field: 'type', headerName: '类型', width: 120 }, { field: 'status', headerName: '状态', width: 120 }, { field: 'err', headerName: '异常' }, + { field: 'progress', headerName: '进度' }, { field: 'payload', headerName: '任务负载', width: 600 }, { field: 'priority', headerName: '优先级', width: 120 }, { field: 'info', headerName: '任务明细', width: 800 }, @@ -65,7 +70,7 @@ const data: TaskViewData = { field: 'title', width: 300, }, - groupDefaultExpanded: -1, + // groupDefaultExpanded: -1, onGridReady(event: GridReadyEvent) { data.api = event.api; }, @@ -160,12 +165,13 @@ function toTreeData(data: Array) { info: `报文类型: ${device.packetType}, 报文目标点: ${device.packetEndPoint}, 报文内容: ${device.packetPayload}, 执行器ID: ${device.deviceItemId}`, children: [], }; - // planNode.children.push(deviceNode); + planNode.children.push(deviceNode); tree.push(deviceNode); } - // bizNode.children.push(planNode); + bizNode.children.push(planNode); tree.push(planNode); } + bizNode.progress = `${bizNode.children.filter(item => item.status === PlanTaskStatus.FINISHED).length}/${bizNode.children.length}`; tree.push(bizNode); } return tree; @@ -190,10 +196,27 @@ export type {