| | |
| | | import com.zy.acs.conveyor.core.constant.StationStatusField; |
| | | import com.zy.acs.conveyor.core.model.StaProtocol; |
| | | import com.zy.acs.conveyor.core.properties.DevpSlave; |
| | | import com.zy.acs.conveyor.core.service.DevpS7Service; |
| | | import com.zy.acs.conveyor.core.service.StationService; |
| | | import com.zy.acs.conveyor.entity.Devp; |
| | | import com.zy.acs.conveyor.service.DevpService; |
| | | import com.zy.acs.conveyor.utils.SpringContextUtil; |
| | |
| | | private SiemensS7Net siemensS7Net; |
| | | |
| | | private Map<Integer, StaProtocol> station; |
| | | |
| | | private volatile boolean connected = false; |
| | | |
| | | private static final int WRITE_RETRY_MAX = 5; |
| | | |
| | |
| | | * 读取状态 ====> 整块plc |
| | | */ |
| | | private void read() throws InterruptedException { |
| | | if (!connected || siemensS7Net == null) { |
| | | if (siemensS7Net == null) { |
| | | DevpS7Service devpS7Service = SpringContextUtil.getBean(DevpS7Service.class); |
| | | if (devpS7Service != null) { |
| | | siemensS7Net = devpS7Service.get(slave.getId()); |
| | | } |
| | | log.warn("PLC未连接,跳过读取 [id:{}]", slave.getId()); |
| | | return; |
| | | } |
| | | if (station == null) { |
| | | StationService stationService = SpringContextUtil.getBean(StationService.class); |
| | | if (stationService != null) { |
| | | station = stationService.getStationMap(slave.getId()); |
| | | } |
| | | log.warn("站点未连接,跳过读取 [id:{}]", slave.getId()); |
| | | return; |
| | | } |
| | | |
| | |
| | | |
| | | if (!result.IsSuccess) { |
| | | log.error("读取站点状态失败 [id:{}] [error:{}]", slave.getId(), result.Message); |
| | | connected = false; |
| | | return; |
| | | } |
| | | |
| | |
| | | if (!Cools.isEmpty(barcode)) { |
| | | StaProtocol staProtocol = station.get(barcodeArr.get(i)); |
| | | staProtocol.setBarcode(barcode); |
| | | log.info("料箱码:{}", barcode); |
| | | News.info("料箱码:{}", barcode); |
| | | } |
| | | } |
| | | } |