| | |
| | | return false; |
| | | } |
| | | |
| | | //下发前克隆一份 |
| | | CrnCommand crnCommand = new CrnCommand(); |
| | | crnCommand.setCrnNo(command.getCrnNo()); |
| | | crnCommand.setAckFinish(command.getAckFinish()); |
| | | crnCommand.setTaskNo(command.getTaskNo()); |
| | | crnCommand.setTaskMode(command.getTaskMode()); |
| | | crnCommand.setSourcePosX(command.getSourcePosX()); |
| | | crnCommand.setSourcePosY(command.getSourcePosY()); |
| | | crnCommand.setSourcePosZ(command.getSourcePosZ()); |
| | | crnCommand.setDestinationPosX(command.getDestinationPosX()); |
| | | crnCommand.setDestinationPosY(command.getDestinationPosY()); |
| | | crnCommand.setDestinationPosZ(command.getDestinationPosZ()); |
| | | crnCommand.setSourceStaNo(command.getSourceStaNo()); |
| | | crnCommand.setDestinationStaNo(command.getDestinationStaNo()); |
| | | crnCommand.setCommand(command.getCommand()); |
| | | |
| | | // convertRow(command); |
| | | command.setCrnNo(slave.getId()); |
| | | short[] array = new short[10]; |
| | |
| | | array[9] = command.getCommand(); |
| | | OperateResult result = siemensNet.Write("DB100.0", array); |
| | | |
| | | if(!result.IsSuccess){ |
| | | log.error("写入堆垛机plc数据失败,重新添加任务到队列 ===>> [id:{}],{}", slave.getId(), JSON.toJSON(crnCommand)); |
| | | MessageQueue.offer(SlaveType.Crn, slave.getId(), new Task(2, crnCommand)); |
| | | Thread.sleep(100); |
| | | readStatus(); |
| | | return false; |
| | | } |
| | | |
| | | //堆垛机任务写入后,回读一次,看是否成功 |
| | | Thread.sleep(200); |
| | | OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 20); |
| | |
| | | one.setDestinationPosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 12)); |
| | | one.setDestinationPosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 14)); |
| | | one.setDestinationPosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 16)); |
| | | if (command.getTaskNo()!=one.getTaskNo() || command.getTaskMode()!=one.getTaskMode() |
| | | if (!command.getTaskNo().equals(one.getTaskNo()) || command.getTaskMode()!=one.getTaskMode() |
| | | || command.getSourcePosX()!=one.getSourcePosX() || command.getSourcePosY()!=one.getSourcePosY() |
| | | || command.getSourcePosZ()!=one.getSourcePosZ() || command.getDestinationPosX()!=one.getDestinationPosX() |
| | | || command.getDestinationPosY()!=one.getDestinationPosY() || command.getDestinationPosZ()!=one.getDestinationPosZ() |
| | | ){ |
| | | News.error("堆垛机命令地址写入后回读失败[id:{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), JSON.toJSON(command),JSON.toJSON(one)); |
| | | News.error("堆垛机命令回读失败后,重新添加任务到队列 ===>> [id:{}],{}", slave.getId(), JSON.toJSON(crnCommand)); |
| | | MessageQueue.offer(SlaveType.Crn, slave.getId(), new Task(2, crnCommand)); |
| | | Thread.sleep(100); |
| | | readStatus(); |
| | | return false; |
| | | }else{ |
| | | News.info("堆垛机命令地址写入后回读成功[id:{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), JSON.toJSON(command),JSON.toJSON(one)); |
| | | } |
| | | } |
| | | |
| | |
| | | short commandFinish = 1; |
| | | Thread.sleep(300); |
| | | News.info("堆垛机命令地址写入成功,开始写确认位[id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command)); |
| | | result = siemensNet.Write("DB100.18", commandFinish); |
| | | Integer counts = 0; |
| | | while(true) { |
| | | result = siemensNet.Write("DB100.18", commandFinish); |
| | | if(result.IsSuccess){ |
| | | break; |
| | | } else { |
| | | counts++; |
| | | if(counts>5){ |
| | | break; |
| | | } |
| | | } |
| | | Thread.sleep(300); |
| | | } |
| | | } |
| | | } |
| | | |