自动化立体仓库 - 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,7 +145,7 @@
    private void initSite() {
        count ++;
        ArrayList<Integer> staNos = getStaNo();
        if(count > 50) {
        // 站点编号
        for (Integer siteId : staNos) {
            StaProtocol staProtocol = station.get(siteId);
@@ -160,6 +170,18 @@
            }
        }
        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));