| | |
| | | command.setTaskMode1(RgvTaskModeType.NONE); // 任务模式 |
| | | command.setSourceStaNo1((short)0); // 源站 |
| | | command.setDestinationStaNo1((short)0); // 目标站 |
| | | write(command); |
| | | write3(command); |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | return false; |
| | | } |
| | | } |
| | | private boolean write3(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); |
| | | OperateResult result = null; |
| | | if (command.getAckFinish1().equals((short)0)) { |
| | | Thread.sleep(100L); |
| | | 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; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void close() { |