| | |
| | | public class BarcodeThread implements Runnable, ThreadHandler { |
| | | |
| | | private Slave slave; |
| | | private String barcode; |
| | | private String barcode = ""; |
| | | private Socket socket; |
| | | private DataOutputStream dataOutputStream; |
| | | private DataInputStream dataInputStream; |
| | |
| | | this.slave = slave; |
| | | } |
| | | |
| | | // // PLC读取条码数据处理方式, 1到6号扫码器---------------------- |
| | | // private StringBuffer barcodePlc = new StringBuffer(); |
| | | // |
| | | // public String getBarcodePlc() { |
| | | // return barcodePlc.toString(); |
| | | // } |
| | | // |
| | | // public void setBarcodePlc(String barcodePlc) { |
| | | // this.barcodePlc.delete(0, this.barcodePlc.length()); |
| | | // this.barcodePlc.append(barcodePlc); |
| | | // if(!Cools.isEmpty(barcodePlc)) { |
| | | // log.info("{}号条码器,检索数据:{}", slave.getId(), this.barcodePlc); |
| | | // JSONObject jsonObject = new JSONObject(); |
| | | // jsonObject.put("time", DateUtils.convert(new Date(), DateUtils.yyyyMMddHHmmss_F)); |
| | | // jsonObject.put("barcode", barcodePlc); |
| | | // if (OutputQueue.BARCODE.size() >= 32) { |
| | | // OutputQueue.BARCODE.poll(); |
| | | // } |
| | | // OutputQueue.BARCODE.offer(jsonObject); |
| | | // } |
| | | // } |
| | | // // PLC读取条码数据处理方式------------------------------ |
| | | |
| | | @Override |
| | | @SuppressWarnings("InfiniteLoopStatement") |
| | | public void run() { |
| | | connect(); |
| | | while (true) { |
| | | try { |
| | | byte[] read = read(8, 200); |
| | | byte[] read = read(16, 200); |
| | | if (null != read) { |
| | | String s = new String(read); |
| | | if (!Cools.isEmpty(s)) { |