| | |
| | | rgvOpt(command); |
| | | write3(command); |
| | | break; |
| | | //工位1写入取消数据 |
| | | case 4: |
| | | RgvCommand command4 = (RgvCommand) task.getData(); |
| | | rgvOpt(command4); |
| | | write4(command4); |
| | | break; |
| | | // 漫游 |
| | | case 5: |
| | | Long aLong = (Long) task.getData(); |
| | |
| | | rgvProtocol.setxDistance((short) 0); |
| | | rgvProtocol.setxDuration((short) 0); |
| | | } |
| | | |
| | | // /** |
| | | // * 初始化RGV状态 |
| | | // */ |
| | | // private void initRgv() { |
| | | // if (null == rgvProtocol) { |
| | | // rgvProtocol = new RgvProtocol(); |
| | | // } |
| | | // rgvProtocol.setRgvNo(slave.getId()); |
| | | // rgvProtocol.setMode((short) 3); |
| | | // rgvProtocol.setStatus((short)0); |
| | | // rgvProtocol.setTaskNo1((short)0); |
| | | // rgvProtocol.setStatus1((short)0); |
| | | // rgvProtocol.setLoaded1((short)0); |
| | | // rgvProtocol.setWalkPos((short)0); |
| | | // rgvProtocol.setRgvPos(slave.getId()*100000L); |
| | | // rgvProtocol.setTaskNo2((short)0); |
| | | // rgvProtocol.setStatus2((short)0); |
| | | // rgvProtocol.setLoaded2((short)0); |
| | | // rgvProtocol.setAlarm((short)0); |
| | | // rgvProtocol.setxSpeed((short) 0); |
| | | // rgvProtocol.setxDistance((short) 0); |
| | | // rgvProtocol.setxDuration((short) 0); |
| | | // } |
| | | |
| | | @Override |
| | | public boolean connect() { |
| | |
| | | return false; |
| | | } |
| | | } |
| | | private boolean write4(RgvCommand command) throws InterruptedException { |
| | | if (null == command) { |
| | | log.error("RGV写入命令为空"); |
| | | return false; |
| | | } |
| | | |
| | | // siemensNet.Write("DB24.10.0", false); |
| | | // siemensNet.Write("DB24.10.1", false); |
| | | |
| | | command.setRgvNo(slave.getId()); |
| | | short[] array = new short[5]; |
| | | array[0] = command.getRgvNo().shortValue(); |
| | | array[1] = command.getSourceStaNo1(); |
| | | array[2] = command.getDestinationStaNo1(); |
| | | array[3] = command.getTaskMode1();//任务模式 |
| | | array[4] = command.getTaskNo1(); |
| | | |
| | | |
| | | |
| | | OperateResult result = siemensNet.Write("DB24.0", array); |
| | | // |
| | | // if (command.getAckFinish1().equals((short)0)) { |
| | | //// Thread.sleep(100L); |
| | | //// siemensNet.Write("DB24.10.7", command.getRgvSome() == 1); |
| | | //// Thread.sleep(20L); |
| | | //// result = siemensNet.Write("DB24.10.0", true); |
| | | // } else { |
| | | // siemensNet.Write("DB24.10.1", true); |
| | | // } |
| | | |
| | | try { |
| | | // 日志记录 |
| | | BasRgvOptService bean = SpringUtils.getBean(BasRgvOptService.class); |
| | | BasRgvOpt basRgvOpt = new BasRgvOpt( |
| | | command.getTaskNo1().intValue(), |
| | | command.getTaskNo2().intValue(), |
| | | command.getRgvNo(), |
| | | new Date(), |
| | | command.getTaskModeType1().toString(), |
| | | command.getSourceStaNo1().intValue(), |
| | | command.getDestinationStaNo1().intValue(), |
| | | command.getSourceStaNo2().intValue(), |
| | | command.getDestinationStaNo2().intValue(), |
| | | null, |
| | | new Date(), |
| | | null |
| | | ); |
| | | bean.insert(basRgvOpt); |
| | | } catch (Exception ignore) {} |
| | | |
| | | if (result != null && result.IsSuccess) { |
| | | // Thread.sleep(200); |
| | | // this.readStatus(); |
| | | log.info("RGV 工位1取消命令下发[id:{}] >>>>> {}", slave.getId(), JSON.toJSONString(command)); |
| | | OutputQueue.RGV.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 工位1命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSONString(command))); |
| | | return true; |
| | | } else { |
| | | OutputQueue.RGV.offer(MessageFormat.format("【{0}】写入RGV plc工位1数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); |
| | | log.error("写入RGV plc工位1取消数据失败 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 完成 |