Browse Source

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

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

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

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

Loading…
Cancel
Save