| | |
| | | case 2: |
| | | write((StaProtocol)task.getData()); |
| | | break; |
| | | // 写数据 103站点写入PACK码 |
| | | case 4: |
| | | write103((String)task.getData()); |
| | | break; |
| | | // 写数据 103站点写入PACK码 |
| | | case 5: |
| | | StaProtocol staProtocol2 = (StaProtocol)task.getData(); |
| | | siemensS7Net.Write("DB102.0" + staProtocol2.getSiteId(), staProtocol2.getStaNo()==1); |
| | | break; |
| | | //复位测试信号 |
| | | case 3: |
| | | StaProtocol staProtocol = (StaProtocol)task.getData(); |
| | |
| | | } |
| | | |
| | | Thread.sleep(200); |
| | | OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB100.190",(short)(barcodeSize*6)); |
| | | OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB100.190",(short)(26)); |
| | | OperateResultExOne<byte[]> result5 = siemensS7Net.Read("DB100.216",(short)(6)); |
| | | if (result2.IsSuccess) { |
| | | for (int i = 0; i < barcodeSize; i++) { |
| | | String barcode =siemensS7Net.getByteTransform().TransString(result2.Content,i*6,6, "UTF-8"); |
| | | String barcode =siemensS7Net.getByteTransform().TransString(result2.Content,0,26, "UTF-8"); |
| | | // String barcode=new String(result2.Content,i*12,12); |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 1); |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 1); |
| | | if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { |
| | | barcodeThread.setBarcode(barcode); |
| | | } |
| | | } |
| | | if (result5.IsSuccess) { |
| | | String barcode =siemensS7Net.getByteTransform().TransString(result5.Content,0,6, "UTF-8"); |
| | | // String barcode=new String(result2.Content,i*12,12); |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 2); |
| | | if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { |
| | | barcodeThread.setBarcode(barcode); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 写入 pack码 =====> 单站点写入 |
| | | */ |
| | | private void write103(String packNo){ |
| | | try{ |
| | | OperateResult write = siemensS7Net.Write("DB100.", packNo); |
| | | if (!write.IsSuccess) { |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线站点数据失败。输送线plc编号={1},站点数据={2}", slave.getId(), JSON.toJSON(packNo))); |
| | | log.error("写入输送线站点数据失败。输送线plc编号={},站点数据={}", slave.getId(), JSON.toJSON(packNo)); |
| | | } else { |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】 输送线命令下发 [id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(packNo))); |
| | | log.info("输送线命令下发 [id:{}] >>>>> 命令下发: {}", slave.getId(), JSON.toJSON(packNo)); |
| | | } |
| | | }catch (Exception e){ |
| | | log.error("103站点写入数据失败,输送线线程write103"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 写入 ID+目标站 =====> 单站点写入 |
| | | */ |
| | | private void write(StaProtocol staProtocol) throws InterruptedException { |