自动化立体仓库 - WCS系统
#
LSH
2022-11-04 5252d40ed210204c9055207a834f1162f9616e08
src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -42,9 +42,9 @@
    private Map<Integer, StaProtocol> station = new ConcurrentHashMap<>();
    private short heartBeatVal = 1;
    public static final ArrayList<Integer> staNos = new ArrayList<Integer>() {{
        add(101);add(102);add(103);add(104);
        add(201);add(202);add(203);add(204);
        add(301);add(302);add(303);add(304);add(305);add(306);
        add(101);add(102);add(103);add(104);add(105);add(106);add(107);add(108);add(109);
//        add(201);add(202);add(203);add(204);
//        add(301);add(302);add(303);add(304);add(305);add(306);
    }};
    /**
@@ -52,6 +52,8 @@
     */
    private int barcodeSize = 1;
    public IoModeType ioMode = IoModeType.NONE;
    public int[] startSignal = new int[48];
    public SiemensDevpThread(DevpSlave slave) {
        this.slave = slave;
@@ -76,6 +78,11 @@
                    // 写数据 ID+目标站
                    case 2:
                        write((StaProtocol)task.getData());
                        break;
                    //复位测试信号
                    case 3:
                        StaProtocol staProtocol = (StaProtocol)task.getData();
                        siemensS7Net.Write("DB102.0" + staProtocol.getSiteId(), staProtocol.getStaNo());
                        break;
                    default:
                        break;
@@ -146,7 +153,7 @@
//            }
//        }
        Thread.sleep(200);
        OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB150.0", (short) (staNoSize*2));
        OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB101.0", (short) (staNoSize*2));
        if (result1.IsSuccess) {
            for (int i = 0; i < staNoSize; i++) {
                Integer siteId = staNos.get(i); // 站点编号
@@ -168,18 +175,25 @@
        }
        Thread.sleep(200);
        OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB100.190",(short)(barcodeSize*8));
        OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB100.190",(short)(barcodeSize*12));
        if (result2.IsSuccess) {
            for (int i = 0; i < barcodeSize; i++) {
                String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*8,8, "UTF-8");
                String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*12,12, "UTF-8");
//                String barcode=new String(result2.Content,i*12,12);
                BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 1);
                if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) {
                    barcodeThread.setBarcode(barcode);
                }
            }
        }
        Thread.sleep(200);
        OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB102.0", (short) 96);
        if(result3.IsSuccess) {
            for(int i=0; i<48; i++){
                startSignal[i] = siemensS7Net.getByteTransform().TransInt16(result3.Content, i*2);
            }
        }
//        OperateResultExOne<Short> result2 = siemensS7Net.ReadInt16("DB200.0");
//        if (result2.IsSuccess) {
//            this.ioMode = IoModeType.get(result2.Content);
@@ -221,7 +235,7 @@
            return;
        }
        int index = staNos.indexOf(staProtocol.getSiteId());
        short[] array = new short[10];
        short[] array = new short[2];
        array[0] = staProtocol.getWorkNo();
        array[1] = staProtocol.getStaNo();
        OperateResult write = siemensS7Net.Write("DB100." + index*4, array);
@@ -240,6 +254,11 @@
        } else {
            OutputQueue.DEVP.offer(MessageFormat.format("【{0}】 输送线命令下发 [id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(staProtocol)));
            log.info("输送线命令下发 [id:{}] >>>>> 命令下发: {}",  slave.getId(), JSON.toJSON(staProtocol));
            Integer siteId = staProtocol.getSiteId();
            staProtocol = station.get(siteId);
            if ( siteId == 102 && (staProtocol.getWorkNo() == 0 && staProtocol.getStaNo() ==0)) {
                staProtocol.setPakMk(true);
            }
        }
    }