| | |
| | | /** |
| | | * 读取状态 |
| | | */ |
| | | private void readStatus(){ |
| | | private void readStatus() throws InterruptedException { |
| | | |
| | | OperateResultExOne<byte[]> result = siemensNet.Read("DB101.0", (short) 56); |
| | | if (result.IsSuccess) { |
| | |
| | | /** |
| | | * 写入数据 |
| | | */ |
| | | private boolean write(CrnCommand command){ |
| | | private boolean write(CrnCommand command) throws InterruptedException { |
| | | if (null == command) { |
| | | log.error("堆垛机写入命令为空"); |
| | | return false; |
| | |
| | | array[6] = command.getDestinationPosZ(); |
| | | array[7] = command.getDestinationPosX(); |
| | | array[8] = command.getDestinationPosY(); |
| | | array[9] = command.getCommand(); |
| | | // array[9] = command.getCommand(); |
| | | |
| | | // 作业信息 |
| | | OperateResult result = siemensNet.Write("DB100.0", array); |
| | |
| | | }catch (Exception e){ |
| | | log.error("堆垛机命令地址写入后回读出错"); |
| | | } |
| | | |
| | | if (command.getAckFinish() == 0) { |
| | | if (result.IsSuccess) { |
| | | Thread.sleep(300); |
| | | //任务下发次数 |
| | | int writeCount2 = 0; |
| | | |
| | | do { |
| | | writeCount2++; |
| | | short commandFinish = (short) 1; |
| | | result = siemensNet.Write("DB100.18", commandFinish); |
| | | if(result.IsSuccess){ |
| | | //堆垛机任务写入后,回读一次,看是否成功 |
| | | Thread.sleep(200); |
| | | OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.18", (short) 2); |
| | | if (resultRead.IsSuccess) { |
| | | commandFinish=siemensNet.getByteTransform().TransInt16(resultRead.Content, 0); |
| | | if (commandFinish != 1){ |
| | | log.error("堆垛机任务确认位"+commandFinish+"写入数据与回读数据不一致!"+"循环执行次数:"+writeCount2+"次"); |
| | | }else{ |
| | | //任务命令写入成功 |
| | | log.info("堆垛机任务确认位"+commandFinish+"回读成功!"+"循环执行次数:"+writeCount2+"次"); |
| | | break; |
| | | } |
| | | }else { |
| | | log.error("堆垛机任务确认位"+commandFinish+"回读失败!"+"循环执行次数:"+writeCount2+"次"); |
| | | } |
| | | } else { |
| | | log.error("堆垛机任务确认位"+commandFinish+"写入失败!"+"循环执行次数:"+writeCount2+"次"); |
| | | } |
| | | }while (writeCount2<5); |
| | | } |
| | | } |
| | | |
| | | |
| | | return true; |
| | | } |
| | | |