严智鑫
2024-04-18 ad28331c1e3ed456b72765874b41b83b49dc279f
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package com.mes.common;
 
 
public class PlcBitInfo {
 
    public PlcBitInfo(String startAddress) {
        this.startAddress = startAddress;
    }
 
    private String startAddress;
    // 参数标识
    private String codeId;
 
    // 参数名称
    private String name;
 
    // 读取 参数值
    private Boolean value;
    // 参数地址
    private int addressIndex;
 
    public String getCodeId() {
        return this.codeId;
    }
 
    public void setCodeId(String codeId) {
        this.codeId = codeId;
    }
 
    public String getName() {
        return this.name;
    }
 
    public void setName(String name) {
        this.name = name;
    }
 
    public Boolean getValue() {
        return this.value;
    }
 
    public void setValue(Boolean value) {
        this.value = value;
    }
 
 
    public int getAddressIndex() {
        return this.addressIndex;
    }
 
    /**
     * 获取地址
     *
     * @param index 索引地址
     */
    public String getAddress(int index) {
        String[] stringdatas = this.startAddress.trim().split("\\.");
        if (stringdatas.length < 2)
            return null;
        int dbwindex = 0;
        int bitindex = 0;
        if (stringdatas.length == 3) {
            dbwindex = Integer.parseInt(stringdatas[1]);
            bitindex = Integer.parseInt(stringdatas[2]);
        } else
            return null;
        dbwindex += index / 8;
        bitindex += index % 8;
        return stringdatas[0] + "." + dbwindex + "." + bitindex;
    }
 
 
    public void setAddressIndex(int addressindex) {
        this.addressIndex = addressindex;
    }
}