1
zhang
1 天以前 038634540d95d4a5787b80a1fbab131df4d99823
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
package com.zy.acs.conveyor.core.constant;
 
public enum SafeSignalField {
 
    SAFE_SIGNAL_TO_CONVEYOR("DB7", 4, 4, 8),
    SAFE_SIGNAL_FROM_CONVEYOR("DB7", 40, 4, 8),
 
    ;
 
    private final String addressPattern;
    private final int offset;
    private final int byteLength;
    private final int arrLength;
 
    SafeSignalField(String addressPattern, int offset, int byteLength, int arrLength) {
        this.addressPattern = addressPattern;
        this.offset = offset;
        this.byteLength = byteLength;
        this.arrLength = arrLength;
    }
 
    public String getAddressPattern() {
        return addressPattern;
    }
 
    public int getOffset() {
        return offset;
    }
 
    public int getByteLength() {
        return byteLength;
    }
 
    public int getArrLength() {
        return arrLength;
    }
 
    /**
     * 根据 DB 块编号和站点偏移生成具体地址
     *
     * @return PLC4X 地址字符串,如 "DB100.DBD0"
     */
    public String buildAddress() {
        return addressPattern + PlcConstant.ADDRESS_CONCATENATION + offset;
    }
}