| | |
| | | break; |
| | | // 写数据 ID+目标站 |
| | | case 2: |
| | | write((StaProtocol)task.getData()); |
| | | write((StaProtocol)task.getData(), 0); |
| | | Thread.sleep(300); |
| | | read(); |
| | | break; |
| | |
| | | /** |
| | | * 写入 ID+目标站 =====> 单站点写入 |
| | | */ |
| | | private void write(StaProtocol staProtocol) throws InterruptedException { |
| | | if (null == staProtocol) { |
| | | private void write(StaProtocol staProtocol, int times) throws InterruptedException { |
| | | if (null == staProtocol || times > 2) { |
| | | return; |
| | | } |
| | | int index = staNos.indexOf(staProtocol.getSiteId()); |
| | | OperateResult write = siemensS7Net.Write("DB100." + index*2, staProtocol.getWorkNo()); // 工作号 |
| | | if(!write.IsSuccess){ |
| | | News.error("写入输送线ID失败,重新添加任务到队列。输送线plc编号={},站点数据={}", slave.getId(), JSON.toJSON(staProtocol)); |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线站点数据失败。输送线plc编号={1},站点数据={2}", slave.getId(), JSON.toJSON(staProtocol))); |
| | | MessageQueue.offer(SlaveType.Devp, slave.getId(), new Task(2, staProtocol)); |
| | | return; |
| | | } |
| | | Thread.sleep(200); |
| | | OperateResult write1 = siemensS7Net.Write("DB101." + index*2, staProtocol.getStaNo()); // 目标站 |
| | | |
| | |
| | | MessageQueue.offer(SlaveType.Devp, slave.getId(), new Task(2, staProtocol)); |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线站点数据失败。输送线plc编号={1},站点数据={2}", slave.getId(), JSON.toJSON(staProtocol))); |
| | | News.error("写入输送线站点数据失败,重新添加任务到队列。输送线plc编号={},站点数据={}", slave.getId(), JSON.toJSON(staProtocol)); |
| | | staProtocol = station.get(staProtocol.getSiteId()); |
| | | if (staProtocol.getWorkNo() == 0 && staProtocol.getStaNo() ==0) { |
| | | staProtocol.setPakMk(true); |
| | | } |
| | | times++; |
| | | write(staProtocol, times); |
| | | // staProtocol = station.get(staProtocol.getSiteId()); |
| | | // if (staProtocol.getWorkNo() == 0 && staProtocol.getStaNo() ==0) { |
| | | // staProtocol.setPakMk(true); |
| | | // } |
| | | } else { |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】 输送线命令下发 [id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(staProtocol))); |
| | | News.info("输送线命令下发 [id:{}] >>>>> 命令下发: {}", slave.getId(), JSON.toJSON(staProtocol)); |