| | |
| | | |
| | | //条码扫描器 |
| | | Thread.sleep(200); |
| | | OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.840",(short)(barcodeSize*8)); |
| | | OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.2440",(short)(barcodeSize*8)); |
| | | if (result2.IsSuccess) { |
| | | for (int i = 0; i < barcodeSize; i++) { //1:217 2:221 3:null 4:215 5:219 |
| | | String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*8,6, "UTF-8"); |
| | | int[] staNosRgv = {281,292,173,214,120}; |
| | | |
| | | for (int i = 0; i < barcodeSize; i++) { //1:281 2:292 3:174(173) 4:214 5:120 |
| | | String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*8,8, "UTF-8"); |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 1); |
| | | if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { |
| | | Integer siteId = staNosRgv[i]; // 站点编号 |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | if (null == staProtocol) { |
| | | staProtocol = new StaProtocol(); |
| | | staProtocol.setSiteId(siteId); |
| | | station.put(siteId, staProtocol); |
| | | } |
| | | staProtocol.setBarcode(barcode); |
| | | barcodeThread.setBarcode(barcode); |
| | | } |
| | | } |
| | |
| | | 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)); |
| | | log.info("输送线命令下发完成 给输送复位 [id:{}] >>>>> 命令下发: {}", slave.getId(), JSON.toJSONString(staProtocol)); |
| | | } |
| | | } |
| | | |
| | |
| | | do { |
| | | try{ |
| | | if(!result1.IsSuccess){ |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSON(staProtocol),writeCount); |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSONString(staProtocol),writeCount); |
| | | result1 = siemensS7Net.Write(resultV1, resultS1); |
| | | Thread.sleep(100); |
| | | writeCount++; |
| | |
| | | if (status == 1){ |
| | | break; |
| | | } else { |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSON(staProtocol),writeCount); |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSONString(staProtocol),writeCount); |
| | | result1 = siemensS7Net.Write(resultV1, resultS1); |
| | | Thread.sleep(100); |
| | | writeCount++; |
| | | continue; |
| | | } |
| | | } else { |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSON(staProtocol),writeCount); |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSONString(staProtocol),writeCount); |
| | | result1 = siemensS7Net.Write(resultV1, resultS1); |
| | | Thread.sleep(100); |
| | | writeCount++; |
| | |
| | | do { |
| | | try{ |
| | | if(!result2.IsSuccess){ |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSON(staProtocol),writeCount); |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSONString(staProtocol),writeCount); |
| | | result2 = siemensS7Net.Write(resultV1, resultS2); |
| | | |
| | | Thread.sleep(100); |
| | |
| | | if (status == resultS2){ |
| | | break; |
| | | } else { |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSON(staProtocol),writeCount); |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSONString(staProtocol),writeCount); |
| | | result2 = siemensS7Net.Write(resultV1, resultS2); |
| | | Thread.sleep(100); |
| | | writeCount++; |
| | | continue; |
| | | } |
| | | } else { |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSON(staProtocol),writeCount); |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSONString(staProtocol),writeCount); |
| | | result2 = siemensS7Net.Write(resultV1, resultS2); |
| | | Thread.sleep(100); |
| | | writeCount++; |
| | |
| | | do { |
| | | try{ |
| | | if(!result1.IsSuccess){ |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSON(staProtocol),writeCount); |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSONString(staProtocol),writeCount); |
| | | result1 = siemensS7Net.Write(resultV1, resultS1); |
| | | Thread.sleep(100); |
| | | writeCount++; |
| | |
| | | if (statusR1 == resultS1){ |
| | | break; |
| | | } else { |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSON(staProtocol),writeCount); |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSONString(staProtocol),writeCount); |
| | | result1 = siemensS7Net.Write(resultV1, resultS1); |
| | | Thread.sleep(100); |
| | | writeCount++; |
| | | continue; |
| | | } |
| | | } else { |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSON(staProtocol),writeCount); |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSONString(staProtocol),writeCount); |
| | | result1 = siemensS7Net.Write(resultV1, resultS1); |
| | | Thread.sleep(100); |
| | | writeCount++; |
| | |
| | | do { |
| | | try{ |
| | | if(!result2.IsSuccess){ |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSON(staProtocol),writeCount); |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSONString(staProtocol),writeCount); |
| | | result2 = siemensS7Net.Write(resultV1, resultS2); |
| | | Thread.sleep(100); |
| | | writeCount++; |
| | |
| | | if (statusR1 == resultS2){ |
| | | break; |
| | | } else { |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSON(staProtocol),writeCount); |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSONString(staProtocol),writeCount); |
| | | result2 = siemensS7Net.Write(resultV1, resultS2); |
| | | |
| | | Thread.sleep(100); |
| | |
| | | continue; |
| | | } |
| | | } else { |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSON(staProtocol),writeCount); |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSONString(staProtocol),writeCount); |
| | | result2 = siemensS7Net.Write(resultV1, resultS2); |
| | | Thread.sleep(100); |
| | | writeCount++; |
| | |
| | | do { |
| | | try{ |
| | | if(!result1.IsSuccess){ |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSON(staProtocol),writeCount); |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSONString(staProtocol),writeCount); |
| | | result1 = siemensS7Net.Write(resultV1, resultS1); |
| | | Thread.sleep(100); |
| | | writeCount++; |
| | |
| | | if (transInt16 == resultS1){ |
| | | break; |
| | | } else { |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSON(staProtocol),writeCount); |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSONString(staProtocol),writeCount); |
| | | result1 = siemensS7Net.Write(resultV1, resultS1); |
| | | Thread.sleep(100); |
| | | writeCount++; |
| | | continue; |
| | | } |
| | | } else { |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSON(staProtocol),writeCount); |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSONString(staProtocol),writeCount); |
| | | result1 = siemensS7Net.Write(resultV1, resultS1); |
| | | Thread.sleep(100); |
| | | writeCount++; |
| | |
| | | do { |
| | | try{ |
| | | if(!result2.IsSuccess){ |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSON(staProtocol),writeCount); |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSONString(staProtocol),writeCount); |
| | | result2 = siemensS7Net.Write(resultV2, resultS1); |
| | | Thread.sleep(100); |
| | | writeCount++; |
| | |
| | | if (transInt16 == resultS1){ |
| | | break; |
| | | } else { |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSON(staProtocol),writeCount); |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSONString(staProtocol),writeCount); |
| | | result2 = siemensS7Net.Write(resultV2, resultS1); |
| | | Thread.sleep(100); |
| | | writeCount++; |
| | | continue; |
| | | } |
| | | } else { |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSON(staProtocol),writeCount); |
| | | log.error("写入RGV数据失败,重新下发任务 写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSONString(staProtocol),writeCount); |
| | | result2 = siemensS7Net.Write(resultV2, resultS1); |
| | | Thread.sleep(100); |
| | | writeCount++; |
| | |
| | | |
| | | if (!result1.IsSuccess) { |
| | | staProtocol = station.get(staProtocol.getSiteId()); |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线站点数据失败。输送线plc编号={1},站点数据={2}", slave.getId(), JSON.toJSON(staProtocol))); |
| | | log.error("写入输送线站点数据失败。输送线plc编号={},站点数据={}", slave.getId(), JSON.toJSON(staProtocol)); |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线站点数据失败。输送线plc编号={1},站点数据={2}", slave.getId(), JSON.toJSONString(staProtocol))); |
| | | log.error("写入输送线站点数据失败。输送线plc编号={},站点数据={}", slave.getId(), JSON.toJSONString(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)); |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】 输送线命令下发 [id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSONString(staProtocol))); |
| | | log.info("输送线命令下发完成 给输送复位 [id:{}] >>>>> 命令下发: {}", slave.getId(), JSON.toJSONString(staProtocol)); |
| | | } |
| | | } |
| | | |