| | |
| | | add(1029);add(1031); |
| | | add(1032);add(1033);add(1035); |
| | | add(1036);add(1037);add(1038); |
| | | add(1039);add(1041); |
| | | add(1039);add(1040);add(1041); |
| | | add(1042);add(1043);add(1044);add(1045);add(1046);add(1047);add(1048);add(1050);add(1051);add(1052);add(1053);add(1054);add(1055);add(1056);add(1057); |
| | | add(1058);add(1059);add(1060);add(1061);add(1062);add(1063);add(1064);add(1065);add(1066);add(1067);add(1068);add(1069);add(1070);add(1071);add(1072); |
| | | add(1073);add(1074);add(1075);add(1076);add(1077);add(1078);add(1079);add(1080);add(1081);add(1082);add(1083);add(1084);add(1085);add(1086);add(1087); |
| | |
| | | // 特殊站点集合 |
| | | private static final Set<Integer> specialSites2 = new HashSet<>( |
| | | Arrays.asList(1051,1055,1057,1065,1067,1069,1077,1081,1083,1086,1089,1092,1095,1097,1100)); |
| | | |
| | | private static final Set<Integer> specialSites3 = new HashSet<>(//机械臂站点 |
| | | Arrays.asList(1098,1093,1087,1082,1074,1071,1062,1059)); |
| | | |
| | | |
| | | public static final ArrayList<Integer> BarcodeList = new ArrayList<Integer>() {{ |
| | |
| | | ArrayList<Integer> staNos = getStaNo(); |
| | | int staNoSize = staNos.size(); |
| | | OperateResultExOne<byte[]> result = null; |
| | | OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB100.0", (short) (2764));//1001-1028 |
| | | OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.0", (short) (1264));//1029-1037 |
| | | OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB104.0", (short) (1264));//1042-1053 |
| | | OperateResultExOne<byte[]> result4 = siemensS7Net.Read("DB103.0", (short) (2820));//1054-1079 |
| | | OperateResultExOne<byte[]> result5 = siemensS7Net.Read("DB102.0", (short) (3424));//1080-1110 |
| | | OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB100.0", (short) (2768));//1001-1028 |
| | | OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.0", (short) (1268));//1029-1037 |
| | | OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB104.0", (short) (1268));//1042-1053 |
| | | OperateResultExOne<byte[]> result4 = siemensS7Net.Read("DB103.0", (short) (2824));//1054-1079 |
| | | OperateResultExOne<byte[]> result5 = siemensS7Net.Read("DB102.0", (short) (3428));//1080-1110 |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | Integer offset2 = getOffsetBySiteId(siteId); |
| | | Integer offset3 = getOffsetBySiteId2(siteId); |
| | | if(siteId == 1040){ |
| | | boolean[] full = siemensS7Net.getByteTransform().TransBool(result.Content, offset, 2); |
| | | staProtocol.setFull(full[0]); |
| | | } |
| | | staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt32(result.Content, offset + offset2)); // 工作号 |
| | | staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result.Content, offset + offset2 + 12)); // 目标站 |
| | | staProtocol.setStaNo((short)siemensS7Net.getByteTransform().TransInt32(result.Content, offset + offset2 + 12)); // 目标站 |
| | | staProtocol.setBarcode(String.valueOf(siemensS7Net.getByteTransform().TransInt32(result.Content, offset + offset2 + 16))); //条码 |
| | | |
| | | if(specialSites2.contains(siteId)){ |
| | | staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result.Content, offset + offset2 + 48)); // 目标站 |
| | | staProtocol.setStaNo((short)siemensS7Net.getByteTransform().TransInt32(result.Content, offset + offset2 + 48)); // 目标站 |
| | | staProtocol.setBarcode(String.valueOf(siemensS7Net.getByteTransform().TransInt32(result.Content, offset + offset2 + 52))); //条码 |
| | | |
| | | } |
| | | |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(result.Content, offset + offset3, 2); |
| | |
| | | |
| | | staProtocol.setLoading(!status1[0]); // 有物 |
| | | |
| | | staProtocol.setInEnable(true); // 可入 |
| | | staProtocol.setOutEnable(true);// 可出 |
| | | staProtocol.setInEnable(status1[2]); // 可入 |
| | | staProtocol.setOutEnable(status1[2]);// 可出 |
| | | staProtocol.setErr(status1[6]); |
| | | // staProtocol.setInEnable(status1[1]); // 可入 |
| | | // staProtocol.setOutEnable(status1[3]);// 可出 |
| | | // staProtocol.setEmptyMk(status[4]); // 空板信号 |
| | |
| | | } |
| | | } |
| | | } |
| | | BasRgvMapService basRgvMapService = SpringUtils.getBean(BasRgvMapService.class); |
| | | //条码扫描器 |
| | | ArrayList<Integer> barcodeList = BarcodeList; |
| | | OperateResultExOne<byte[]> reasultBarcode1 = siemensS7Net.Read("DB101.780", (short) 8);//1036 |
| | | OperateResultExOne<byte[]> reasultBarcode2 = siemensS7Net.Read("DB104.548", (short) 8);//1047 |
| | | OperateResultExOne<byte[]> reasultBarcode3 = siemensS7Net.Read("DB102.2780", (short) 8);//1103 |
| | | // OperateResultExOne<byte[]> reasultBarcode4 = siemensS7Net.Read("DB104.180", (short) 184); |
| | | if(reasultBarcode1.IsSuccess){ |
| | | Integer barcodeId = barcodeList.get(0); |
| | | String barcode = String.valueOf(siemensS7Net.getByteTransform().TransInt32(reasultBarcode1.Content, 0)); |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, barcodeId + 1); |
| | | if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { |
| | | barcodeThread.setBarcode(barcode); |
| | | } |
| | | // News.error(JSON.toJSONString(barcode+"线程"+barcodeId)); |
| | | |
| | | } |
| | | if(reasultBarcode2.IsSuccess){ |
| | | Integer barcodeId = barcodeList.get(1); |
| | | String barcode = String.valueOf(siemensS7Net.getByteTransform().TransInt32(reasultBarcode2.Content, 0)); |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, barcodeId + 1); |
| | | if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { |
| | | barcodeThread.setBarcode(barcode); |
| | | } |
| | | // News.error(JSON.toJSONString(barcode+"线程"+barcodeId)); |
| | | |
| | | } |
| | | if(reasultBarcode3.IsSuccess){ |
| | | Integer barcodeId = barcodeList.get(2); |
| | | String barcode = String.valueOf(siemensS7Net.getByteTransform().TransInt32(reasultBarcode3.Content, 0)); |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, barcodeId + 1); |
| | | if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { |
| | | barcodeThread.setBarcode(barcode); |
| | | } |
| | | // News.error(JSON.toJSONString(barcode+"线程"+barcodeId)); |
| | | |
| | | } |
| | | |
| | | |
| | | // BasRgvMapService basRgvMapService = SpringUtils.getBean(BasRgvMapService.class); |
| | | // RGV小车1 |
| | | // Thread.sleep(100); |
| | | // OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB101.",(short)27); |
| | | // if (result3.IsSuccess) { |
| | | // BasRgvMap basRgvMap = basRgvMapService.selectByRgvNo((int) siemensS7Net.getByteTransform().TransInt16(result3.Content, 0)); |
| | | // OperateResultExOne<byte[]> resultCar1 = siemensS7Net.Read("DB101.0",(short)36); |
| | | // if (resultCar1.IsSuccess) { |
| | | // BasRgvMap basRgvMap = basRgvMapService.selectByRgvNo((int) siemensS7Net.getByteTransform().TransInt16(resultCar1.Content, 0) + 1); |
| | | // if (!Cools.isEmpty(basRgvMap)){ |
| | | // Integer siteId1 = 1; |
| | | // Integer siteId2 = 2; |
| | | // StaProtocol staProtocol1 = station.get(siteId1); |
| | | // StaProtocol staProtocol2 = station.get(siteId1); |
| | | // StaProtocol staProtocol2 = station.get(siteId2); |
| | | // |
| | | // if (null == staProtocol1) { |
| | | // staProtocol1 = new StaProtocol(); |
| | |
| | | // station.put(siteId2, staProtocol2); |
| | | // |
| | | // } |
| | | // String pos = String.valueOf(getRgvPosI(siemensS7Net.getByteTransform().TransInt32(result.Content, 4))); |
| | | // staProtocol1.setAutoing(siemensS7Net.getByteTransform().TransInt16(result.Content, 2) == 2); |
| | | // staProtocol2.setAutoing(siemensS7Net.getByteTransform().TransInt16(result.Content, 2) == 2); |
| | | // String pos = String.valueOf(getRgvPosI(siemensS7Net.getByteTransform().TransInt32(resultCar1.Content, 4))); |
| | | // staProtocol1.setAutoing(siemensS7Net.getByteTransform().TransInt16(result.Content, 2) == 0); |
| | | // staProtocol2.setAutoing(siemensS7Net.getByteTransform().TransInt16(result.Content, 2) == 0); |
| | | // staProtocol1.setNearbySta(pos); |
| | | // staProtocol1.setStaNo((short) siemensS7Net.getByteTransform().TransInt32(result.Content, 8)); |
| | | // staProtocol2.setStaNo((short) siemensS7Net.getByteTransform().TransInt32(result.Content, 8)); |
| | | // staProtocol1.setWorkNo(siemensS7Net.getByteTransform().TransInt32(result.Content, 16)); |
| | | // staProtocol2.setWorkNo(siemensS7Net.getByteTransform().TransInt32(result.Content, 20)); |
| | | // boolean[] status1 = siemensS7Net.getByteTransform().TransBool(result.Content, 24, 2); |
| | | // staProtocol1.setStaNo((short) siemensS7Net.getByteTransform().TransInt32(resultCar1.Content, 28)); |
| | | // staProtocol2.setStaNo((short) siemensS7Net.getByteTransform().TransInt32(resultCar1.Content, 32)); |
| | | // staProtocol1.setWorkNo(siemensS7Net.getByteTransform().TransInt32(resultCar1.Content, 16)); |
| | | // staProtocol2.setWorkNo(siemensS7Net.getByteTransform().TransInt32(resultCar1.Content, 20)); |
| | | // boolean[] status1 = siemensS7Net.getByteTransform().TransBool(resultCar1.Content, 24, 1); |
| | | // staProtocol1.setLoading(status1[0]); |
| | | // staProtocol2.setLoading(status1[1]); |
| | | // // staProtocol.setNearbySta(String.valueOf(siemensS7Net.getByteTransform().TransInt16(result3.Content, 8))); |
| | |
| | | // } |
| | | // } |
| | | |
| | | // //条码扫描器 |
| | | // ArrayList<Integer> barcodeList = BarcodeList; |
| | | // OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.840", (short) (barcodeList.size() * 8)); |
| | | // if (result2.IsSuccess) { |
| | | // for (int i = 0; i < barcodeList.size(); i++) { |
| | | // Integer barcodeId = barcodeList.get(i); |
| | | // String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*8,8, "UTF-8"); |
| | | // BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, barcodeId + 1); |
| | | // if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { |
| | | // barcodeThread.setBarcode(barcode); |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | |
| | | //条码扫描器 |
| | | // ArrayList<Integer> barcodeListMat = BarcodeListMat; |
| | | // OperateResultExOne<byte[]> result2Mat = siemensS7Net.Read("DB103.0", (short) (barcodeListMat.size() * 30)); |
| | |
| | | write1 = siemensS7Net.Write("DB104." + (offset + offset2 + 12), staProtocol.getStaNo().intValue()); // 目标站 |
| | | } |
| | | }else if(siteId < 1080){ |
| | | write = siemensS7Net.Write("DB104." + (offset + offset2), staProtocol.getWorkNo()); // 工作号 |
| | | write = siemensS7Net.Write("DB103." + (offset + offset2), staProtocol.getWorkNo()); // 工作号 |
| | | Thread.sleep(200); |
| | | if(specialSites2.contains(siteId)){ |
| | | write1 = siemensS7Net.Write("DB103." + (offset + offset2 + 48), staProtocol.getStaNo().intValue()); // 目标站 |
| | |
| | | write1 = siemensS7Net.Write("DB103." + (offset + offset2 + 12), staProtocol.getStaNo().intValue()); // 目标站 |
| | | } |
| | | }else if(siteId < 1111){ |
| | | write = siemensS7Net.Write("DB104." + (offset + offset2), staProtocol.getWorkNo()); // 工作号 |
| | | write = siemensS7Net.Write("DB102." + (offset + offset2), staProtocol.getWorkNo()); // 工作号 |
| | | Thread.sleep(200); |
| | | if(specialSites2.contains(siteId)){ |
| | | write1 = siemensS7Net.Write("DB102." + (offset + offset2 + 48), staProtocol.getStaNo().intValue()); // 目标站 |
| | |
| | | |
| | | if (!write.IsSuccess) { |
| | | staProtocol = station.get(staProtocol.getSiteId()); |
| | | if (staProtocol.getWorkNo() == 0 && staProtocol.getStaNo() ==0) { |
| | | if (staProtocol.getWorkNo() == 0 && staProtocol.getStaNo() ==0 && !staProtocol.isLoading()) { |
| | | staProtocol.setPakMk(true); |
| | | } |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线站点数据失败。输送线plc编号={1},站点数据={2}", slave.getId(), JSON.toJSON(staProtocol))); |