| | |
| | | |
| | | @Override |
| | | public boolean disconnect() { |
| | | try { executor.shutdownNow(); } catch (Exception ignore) {} |
| | | return true; |
| | | } |
| | | |
| | |
| | | } |
| | | response.setResult(true); |
| | | return response; |
| | | } |
| | | |
| | | @Override |
| | | public CommandResponse sendCommand1(CrnCommand command) { |
| | | CommandResponse response = new CommandResponse(false); |
| | | if (command.getTaskMode().intValue() == CrnTaskModeType.LOC_MOVE.id) { |
| | | //取放货 |
| | | executor.submit(() -> commandTake(command)); |
| | | } else if (command.getTaskMode().intValue() == CrnTaskModeType.CRN_MOVE.id) { |
| | | //移动 |
| | | executor.submit(() -> commandMove(command)); |
| | | } else if (command.getTaskMode().intValue() == CrnTaskModeType.NONE.id) { |
| | | //复位 |
| | | executor.submit(() -> commandTaskComplete(command)); |
| | | } |
| | | response.setResult(true); |
| | | return response; |
| | | } |
| | | |
| | | @Override |
| | | public CommandResponse sendCommand2(CrnCommand command) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public CommandResponse sendCommand3(CrnCommand command) { |
| | | return null; |
| | | } |
| | | |
| | | private void commandTaskComplete(CrnCommand command) { |
| | |
| | | moveZ(this.crnStatus.getLevel(), sourcePosZ); |
| | | this.crnStatus.setStatus(CrnStatusType.FETCHING.id); |
| | | sleep(2000); |
| | | if (Thread.currentThread().isInterrupted()) { |
| | | return; |
| | | } |
| | | |
| | | this.crnStatus.setLoaded(1); |
| | | this.crnStatus.setStatus(CrnStatusType.PUT_MOVING.id); |
| | |
| | | moveZ(this.crnStatus.getLevel(), destinationPosZ); |
| | | this.crnStatus.setStatus(CrnStatusType.PUTTING.id); |
| | | sleep(2000); |
| | | if (Thread.currentThread().isInterrupted()) { |
| | | return; |
| | | } |
| | | this.crnStatus.setLoaded(0); |
| | | this.crnStatus.setStatus(CrnStatusType.WAITING.id); |
| | | } |
| | |
| | | initSourcePosZ++; |
| | | this.crnStatus.setLevel(initSourcePosZ); |
| | | sleep(1000); |
| | | if (Thread.currentThread().isInterrupted()) { |
| | | return; |
| | | } |
| | | } |
| | | }else { |
| | | int moveLength = sourcePosZ - destinationPosZ; |
| | |
| | | initSourcePosZ--; |
| | | this.crnStatus.setLevel(initSourcePosZ); |
| | | sleep(1000); |
| | | if (Thread.currentThread().isInterrupted()) { |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | initSourcePosY++; |
| | | this.crnStatus.setBay(initSourcePosY); |
| | | sleep(1000); |
| | | if (Thread.currentThread().isInterrupted()) { |
| | | return; |
| | | } |
| | | } |
| | | }else { |
| | | int moveLength = sourcePosY - destinationPosY; |
| | |
| | | initSourcePosY--; |
| | | this.crnStatus.setBay(initSourcePosY); |
| | | sleep(1000); |
| | | if (Thread.currentThread().isInterrupted()) { |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void sleep(long ms) { |
| | | private void sleep(long ms) { |
| | | try { |
| | | Thread.sleep(ms); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | Thread.currentThread().interrupt(); |
| | | } |
| | | } |
| | | } |