自动化立体仓库 - WCS系统
野心家
2024-09-04 bfc2fee36897a0e6ca4d77701cf4d8f6a7281aec
src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -48,7 +48,12 @@
    private Map<Integer, StaProtocol> station = new ConcurrentHashMap<>();
    private short heartBeatVal = 1;
    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(100);add(101);add(102);add(103);add(104);
        add(105);add(106);add(107);add(108);add(109);
        add(110);add(111);add(112);add(113);add(114);
        add(115);add(116);add(117);add(118);add(119);
        add(120);add(121);add(122);add(123);add(124);
        add(125);add(1001);add(1002);add(1003);add(1004);
    }};
    /*public static final ArrayList<Integer> staNos2 = new ArrayList<Integer>() {{
        add(200);add(201);add(202);add(203);
@@ -73,7 +78,7 @@
    /**
     * 条码数量
     */
    private int barcodeSize = 7;
    private int barcodeSize = 1;
    /**
     * 入出库模式
@@ -234,79 +239,79 @@
            }
        }
        OperateResultExOne<byte[]> resultAgvAndPlc = siemensS7Net.Read("DB102.0", (short) 30);
        if (resultAgvAndPlc.IsSuccess) {
            for (int i = 0; i < staNoSize; i++) {
                int sign =(i+2)/2-1;
                if ((i+2)%2!=0){
                    Integer siteId = staNos.get(i); // 站点编号
                    StaProtocol staProtocol = station.get(siteId);
                    if (null == staProtocol) {
                        staProtocol = new StaProtocol();
                        staProtocol.setSiteId(siteId);
                        station.put(siteId, staProtocol);
                    }
                    staProtocol.setAgvStartPick(siemensS7Net.getByteTransform().TransInt16(resultAgvAndPlc.Content, sign*6+4));     // 允许取货
                    staProtocol.setAgvStartPlace((short)0);   // 允许放货
                    continue;
                }
                Integer siteId = staNos.get(i); // 站点编号
                StaProtocol staProtocol = station.get(siteId);
                if (null == staProtocol) {
                    staProtocol = new StaProtocol();
                    staProtocol.setSiteId(siteId);
                    station.put(siteId, staProtocol);
                }
                staProtocol.setAgvStartPick(siemensS7Net.getByteTransform().TransInt16(resultAgvAndPlc.Content, sign*6));     // 允许取货
                staProtocol.setAgvStartPlace(siemensS7Net.getByteTransform().TransInt16(resultAgvAndPlc.Content, sign*6 + 2));   // 允许放货
            }
        }
//        OperateResultExOne<byte[]> resultAgvAndPlc = siemensS7Net.Read("DB102.0", (short) 30);
//        if (resultAgvAndPlc.IsSuccess) {
//            for (int i = 0; i < staNoSize; i++) {
//                int sign =(i+2)/2-1;
//                if ((i+2)%2!=0){
//                    Integer siteId = staNos.get(i); // 站点编号
//                    StaProtocol staProtocol = station.get(siteId);
//                    if (null == staProtocol) {
//                        staProtocol = new StaProtocol();
//                        staProtocol.setSiteId(siteId);
//                        station.put(siteId, staProtocol);
//                    }
//                    staProtocol.setAgvStartPick(siemensS7Net.getByteTransform().TransInt16(resultAgvAndPlc.Content, sign*6+4));     // 允许取货
//                    staProtocol.setAgvStartPlace((short)0);   // 允许放货
//                    continue;
//                }
//                Integer siteId = staNos.get(i); // 站点编号
//                StaProtocol staProtocol = station.get(siteId);
//                if (null == staProtocol) {
//                    staProtocol = new StaProtocol();
//                    staProtocol.setSiteId(siteId);
//                    station.put(siteId, staProtocol);
//                }
//                staProtocol.setAgvStartPick(siemensS7Net.getByteTransform().TransInt16(resultAgvAndPlc.Content, sign*6));     // 允许取货
//                staProtocol.setAgvStartPlace(siemensS7Net.getByteTransform().TransInt16(resultAgvAndPlc.Content, sign*6 + 2));   // 允许放货
//            }
//        }
        OperateResultExOne<byte[]> resultAgvAndPlcOk = siemensS7Net.Read("DB132.0", (short) 30);
        if (resultAgvAndPlcOk.IsSuccess) {
            for (int i = 0; i < staNoSize; i++) {
                int sign =(i+2)/2-1;
                if ((i+2)%2!=0){
                    Integer siteId = staNos.get(i); // 站点编号
                    StaProtocol staProtocol = station.get(siteId);
                    if (null == staProtocol) {
                        staProtocol = new StaProtocol();
                        staProtocol.setSiteId(siteId);
                        station.put(siteId, staProtocol);
                    }
                    staProtocol.setAgvTargetPick(siemensS7Net.getByteTransform().TransInt16(resultAgvAndPlcOk.Content, sign*6+4));     // 允许取货
                    staProtocol.setAgvTargetPlace((short)0);   // 允许放货
                    continue;
                }
                Integer siteId = staNos.get(i); // 站点编号
                StaProtocol staProtocol = station.get(siteId);
                if (null == staProtocol) {
                    staProtocol = new StaProtocol();
                    staProtocol.setSiteId(siteId);
                    station.put(siteId, staProtocol);
                }
                try{
                    staProtocol.setAgvTargetPick(siemensS7Net.getByteTransform().TransInt16(resultAgvAndPlcOk.Content, sign*6));     // 取货完成
                    if (staProtocol.getAgvTargetPick()!=0){
                        System.out.println(staProtocol.getAgvTargetPick());
                    }
                    staProtocol.setAgvTargetPlace(siemensS7Net.getByteTransform().TransInt16(resultAgvAndPlcOk.Content, sign*6 + 2));   // 放货完成
                    if (staProtocol.getAgvTargetPlace()!=0){
                        System.out.println(staProtocol.getAgvTargetPlace());
                    }
                }catch (Exception e){
                    log.error(""+e);
                }
            }
        }
//        OperateResultExOne<byte[]> resultAgvAndPlcOk = siemensS7Net.Read("DB132.0", (short) 30);
//        if (resultAgvAndPlcOk.IsSuccess) {
//            for (int i = 0; i < staNoSize; i++) {
//                int sign =(i+2)/2-1;
//                if ((i+2)%2!=0){
//                    Integer siteId = staNos.get(i); // 站点编号
//                    StaProtocol staProtocol = station.get(siteId);
//                    if (null == staProtocol) {
//                        staProtocol = new StaProtocol();
//                        staProtocol.setSiteId(siteId);
//                        station.put(siteId, staProtocol);
//                    }
//                    staProtocol.setAgvTargetPick(siemensS7Net.getByteTransform().TransInt16(resultAgvAndPlcOk.Content, sign*6+4));     // 允许取货
//                    staProtocol.setAgvTargetPlace((short)0);   // 允许放货
//                    continue;
//                }
//                Integer siteId = staNos.get(i); // 站点编号
//                StaProtocol staProtocol = station.get(siteId);
//                if (null == staProtocol) {
//                    staProtocol = new StaProtocol();
//                    staProtocol.setSiteId(siteId);
//                    station.put(siteId, staProtocol);
//                }
//                try{
//                    staProtocol.setAgvTargetPick(siemensS7Net.getByteTransform().TransInt16(resultAgvAndPlcOk.Content, sign*6));     // 取货完成
//                    if (staProtocol.getAgvTargetPick()!=0){
//                        System.out.println(staProtocol.getAgvTargetPick());
//                    }
//                    staProtocol.setAgvTargetPlace(siemensS7Net.getByteTransform().TransInt16(resultAgvAndPlcOk.Content, sign*6 + 2));   // 放货完成
//                    if (staProtocol.getAgvTargetPlace()!=0){
//                        System.out.println(staProtocol.getAgvTargetPlace());
//                    }
//                }catch (Exception e){
//                    log.error(""+e);
//                }
//            }
//        }
        if (slave.getId() == 1) {
            //条码
            //Thread.sleep(200);
            OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.840.0", (short) 32);
            OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.848.0", (short) 8);
            if (result2.IsSuccess) {
                for (int i = 0; i < 4; i++) {
                for (int i = 0; i < 1; i++) {
                    String barcode = siemensS7Net.getByteTransform().TransString(result2.Content, i * 8, 8, "UTF-8");
                    BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 1);
                    if (!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) {
@@ -315,8 +320,19 @@
                }
            }
            //外形检测
            OperateResultExOne<byte[]> resultErr1 = siemensS7Net.Read("DB101.810.0", (short) (barcodeSize*1));
            StaProtocol staProtocol1 = station.get(116);
            boolean[] status1 = siemensS7Net.getByteTransform().TransBool(resultErr1.Content, 0, 1);
            staProtocol1.setFrontErr(status1[0]);
            staProtocol1.setBackErr(status1[1]);
            staProtocol1.setHighErr(status1[2]);
            staProtocol1.setLeftErr(status1[3]);
            staProtocol1.setRightErr(status1[4]);
            staProtocol1.setWeightErr(status1[5]);
            staProtocol1.setBarcodeErr(status1[6]);
            OperateResultExOne<byte[]> resultErr = siemensS7Net.Read("DB13.2", (short) (staNoSize * 4));
            OperateResultExOne<byte[]> resultErr = siemensS7Net.Read("DB101.922.0", (short) (staNoSize * 4));
            if (resultErr.IsSuccess) {
                for (int i = 0; i < staNoSize; i++) {
                    Integer siteId = staNos.get(i); // 站点编号