| | |
| | | write((StaProtocol)task.getData()); |
| | | read(); |
| | | break; |
| | | // 写数据 ID+目标站 |
| | | case 4: |
| | | writeAgvOk((StaProtocol)task.getData()); |
| | | read(); |
| | | break; |
| | | /* case 3: |
| | | write2((StaProtocol)task.getData()); |
| | | read(); |
| | |
| | | } |
| | | } |
| | | |
| | | OperateResultExOne<byte[]> resultAgvAndPlc = siemensS7Net.Read("DB102.0", (short) 30); |
| | | if (resultAgvAndPlc.IsSuccess) { |
| | | for (int i = 0; i < staNoSize; i++) { |
| | | int sign =(i+2)/2-1; |
| | | if ((i+2)%2!=0){ |
| | | Integer siteId = staNos.get(i); // 站点编号 |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | if (null == staProtocol) { |
| | | staProtocol = new StaProtocol(); |
| | | staProtocol.setSiteId(siteId); |
| | | station.put(siteId, staProtocol); |
| | | } |
| | | staProtocol.setAgvStartPick(siemensS7Net.getByteTransform().TransInt16(resultAgvAndPlc.Content, sign*6+4)); // 允许取货 |
| | | staProtocol.setAgvStartPlace((short)0); // 允许放货 |
| | | continue; |
| | | } |
| | | Integer siteId = staNos.get(i); // 站点编号 |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | if (null == staProtocol) { |
| | | staProtocol = new StaProtocol(); |
| | | staProtocol.setSiteId(siteId); |
| | | station.put(siteId, staProtocol); |
| | | } |
| | | staProtocol.setAgvStartPick(siemensS7Net.getByteTransform().TransInt16(resultAgvAndPlc.Content, sign*6)); // 允许取货 |
| | | staProtocol.setAgvStartPlace(siemensS7Net.getByteTransform().TransInt16(resultAgvAndPlc.Content, sign*6 + 2)); // 允许放货 |
| | | } |
| | | } |
| | | |
| | | |
| | | if (slave.getId() == 1) { |
| | | //条码 |
| | |
| | | /** |
| | | * 写入 ID+目标站 =====> 单站点写入 |
| | | */ |
| | | private void writeAgvOk(StaProtocol staProtocol) throws InterruptedException { |
| | | if (null == staProtocol) { |
| | | return; |
| | | } |
| | | ArrayList<Integer> staNos = getStaNo(); |
| | | int index = staNos.indexOf(staProtocol.getSiteId()); |
| | | if (staProtocol.getAgvTypeSign()==0){ //0取货 |
| | | switch (staProtocol.getSiteId()){ |
| | | case 100: |
| | | index=32; |
| | | break; |
| | | case 101: |
| | | index=34; |
| | | break; |
| | | case 102: |
| | | index=38; |
| | | break; |
| | | case 103: |
| | | index=40; |
| | | break; |
| | | case 104: |
| | | index=44; |
| | | break; |
| | | case 105: |
| | | index=46; |
| | | break; |
| | | case 106: |
| | | index=50; |
| | | break; |
| | | case 107: |
| | | index=52; |
| | | break; |
| | | default: |
| | | return; |
| | | } |
| | | }else { |
| | | switch (staProtocol.getSiteId()){ |
| | | case 100: |
| | | index=30; |
| | | break; |
| | | case 102: |
| | | index=36; |
| | | break; |
| | | case 104: |
| | | index=42; |
| | | break; |
| | | case 106: |
| | | index=48; |
| | | break; |
| | | default: |
| | | return; |
| | | } |
| | | } |
| | | |
| | | OperateResult write = null; |
| | | //任务下发次数 |
| | | int writeCount = 0; |
| | | do { |
| | | write = siemensS7Net.Write("DB102." + index, (short) 1); // 任务完成 |
| | | if(write.IsSuccess){ |
| | | writeCount=6; |
| | | }else { |
| | | writeCount++; |
| | | log.error("写入输送线取放货完成命令后读取失败。输送线plc编号={},站点数据={},写入次数={}", slave.getId(), JSON.toJSON(staProtocol), writeCount); |
| | | } |
| | | }while (writeCount<5); |
| | | |
| | | if (!write.IsSuccess) { |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线站点数据失败。输送线plc编号={1},站点数据={2}", slave.getId(), JSON.toJSON(staProtocol))); |
| | | log.error("写入输送线取放货完成站点数据失败。输送线plc编号={},站点数据={}", slave.getId(), JSON.toJSON(staProtocol)); |
| | | } else { |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】 输送线命令下发 [id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(staProtocol))); |
| | | log.info("输送线取放货完成命令下发码垛完成 给输送线写任务完成 [id:{}] >>>>> 命令下发: {}", slave.getId(), JSON.toJSON(staProtocol)); |
| | | } |
| | | |
| | | |
| | | } |
| | | private void write(StaProtocol staProtocol) throws InterruptedException { |
| | | if (null == staProtocol) { |
| | | return; |