1
zhang
昨天 9d82e56ee05e2be1150b98da80b720b4f93f6afd
zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/thread/SiemensDevpThread.java
@@ -8,6 +8,8 @@
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;
@@ -32,8 +34,6 @@
    private SiemensS7Net siemensS7Net;
    private Map<Integer, StaProtocol> station;
    private volatile boolean connected = false;
    private static final int WRITE_RETRY_MAX = 5;
@@ -75,8 +75,20 @@
     * 读取状态 ====> 整块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;
        }
@@ -90,7 +102,6 @@
        if (!result.IsSuccess) {
            log.error("读取站点状态失败 [id:{}] [error:{}]", slave.getId(), result.Message);
            connected = false;
            return;
        }
@@ -165,7 +176,7 @@
            if (!Cools.isEmpty(barcode)) {
                StaProtocol staProtocol = station.get(barcodeArr.get(i));
                staProtocol.setBarcode(barcode);
                log.info("料箱码:{}", barcode);
                News.info("料箱码:{}", barcode);
            }
        }
    }