自动化立体仓库 - WCS系统
#
tqs
2022-12-06 c2a4b1abdb0e51e4abc41210e0f61f09f0ac0011
src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -42,10 +42,10 @@
    private Map<Integer, StaProtocol> station = new ConcurrentHashMap<>();
    private short heartBeatVal = 1;
    public static final ArrayList<Integer> staNos = new ArrayList<Integer>() {{
        add(1);add(2);add(3);add(4);
        add(5);add(6);add(7);add(8);
        add(9);add(10);add(11);add(12);
        add(13);add(14);add(15);add(16);
        add(100);add(101);add(102);add(103);add(104);add(105);add(106);
        add(110);add(111);add(112);add(113);add(114);add(115);add(116);
        add(200);add(201);add(202);add(203);add(204);add(205);
        add(300);add(301);add(302);add(303);add(304);add(305);
    }};
    /**
@@ -62,9 +62,7 @@
     * 4.出库模式
     */
    public IoModeType ioModeOf2F = IoModeType.NONE;
//    public IoModeType ioMode = IoModeType.NONE;
    public IoModeType ioModeOf4F = IoModeType.NONE;
//    public IoModeType ioMode = IoModeType.NONE;
    public SiemensDevpThread(DevpSlave slave) {
        this.slave = slave;
@@ -129,8 +127,9 @@
//        // 更新入出库模式
//        updateIoMode();
        int staNoSize = staNos.size();
        OperateResultExOne<byte[]> result = siemensS7Net.Read("DB100.0", (short) (staNoSize*4));
        if (result.IsSuccess) {
        OperateResultExOne<byte[]> result = siemensS7Net.Read("DB100.0", (short) (staNoSize*2));
        OperateResultExOne<byte[]> result4 = siemensS7Net.Read("DB101.0", (short) (staNoSize*2));
        if (result.IsSuccess && result4.IsSuccess) {
            for (int i = 0; i < staNoSize; i++) {
                Integer siteId = staNos.get(i); // 站点编号
                StaProtocol staProtocol = station.get(siteId);
@@ -139,9 +138,9 @@
                    staProtocol.setSiteId(siteId);
                    station.put(siteId, staProtocol);
                }
                staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i*4));     // 工作号
                staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i*2));     // 工作号
                staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i*4 + 2));   // 目标站
                staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result4.Content, i*2));   // 目标站
            }
        }
//        Thread.sleep(200);
@@ -159,7 +158,7 @@
//            }
//        }
        Thread.sleep(200);
        OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB100.100", (short) (staNoSize * 2));
        OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB102.100", (short) (staNoSize * 2));
        if (result1.IsSuccess) {
            for (int i = 0; i < staNoSize; i++) {
                Integer siteId = staNos.get(i); // 站点编号
@@ -182,7 +181,7 @@
        //条码扫描器
        Thread.sleep(200);
        OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB100.150",(short)(barcodeSize*8));
        OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB100.200",(short)(barcodeSize*8));
        if (result2.IsSuccess) {
            for (int i = 0; i < barcodeSize; i++) {
                String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*8,8, "UTF-8");
@@ -193,19 +192,19 @@
            }
        }
        //RGV小车
        Thread.sleep(200);
        OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB100.160",(short)2);
        if (result3.IsSuccess) {
            Integer siteId = 16;
            StaProtocol staProtocol = station.get(siteId);
            if (null == staProtocol) {
                staProtocol = new StaProtocol();
                staProtocol.setSiteId(siteId);
                station.put(siteId, staProtocol);
            }
            staProtocol.setNearbySta(String.valueOf(siemensS7Net.getByteTransform().TransInt16(result3.Content, 0)));
        }
//        //RGV小车
//        Thread.sleep(200);
//        OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB100.160",(short)2);
//        if (result3.IsSuccess) {
//            Integer siteId = 16;
//            StaProtocol staProtocol = station.get(siteId);
//            if (null == staProtocol) {
//                staProtocol = new StaProtocol();
//                staProtocol.setSiteId(siteId);
//                station.put(siteId, staProtocol);
//            }
//            staProtocol.setNearbySta(String.valueOf(siemensS7Net.getByteTransform().TransInt16(result3.Content, 0)));
//        }
@@ -248,11 +247,11 @@
        short[] array = new short[2];
        array[0] = staProtocol.getWorkNo();
        array[1] = staProtocol.getStaNo();
        OperateResult write = siemensS7Net.Write("DB100." + index*4, array);
//        OperateResult write = siemensS7Net.Write("DB100." + index*4, array);
//        OperateResult write = siemensS7Net.Write("DB100." + index*2, staProtocol.getWorkNo());    // 工作号
//        Thread.sleep(500);
//        OperateResult write1 = siemensS7Net.Write("DB101." + index*2, staProtocol.getStaNo());    // 目标站
        OperateResult write = siemensS7Net.Write("DB100." + index*2, staProtocol.getWorkNo());    // 工作号
        Thread.sleep(500);
        OperateResult write1 = siemensS7Net.Write("DB101." + index*2, staProtocol.getStaNo());    // 目标站
        if (!write.IsSuccess) {
            staProtocol = station.get(staProtocol.getSiteId());