| | |
| | | array[9] = command.getCommand(); |
| | | // array[10] = 0; //备用1 |
| | | |
| | | boolean[] array2 = new boolean[1]; |
| | | array2[0] = command.isTraySize(); |
| | | |
| | | OperateResult result = siemensNet.Write("DB100.0", array); |
| | | OperateResult result2 = siemensNet.Write("DB100.22", array2); |
| | | News.info("堆垛机命令下发[id:{}] >>>>> {}", slave.getId(), array); |
| | | |
| | | //堆垛机任务写入后,回读一次,看是否成功 |
| | |
| | | |
| | | do { |
| | | try{ |
| | | if(!result.IsSuccess || !result2.IsSuccess){ |
| | | if(!result.IsSuccess ){ |
| | | if (!resetFlag){ |
| | | News.error("写入堆垛机plc数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSON(command),writeCount1); |
| | | // MessageQueue.offer(SlaveType.Crn, slave.getId(), new Task(2, command)); |
| | | result = siemensNet.Write("DB100.0", array); |
| | | result2 = siemensNet.Write("DB100.22", array2); |
| | | } |
| | | Thread.sleep(100); |
| | | writeCount1++; |
| | | continue; |
| | | } |
| | | OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 24); |
| | | OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 18); |
| | | if (resultRead.IsSuccess) { |
| | | CrnCommand one = new CrnCommand(); |
| | | one.setTaskNo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 2)); |
| | |
| | | one.setDestinationPosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 12)); |
| | | one.setDestinationPosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 14)); |
| | | one.setDestinationPosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 16)); |
| | | one.setTraySize(siemensNet.getByteTransform().TransBool(resultRead.Content, 22)); |
| | | if (!command.getTaskNo().equals(one.getTaskNo()) || !command.getTaskMode().equals(one.getTaskMode()) |
| | | || !command.getSourcePosX().equals(one.getSourcePosX()) || !command.getSourcePosY().equals(one.getSourcePosY()) |
| | | || !command.getSourcePosZ().equals(one.getSourcePosZ()) || !command.getDestinationPosX().equals(one.getDestinationPosX()) |
| | | || !command.getDestinationPosY().equals(one.getDestinationPosY()) || !command.getDestinationPosZ().equals(one.getDestinationPosZ()) |
| | | || !command.isTraySize() == one.isTraySize() |
| | | ){ |
| | | try{ |
| | | News.error("堆垛机命令地址写入后回读失败==>不一致[id:{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), JSON.toJSON(command),JSON.toJSON(one)); |
| | |
| | | |
| | | } |
| | | if (!resetFlag){ |
| | | // News.error("堆垛机命令回读失败后,重新添加任务到队列 ===>> [id:{}],{},resetFlag={}", slave.getId(), JSON.toJSON(command),resetFlag); |
| | | // MessageQueue.offer(SlaveType.Crn, slave.getId(), new Task(2, command)); |
| | | News.error("写入堆垛机plc数据失败,重新下发任务 回读不一致 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSON(command),writeCount1); |
| | | result = siemensNet.Write("DB100.0", array); |
| | | result2 = siemensNet.Write("DB100.22", array2); |
| | | } |
| | | writeCount1++; |
| | | continue; |
| | |
| | | News.error("堆垛机任务确认位"+commandFinish+"写入数据与回读数据不一致!"+"循环执行次数:"+writeCount2+"次"); |
| | | }else{ |
| | | //任务命令写入成功 |
| | | // News.info("堆垛机任务确认位"+commandFinish+"回读成功!"+"循环执行次数:"+writeCount2+"次"); |
| | | News.info("堆垛机任务确认位"+commandFinish+"回读成功!"+"循环执行次数:"+writeCount2+"次"); |
| | | break; |
| | | } |
| | | }else { |