whyclj
2020-10-20 2a1aa055a75826211327ce37a7ad761bb7016c68
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
package com.dev.data;
 
public class ConfigData {
    
    //¸æ¾¯±àºÅ¶ÔÓ¦¹ØÏµ
    public static final int ALARM_TYPE_NULL         = -1;        //²»´¥·¢¸æ¾¯
    public static final int ALARM_TYPE_BIG             = 1;        //´óÓڸ澯
    public static final int ALARM_TYPE_BIGBIG         = 2;        //´óÓÚ´óÓڸ澯
    public static final int ALARM_TYPE_SMALL         = 3;        //СÓڸ澯
    public static final int ALARM_TYPE_SMALLSMALL     = 4;        //СÓÚСÓڸ澯
    public static final int ALARM_TYPE_EQUAL         = 5;        //µÈÓڸ澯
    public static final int ALARM_TYPE_NOTEQUAL     = 6;        //²»´¥·¢¸æ¾¯
    
    
    public int dev_id;                        //É豸id
    public int dev_number;                    //Êý¾Ý±àºÅ
    public String dev_num;                    //Êý¾Ý±àºÅstr
    public String data_value;                //Êý¾ÝÃû³Æ
    public String unit;                        //µ¥Î»
    public float value_min;                    //×îСֵ
    public float value_max;                    //×î´óÖµ
    public float dataacc;                    //¾«¶È(1->ÕûÊý£»10->0.1;100->0.01)
    public int alm_num1 = -1;                //±¨¾¯1±àºÅ
    public float alm_num1_value;            //±¨¾¯1¸æ¾¯Öµ
    public int alm_num2 = -1;                //±¨¾¯2±àºÅ    
    public float alm_num2_value;            //±¨¾¯2¸æ¾¯Öµ
    public String varname;                    //±äÁ¿Ãû³Æ
    public String vname = "";                //É豸±êʶ·û
    public String macsource;                //ʵʱÊý¾Ý¿âËù´¦¼ÆËã»ú
    public String datasource;                //Êý¾ÝÔ´
    public String dataaccess;                //»ñȡ;¾¶
    public int vartype;                        //±äÁ¿ÀàÐÍ(1¡ª>Ä£ÄâÁ¿;2->¿ª¹ØÁ¿;3->״̬Á¿)
    public String wanlogo;                    //ÒÔÌ«Íø±êʶ
    public int frameposit;                    //Ö¡ÖÐλÖÃ
    public float defalutval;                //ĬÈÏÖµ
    public String codename;                    //´úºÅ
    public float value;                        //µ±Ç°×Ö¶ÎÖµ
    
    public int update_code;                    //¸üбêʶ[0:ʵʱ¸üУ»1:°´Ðè¸üÐÂ]
    public int update_en;                    //ÐèÒª¸üÐÂ[0:²»ÐèÒª¸üÐÂ;1:ÐèÒª¸üÐÂ]
    
    //¸æ¾¯´¥·¢×Ö¶Î
    public boolean isNewUpdate = true;        //ÊÇ·ñ¸üи澯Êý¾Ý        true:ÐèÒª¸üи澯¼Ç¼     false:²»ÐèÒª¸üмǼ
    public boolean alarm_en = false;        //ÊÇ·ñ´¥·¢¸æ¾¯            true:´¥·¢¸æ¾¯      false:¸æ¾¯Ïûʧ
    public int alarm_type = 0;                //¸æ¾¯ÀàÐÍ1:ÉÏÏ޸澯    2:ÏÂÏ޸澯       3:²»µÈ¸æ¾¯      4£ºµÈÓڸ澯
    
    
    public int getDev_number() {
        return dev_number;
    }
    public String getDev_num() {
        return dev_num;
    }
    public String getData_value() {
        return data_value;
    }
    public String getUnit() {
        return unit;
    }
    public float getValue_min() {
        return value_min;
    }
    public float getValue_max() {
        return value_max;
    }
    public float getDataacc() {
        return dataacc;
    }
    public float getAlm_num1() {
        return alm_num1;
    }
    public float getAlm_num1_value() {
        return alm_num1_value;
    }
    public float getAlm_num2() {
        return alm_num2;
    }
    public float getAlm_num2_value() {
        return alm_num2_value;
    }
    public String getVarname() {
        return varname;
    }
    public String getVname() {
        return vname;
    }
    public String getMacsource() {
        return macsource;
    }
    public String getDatasource() {
        return datasource;
    }
    public String getDataaccess() {
        return dataaccess;
    }
    public int getVartype() {
        return vartype;
    }
    public String getWanlogo() {
        return wanlogo;
    }
    public int getFrameposit() {
        return frameposit;
    }
    public float getDefalutval() {
        return defalutval;
    }
    public String getCodename() {
        return codename;
    }
    public void setDev_number(int dev_number) {
        this.dev_number = dev_number;
    }
    public void setDev_num(String dev_num) {
        this.dev_num = dev_num;
    }
    public void setData_value(String data_value) {
        this.data_value = data_value;
    }
    public void setUnit(String unit) {
        this.unit = unit;
    }
    public void setValue_min(float value_min) {
        this.value_min = value_min;
    }
    public void setValue_max(float value_max) {
        this.value_max = value_max;
    }
    public void setDataacc(float dataacc) {
        this.dataacc = dataacc;
    }
    public void setAlm_num1(int alm_num1) {
        this.alm_num1 = alm_num1;
    }
    public void setAlm_num1_value(float alm_num1_value) {
        this.alm_num1_value = alm_num1_value;
    }
    public void setAlm_num2(int alm_num2) {
        this.alm_num2 = alm_num2;
    }
    public void setAlm_num2_value(float alm_num2_value) {
        this.alm_num2_value = alm_num2_value;
    }
    public void setVarname(String varname) {
        this.varname = varname;
    }
    public void setVname(String vname) {
        this.vname = vname;
    }
    public void setMacsource(String macsource) {
        this.macsource = macsource;
    }
    public void setDatasource(String datasource) {
        this.datasource = datasource;
    }
    public void setDataaccess(String dataaccess) {
        this.dataaccess = dataaccess;
    }
    public void setVartype(int vartype) {
        this.vartype = vartype;
    }
    public void setWanlogo(String wanlogo) {
        this.wanlogo = wanlogo;
    }
    public void setFrameposit(int frameposit) {
        this.frameposit = frameposit;
    }
    public void setDefalutval(float defalutval) {
        this.defalutval = defalutval;
    }
    public void setCodename(String codename) {
        this.codename = codename;
    }
    public float getValue() {
        return value;
    }
    
    /**
     *     »ñÈ¡µ±Ç°×Ö¶ÎÊýÖµ,²¢ÖØÖõ±Ç°¸üÐÂÖµ
     * @return
     */
    public float getDataValue() {
        this.isNewUpdate = false;
        return this.value;
    }
    
    //¼ì²âµ±Ç°ÊýÖµ
    public void setValue(float value) {
        if(dataacc >1) {
            //¼ÆËãʵ¼ÊÊýÖµ
            this.value = (float)value/dataacc;
        } else {
            this.value = value;
        }        
        checkAlarm();                        //УÑ鏿¾¯Öµ
    }
    
    /**
     *     ¼ì²éµ±Ç°Êý¾Ý¸æ¾¯
     */
    public void checkAlarm() {
        boolean lastalarm_en = this.alarm_en;
        //¼ì²â¸æ¾¯±àºÅ2
        switch(this.alm_num2) {
            case ALARM_TYPE_NULL:{                
            }break;
            case ALARM_TYPE_BIG:
            case ALARM_TYPE_BIGBIG:{
                //´óÓڸ澯
                if(this.value > this.alm_num2_value) {
                    this.alarm_en = true;
                    this.alarm_type = ALARM_TYPE_BIG;
                }
            }break;
            case ALARM_TYPE_SMALL:
            case ALARM_TYPE_SMALLSMALL:{
                //СÓڸ澯
                if(this.value < this.alm_num2_value) {
                    this.alarm_en = true;
                    this.alarm_type = ALARM_TYPE_SMALL;
                }
            }break;
            case ALARM_TYPE_EQUAL:{
                //µÈÓڸ澯
                if(this.value == this.alm_num2_value) {
                    this.alarm_en = true;
                    this.alarm_type = ALARM_TYPE_EQUAL;
                }
            }break;
            case ALARM_TYPE_NOTEQUAL:{
                //²»µÈÓڸ澯
                if(this.value != this.alm_num2_value) {
                    this.alarm_en = true;
                    this.alarm_type = ALARM_TYPE_NOTEQUAL;
                }
            }break;
        }
        if(!this.alarm_en) {
            //¼ì²â¸æ¾¯±àºÅ1
            switch(this.alm_num1) {
                case ALARM_TYPE_NULL:{                
                }break;
                case ALARM_TYPE_BIG:
                case ALARM_TYPE_BIGBIG:{
                    //´óÓڸ澯
                    if(this.value > this.alm_num1_value) {
                        this.alarm_en = true;
                        this.alarm_type = ALARM_TYPE_BIG;
                    }
                }break;
                case ALARM_TYPE_SMALL:
                case ALARM_TYPE_SMALLSMALL:{
                    //СÓڸ澯
                    if(this.value < this.alm_num1_value) {
                        this.alarm_en = true;
                        this.alarm_type = ALARM_TYPE_SMALL;
                    }
                }break;
                case ALARM_TYPE_EQUAL:{
                    //µÈÓڸ澯
                    if(this.value == this.alm_num1_value) {
                        this.alarm_en = true;
                        this.alarm_type = ALARM_TYPE_EQUAL;
                    }
                }break;
                case ALARM_TYPE_NOTEQUAL:{
                    //²»µÈÓڸ澯
                    if(this.value != this.alm_num1_value) {
                        this.alarm_en = true;
                        this.alarm_type = ALARM_TYPE_NOTEQUAL;
                    }
                }break;
            }
        }
        if(lastalarm_en != this.alarm_en) {
            isNewUpdate = true;
        }
    }
    
    //ÅжÏÊÇ·ñÐèÒª¸üÐÂ״̬
    public boolean checkCanUpdate(ConfigData cfg,int update_en) {
        if(cfg.update_code == 0 || (cfg.update_code ==1 && update_en == 1)) {
            cfg.update_en = 1;
            return true;
        }
        return false;
    }
    
    @Override
    public String toString() {
        return "ConfigData [dev_id="+dev_id+",dev_number=" + dev_number + ", dev_num=" + dev_num + ", data_value=" + data_value
                + ", unit=" + unit + ", value_min=" + value_min + ", value_max=" + value_max + ", dataacc=" + dataacc
                + ", alm_num1=" + alm_num1 + ", alm_num1_value=" + alm_num1_value + ", alm_num2=" + alm_num2
                + ", alm_num2_value=" + alm_num2_value + ", varname=" + varname + ", vname=" + vname + ", macsource="
                + macsource + ", datasource=" + datasource + ", dataaccess=" + dataaccess + ", vartype=" + vartype
                + ", wanlogo=" + wanlogo + ", frameposit=" + frameposit + ", defalutval=" + defalutval + ", codename="
                + codename + "]";
    }
    
    
    public static void main(String[] args) {
        
    }
}