| | |
| | | return response; |
| | | } |
| | | |
| | | Integer commandTaskNo = command.getTaskNo(); |
| | | Integer commandTaskMode = command.getTaskMode(); |
| | | if (commandTaskMode.equals(CrnTaskModeType.RESET.id)) { |
| | | commandTaskNo = 0; |
| | | commandTaskMode = 0; |
| | | } |
| | | |
| | | short[] array = new short[9]; |
| | | array[0] = command.getAckFinish().shortValue(); |
| | | array[1] = commandTaskNo.shortValue(); |
| | | array[2] = commandTaskMode.shortValue(); |
| | | array[1] = (short) 0; |
| | | array[2] = (short) 0; |
| | | array[3] = (short) 0; |
| | | array[4] = (short) 0; |
| | | array[5] = (short) 0; |
| | | array[6] = (short) 0; |
| | | array[7] = (short) 0; |
| | | array[8] = (short) 0; |
| | | |
| | | int idx = 0; |
| | | boolean commandDataResult = false; |
| | | do { |
| | | OperateResult result = siemensNet.Write("DB100.0", array); |
| | | if (result.IsSuccess) { |
| | | OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 20); |
| | | if (resultRead.IsSuccess) { |
| | | short taskNo = siemensNet.getByteTransform().TransInt16(resultRead.Content, 2); |
| | | short taskMode = siemensNet.getByteTransform().TransInt16(resultRead.Content, 4); |
| | | short sourcePosX = siemensNet.getByteTransform().TransInt16(resultRead.Content, 6); |
| | | short sourcePosY = siemensNet.getByteTransform().TransInt16(resultRead.Content, 8); |
| | | short sourcePosZ = siemensNet.getByteTransform().TransInt16(resultRead.Content, 10); |
| | | short destinationPosX = siemensNet.getByteTransform().TransInt16(resultRead.Content, 12); |
| | | short destinationPosY = siemensNet.getByteTransform().TransInt16(resultRead.Content, 14); |
| | | short destinationPosZ = siemensNet.getByteTransform().TransInt16(resultRead.Content, 16); |
| | | if (taskNo != 0 || taskMode != 0 || sourcePosX != 0 || sourcePosY != 0 || sourcePosZ != 0 || destinationPosX != 0 || destinationPosY != 0 || destinationPosZ != 0) { |
| | | result = siemensNet.Write("DB100.0", array); |
| | | } else { |
| | | commandDataResult = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | idx++; |
| | | Thread.sleep(200); |
| | | } while (idx < 5); |
| | | |
| | | if (!commandDataResult) { |
| | | response.setMessage("堆垛机命令下发[id:{}] >>>>> {}" + command.getCrnNo() + "堆垛机写入任务数据失败"); |
| | | return response; |
| | | } |
| | | }else { |
| | | short[] array = new short[9]; |
| | | array[0] = command.getAckFinish().shortValue(); |
| | | array[1] = command.getTaskNo().shortValue(); |
| | | array[2] = command.getTaskMode().shortValue(); |
| | | array[3] = command.getSourcePosX().shortValue(); |
| | | array[4] = command.getSourcePosY().shortValue(); |
| | | array[5] = command.getSourcePosZ().shortValue(); |
| | |
| | | response.setMessage("堆垛机写入确认数据失败"); |
| | | return response; |
| | | } |
| | | } |
| | | |
| | | News.info("堆垛机命令下发[id:{}] >>>>> {}", command.getCrnNo(), JSON.toJSON(command)); |
| | | OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), command.getCrnNo(), JSON.toJSON(command))); |