| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.zy.asrs.entity.DeviceConfig; |
| | | import com.zy.core.enums.CrnStatusType; |
| | | import com.zy.core.enums.CrnTaskModeType; |
| | | import com.zy.core.enums.DualCrnTaskModeType; |
| | | import com.zy.core.model.CommandResponse; |
| | | import com.zy.core.model.command.DualCrnCommand; |
| | | import com.zy.core.network.api.ZyDualCrnConnectApi; |
| | |
| | | @Override |
| | | public CommandResponse sendCommand(DualCrnCommand command) { |
| | | CommandResponse response = new CommandResponse(false); |
| | | if (command.getTaskMode().intValue() == CrnTaskModeType.LOC_MOVE.id) { |
| | | if (command.getTaskMode().intValue() == DualCrnTaskModeType.TRANSFER.id) { |
| | | //取放货 |
| | | executor.submit(() -> commandTake(command)); |
| | | } else if (command.getTaskMode().intValue() == CrnTaskModeType.CRN_MOVE.id) { |
| | | } else if (command.getTaskMode().intValue() == DualCrnTaskModeType.PICK.id) { |
| | | //取货 |
| | | executor.submit(() -> commandPick(command)); |
| | | } else if (command.getTaskMode().intValue() == DualCrnTaskModeType.PUT.id) { |
| | | //放货 |
| | | executor.submit(() -> commandPut(command)); |
| | | } else if (command.getTaskMode().intValue() == DualCrnTaskModeType.MOVE.id) { |
| | | //移动 |
| | | executor.submit(() -> commandMove(command)); |
| | | } else if (command.getTaskMode().intValue() == CrnTaskModeType.NONE.id) { |
| | | } else if (command.getTaskMode().intValue() == DualCrnTaskModeType.CONFIRM.id) { |
| | | //复位 |
| | | executor.submit(() -> commandTaskComplete(command)); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | private void commandPick(DualCrnCommand command) { |
| | | int destinationPosX = command.getDestinationPosX().intValue(); |
| | | int destinationPosY = command.getDestinationPosY().intValue(); |
| | | int destinationPosZ = command.getDestinationPosZ().intValue(); |
| | | int taskMode = command.getTaskMode().intValue(); |
| | | int taskNo = command.getTaskNo().intValue(); |
| | | |
| | | this.crnStatus.setMode(taskMode); |
| | | if(command.getStation() == 1) { |
| | | this.crnStatus.setTaskNo(taskNo); |
| | | this.crnStatus.setStatus(CrnStatusType.FETCH_MOVING.id); |
| | | |
| | | moveY(this.crnStatus.getBay(), destinationPosY, command.getStation().intValue()); |
| | | moveZ(this.crnStatus.getLevel(), destinationPosZ, command.getStation().intValue()); |
| | | this.crnStatus.setStatus(CrnStatusType.FETCHING.id); |
| | | sleep(2000); |
| | | if (Thread.currentThread().isInterrupted()) { |
| | | return; |
| | | } |
| | | this.crnStatus.setLoaded(1); |
| | | this.crnStatus.setStatus(CrnStatusType.WAITING.id); |
| | | }else { |
| | | this.crnStatus.setTaskNoTwo(taskNo); |
| | | this.crnStatus.setStatusTwo(CrnStatusType.FETCH_MOVING.id); |
| | | |
| | | moveY(this.crnStatus.getBayTwo(), destinationPosY, command.getStation().intValue()); |
| | | moveZ(this.crnStatus.getLevelTwo(), destinationPosZ, command.getStation().intValue()); |
| | | this.crnStatus.setStatusTwo(CrnStatusType.FETCHING.id); |
| | | sleep(2000); |
| | | if (Thread.currentThread().isInterrupted()) { |
| | | return; |
| | | } |
| | | this.crnStatus.setLoadedTwo(1); |
| | | this.crnStatus.setStatusTwo(CrnStatusType.WAITING.id); |
| | | } |
| | | } |
| | | |
| | | private void commandPut(DualCrnCommand command) { |
| | | int destinationPosX = command.getDestinationPosX().intValue(); |
| | | int destinationPosY = command.getDestinationPosY().intValue(); |
| | | int destinationPosZ = command.getDestinationPosZ().intValue(); |
| | | int taskMode = command.getTaskMode().intValue(); |
| | | int taskNo = command.getTaskNo().intValue(); |
| | | |
| | | this.crnStatus.setMode(taskMode); |
| | | if(command.getStation() == 1) { |
| | | this.crnStatus.setTaskNo(taskNo); |
| | | this.crnStatus.setStatus(CrnStatusType.PUT_MOVING.id); |
| | | |
| | | moveY(this.crnStatus.getBay(), destinationPosY, command.getStation().intValue()); |
| | | moveZ(this.crnStatus.getLevel(), destinationPosZ, command.getStation().intValue()); |
| | | this.crnStatus.setStatus(CrnStatusType.PUTTING.id); |
| | | sleep(2000); |
| | | if (Thread.currentThread().isInterrupted()) { |
| | | return; |
| | | } |
| | | this.crnStatus.setLoaded(0); |
| | | this.crnStatus.setStatus(CrnStatusType.WAITING.id); |
| | | }else { |
| | | this.crnStatus.setTaskNoTwo(taskNo); |
| | | this.crnStatus.setStatusTwo(CrnStatusType.PUT_MOVING.id); |
| | | |
| | | moveY(this.crnStatus.getBayTwo(), destinationPosY, command.getStation().intValue()); |
| | | moveZ(this.crnStatus.getLevelTwo(), destinationPosZ, command.getStation().intValue()); |
| | | this.crnStatus.setStatusTwo(CrnStatusType.PUTTING.id); |
| | | sleep(2000); |
| | | if (Thread.currentThread().isInterrupted()) { |
| | | return; |
| | | } |
| | | this.crnStatus.setLoadedTwo(0); |
| | | this.crnStatus.setStatusTwo(CrnStatusType.WAITING.id); |
| | | } |
| | | } |
| | | |
| | | private void moveZ(int sourcePosZ, int destinationPosZ, int station) { |
| | | if(destinationPosZ - sourcePosZ > 0) { |
| | | int moveLength = destinationPosZ - sourcePosZ; |