| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 输送线线程 |
| | |
| | | |
| | | public static final ArrayList<Integer> staNos2 = new ArrayList<Integer>() {{ |
| | | add(301);add(302);add(303);add(304);add(305);add(306);add(307);add(308); |
| | | }}; |
| | | |
| | | // 正面5个条码扫描站 |
| | | public static final ArrayList<Integer> barcodeSite2 = new ArrayList<Integer>() {{ |
| | | add(102);add(105);add(108);add(111);add(114); |
| | | }}; |
| | | |
| | | // 侧面三个条码扫描站 |
| | |
| | | } |
| | | |
| | | // 读取正面条码 |
| | | OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.1404", (short) (16 * 8)); |
| | | OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB103.0", (short) (5 * 40)); |
| | | if (result2.IsSuccess) { |
| | | for (int i = 0; i < 16; i++) { |
| | | int barcodeId = 0; |
| | | switch (i) { |
| | | case 1: |
| | | barcodeId = 1; |
| | | break; |
| | | case 4: |
| | | barcodeId = 2; |
| | | break; |
| | | case 7: |
| | | barcodeId = 3; |
| | | break; |
| | | case 10: |
| | | barcodeId = 4; |
| | | break; |
| | | case 13: |
| | | barcodeId = 5; |
| | | break; |
| | | default: |
| | | for (int i = 0; i < 5; i++) { |
| | | String barcode = siemensS7Net.getByteTransform().TransString(result2.Content, i * 40, 40, "UTF-8"); |
| | | if(!Cools.isEmpty()){ |
| | | barcode = barcode.trim(); |
| | | } |
| | | if (barcodeId != 0) { |
| | | String barcode = siemensS7Net.getByteTransform().TransString(result2.Content, i * 8, 6, "UTF-8"); |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, barcodeId); |
| | | if (!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { |
| | | barcodeThread.setBarcode(barcode); |
| | | List<String> barcodeList = Arrays.stream(barcode.split(",")).collect(Collectors.toList()); |
| | | Iterator<String> iterator = barcodeList.iterator(); |
| | | while (iterator.hasNext()){ |
| | | String next = iterator.next(); |
| | | if(next.length() == 6) { |
| | | barcode = next; |
| | | iterator.remove(); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i); |
| | | if (!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { |
| | | barcodeThread.setBarcode(barcode); |
| | | } |
| | | StaProtocol staProtocol = station.get(barcodeSite2.get(i)); |
| | | if (staProtocol != null) { |
| | | staProtocol.setMatIdList(barcodeList); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 读取正面条码 |
| | | // OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.1404", (short) (16 * 8)); |
| | | // if (result2.IsSuccess) { |
| | | // for (int i = 0; i < 16; i++) { |
| | | // int barcodeId = 0; |
| | | // switch (i) { |
| | | // case 1: |
| | | // barcodeId = 1; |
| | | // break; |
| | | // case 4: |
| | | // barcodeId = 2; |
| | | // break; |
| | | // case 7: |
| | | // barcodeId = 3; |
| | | // break; |
| | | // case 10: |
| | | // barcodeId = 4; |
| | | // break; |
| | | // case 13: |
| | | // barcodeId = 5; |
| | | // break; |
| | | // default: |
| | | // } |
| | | // if (barcodeId != 0) { |
| | | // String barcode = siemensS7Net.getByteTransform().TransString(result2.Content, i * 8, 6, "UTF-8"); |
| | | // BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, barcodeId); |
| | | // if (!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { |
| | | // barcodeThread.setBarcode(barcode); |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | // 读取侧面条码 |
| | | OperateResultExOne<byte[]> resultCM2 = siemensS7Net.Read("DB101.2574", (short) (3 * 4 * 6)); |
| | | if (resultCM2.IsSuccess) { |