wuyouming666
2024-02-28 d765f491fe415a218975892c6f4651c13764e1f3
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package com.mes.entity.device;
public  class PlcParameterInfo {
      public PlcParameterInfo(String startAddress) {
        this.startAddress = startAddress;
      } 
        private String startAddress;
        // 参数标识
        private String codeId;
 
        // 参数名称
        private String name;
 
        // 读取 参数值
        private String value;
 
        // // 写入 参数值
        // private String writeValue;
 
        // 参数单位
        private String unit;
 
        // 参数值转换系数
        private int ratio;
 
        // 参数地址
        private int addressIndex;
 
        // 参数地址位长度
        private int addressLength;
 
        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 String getValue() {
            return this.value;
        }
 
        public void setValue(String value) {
            this.value = value;
        }
 
        // public String getWriteValue() {
        //     return this.writeValue;
        // }
 
        // public void setWriteValue(String writeValue) {
        //     this.writeValue = writeValue;
        // }
 
        public String getUnit() {
            return this.unit;
        }
 
        public void setUnit(String unit) {
            this.unit = unit;
        }
 
        public int getAddressIndex() {
            return this.addressIndex;
        }
 
        public void setAddressIndex(int addressindex) {
            this.addressIndex = addressindex;
        }
 
        public int getAddressLength() {
            return this.addressLength;
        }
 
        public void setAddressLength(int addresslength) {
            this.addressLength = addresslength;
        }
 
        public int getRatio() {
            return this.ratio;
        }
 
        public void setRatio(int ratio) {
            this.ratio = ratio;
        }
 
           /**
     * 获取地址
     * 
     * @param index 索引地址
     */
    public String getAddress(int index) {
        String[] stringdatas = this.startAddress.trim().split("\\.");
        int addressLength=this.addressLength;
        if (addressLength < 2 ){
            return null;
        }
 
        if (addressLength == 2 ) {
            int wordindex = index;
 
            return stringdatas[0] + "." + wordindex;
        }
        if (addressLength == 14 ) {
            int wordindex = index;
            int newIndex = wordindex + 13;
            return stringdatas[0] + "." + wordindex +"-" + newIndex;
        }
        return null;
    }
 
    public int getPlcAddress() {
 
        return addressIndex;
    }
}