| | |
| | | break; |
| | | // 写入数据 1号工位 |
| | | case 2: |
| | | write((CrnCommand) task.getData()); |
| | | CrnCommand data = (CrnCommand) task.getData(); |
| | | if (data.getPltType() == null || data.getPltType() == 1) { |
| | | write(data); |
| | | } else if (data.getPltType() == 2) { |
| | | write2(data); |
| | | } |
| | | break; |
| | | // 复位 1号工位 |
| | | case 3: |
| | |
| | | command.setDestinationPosY((short) 0); // 目标库位列 |
| | | command.setDestinationPosZ((short) 0); // 目标库位层 |
| | | write(command); |
| | | break; |
| | | // 写入数据 2号工位 |
| | | case 4: |
| | | write2((CrnCommand) task.getData()); |
| | | break; |
| | | // 复位 2号工位 |
| | | case 6: |
| | |
| | | return false; |
| | | } |
| | | // 向堆垛机发任务前的堆垛机状态 |
| | | try{ |
| | | try { |
| | | OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 18); |
| | | if (resultRead.IsSuccess) { |
| | | CrnCommand one = new CrnCommand(); |
| | |
| | | || !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()) |
| | | ){ |
| | | ) { |
| | | // News.error("下发前:[id:{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), JSON.toJSON(command),JSON.toJSON(one)); |
| | | } else { |
| | | // News.info("下发前:[id:{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), JSON.toJSON(command),JSON.toJSON(one)); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | News.error("堆垛机命令地址写入后回读出错"); |
| | | } |
| | | // convertRow(command); |
| | |
| | | // array[10] = 0; //备用1 |
| | | |
| | | short[] array2 = new short[1]; |
| | | array2[0] = command.getAckFinish(); |
| | | array2[0] = command.getAckFinish(); |
| | | OperateResult result = siemensNet.Write("DB100.20", array); |
| | | OperateResult result2 = siemensNet.Write("DB100.0", array2); |
| | | News.info("堆垛机命令下发[id:{}] >>>>> {}", slave.getId(), array); |
| | |
| | | int writeCount1 = 1; |
| | | do { |
| | | try { |
| | | if (!result.IsSuccess||!result2.IsSuccess) { |
| | | if (!result.IsSuccess || !result2.IsSuccess) { |
| | | // if (!resetFlag){ |
| | | News.error("写入堆垛机plc数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSON(command), writeCount1); |
| | | result = siemensNet.Write("DB100.0", array); |
| | |
| | | writeCount2++; |
| | | short commandFinish = (short) 1; |
| | | result = siemensNet.Write("DB100.38", commandFinish); |
| | | if(result.IsSuccess){ |
| | | if (result.IsSuccess) { |
| | | //堆垛机任务写入后,回读一次,看是否成功 |
| | | Thread.sleep(200); |
| | | OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.38", (short) 2); |
| | | if (resultRead.IsSuccess) { |
| | | commandFinish=siemensNet.getByteTransform().TransInt16(resultRead.Content, 0); |
| | | if (commandFinish != 1){ |
| | | News.error("堆垛机任务确认位"+commandFinish+"写入数据与回读数据不一致!"+"循环执行次数:"+writeCount2+"次"); |
| | | }else{ |
| | | commandFinish = siemensNet.getByteTransform().TransInt16(resultRead.Content, 0); |
| | | if (commandFinish != 1) { |
| | | News.error("堆垛机任务确认位" + commandFinish + "写入数据与回读数据不一致!" + "循环执行次数:" + writeCount2 + "次"); |
| | | } else { |
| | | //任务命令写入成功 |
| | | // News.info("堆垛机任务确认位"+commandFinish+"回读成功!"+"循环执行次数:"+writeCount2+"次"); |
| | | break; |
| | | } |
| | | }else { |
| | | News.error("堆垛机任务确认位"+commandFinish+"回读失败!"+"循环执行次数:"+writeCount2+"次"); |
| | | } else { |
| | | News.error("堆垛机任务确认位" + commandFinish + "回读失败!" + "循环执行次数:" + writeCount2 + "次"); |
| | | } |
| | | } else { |
| | | News.error("堆垛机任务确认位"+commandFinish+"写入失败!"+"循环执行次数:"+writeCount2+"次"); |
| | | News.error("堆垛机任务确认位" + commandFinish + "写入失败!" + "循环执行次数:" + writeCount2 + "次"); |
| | | } |
| | | }while (writeCount2<5); |
| | | } while (writeCount2 < 5); |
| | | } |
| | | } |
| | | |
| | |
| | | null // 修改人员 |
| | | ); |
| | | bean.insert(basCrnOpt); |
| | | } catch (Exception ignore) {} |
| | | } catch (Exception ignore) { |
| | | } |
| | | |
| | | if (result != null && result.IsSuccess) { |
| | | Thread.sleep(200); |
| | |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | public void requestStop() { |
| | | isRunning = false; |
| | | } |