| | |
| | | case 10: |
| | | write10((String) task.getData()); |
| | | break; |
| | | //单机写入数据 |
| | | case 11: |
| | | write11((RgvCommand) task.getData()); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | //单步任务 |
| | | private boolean write11(RgvCommand command) throws InterruptedException { |
| | | if (null == command) { |
| | | log.error("RGV写入命令为空"); |
| | | return false; |
| | | } |
| | | String status = ""; |
| | | command.setRgvNo(slave.getId()); |
| | | short[] array = new short[2]; |
| | | array[0] = command.getDestinationStaNo1(); |
| | | array[1] = command.getSourceStaNo1(); |
| | | |
| | | OperateResult result = siemensNet.Write("DB19.0", array); |
| | | if (command.getTaskMode1().equals(RgvTaskModeType.FETCH.id.shortValue())){ |
| | | status = "4.1"; |
| | | } else if (command.getTaskMode1().equals(RgvTaskModeType.PUT.id.shortValue())){ |
| | | status = "4.2"; |
| | | } else if (command.getTaskMode1().equals(RgvTaskModeType.X_MOVE.id.shortValue())){ |
| | | status = "4.0"; |
| | | } else if (command.getTaskMode1().equals(RgvTaskModeType.FETCH_PUT.id.shortValue())){ |
| | | status = "4.3"; |
| | | } else { |
| | | OutputQueue.RGV.offer(MessageFormat.format("【{0}】写入RGV plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}] [DB块:{4}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), "DB19."+status)); |
| | | log.error("写入RGV plc数据失败 未知任务类型 ===>> [id:{}] [ip:{}] [port:{}] [DB块:{4}]", slave.getId(), slave.getIp(), slave.getPort(), "DB19."+status); |
| | | return false; |
| | | } |
| | | OperateResult result1 = siemensNet.Write("DB19."+status, true); |
| | | if (result != null && result.IsSuccess && result1 != null && result1.IsSuccess) { |
| | | Thread.sleep(200); |
| | | this.readStatus(); |
| | | log.info("RGV 命令下发[id:{}] >>>>> {}", slave.getId(), JSON.toJSON("DB19."+status)); |
| | | OutputQueue.RGV.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), "DB19."+status)); |
| | | return true; |
| | | } else { |
| | | OutputQueue.RGV.offer(MessageFormat.format("【{0}】写入RGV plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}] [DB块:{4}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), "DB19."+status)); |
| | | log.error("写入RGV plc数据失败 ===>> [id:{}] [ip:{}] [port:{}] [DB块:{4}]", slave.getId(), slave.getIp(), slave.getPort(), "DB19."+status); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void close() { |
| | | siemensNet.ConnectClose(); |