| | |
| | | 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] = command.getTaskNo().shortValue(); |
| | | array[2] = command.getTaskMode().shortValue(); |
| | | array[3] = command.getSourcePosX().shortValue(); |
| | | array[4] = command.getSourcePosY().shortValue(); |
| | | array[5] = command.getSourcePosZ().shortValue(); |
| | |
| | | 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) { |
| | | if (taskNo != command.getTaskNo().shortValue() |
| | | || taskMode != command.getTaskMode().shortValue() |
| | | || sourcePosX != command.getSourcePosX().shortValue() |
| | | || sourcePosY != command.getSourcePosY().shortValue() |
| | | || sourcePosZ != command.getSourcePosZ().shortValue() |
| | | || destinationPosX != command.getDestinationPosX().shortValue() |
| | | || destinationPosY != command.getDestinationPosY().shortValue() |
| | | || destinationPosZ != command.getDestinationPosZ().shortValue()) { |
| | | result = siemensNet.Write("DB100.0", array); |
| | | } else { |
| | | commandDataResult = true; |
| | |
| | | return response; |
| | | } |
| | | |
| | | int confirmIdx = 0; |
| | | boolean confirmFlag = false; |
| | | int writeConfirmIdx = 0; |
| | | boolean commandConfirmResult = false; |
| | | do { |
| | | OperateResult confirmResult = siemensNet.Write("DB100.18", (short) 1); |
| | | if (!confirmResult.IsSuccess) { |
| | | OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.18", (short) 2); |
| | | if (resultRead.IsSuccess) { |
| | | short confirm = siemensNet.getByteTransform().TransInt16(resultRead.Content, 0); |
| | | if(confirm == 0) { |
| | | OperateResult result = siemensNet.Write("DB100.18", (short) 1); |
| | | if (result.IsSuccess) { |
| | | OperateResultExOne<byte[]> commandReadResult = siemensNet.Read("DB100.18", (short) 2); |
| | | if (commandReadResult.IsSuccess) { |
| | | short commandRead = siemensNet.getByteTransform().TransInt16(commandReadResult.Content, 0); |
| | | if (commandRead == 0) { |
| | | Thread.sleep(500); |
| | | }else { |
| | | confirmFlag = true; |
| | | commandConfirmResult = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | confirmIdx++; |
| | | writeConfirmIdx++; |
| | | Thread.sleep(200); |
| | | } while (confirmIdx < 5); |
| | | } while (writeConfirmIdx < 5); |
| | | |
| | | if(!confirmFlag) { |
| | | if (!commandConfirmResult) { |
| | | News.error("堆垛机写入确认数据失败 ===>> [id:{}]", command.getCrnNo()); |
| | | response.setMessage("堆垛机写入确认数据失败"); |
| | | return response; |