| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import java.io.Console; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.text.MessageFormat; |
| | | import java.util.*; |
| | |
| | | add(2034);add(2035);add(2037); |
| | | // add(2041);add(2042);add(2043);add(2044); |
| | | // add(2045);add(2046);add(2047);add(2048); |
| | | // add(2101);add(2102);add(2103);add(2104);add(2105);add(2106);add(2107);add(2108);add(2109);add(2110); |
| | | // add(2111);add(2112);add(2113);add(2114);add(2115);add(2116);add(2117);add(2118);add(2119);add(2120); |
| | | add(2101);add(2102);add(2103);add(2104);add(2105);add(2106);add(2107);add(2108);add(2109);add(2110); |
| | | add(2111);add(2112);add(2113);add(2114);add(2115);add(2116);add(2117);add(2118);add(2119);add(2120); |
| | | add(2121);add(2122); |
| | | add(4001);add(4003);add(4004);add(4006); |
| | | }}; |
| | | |
| | |
| | | put(2026, 2516);put(2027, 2608);put(2028, 2792);put(2029, 2700);put(2030, 2908); |
| | | put(2031, 464);put(2032, 348);put(2033, 556);put(2034, 92);put(2035, 0); |
| | | put(2037, 256); |
| | | |
| | | put(2101, 0);put(2102, 92);put(2103, 184);put(2104, 276);put(2105, 368); |
| | | put(2106, 460);put(2107, 552);put(2108, 644);put(2109, 736);put(2110, 828); |
| | | put(2111, 920);put(2112, 1012);put(2113, 1104);put(2114, 1196);put(2115, 1288); |
| | | put(2116, 1380);put(2117, 1472);put(2118, 1564);put(2119, 1656);put(2120, 1748); |
| | | put(2121, 1840);put(2122, 1932); |
| | | |
| | | put(4001, 0);put(4002, 116);put(4003, 508);put(4004, 392);put(4005, 300); |
| | | put(4006, 208); |
| | |
| | | put(2031, 120);put(2032, 124);put(2033, 128);put(2034, 132);put(2035, 136); |
| | | put(2037, 144); |
| | | |
| | | put(4001, 240);put(4002, 244);put(4003, 248);put(4004, 252);put(4005, 256); |
| | | put(4006, 260); |
| | | put(2101, 160);put(2102, 164);put(2103, 168);put(2104, 172);put(2105, 176); |
| | | put(2106, 180);put(2107, 184);put(2108, 188);put(2109, 192);put(2110, 196); |
| | | put(2111, 200);put(2112, 204);put(2113, 208);put(2114, 212);put(2115, 216); |
| | | put(2116, 220);put(2117, 224);put(2118, 228);put(2119, 232);put(2120, 236); |
| | | put(2121, 240);put(2122, 244); |
| | | put(4001, 248);put(4002, 252);put(4003, 256);put(4004, 260);put(4005, 264); |
| | | put(4006, 268); |
| | | // 其他站点同理继续加 |
| | | }}; |
| | | |
| | | public static final Map<Integer, Integer> siteErrOffsetMap = new HashMap<Integer, Integer>() {{ |
| | | put(1036, 512);put(1103, 476);put(1047, 452);put(2037, 270);put(4001,294); |
| | | put(1036, 512);put(1103, 476);put(1047, 452);put(2037, 278);put(4001,302); |
| | | |
| | | }}; |
| | | public static final Map<Integer, Integer> siteAgvOffsetMap = new HashMap<Integer, Integer>() {{ |
| | | put(1037, 0);put(1039, 2);put(1041, 4);put(2033, 0);put(2034,2);put(4003,4);put(4006,6); |
| | | |
| | | }}; |
| | | |
| | | public static final Map<Integer, Integer> site2lBarcodeOffsetMap = new HashMap<Integer, Integer>() {{//2楼pda写入条码 |
| | | put(2102, 2280);put(2105, 3048);put(2112, 4840);put(2115, 5608); |
| | | |
| | | }}; |
| | | |
| | |
| | | OperateResultExOne<byte[]> result3 = null;//1042-1053 |
| | | OperateResultExOne<byte[]> result4 = null;//1054-1079 |
| | | OperateResultExOne<byte[]> result5 = null;//1080-1110 |
| | | OperateResultExOne<byte[]> result6 = null;//2101-2122 |
| | | |
| | | OperateResultExOne<byte[]> resultErr = null; |
| | | OperateResultExOne<byte[]> resultPlc = null; |
| | | OperateResultExOne<byte[]> resultAgv = null; |
| | | |
| | | OperateResultExOne<byte[]> resultArm5 = null;//2110 |
| | | OperateResultExOne<byte[]> resultArm6 = null;//2120 |
| | | |
| | | if(staNoSize == 102){ |
| | | result1 = siemensS7Net.Read("DB100.0", (short) (2768));//1001-1028 |
| | |
| | | result1 = siemensS7Net.Read("DB200.0", (short) (3000));//2001-2030 |
| | | result2 = siemensS7Net.Read("DB201.0", (short) (720));//2031-2037 |
| | | result3 = siemensS7Net.Read("DB400.0", (short) (600));//4001-4006 |
| | | resultErr = siemensS7Net.Read("DB3.0", (short) (354)); |
| | | result6 = siemensS7Net.Read("DB202.0", (short) (2024));//2101-2122 |
| | | resultErr = siemensS7Net.Read("DB3.0", (short) (386)); |
| | | // resultAgv = siemensS7Net.Read("DB901.0", (short) (7)); //agv取放货请求 |
| | | // resultPlc = siemensS7Net.Read("DB902.0", (short) (7)); //输送线确认 |
| | | resultArm5 = siemensS7Net.Read("DB202.4328", (short) (256));//2110 |
| | | resultArm6 = siemensS7Net.Read("DB202.6888", (short) (256));//2120 |
| | | } |
| | | |
| | | |
| | |
| | | }else{ |
| | | if (siteId < 2031) { |
| | | result = result1; |
| | | } else if (siteId < 4001) { |
| | | } else if (siteId < 2040) { |
| | | result = result2; |
| | | } else { |
| | | } else if(siteId<4000){ |
| | | if (siteId == 2110) { |
| | | if (resultArm5.IsSuccess) { |
| | | // 转换为字符串 |
| | | String resultString = siemensS7Net.getByteTransform().TransString(resultArm5.Content, 2, 254,"UTF-8"); |
| | | // 去除可能的空字符 |
| | | // resultString = resultString.TrimEnd('\0'); |
| | | // System.out.println("2110Barcode:"+resultString); |
| | | staProtocol.setBarcode(resultString); |
| | | } else { |
| | | staProtocol.setBarcode(""); |
| | | } |
| | | } else if (siteId == 2120){ |
| | | if (resultArm6.IsSuccess) { |
| | | // 转换为字符串 |
| | | String resultString = siemensS7Net.getByteTransform().TransString(resultArm6.Content, 2, 254,"UTF-8"); |
| | | // 去除可能的空字符 |
| | | // resultString = resultString.TrimEnd('\0'); |
| | | // System.out.println("2120Barcode:"+resultString); |
| | | staProtocol.setBarcode(resultString); |
| | | } else { |
| | | staProtocol.setBarcode(""); |
| | | } |
| | | } |
| | | result = result6; |
| | | } |
| | | else { |
| | | result = result3; |
| | | } |
| | | } |
| | |
| | | } |
| | | staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt32(result.Content, offset + offset2)); // 工作号 |
| | | staProtocol.setStaNo((short)siemensS7Net.getByteTransform().TransInt32(result.Content, offset + offset2 + 12)); // 目标站 |
| | | staProtocol.setBarcode(String.valueOf(siemensS7Net.getByteTransform().TransInt32(result.Content, offset + offset2 + 16))); //条码 |
| | | |
| | | if (staProtocol.getSiteId()!=2110 && staProtocol.getSiteId()!=2120 ){ |
| | | staProtocol.setBarcode(String.valueOf(siemensS7Net.getByteTransform().TransInt32(result.Content, offset + offset2 + 16))); //条码 |
| | | } |
| | | if(specialSites2.contains(siteId)){ |
| | | staProtocol.setStaNo((short)siemensS7Net.getByteTransform().TransInt32(result.Content, offset + offset2 + 48)); // 目标站 |
| | | staProtocol.setBarcode(String.valueOf(siemensS7Net.getByteTransform().TransInt32(result.Content, offset + offset2 + 52))); //条码 |
| | | if (staProtocol.getSiteId()!=2110 && staProtocol.getSiteId()!=2120 ){ |
| | | staProtocol.setBarcode(String.valueOf(siemensS7Net.getByteTransform().TransInt32(result.Content, offset + offset2 + 52))); //条码 |
| | | } |
| | | } |
| | | if(staNosErrList.contains(siteId)){ |
| | | Integer offsetErr = siteErrOffsetMap.get(siteId); |
| | |
| | | boolean[] status1 = siemensS7Net.getByteTransform().TransBool(result.Content, offset + offset3 - 4, 3); |
| | | boolean[] statusErr = siemensS7Net.getByteTransform().TransBool(result.Content, offset + offset3 - 8, 3); |
| | | boolean[] statusSign = siemensS7Net.getByteTransform().TransBool(resultErr.Content, offsetSign, 3); |
| | | |
| | | boolean loading = false; |
| | | if(!status1[0]) |
| | | { |
| | |
| | | for (Integer siteId : staNos) { |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | basDevps.add(staProtocol.toSqlModel()); |
| | | if(siteId == 2110){ |
| | | basDevps.add(staProtocol.toSqlModel()); |
| | | } |
| | | if(staProtocol.isWriteMk() && staProtocol.isErrorMk()){ |
| | | try { |
| | | // 日志记录异常情况 |
| | |
| | | }else{ |
| | | write1 = siemensS7Net.Write("DB200." + (offset + offset2 + 12), staProtocol.getStaNo().intValue()); // 目标站 |
| | | } |
| | | }else if(siteId < 4000){ |
| | | }else if(siteId < 2121){ |
| | | write = siemensS7Net.Write("DB201." + (offset + offset2), staProtocol.getWorkNo()); // 工作号 |
| | | Thread.sleep(200); |
| | | if(specialSites2.contains(siteId)){ |
| | |
| | | }else{ |
| | | write1 = siemensS7Net.Write("DB201." + (offset + offset2 + 12), staProtocol.getStaNo().intValue()); // 目标站 |
| | | } |
| | | } else if(siteId < 4000){ |
| | | Integer offsetBarcode = site2lBarcodeOffsetMap.get(siteId); |
| | | write = siemensS7Net.Write("DB202." + offsetBarcode, staProtocol.getBarcode()); // 条码 |
| | | write1 = siemensS7Net.Write("DB202." + offsetBarcode, staProtocol.getBarcode()); |
| | | Thread.sleep(200); |
| | | }else{ |
| | | write = siemensS7Net.Write("DB400." + (offset + offset2), staProtocol.getWorkNo()); // 工作号 |
| | | Thread.sleep(200); |