Browse Source

cl2 基于设备状态和任务状态分步生成设备任务消息

master
yuliang 6 months ago
parent
commit
c931454a01
  1. 61
      src/modules/amr/ptr/PtrObject.ts

61
src/modules/amr/ptr/PtrObject.ts

@ -385,12 +385,17 @@ export default class PtrObject extends THREE.Object3D {
// 处理任务
handle10010Message(data: AmrMsg10010) {
if (this.currentStepTaskList.length > 0) {
const tindex = this.currentStepTaskList.length
const lt = this.currentStepTaskList[tindex - 1]
if (this.runningStepTask.OperationType == 0 && this.runningStepTask.X == data.StartX && this.runningStepTask.Y == data.StartY) {
// this.currentStepTaskList = []
this.makeStepTask(data)
this.executeTask()
} else {
} else if (lt.OperationType == 0 && lt.X == data.StartX && lt.Y == data.StartY) {
this.makeStepTask(data)
}else {
// 此处应该有错误处理
console.log('handle10010Message:', data)
}
} else {
this.makeStepTask(data)
@ -464,31 +469,36 @@ export default class PtrObject extends THREE.Object3D {
let currentStepTask: StepTask = this.runningStepTask
if (currentStepTask == null) {
currentStepTask = {
SeqNo: 0,
StepTaskType: "MOVE",
OperationType: 0,
PickMode: 0,
X: this.currentLogicX,
Y: this.currentLogicY,
Speed: 1000,
EndDirection: this.currentDirection,
ChargeLocation: 0,
GoodsSlotHeight: 0,
position: this.position,
isCompleted: true
if (this.currentStepTaskList && this.currentStepTaskList.length > 0) {
currentStepTask = this.currentStepTaskList[this.currentStepTaskList.length - 1]
} else {
currentStepTask = {
SeqNo: 0,
StepTaskType: "MOVE",
OperationType: 0,
PickMode: 0,
X: this.currentLogicX,
Y: this.currentLogicY,
Speed: 1000,
EndDirection: this.currentDirection,
ChargeLocation: 0,
GoodsSlotHeight: 0,
position: this.position,
isCompleted: true
}
}
}
let endDirection = currentStepTask.EndDirection
const linkCount = data.Link?.length || 0
if (linkCount > 0) {
let prevLink = {X: data.StartX, Y: data.StartY, Speed: 1000}
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
prevLink = link
continue
} else if (currentStepTask.X < link.X) {
if (link.Speed > 0) {
@ -522,13 +532,13 @@ export default class PtrObject extends THREE.Object3D {
StepTaskType: "ROTATION",
OperationType: 0,
PickMode: 0,
X: link.X,
Y: link.Y,
Speed: link.Speed,
X: prevLink.X,
Y: prevLink.Y,
Speed: prevLink.Speed,
EndDirection: endDirection,
ChargeLocation: data.ChargeLocation,
GoodsSlotHeight: data.GoodsSlotHeight,
position: Model.getPositionByLogicXY(link.X, link.Y) as THREE.Vector3,
position: Model.getPositionByLogicXY(prevLink.X, prevLink.Y) as THREE.Vector3,
isCompleted: false
}
currentStepTask = stepTask
@ -551,6 +561,7 @@ export default class PtrObject extends THREE.Object3D {
}
currentStepTask = stepTask
this.currentStepTaskList.push(stepTask)
prevLink = link
}
}
@ -569,7 +580,14 @@ export default class PtrObject extends THREE.Object3D {
endDirection = (data.GoodsSlotDirection - 1) as LogicDirection
}
}
const item = this.viewport.entityManager.findItemByLogicXY(data.EndX, data.EndY)
if (endDirection != currentStepTask.EndDirection) {
// 如果此处不能转弯,忽略结束方向 等待后续任务
if (!item.dt?.agvRotation || !item.dt?.agvRotation?.length <= 0) {
return
}
const stepTask: StepTask = {
SeqNo: data.SeqNo,
StepTaskType: "ROTATION",
@ -586,6 +604,7 @@ export default class PtrObject extends THREE.Object3D {
}
this.currentStepTaskList.push(stepTask)
}
if (data.OperationType == 3) {
const stepTask: StepTask = {
@ -709,7 +728,7 @@ export default class PtrObject extends THREE.Object3D {
return new Promise(resolve => {
this.rotationAnimation = gsap.to(this.rotation, {
y: tr,
y: rad,
duration,
ease: 'none',
onComplete: ()=>{

Loading…
Cancel
Save