| | |
| | | private DeviceConfig deviceConfig; |
| | | private final ExecutorService executor = Executors.newSingleThreadExecutor(); |
| | | |
| | | private long fetchPutDurationMs() { return FakeConfigSupport.getLong(FakeConfigKeys.FAKE_CRN_FETCH_PUT_DURATION_MS); } |
| | | private long levelStepDurationMs() { return FakeConfigSupport.getLong(FakeConfigKeys.FAKE_CRN_LEVEL_STEP_DURATION_MS); } |
| | | private long bayStepDurationMs() { return FakeConfigSupport.getLong(FakeConfigKeys.FAKE_CRN_BAY_STEP_DURATION_MS); } |
| | | private long resetDurationMs() { return FakeConfigSupport.getLong(FakeConfigKeys.FAKE_CRN_RESET_DURATION_MS); } |
| | | |
| | | public ZyCrnFakeConnect(DeviceConfig deviceConfig) { |
| | | this.deviceConfig = deviceConfig; |
| | | this.crnStatus = JSON.parseObject(deviceConfig.getFakeInitStatus(), ZyCrnStatusEntity.class); |
| | |
| | | } |
| | | |
| | | private void commandTaskComplete(CrnCommand command) { |
| | | sleep(resetDurationMs()); |
| | | this.crnStatus.setLoaded(0); |
| | | this.crnStatus.setTaskNo(0); |
| | | this.crnStatus.setStatus(CrnStatusType.IDLE.id); |
| | | } |
| | |
| | | moveY(this.crnStatus.getBay(), sourcePosY); |
| | | moveZ(this.crnStatus.getLevel(), sourcePosZ); |
| | | this.crnStatus.setStatus(CrnStatusType.FETCHING.id); |
| | | sleep(2000); |
| | | sleep(fetchPutDurationMs()); |
| | | if (Thread.currentThread().isInterrupted()) { |
| | | return; |
| | | } |
| | |
| | | moveY(this.crnStatus.getBay(), destinationPosY); |
| | | moveZ(this.crnStatus.getLevel(), destinationPosZ); |
| | | this.crnStatus.setStatus(CrnStatusType.PUTTING.id); |
| | | sleep(2000); |
| | | sleep(fetchPutDurationMs()); |
| | | if (Thread.currentThread().isInterrupted()) { |
| | | return; |
| | | } |
| | |
| | | for(int i = 0; i < moveLength; i++) { |
| | | initSourcePosZ++; |
| | | this.crnStatus.setLevel(initSourcePosZ); |
| | | sleep(1000); |
| | | sleep(levelStepDurationMs()); |
| | | if (Thread.currentThread().isInterrupted()) { |
| | | return; |
| | | } |
| | |
| | | for(int i = 0; i < moveLength; i++) { |
| | | initSourcePosZ--; |
| | | this.crnStatus.setLevel(initSourcePosZ); |
| | | sleep(1000); |
| | | sleep(levelStepDurationMs()); |
| | | if (Thread.currentThread().isInterrupted()) { |
| | | return; |
| | | } |
| | |
| | | for(int i = 0; i < moveLength; i++) { |
| | | initSourcePosY++; |
| | | this.crnStatus.setBay(initSourcePosY); |
| | | sleep(1000); |
| | | sleep(bayStepDurationMs()); |
| | | if (Thread.currentThread().isInterrupted()) { |
| | | return; |
| | | } |
| | |
| | | for(int i = 0; i < moveLength; i++) { |
| | | initSourcePosY--; |
| | | this.crnStatus.setBay(initSourcePosY); |
| | | sleep(1000); |
| | | sleep(bayStepDurationMs()); |
| | | if (Thread.currentThread().isInterrupted()) { |
| | | return; |
| | | } |