自动化立体仓库 - WCS系统
#
zjj
2024-10-14 056cf9d0311e1345017ab4c52c5946144fb4ccb8
src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -45,11 +45,19 @@
    private Map<Integer, StaProtocol> station = new ConcurrentHashMap<>();
    private short heartBeatVal = 1;
    private StaError1 staError1;
    public static boolean is = true;
//    public static final ArrayList<Integer> staNos = new ArrayList<Integer>() {{
//
//    }};
    public static final ArrayList<Integer> staNos1 = new ArrayList<Integer>() {{
        add(140);add(141);
    add(1000);   add(1001);   add(1002);   add(1003);   add(1004);   add(1005);   add(1006);   add(1007);   add(1008);   add(1009);   add(1010);
    add(1011);   add(1012);   add(1013);   add(1014);   add(1015);   add(1016);   add(1017);   add(1018);   add(1019);   add(1020);   add(1021);
    add(1022);   add(1023);   add(1024);   add(1025);   add(1026);   add(1027);   add(1028);   add(1029);   add(1030);
//        add(200);add(201);add(202);
    }};
    public static final ArrayList<Integer> staNos2 = new ArrayList<Integer>() {{
       add(1400);
//        add(200);add(201);add(202);
    }};
@@ -91,6 +99,8 @@
        switch (slave.getId()) {
            case 1:
                return staNos1;
            case 2:
                return staNos2;
            default:
                throw new CoolException("服务器异常");
        }
@@ -135,31 +145,43 @@
    private void initSite() {
        count ++;
        ArrayList<Integer> staNos = getStaNo();
        if(count > 50) {
            // 站点编号
            for (Integer siteId : staNos) {
                StaProtocol staProtocol = station.get(siteId);
                if (null == staProtocol) {
                    staProtocol = new StaProtocol();
                    staProtocol.setSiteId(siteId);
                    station.put(siteId, staProtocol);
                }
                staProtocol.setWorkNo(0);     // 工作号
                staProtocol.setStaNo((short) 0);   // 目标站
                staProtocol.setState((short) 0);  // 模式状态 0停机,=1手动,=2自动,=3故障
                staProtocol.setWorkIo((short) 0);
                staProtocol.setRequestIo((short) 0);
                staProtocol.setTrayIo((short) 0);
                staProtocol.setLocIo((short) 0);
                staProtocol.setBarcode("-");
                staProtocol.setWeightIo(0.0);
                staProtocol.setMode((short) 0);
        // 站点编号
        for (Integer siteId : staNos) {
            StaProtocol staProtocol = station.get(siteId);
            if (null == staProtocol) {
                staProtocol = new StaProtocol();
                staProtocol.setSiteId(siteId);
                station.put(siteId, staProtocol);
                if (!staProtocol.isPakMk() && staProtocol.workType == DevpWorkType.IDLE) {
                    staProtocol.setPakMk(true);
                }
            }
            staProtocol.setWorkNo(0);     // 工作号
            staProtocol.setStaNo((short) 0);   // 目标站
            staProtocol.setState((short) 0);  // 模式状态 0停机,=1手动,=2自动,=3故障
            staProtocol.setWorkIo((short) 0);
            staProtocol.setRequestIo((short) 0);
            staProtocol.setTrayIo((short) 0);
            staProtocol.setLocIo((short) 0);
            staProtocol.setBarcode("-");
            staProtocol.setWeightIo(0.0);
            staProtocol.setMode((short) 0);
            if (!staProtocol.isPakMk() && staProtocol.workType == DevpWorkType.IDLE) {
                staProtocol.setPakMk(true);
            }
            count = 0;
        }
        count = 0;
    }
    public void initSta(){
        if (is){
            for (int i = 1000; i <= 1300; i++) {
                staNos1.add(i);
            }
            is = false;
        }
    }
@@ -295,7 +317,7 @@
        int index = staNos.indexOf(staProtocol.getSiteId());
        OperateResult write1 = siemensS7Net.Write("DB100." + index*66, staProtocol.getWorkNo());    // 工作号
        Thread.sleep(200);
        Thread.sleep(100);
        OperateResult write2 = siemensS7Net.Write("DB100." + (index*66+4), staProtocol.getStaNo());    // 目标站
        if(write1.IsSuccess && write2.IsSuccess){
            OperateResultExOne<byte[]> result = siemensS7Net.Read("DB100."+(index*66), (short) 6);
@@ -317,7 +339,9 @@
                    OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB100."+(index*66 +6), (short) 2);
                    short mk = siemensS7Net.getByteTransform().TransInt16(result2.Content, 0);
                    if (mk == 2){
                        OperateResult write4 = siemensS7Net.Write("DB100." + (index*66+6), 0);
                        OperateResult write5 = siemensS7Net.Write("DB100." + index*66, 0);    // 工作号
                        OperateResult write6 = siemensS7Net.Write("DB100." + (index*66+4), (short) 0);    // 目标站
                        OperateResult write4 = siemensS7Net.Write("DB100." + (index*66+6), (short) 0);
                        if (write4.IsSuccess){
                            OutputQueue.DEVP.offer(MessageFormat.format("【{0}】 输送线命令下发 [id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(staProtocol)));
                            News.info("SiemensDevp"+" - 5"+" - 输送线命令下发 [id:{}] >>>>> 命令下发: {}",  slave.getId(), JSON.toJSON(staProtocol));