1
zhang
2 天以前 818fdd469e2ed47c9e02e06fcb4c7dc791977a0b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package com.zy.acs.conveyor.core.constant;
 
 
/**
 * 设备字段枚举(对应 §2.2)
 */
public enum DeviceField {
    // 扫码器:每站点16字节,String[14]
    BARCODE("DB103", 254, 18, new int[]{0, 2}, 21),
    // 出入库模式
    IO_MODE("DB103", 170, 4, new int[]{0, 2}, 21),
    // 称重:每站点4字节,Float
    WEIGHT("DB103", 634, 6, new int[]{0, 2}, 21),
    // 尺寸异常:每站点2字节,Bit数组
    DIMENSION_WORD("DB103", 2, 8, new int[]{0, 2, 4, 6}, 21);
 
    private final String addressPattern;
    private final int offset;
    private final int byteLength;
    private final int[] seg;
    private final int arrLength;
 
    DeviceField(String addressPattern, int offset, int byteLength, int[] seg, int arrLength) {
        this.addressPattern = addressPattern;
        this.offset = offset;
        this.byteLength = byteLength;
        this.seg = seg;
        this.arrLength = arrLength;
    }
 
    public String getAddressPattern() {
        return addressPattern;
    }
 
    public int getOffset() {
        return offset;
    }
 
    public int getByteLength() {
        return byteLength;
    }
 
    public int getArrLength() {
        return arrLength;
    }
 
    public int[] getSeg() {
        return seg;
    }
 
    /**
     * 根据 DB 块编号和站点偏移生成具体地址
     *
     * @return PLC4X 地址字符串,如 "DB100.DBD0"
     */
    public String buildAddress() {
        return addressPattern + PlcConstant.ADDRESS_CONCATENATION + offset;
    }
}