lsh
2024-08-09 e3b8bc50db4cf9d5fcac58b56d1cb7e25154c3a6
src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -8,6 +8,7 @@
import com.core.common.Cools;
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.mapper.BasDevpMapper;
import com.zy.asrs.service.BasDevpService;
@@ -44,12 +45,18 @@
    private Map<Integer, StaProtocol> station = new ConcurrentHashMap<>();
    private short heartBeatVal = 1;
    private int barcodeSize = 2;
    public static final ArrayList<Integer> staNos = new ArrayList<Integer>() {{
    public static final ArrayList<Integer> staNos1 = new ArrayList<Integer>() {{
        add(100);add(101);add(102);add(103);add(104);add(105);add(106);add(107);add(108);add(109);
        add(110);add(111);
        add(200);add(201);add(202);add(203);add(204);add(205);add(206);add(207);add(208);add(209);
        add(210);add(211);
        add(300);
    }};
    public static final ArrayList<Integer> staNos2 = new ArrayList<Integer>() {{
        add(112);add(113);add(114);
    }};
    public static final ArrayList<Integer> staNos3 = new ArrayList<Integer>() {{
        add(212);add(213);add(214);
    }};
    public boolean charge0;
@@ -70,6 +77,20 @@
     */
    public IoModeType ioModeOf1F = IoModeType.NONE;
    public IoModeType ioModeOf2F = IoModeType.NONE;
    private ArrayList<Integer> getStaNo() {
        switch (slave.getId()) {
            case 1:
                return staNos1;
            case 2:
                return staNos2;
            case 3:
                return staNos3;
            default:
                throw new CoolException("服务器异常");
        }
    }
    @Override
    @SuppressWarnings("InfiniteLoopStatement")
@@ -132,6 +153,7 @@
    private void read() throws InterruptedException {
        // 更新入出库模式
        updateIoMode();
        ArrayList<Integer> staNos = getStaNo();
        OperateResultExOne<byte[]> result = siemensS7Net.Read("DB100.0", (short) 50);
        if (result.IsSuccess) {
            for (int i = 0; i < 25; i++) {
@@ -244,6 +266,7 @@
        if (null == staProtocol) {
            return;
        }
        ArrayList<Integer> staNos = getStaNo();
        int index = staNos.indexOf(staProtocol.getSiteId());
        OperateResult writeId,writeDest;
@@ -358,6 +381,7 @@
        if (null == staProtocol || times > 3) {
            return;
        }
        ArrayList<Integer> staNos = getStaNo();
        int index = staNos.indexOf(staProtocol.getSiteId());
        OperateResult write = siemensS7Net.Write("DB100." + index*2, staProtocol.getWorkNo());    // 工作号
        Thread.sleep(200);