| | |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.SpringUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.BasDevp; |
| | | import com.zy.asrs.entity.BasDevpOpt; |
| | | import com.zy.asrs.entity.BasRgvMap; |
| | | import com.zy.asrs.entity.BasRgvOpt; |
| | | import com.zy.asrs.service.BasDevpOptService; |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.asrs.service.BasRgvMapService; |
| | | import com.zy.asrs.service.BasRgvOptService; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.common.utils.News; |
| | | import com.zy.core.DevpThread; |
| | | import com.zy.core.cache.MessageQueue; |
| | |
| | | add(1022);add(1024); |
| | | add(1025);add(1026);add(1028); |
| | | add(1029);add(1031); |
| | | add(1032);add(1033);add(1035); |
| | | add(1032);add(1033);add(1034);add(1035); |
| | | add(1036);add(1037);add(1038); |
| | | 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); |
| | |
| | | |
| | | put(4001, 0);put(4002, 116);put(4003, 508);put(4004, 392);put(4005, 300); |
| | | put(4006, 208); |
| | | // 其他站点同理继续加 |
| | | }}; |
| | | |
| | | // 站点信号偏移量映射表 |
| | | public static final Map<Integer, Integer> siteOffsetMapSign = new HashMap<Integer, Integer>() {{ |
| | | put(1001, 0);put(1002, 4);put(1003, 8);put(1004, 12);put(1005, 16);put(1006, 20);put(1007, 24); |
| | | put(1008, 28);put(1009, 32);put(1010, 36);put(1011, 40);put(1012, 44);put(1013, 48);put(1014, 52); |
| | | put(1015, 56);put(1016, 60);put(1017, 64);put(1018, 68);put(1019, 72);put(1020, 76);put(1021, 80); |
| | | put(1022, 84);put(1023, 88);put(1024, 92);put(1025, 96);put(1026, 100);put(1027, 104);put(1028, 108); |
| | | put(1029, 112);put(1030, 116);put(1031, 120);put(1032, 124);put(1033, 128);put(1034, 132);put(1035, 136); |
| | | put(1036, 140);put(1037, 144);put(1038, 148);put(1039, 152);put(1040, 156);put(1041, 160); |
| | | |
| | | put(1042, 392);put(1043, 396);put(1044, 400);put(1045, 404);put(1046, 408);put(1047, 412); |
| | | put(1048, 416);put(1049, 420);put(1050, 424);put(1051, 428);put(1052, 432);put(1053, 436); |
| | | |
| | | put(1054, 288);put(1055, 292);put(1056, 296);put(1057, 300);put(1058, 304);put(1059, 308);put(1060, 312); |
| | | put(1061, 316);put(1062, 320);put(1063, 324);put(1064, 328);put(1065, 332);put(1066, 336);put(1067, 340); |
| | | put(1068, 344);put(1069, 348);put(1070, 352);put(1071, 356);put(1072, 360);put(1073, 364);put(1074, 368); |
| | | put(1075, 372);put(1076, 376);put(1077, 380);put(1078, 384);put(1079, 388); |
| | | |
| | | put(1080, 164);put(1081, 168);put(1082, 172);put(1083, 176);put(1084, 180);put(1085, 184);put(1086, 188); |
| | | put(1087, 192);put(1088, 196);put(1089, 200);put(1090, 204);put(1091, 208);put(1092, 212);put(1093, 216); |
| | | put(1094, 220);put(1095, 224);put(1096, 228);put(1097, 232);put(1098, 236);put(1099, 240);put(1100, 244); |
| | | put(1101, 248);put(1102, 252);put(1103, 256);put(1104, 260);put(1105, 264); |
| | | put(1106, 268);put(1107, 272);put(1108, 276);put(1109, 280);put(1110, 284); |
| | | |
| | | put(2001, 0);put(2002, 4);put(2003, 8);put(2004, 12);put(2005, 16); |
| | | put(2006, 20);put(2007, 24);put(2008, 28);put(2009, 32);put(2010, 36); |
| | | put(2011, 40);put(2012, 44);put(2013, 48);put(2014, 52);put(2015, 56); |
| | | put(2016, 60);put(2017, 64);put(2018, 68);put(2019, 72);put(2020, 76); |
| | | put(2021, 80);put(2022, 84);put(2023, 88);put(2024, 92);put(2025, 96); |
| | | put(2026, 100);put(2027, 104);put(2028, 108);put(2029, 112);put(2030, 116); |
| | | 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); |
| | | // 其他站点同理继续加 |
| | | }}; |
| | | |
| | |
| | | OperateResultExOne<byte[]> result4 = null;//1054-1079 |
| | | OperateResultExOne<byte[]> result5 = null;//1080-1110 |
| | | OperateResultExOne<byte[]> resultErr = null; |
| | | if(staNoSize == 99){ |
| | | if(staNoSize == 100){ |
| | | result1 = siemensS7Net.Read("DB100.0", (short) (2768));//1001-1028 |
| | | result2 = siemensS7Net.Read("DB101.0", (short) (1268));//1029-1037 |
| | | result3 = siemensS7Net.Read("DB104.0", (short) (1268));//1042-1053 |
| | |
| | | station.put(siteId, staProtocol); |
| | | } |
| | | staProtocol.setSiteId(siteId); |
| | | if (staNoSize == 99) { |
| | | if (staNoSize == 100) { |
| | | if (siteId < 1029) { |
| | | result = result1; |
| | | } else if (siteId < 1042) { |
| | |
| | | if (offset == null) { |
| | | continue; // 如果没定义偏移量,跳过 |
| | | } |
| | | Integer offset2 = getOffsetBySiteId(siteId); |
| | | Integer offset2 = getOffsetBySiteId(siteId);//特殊偏移量计算 |
| | | Integer offset3 = getOffsetBySiteId2(siteId); |
| | | Integer offsetSign = siteOffsetMapSign.get(siteId); |
| | | if(siteId == 1040){ |
| | | boolean[] full = siemensS7Net.getByteTransform().TransBool(result.Content, offset, 2); |
| | | staProtocol.setFull(full[0]); |
| | |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(result.Content, offset + offset3, 1); |
| | | staProtocol.setAutoing(!status[0]); // 自动 |
| | | boolean[] status1 = siemensS7Net.getByteTransform().TransBool(result.Content, offset + offset3 - 4, 3); |
| | | boolean[] statusErr = siemensS7Net.getByteTransform().TransBool(result.Content, offset + 54, 1); |
| | | 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]) |
| | | // && statusErr[2]) |
| | | { |
| | | loading = 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]); // 空板信号 |
| | | // staProtocol.setFullPlt(status[5]); // 满托盘 |
| | | // staProtocol.setHigh(status[6]); // 高库位 |
| | | // staProtocol.setLow(status[7]); // 低库位 |
| | | |
| | | //报警 |
| | | staProtocol.setPassTimeOut(statusErr[0]); |
| | | staProtocol.setObjectNoIdError(statusErr[1]); |
| | | staProtocol.setIdNoObjectError(statusErr[2]); |
| | | staProtocol.setLmfrError(statusErr[3]); |
| | | staProtocol.setLiftError(statusErr[4]); |
| | | staProtocol.setDlfrError(statusErr[5]); |
| | | staProtocol.setDmfrError(statusErr[6]); |
| | | staProtocol.setVfdError(statusErr[7]); |
| | | staProtocol.setSrvError(statusErr[8]); |
| | | staProtocol.setRes1(statusErr[9]); |
| | | staProtocol.setRes2(statusErr[10]); |
| | | staProtocol.setRes3(statusErr[11]); |
| | | staProtocol.setCommunicationTimeOut(statusErr[12]); |
| | | staProtocol.setParameterIncompleteError(statusErr[13]); |
| | | staProtocol.setDataNotClear(statusErr[14]); |
| | | staProtocol.setSetParameterError(statusErr[15]); |
| | | staProtocol.setRes4(statusErr[16]); |
| | | staProtocol.setRes5(statusErr[17]); |
| | | staProtocol.setDataError(statusErr[18]); |
| | | |
| | | //信号 |
| | | staProtocol.setSensorGArrive(statusSign[0]); |
| | | staProtocol.setSensorGDec(statusSign[1]); |
| | | staProtocol.setSensorGArrive2(statusSign[2]); |
| | | staProtocol.setSensorLimit(statusSign[3]); |
| | | staProtocol.setEmergency(statusSign[4]); |
| | | staProtocol.setSensorGLeave(statusSign[5]); |
| | | staProtocol.setSensorGLeave2(statusSign[6]); |
| | | staProtocol.setSensorCUp(statusSign[7]); |
| | | staProtocol.setSensorCDown(statusSign[8]); |
| | | staProtocol.setLiftMotorFr(statusSign[9]); |
| | | staProtocol.setLineMotorFr(statusSign[10]); |
| | | staProtocol.setTranMotorFr(statusSign[11]); |
| | | staProtocol.setRst1(statusSign[12]); |
| | | staProtocol.setRst2(statusSign[13]); |
| | | staProtocol.setRst3(statusSign[14]); |
| | | staProtocol.setRst4(statusSign[15]); |
| | | staProtocol.setSensorArriveD(statusSign[16]); |
| | | staProtocol.setSensorDecD(statusSign[17]); |
| | | staProtocol.setSensorArriveL(statusSign[18]); |
| | | staProtocol.setSensorDecL(statusSign[19]); |
| | | staProtocol.setSensorArriveR(statusSign[20]); |
| | | staProtocol.setSensorDecR(statusSign[21]); |
| | | |
| | | |
| | | if( (staProtocol.getPassTimeOut() || |
| | | staProtocol.getObjectNoIdError() || |
| | | staProtocol.getIdNoObjectError() || |
| | | staProtocol.getLmfrError() || |
| | | staProtocol.getLiftError() || |
| | | staProtocol.getDlfrError() || |
| | | staProtocol.getDmfrError() || |
| | | staProtocol.getVfdError() || |
| | | staProtocol.getSrvError() || |
| | | staProtocol.getRes1() || |
| | | staProtocol.getRes2() || |
| | | staProtocol.getRes3() || |
| | | staProtocol.getCommunicationTimeOut() || |
| | | staProtocol.getParameterIncompleteError() || |
| | | staProtocol.getDataNotClear() || |
| | | staProtocol.getSetParameterError() || |
| | | staProtocol.getDataError()) && staProtocol.isWriteMk() |
| | | ){ |
| | | staProtocol.setErrorMk(true);//若存在异常触发写入 |
| | | } |
| | | |
| | | if( !staProtocol.getPassTimeOut() && |
| | | !staProtocol.getObjectNoIdError() && |
| | | !staProtocol.getIdNoObjectError() && |
| | | !staProtocol.getLmfrError() && |
| | | !staProtocol.getLiftError() && |
| | | !staProtocol.getDlfrError() && |
| | | !staProtocol.getDmfrError() && |
| | | !staProtocol.getVfdError() && |
| | | !staProtocol.getSrvError() && |
| | | !staProtocol.getRes1() && |
| | | !staProtocol.getRes2() && |
| | | !staProtocol.getRes3() && |
| | | !staProtocol.getCommunicationTimeOut() && |
| | | !staProtocol.getParameterIncompleteError() && |
| | | !staProtocol.getDataNotClear() && |
| | | !staProtocol.getSetParameterError() && |
| | | !staProtocol.getDataError() |
| | | ){ |
| | | staProtocol.setWriteMk(true);//无异常后才能继续写入 |
| | | staProtocol.setErrorMk(false);//若存在异常触发写入 |
| | | |
| | | } |
| | | |
| | | |
| | | if (!staProtocol.isPakMk() && (!staProtocol.isLoading() || staProtocol.getWorkNo()==0)) { |
| | | staProtocol.setPakMk(true); |
| | |
| | | OperateResultExOne<byte[]> reasultBarcode3 = siemensS7Net.Read("DB102.2780", (short) 4);//1103 |
| | | OperateResultExOne<byte[]> reasultBarcode4 = siemensS7Net.Read("DB201.344", (short) 4);//2037 |
| | | OperateResultExOne<byte[]> reasultBarcode5 = siemensS7Net.Read("DB400.112", (short) 4);//4001 |
| | | OperateResultExOne<byte[]> reasultBarcode6 = siemensS7Net.Read("DB201.716", (short) 4);//4001 |
| | | |
| | | if(barcodeList.get(0) == 0){ |
| | | if(reasultBarcode1.IsSuccess){ |
| | |
| | | barcodeThread.setBarcode(barcode); |
| | | } |
| | | } |
| | | if(reasultBarcode6.IsSuccess){ |
| | | Integer barcodeId = barcodeList.get(2); |
| | | String barcode = String.valueOf(siemensS7Net.getByteTransform().TransInt32(reasultBarcode6.Content, 0)); |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, barcodeId + +1); |
| | | if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { |
| | | barcodeThread.setBarcode(barcode); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | for (Integer siteId : staNos) { |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | basDevps.add(staProtocol.toSqlModel()); |
| | | } |
| | | if(staProtocol.isWriteMk() && staProtocol.isErrorMk()){ |
| | | try { |
| | | // 日志记录异常情况 |
| | | BasDevpErrorLog basDevpErrorLogs; |
| | | basDevpErrorLogs = staProtocol.toSqlModelError(); |
| | | BasDevpErrorLogService basDevpErrorLogService = SpringUtils.getBean(BasDevpErrorLogService.class); |
| | | basDevpErrorLogService.insert(basDevpErrorLogs); |
| | | staProtocol.setWriteMk(false); |
| | | } catch (Exception ignore) { |
| | | log.error(ignore.getMessage()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | BasDevpService basDevpService = SpringUtils.getBean(BasDevpService.class); |
| | | |
| | | if (null != basDevpService && !basDevpService.updateBatchById(basDevps)) { |
| | | throw new Exception("更新数据库数据失败"); |
| | | } |
| | | |
| | | |
| | | } catch (Exception e) { |
| | | initSite(); |
| | | e.printStackTrace(); |