whyclj
2020-09-09 491df299f66993c836743774e365dd90f64d84e2
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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
package com.dev.base.data;
 
import java.util.Date;
 
import com.modbus.data.MyModbusMaster;
import com.modbus.data.MyModbusUtils;
import com.serotonin.modbus4j.BatchRead;
import com.serotonin.modbus4j.BatchResults;
import com.serotonin.modbus4j.code.DataType;
 
public class Dynamicload_state {
    
    public int dev_id;
    public Date record_time;            //¼Ç¼ʱ¼ä
    public int start_auto;                //Æô¶¯×Ô¶¯¼ÓÔØ
    public int stop_auto;                //Í£Ö¹×Ô¶¯¼ÓÔØ
    public int sudden_crease;            //Í»¼Óͻж
    public int all_open;                //È«²¿·ÖÕ¢
    public float actual_set_power;        //ʵ¼ÊÉ趨¹¦ÂÊ
    public float output_power;            //ÒÑÊä³ö¹¦ÂÊ
    public float set_power;                //É趨¹¦ÂÊ
    public float interval_time;            //¼ä¸ôʱ¼äs
    public float actual_curr;            //ʵ¼ÊµçÁ÷
    public float actual_mov;            //ʵ¼Êµçѹ
    public int switch_on;                //ÊÇ·ñºÏÕ¢
    public int FZ_autostate1;            //FZ×Ô¶¯×´Ì¬1
    public int FZ_autostate2;            //FZ×Ô¶¯×´Ì¬2
    public int FZ_autostate3;            //FZ×Ô¶¯×´Ì¬3
    public int FZ_autostate4;            //FZ×Ô¶¯×´Ì¬4
    public int FZ_autostate5;            //FZ×Ô¶¯×´Ì¬5
    public int react_overtem;            //µç¿¹³¬ÎÂ
    public int water_overtem;            //ÀäÈ´Ë®³¬ÎÂ
    public int water_level_low;            //ÀäȴˮҺλµÍ
    public int water_pressure_high;        //Àäȴˮѹ¸ß
    public int local_control;            //¾ÍµØ¿ØÖÆ
    public int back_control;            //ºǫ́¿ØÖÆ
    public int central_control;            //ÖпؿØÖÆ
    public int switch_state;            //¿ª¹Ø¹ñ״̬
    public int inter_volume_M200;        //ÖмäÁ¿M200
    public int fan_button;                //·ç»ú°´Å¥
    public int fan_output;                //·ç»úÊä³ö
    public int allow_close;                //ÊÇ·ñÔÊÐíºÏÕ¢
    public String note;
    
    public int fz_button_num;//¸ºÔذ´Å¥¸öÊý
    public Dynamicload_state(int dev_id,int fz_button_num) {
        this.dev_id = dev_id;
        this.fz_button_num=fz_button_num;
    }
    
    public int getDev_id() {
        return dev_id;
    }
    public Date getRecord_time() {
        return record_time;
    }
    public int getStart_auto() {
        return start_auto;
    }
    public int getStop_auto() {
        return stop_auto;
    }
    public int getSudden_crease() {
        return sudden_crease;
    }
    public int getAll_open() {
        return all_open;
    }
    public float getActual_set_power() {
        return actual_set_power;
    }
    public float getOutput_power() {
        return output_power;
    }
    public float getSet_power() {
        return set_power;
    }
    public float getInterval_time() {
        return interval_time;
    }
    public float getActual_curr() {
        return actual_curr;
    }
    public float getActual_mov() {
        return actual_mov;
    }
    public int getSwitch_on() {
        return switch_on;
    }
    public int getFZ_autostate1() {
        return FZ_autostate1;
    }
    public int getFZ_autostate2() {
        return FZ_autostate2;
    }
    public int getFZ_autostate3() {
        return FZ_autostate3;
    }
    public int getFZ_autostate4() {
        return FZ_autostate4;
    }
    public int getFZ_autostate5() {
        return FZ_autostate5;
    }
    public int getReact_overtem() {
        return react_overtem;
    }
    public int getWater_overtem() {
        return water_overtem;
    }
    public int getWater_level_low() {
        return water_level_low;
    }
    public int getWater_pressure_high() {
        return water_pressure_high;
    }
    public int getLocal_control() {
        return local_control;
    }
    public int getBack_control() {
        return back_control;
    }
    public int getCentral_control() {
        return central_control;
    }
    public int getSwitch_state() {
        return switch_state;
    }
    public int getInter_volume_M200() {
        return inter_volume_M200;
    }
    public int getFan_button() {
        return fan_button;
    }
    public int getFan_output() {
        return fan_output;
    }
    public String getNote() {
        return note;
    }
    public void setDev_id(int dev_id) {
        this.dev_id = dev_id;
    }
    public void setRecord_time(Date record_time) {
        this.record_time = record_time;
    }
    public void setStart_auto(int start_auto) {
        this.start_auto = start_auto;
    }
    public void setStop_auto(int stop_auto) {
        this.stop_auto = stop_auto;
    }
    public void setSudden_crease(int sudden_crease) {
        this.sudden_crease = sudden_crease;
    }
    public void setAll_open(int all_open) {
        this.all_open = all_open;
    }
    public void setActual_set_power(float actual_set_power) {
        this.actual_set_power = actual_set_power;
    }
    public void setOutput_power(float output_power) {
        this.output_power = output_power;
    }
    public void setSet_power(float set_power) {
        this.set_power = set_power;
    }
    public void setInterval_time(float interval_time) {
        this.interval_time = interval_time;
    }
    public void setActual_curr(float actual_curr) {
        this.actual_curr = actual_curr;
    }
    public void setActual_mov(float actual_mov) {
        this.actual_mov = actual_mov;
    }
    public void setSwitch_on(int switch_on) {
        this.switch_on = switch_on;
    }
    public void setFZ_autostate1(int fZ_autostate1) {
        FZ_autostate1 = fZ_autostate1;
    }
    public void setFZ_autostate2(int fZ_autostate2) {
        FZ_autostate2 = fZ_autostate2;
    }
    public void setFZ_autostate3(int fZ_autostate3) {
        FZ_autostate3 = fZ_autostate3;
    }
    public void setFZ_autostate4(int fZ_autostate4) {
        FZ_autostate4 = fZ_autostate4;
    }
    public void setFZ_autostate5(int fZ_autostate5) {
        FZ_autostate5 = fZ_autostate5;
    }
    public void setReact_overtem(int react_overtem) {
        this.react_overtem = react_overtem;
    }
    public void setWater_overtem(int water_overtem) {
        this.water_overtem = water_overtem;
    }
    public void setWater_level_low(int water_level_low) {
        this.water_level_low = water_level_low;
    }
    public void setWater_pressure_high(int water_pressure_high) {
        this.water_pressure_high = water_pressure_high;
    }
    public void setLocal_control(int local_control) {
        this.local_control = local_control;
    }
    public void setBack_control(int back_control) {
        this.back_control = back_control;
    }
    public void setCentral_control(int central_control) {
        this.central_control = central_control;
    }
    public void setSwitch_state(int switch_state) {
        this.switch_state = switch_state;
    }
    public void setInter_volume_M200(int inter_volume_M200) {
        this.inter_volume_M200 = inter_volume_M200;
    }
    public void setFan_button(int fan_button) {
        this.fan_button = fan_button;
    }
    public void setFan_output(int fan_output) {
        this.fan_output = fan_output;
    }
    public void setNote(String note) {
        this.note = note;
    }
    @Override
    public String toString() {
        return "Dynamic_State [dev_id=" + dev_id + ", record_time=" + record_time + ", start_auto=" + start_auto
                + ", stop_auto=" + stop_auto + ", sudden_crease=" + sudden_crease + ", all_open=" + all_open
                + ", actual_set_power=" + actual_set_power + ", output_power=" + output_power + ", set_power="
                + set_power + ", interval_time=" + interval_time + ", actual_curr=" + actual_curr + ", actual_mov="
                + actual_mov + ", switch_on=" + switch_on + ", FZ_autostate1=" + FZ_autostate1 + ", FZ_autostate2="
                + FZ_autostate2 + ", FZ_autostate3=" + FZ_autostate3 + ", FZ_autostate4=" + FZ_autostate4
                + ", FZ_autostate5=" + FZ_autostate5 + ", react_overtem=" + react_overtem + ", water_overtem="
                + water_overtem + ", water_level_low=" + water_level_low + ", water_pressure_high="
                + water_pressure_high + ", local_control=" + local_control + ", back_control=" + back_control
                + ", central_control=" + central_control + ", switch_state=" + switch_state + ", inter_volume_M200="
                + inter_volume_M200 + ", fan_button=" + fan_button + ", fan_output=" + fan_output + ", note=" + note
                + "]";
    }                    
 
    /**
     * ´´½¨¶ÁÈ¡Êý¾Ý¼¯ºÏ
     * @param master
     * @return
     */
    public BatchRead<Integer> createBatchRead(MyModbusMaster master,int fz_button_num){
        BatchRead<Integer> batch = new BatchRead<Integer>();        
        batch.addLocator(0,MyModbusUtils.createBaseLocator(8,master));//Æô¶¯×Ô¶¯¼ÓÔØ
        batch.addLocator(1,MyModbusUtils.createBaseLocator(9 ,master));
        batch.addLocator(2,MyModbusUtils.createBaseLocator(10 , master));
        batch.addLocator(3,MyModbusUtils.createBaseLocator(11, master));//È«²¿·ÖÕ¢
        if(fz_button_num==11){
            batch.addLocator(4,MyModbusUtils.createBaseLocator(1,DataType.TWO_BYTE_INT_SIGNED, master));//ʵ¼ÊÉ趨¹¦ÂÊ4                                    
            batch.addLocator(5,MyModbusUtils.createBaseLocator(2,DataType.TWO_BYTE_INT_SIGNED, master));                                
            batch.addLocator(6,MyModbusUtils.createBaseLocator(4,DataType.TWO_BYTE_INT_SIGNED, master));                                
            batch.addLocator(7,MyModbusUtils.createBaseLocator(6,DataType.TWO_BYTE_INT_SIGNED,master));                                
            batch.addLocator(8,MyModbusUtils.createBaseLocator(7,DataType.TWO_BYTE_INT_SIGNED, master));                                
            batch.addLocator(9,MyModbusUtils.createBaseLocator(8,DataType.TWO_BYTE_INT_SIGNED, master));//ʵ¼Êµçѹ4
            
        }else {
            batch.addLocator(4,MyModbusUtils.createBaseLocator(2,DataType.TWO_BYTE_INT_SIGNED, master));//ʵ¼ÊÉ趨¹¦ÂÊ4                                    
            batch.addLocator(5,MyModbusUtils.createBaseLocator(4,DataType.TWO_BYTE_INT_SIGNED, master));                                
            batch.addLocator(6,MyModbusUtils.createBaseLocator(8,DataType.TWO_BYTE_INT_SIGNED, master));                                
            batch.addLocator(7,MyModbusUtils.createBaseLocator(16,DataType.TWO_BYTE_INT_SIGNED,master));                                
            batch.addLocator(8,MyModbusUtils.createBaseLocator(17,DataType.TWO_BYTE_INT_SIGNED, master));                                
            batch.addLocator(9,MyModbusUtils.createBaseLocator(18,DataType.TWO_BYTE_INT_SIGNED, master));//ʵ¼Êµçѹ4
        }
        
        batch.addLocator(10,MyModbusUtils.createBaseLocator(8011, master));//ÊÇ·ñºÏÕ¢
        
        batch.addLocator(11,MyModbusUtils.createBaseLocator(1,master));//×Ô¶¯×´Ì¬1
        batch.addLocator(12,MyModbusUtils.createBaseLocator(2,master));
        batch.addLocator(13,MyModbusUtils.createBaseLocator(3, master));
        batch.addLocator(14,MyModbusUtils.createBaseLocator(4, master));                                
        batch.addLocator(15,MyModbusUtils.createBaseLocator(5, master));//×Ô¶¯×´Ì¬5
        
        batch.addLocator(16,MyModbusUtils.createBaseLocator(4013, master));//µç¿¹³¬Î                                
        batch.addLocator(17,MyModbusUtils.createBaseLocator(4014, master));                                
        batch.addLocator(18,MyModbusUtils.createBaseLocator(4015, master));                                
        batch.addLocator(19,MyModbusUtils.createBaseLocator(4016, master));                                
        batch.addLocator(20,MyModbusUtils.createBaseLocator(40, master));                                    
        batch.addLocator(21,MyModbusUtils.createBaseLocator(41, master));
        batch.addLocator(22,MyModbusUtils.createBaseLocator(42,master));
        batch.addLocator(23,MyModbusUtils.createBaseLocator(4018 ,master));
        batch.addLocator(24,MyModbusUtils.createBaseLocator(160 ,master));
        batch.addLocator(25,MyModbusUtils.createBaseLocator(12, master));                                
        batch.addLocator(26,MyModbusUtils.createBaseLocator(8013, master));//·ç»úÊä³ö                                    
 
        
        return batch;
    }
    /**
     * ½âÎö·µ»ØÇëÇó
     * @param res
     */
    public void putBatchResult(BatchResults<Integer> res) {
        if(res != null) {
            this.start_auto = MyModbusUtils.readBooleanToInt(res.getValue(0));    
            this.stop_auto = MyModbusUtils.readBooleanToInt(res.getValue(1));    
            this.sudden_crease = MyModbusUtils.readBooleanToInt(res.getValue(2));    
            this.all_open = MyModbusUtils.readBooleanToInt(res.getValue(3));    
            
            this.actual_set_power = MyModbusUtils.readShortToFloat(res.getValue(4));                
            this.output_power = MyModbusUtils.readShortToFloat(res.getValue(5));            
            this.set_power = MyModbusUtils.readShortToFloat(res.getValue(6));                
            this.interval_time = MyModbusUtils.readShortToFloat(res.getValue(7));        
            this.actual_curr = MyModbusUtils.readShortToFloat(res.getValue(8));                
            this.actual_mov= MyModbusUtils.readShortToFloat(res.getValue(9));    
            
            this.allow_close= MyModbusUtils.readBooleanToInt(res.getValue(10));    
            
            this.FZ_autostate1 = MyModbusUtils.readBooleanToInt(res.getValue(11));    
            this.FZ_autostate2 = MyModbusUtils.readBooleanToInt(res.getValue(12));    
            this.FZ_autostate3 = MyModbusUtils.readBooleanToInt(res.getValue(13));    
            this.FZ_autostate4 = MyModbusUtils.readBooleanToInt(res.getValue(14));    
            this.FZ_autostate5 = MyModbusUtils.readBooleanToInt(res.getValue(15));    
            
            this.react_overtem = MyModbusUtils.readBooleanToInt(res.getValue(16));    
            this.water_overtem = MyModbusUtils.readBooleanToInt(res.getValue(17));    
            this.water_level_low = MyModbusUtils.readBooleanToInt(res.getValue(18));
            this.water_pressure_high = MyModbusUtils.readBooleanToInt(res.getValue(19));    
            this.local_control= MyModbusUtils.readBooleanToInt(res.getValue(20));    
            this.back_control= MyModbusUtils.readBooleanToInt(res.getValue(21));    
            this.central_control = MyModbusUtils.readBooleanToInt(res.getValue(22));
            this.switch_state = MyModbusUtils.readBooleanToInt(res.getValue(23));
            this.inter_volume_M200 = MyModbusUtils.readBooleanToInt(res.getValue(24));
            this.fan_button = MyModbusUtils.readBooleanToInt(res.getValue(25));
            this.fan_output = MyModbusUtils.readBooleanToInt(res.getValue(26));
            
        }
    }
    
 
}