| | |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.model.DevpSlave; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.protocol.StaError1; |
| | | import com.zy.core.model.protocol.StaProtocol; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | private SiemensS7Net siemensS7Net; |
| | | private Map<Integer, StaProtocol> station = new ConcurrentHashMap<>(); |
| | | private short heartBeatVal = 1; |
| | | private StaError1 staError1; |
| | | // public static final ArrayList<Integer> staNos = new ArrayList<Integer>() {{ |
| | | // |
| | | // }}; |
| | |
| | | |
| | | public static final ArrayList<Integer> BarcodeList = new ArrayList<Integer>() {{ |
| | | add(0); add(1); add(2); |
| | | }}; |
| | | public static final ArrayList<Integer> BarcodeListMat = new ArrayList<Integer>() {{ |
| | | add(3); add(4); |
| | | }}; |
| | | public static final ArrayList<Integer> staNosErrList = new ArrayList<Integer>() {{ |
| | | add(106); add(107); add(159); |
| | |
| | | } |
| | | // 心跳 |
| | | // heartbeat(); |
| | | Thread.sleep(300); |
| | | Thread.sleep(100); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | } |
| | | BasRgvMapService basRgvMapService = SpringUtils.getBean(BasRgvMapService.class); |
| | | //RGV小车1 |
| | | Thread.sleep(100); |
| | | // Thread.sleep(100); |
| | | OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB50.200",(short)10); |
| | | if (result3.IsSuccess) { |
| | | BasRgvMap basRgvMap = basRgvMapService.selectByRgvNo((int) siemensS7Net.getByteTransform().TransInt16(result3.Content, 0)); |
| | |
| | | } |
| | | } |
| | | //RGV小车2 |
| | | Thread.sleep(100); |
| | | // Thread.sleep(100); |
| | | OperateResultExOne<byte[]> result4 = siemensS7Net.Read("DB50.212",(short)10); |
| | | if (result4.IsSuccess) { |
| | | BasRgvMap basRgvMap = basRgvMapService.selectByRgvNo((int) siemensS7Net.getByteTransform().TransInt16(result4.Content, 0)); |
| | |
| | | } |
| | | |
| | | //RGV小车3 |
| | | Thread.sleep(100); |
| | | // Thread.sleep(100); |
| | | OperateResultExOne<byte[]> result5 = siemensS7Net.Read("DB50.224",(short)10); |
| | | if (result5.IsSuccess) { |
| | | BasRgvMap basRgvMap = basRgvMapService.selectByRgvNo((int) siemensS7Net.getByteTransform().TransInt16(result5.Content, 0)); |
| | |
| | | } |
| | | } |
| | | } |
| | | //条码扫描器 |
| | | ArrayList<Integer> barcodeListMat = BarcodeListMat; |
| | | OperateResultExOne<byte[]> result2Mat = siemensS7Net.Read("DB103.0", (short) (barcodeListMat.size() * 30)); |
| | | if (result2Mat.IsSuccess) { |
| | | for (int i = 0; i < barcodeListMat.size(); i++) { |
| | | Integer barcodeId = barcodeListMat.get(i); |
| | | String barcode = siemensS7Net.getByteTransform().TransString(result2Mat.Content,i*30,30, "UTF-8"); |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, barcodeId + 1); |
| | | if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { |
| | | barcodeThread.setBarcode(barcode); |
| | | } |
| | | } |
| | | } |
| | | //外形检测 |
| | | ArrayList<Integer> staNoErrs = staNosErrList; |
| | | int staNoErrsSize = staNoErrs.size(); |
| | |
| | | staProtocol.setBarcodeErr(status[6]); |
| | | } |
| | | } |
| | | |
| | | OperateResultExOne<byte[]> resultErr2 = siemensS7Net.Read("DB13.2", (short) (staNoSize*4)); |
| | | if (resultErr2.IsSuccess) { |
| | | for (int i = 0; i < staNoSize; i++) { |
| | | Integer siteId = staNos.get(i); // 站点编号 |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(resultErr2.Content, i*4, 1); |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | staProtocol.setBreakerErr(status[0]); |
| | | staProtocol.setInfraredErr(status[1]); |
| | | staProtocol.setOutTimeErr(status[2]); |
| | | staProtocol.setSeizeSeatErr(status[3]); |
| | | staProtocol.setWrkYgoodsN(status[4]); |
| | | staProtocol.setInverterErr(status[5]); |
| | | staProtocol.setContactErr(status[6]); |
| | | staProtocol.setUpcontactErr(status[7]); |
| | | |
| | | } |
| | | } |
| | | OperateResultExOne<byte[]> resultErr3 = siemensS7Net.Read("DB13.400", (short) 3); |
| | | if (resultErr3.IsSuccess) { |
| | | if (staError1 == null){ |
| | | staError1 = new StaError1(); |
| | | } |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(resultErr3.Content, 0, 3); |
| | | staError1.setEMERGENCY_Stop_Core(status[0]); |
| | | staError1.setEMERGENCY_STOP1(status[1]); |
| | | staError1.setEMERGENCY_STOP2(status[2]); |
| | | staError1.setEMERGENCY_STOP3(status[3]); |
| | | staError1.setEMERGENCY_STOP4(status[4]); |
| | | |
| | | staError1.setDoor_EMERGENCY_STOP1(status[5]); |
| | | staError1.setDoor_EMERGENCY_STOP2(status[6]); |
| | | staError1.setDoor_EMERGENCY_STOP3(status[7]); |
| | | staError1.setDoor_EMERGENCY_STOP4(status[8]); |
| | | staError1.setDoor_EMERGENCY_STOP5(status[9]); |
| | | staError1.setDoor_EMERGENCY_STOP6(status[10]); |
| | | |
| | | staError1.setDoor_Open_Err1(status[11]); |
| | | staError1.setDoor_Open_Err1(status[12]); |
| | | staError1.setDoor_Open_Err1(status[13]); |
| | | staError1.setDoor_Open_Err1(status[14]); |
| | | staError1.setDoor_Open_Err1(status[15]); |
| | | staError1.setDoor_Open_Err1(status[16]); |
| | | |
| | | } |
| | | |
| | | |
| | | if (result.IsSuccess) { |
| | | |
| | |
| | | Thread.sleep(200); |
| | | write1 = siemensS7Net.Write("DB100." + (index*6+4), staProtocol.getStaNo().shortValue()); // 目标站 |
| | | if(write.IsSuccess && write1.IsSuccess){ |
| | | log.error("写入输送线命令成功。输送线plc编号={},站点数据={},写入次数={}", slave.getId(), JSON.toJSON(staProtocol), writeCount); |
| | | break; |
| | | } |
| | | else { |