Administrator
2022-02-28 64659e3795b4f7cbafb2eaca8fd3831485035d71
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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
package com.dev.fg;
 
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Date;
 
import com.battdata_rt.BattData_RT;
import com.battdata_rt.BattStatData;
import com.dev.fbs9100.FBS9100_ComBase;
import com.dev.fbs9100.FBS9100_Crc16;
import com.dev.modbus4j.MyModbusMaster;
import com.dev.modbus4j.MyModbusUtils;
import com.serotonin.modbus4j.BatchRead;
import com.serotonin.modbus4j.BatchResults;
import com.serotonin.modbus4j.code.DataType;
 
public class FBS9600_State {
    private static final int GroupInfoLen = 20;
    public static final int GroupRegCount = 6;
    
    
    private static final int BYTE_LEN = 35;
    
    private static final int BATT_MAXGOROUP_COUNT = 16;                    //最大电池组数目
    private static final int BATT_MAXMONDATA_COUNT = 256;                //单组最大单体数目
    
    /****************** 电池状态 **********************************/
    final public static byte BATTSTATE_FLOAT         = 0;    //浮充
    final public static byte BATTSTATE_DISCHARGE     = 1;    //放电
    final public static byte BATTSTATE_CHARGE         = 2;    //充电
    final public static byte BATTSTATE_RESTEST         = 4;    //内阻测试
    
    
    public int batt_res_test_cnt;                    //
    
    private int dev_testgroupnum;                    //被测电池组号
    private int dev_workstate;                        //设备状态,电池组放电或充电时可自动加快数据采集速率
    
    
    static final int UsrCmdNull = 0;
    static final int UsrCmdTestRes = 81;
    static final int UsrCmdTestResSuc = 82;
    static final int WorkStateNull = 0;
    static final int WorkStateRes = 1;
    public String ip_addr;
    public int dev_id;
    public int check_dev_id;                                            //校验设备id
    
    public int op_cmd;
    public int test_cmd;
    public int BattGroupNum;                                            //当前电池组号启动或停止时判断要启动和停止的组号
    private boolean op_cmd_ack_fromdev = false;
    int work_state;
    public int com_count;
    public int com_err_count;
    long alm_rec_id = 0L;
    
    public int[] ResState = new int[BATT_MAXGOROUP_COUNT];                //内阻测试状态
    
    public int[] battState = new int[BATT_MAXGOROUP_COUNT];                //电池状态
    public double[] groupVol = new double[BATT_MAXGOROUP_COUNT];        //组端电压
    public double[]    groupCurr = new double[BATT_MAXGOROUP_COUNT];        //组端电流
    public double[] groupTmp = new double[BATT_MAXGOROUP_COUNT];        //环境温度
    public int[] totalEndurance = new int[BATT_MAXGOROUP_COUNT];        //总续航时间
    public int[] remainEndurance = new int[BATT_MAXGOROUP_COUNT];        //剩余续航时间
    public double[] realCap = new double[BATT_MAXGOROUP_COUNT];            //预估实际容量
    public double[] reCharAmount = new double[BATT_MAXGOROUP_COUNT];    //预估可充电量
    public double[] reDisAmount = new double[BATT_MAXGOROUP_COUNT];        //预估可放电量
    public double[] restCap = new double[BATT_MAXGOROUP_COUNT];            //剩余容量SOC
    public int[] monCount = new int[BATT_MAXGOROUP_COUNT];                //单体总数
    public int[] battCount = new int[BATT_MAXGOROUP_COUNT];                //电池组总数
    public double[] capStd = new double[BATT_MAXGOROUP_COUNT];            //标称容量
    public double[] battSoh = new double[BATT_MAXGOROUP_COUNT];            //电池组SOH
    
    public double[][] mon_vols = new double[BATT_MAXGOROUP_COUNT][BATT_MAXMONDATA_COUNT];        //单体电压    
    public double[][] mon_ress = new double[BATT_MAXGOROUP_COUNT][BATT_MAXMONDATA_COUNT];        //单体内阻    
    public double[][] mon_tmps = new double[BATT_MAXGOROUP_COUNT][BATT_MAXMONDATA_COUNT];        //单体温度    
    public double[][] mon_caps = new double[BATT_MAXGOROUP_COUNT][BATT_MAXMONDATA_COUNT];        //单体剩余容量
    public double[][] mon_cap_pers = new double[BATT_MAXGOROUP_COUNT][BATT_MAXMONDATA_COUNT];    //单体容量百分比
    public double[][] mon_socs = new double[BATT_MAXGOROUP_COUNT][BATT_MAXMONDATA_COUNT];        //单体SOC
 
    
    public FBS9600_State(String ipaddr, int id) {
        this.ip_addr = ipaddr;
        this.dev_id = id;
    }
 
    public void setWorkState() {
        this.work_state = 1;
    }
 
    public void clearWorkState() {
        this.work_state = 0;
    }
 
    public int getWorkState() {
        return this.work_state;
    }
 
    public void setFBS9600CmdAckFromDev(boolean stat) {
        this.op_cmd_ack_fromdev = stat;
    }
 
    public boolean getFBS9600CmdAckFromDev() {
        return this.op_cmd_ack_fromdev;
    }
 
    public void setFBS9600Cmd(int cmd) {
        this.op_cmd = cmd;
    }
 
    public int getFBS9600Cmd() {
        return this.op_cmd;
    }
 
    public int getOp_cmd() {
        return op_cmd;
    }
 
    public int getTest_cmd() {
        return test_cmd;
    }
 
    public int getBattGroupNum() {
        return BattGroupNum;
    }
 
    public void setOp_cmd(int op_cmd) {
        this.op_cmd = op_cmd;
    }
 
    public void setTest_cmd(int test_cmd) {
        this.test_cmd = test_cmd;
    }
 
    public void setBattGroupNum(int battGroupNum) {
        BattGroupNum = battGroupNum;
    }
 
    public void setComCountInc() {
        this.com_count += 1;
        if (this.com_count >= 90000000)
            this.com_count = 1;
    }
 
    public void setComErrCountInc() {
        this.com_err_count += 1;
        if (this.com_err_count >= 90000000)
            this.com_err_count = 20;
    }
 
    /**
     * 构造State读取集合
     * @param master
     * @return
     */
    public BatchRead<Integer> createBatchRead(MyModbusMaster master) {
        BatchRead<Integer> batch = new BatchRead<Integer>();
        batch.addLocator(0,MyModbusUtils.createBaseLocator(0xF001,DataType.TWO_BYTE_INT_UNSIGNED, master));                                    //机箱跳闸输出    
        batch.addLocator(1,MyModbusUtils.createBaseLocator(0xF002, DataType.TWO_BYTE_INT_UNSIGNED, master));                                    //故障复位信号    
        
        return batch;
    }
    
    /**
     * 解析State读取集合
     * @param res
     */
    public boolean putBatchResult(BatchResults<Integer> res) {
        if(res != null) {
            int dev_head = res.getIntValue(0);
            int dev_food = res.getIntValue(1);
            
            this.check_dev_id = dev_head*100000+dev_food;
            System.err.println(this.check_dev_id+"===="+dev_head+"==="+dev_food);
            return true;
        }
        return false;
    }
 
    /**
     *     读取电池组组端数据信息
     * @param master
     * @return
     */
    public BatchRead<Integer> createGruopBatchRead(MyModbusMaster master,int index) {
        int offset = index*0x1000;
        BatchRead<Integer> batch = new BatchRead<Integer>();
        batch.addLocator(0,MyModbusUtils.createBaseLocator(0x0000+offset,DataType.TWO_BYTE_INT_UNSIGNED, master));        //电池组状态
        batch.addLocator(1,MyModbusUtils.createBaseLocator(0x0001+offset,DataType.FOUR_BYTE_INT_SIGNED, master));        //组端电压
        batch.addLocator(2,MyModbusUtils.createBaseLocator(0x0003+offset,DataType.FOUR_BYTE_INT_SIGNED, master));        //组端电流
        batch.addLocator(3,MyModbusUtils.createBaseLocator(0x0005+offset,DataType.TWO_BYTE_INT_SIGNED, master));        //环境温度
        batch.addLocator(4,MyModbusUtils.createBaseLocator(0x0006+offset,DataType.FOUR_BYTE_INT_UNSIGNED, master));        //总续航时间
        batch.addLocator(5,MyModbusUtils.createBaseLocator(0x0008+offset,DataType.FOUR_BYTE_INT_UNSIGNED, master));        //剩余续航时间
        batch.addLocator(6,MyModbusUtils.createBaseLocator(0x000C+offset,DataType.FOUR_BYTE_INT_SIGNED, master));        //预估实际容量
        batch.addLocator(7,MyModbusUtils.createBaseLocator(0x000E+offset,DataType.FOUR_BYTE_INT_SIGNED, master));        //可充电量
        batch.addLocator(8,MyModbusUtils.createBaseLocator(0x0010+offset,DataType.FOUR_BYTE_INT_SIGNED, master));        //可放电量
        batch.addLocator(9,MyModbusUtils.createBaseLocator(0x0012+offset,DataType.TWO_BYTE_INT_UNSIGNED, master));        //电池组剩余容量SOC
        batch.addLocator(10,MyModbusUtils.createBaseLocator(0x001B+offset,DataType.TWO_BYTE_INT_UNSIGNED, master));        //电池组单体总数
        batch.addLocator(11,MyModbusUtils.createBaseLocator(0x001E+offset,DataType.TWO_BYTE_INT_UNSIGNED, master));        //平板挂载电池组总数
        batch.addLocator(12,MyModbusUtils.createBaseLocator(0x001F+offset,DataType.FOUR_BYTE_INT_SIGNED, master));        //电池组标称容量
        batch.addLocator(13,MyModbusUtils.createBaseLocator(0x0021+offset,DataType.TWO_BYTE_INT_UNSIGNED, master));        //电池组SOH
        
        return batch;
    }
 
    public boolean putGroupInfo(ByteBuffer buff,int index,BattData_RT battData_RT) {
        if(buff.limit() < GroupRegCount*2) {
            return false;
        }
        ByteBuffer tmpbuf = buff;
        if(index < BATT_MAXGOROUP_COUNT) {
            
            battState[index] = FBS9100_ComBase.changeShortToInt(tmpbuf.getShort());        //电池状态
            
            groupVol[index] = (double)tmpbuf.getInt()/1000;                                //组端电压
            groupCurr[index] = (double)tmpbuf.getInt()/1000;                            //组端电流
            groupTmp[index] = (double)tmpbuf.getShort()/10;                                //环境温度
            
            
//            tmpbuf.position(0);
//            System.out.println("状态:"+tmpbuf.getShort());
//            System.out.println("组压"+tmpbuf.getInt());
//            System.out.println("电流"+tmpbuf.getInt());            
//            tmpbuf.position(0);
//            System.out.println("状态:"+tmpbuf.getShort());
//            System.out.println("组压"+tmpbuf.getInt());
//            System.out.println("电流"+tmpbuf.getInt());
            //System.out.println(battState[index]+"==="+groupVol[index]+"=="+groupCurr[index]+"=="+groupTmp[index]);
//            totalEndurance[index] = tmpbuf.getInt();                                    //总续航时间
//            remainEndurance[index] = tmpbuf.getInt();                                    //剩余续航时间
//            realCap[index] = (double)tmpbuf.getFloat()/1000;                            //预估实际容量
//            reCharAmount[index] = (double)tmpbuf.getFloat()/10;                            //预估可充电量
//            reDisAmount[index] = (double)tmpbuf.getFloat()/10;                            //预估可放电量
//            restCap[index] = (double)tmpbuf.getShort()/10;                                //剩余容量SOC
//            monCount[index] = tmpbuf.getShort();                                        //单体总数
//            battCount[index] = tmpbuf.getShort();                                        //电池组总数
//            capStd[index] = (double)tmpbuf.getInt()/1000;                                //标称容量
//            battSoh[index] = (double) tmpbuf.getShort()/10;                                //电池组SOH
            
            //groupCurr[index] = Math.abs(groupCurr[index]);
            if(BATTSTATE_DISCHARGE == battState[index]) {
                //放电状态
                //groupCurr[index] = (-1)*groupCurr[index];
                if(BATTSTATE_FLOAT == dev_workstate) {
                    dev_workstate = BATTSTATE_DISCHARGE;
                    dev_testgroupnum = index+1;
                }else if(dev_testgroupnum == (index+1) && BATTSTATE_CHARGE == dev_workstate){
                    dev_workstate = BATTSTATE_DISCHARGE;
                }
                
            }else if(BATTSTATE_CHARGE == battState[index]) {
                //充电状态
                if(BATTSTATE_FLOAT == dev_workstate) {
                    dev_workstate = BATTSTATE_FLOAT;
                    dev_testgroupnum = index+1;
                }else if(dev_testgroupnum == (index+1) && BATTSTATE_DISCHARGE == dev_workstate) {
                    dev_workstate = BATTSTATE_DISCHARGE;
                }
            }else {
                if(dev_testgroupnum == (index+1)) {
                    dev_workstate = BATTSTATE_FLOAT;
                    dev_testgroupnum = 0;
                }
            }        
            
//            System.err.println("电池状态:"+battState[index]);
            //battData_RT.mTestData.updateCurrFrom_FBSDev(10);
            
            int last_res_state = battData_RT.mTestData.batt_res_test_state;
            
            battData_RT.mTestData.updateCurrFrom_FBSDev((float)groupCurr[index]);
            battData_RT.mTestData.updateGroupVolFrom_FBSDev((float)groupVol[index]);
            battData_RT.mTestData.updateGroupTempFrom_FBSDev((float)groupTmp[index]);
            battData_RT.mTestData.updateNewDataRCTime(new Date());
            
            battData_RT.updata_BattRtSate_To_RamDb();
 
            if(BATTSTATE_RESTEST == battState[index]) {
                //内阻测试判断
                if(last_res_state != 1) {                    
                    battData_RT.mTestData.batt_res_test_state = 1;
                    battData_RT.mTestData.addBatt_res_test_cnt();
                }
                battData_RT.mTestData.batt_res_test_cnt_out = 0;
            }else {
                battData_RT.mTestData.batt_res_test_cnt_out ++;
                if(battData_RT.mTestData.batt_res_test_cnt_out > 3) {
                    battData_RT.mTestData.batt_res_test_state = 0;                    
                }
            }    
            ResState[index] = battData_RT.mTestData.batt_res_test_state;
            batt_res_test_cnt = battData_RT.mTestData.batt_res_test_cnt;
        }
        return true;
    }
    
    /**
     * 获取单体电压
     * @param buff
     * @param index
     * @param battData_RT
     * @return
     */
    public boolean putMonVolData(ByteBuffer buff,int index,BattData_RT battData_RT) {
        if(buff.limit() < battData_RT.MonCount*2) {
            return false;
        }
        ByteBuffer tmpbuf = buff;
        for(int i=0;i<battData_RT.MonCount;i++) {
            battData_RT.al_MonVol.get(i).monVol = (float)FBS9100_ComBase.changeShortToDouble(tmpbuf.getShort())/1000;
            //System.out.println(battData_RT.al_MonVol.get(i));
 
        }        
        return true;
    }
    /**
     * 获取单体内阻
     * @param buff
     * @param index
     * @param battData_RT
     * @return
     */
    public boolean putMonResData(ByteBuffer buff,int index,BattData_RT battData_RT) {
        if(buff.limit() < battData_RT.MonCount*2) {
            return false;
        }
        ByteBuffer tmpbuf = buff;
        for(int i=0;i<battData_RT.MonCount;i++) {
            battData_RT.al_MonVol.get(i).monRes = (float)FBS9100_ComBase.changeShortToDouble(tmpbuf.getShort())/1000;
        }        
        return true;
    }
    /**
     * 获取单体电压
     * @param buff
     * @param index
     * @param battData_RT
     * @return
     */
    public boolean putMonTmpData(ByteBuffer buff,int index,BattData_RT battData_RT) {
        if(buff.limit() < battData_RT.MonCount*2) {
            return false;
        }
        ByteBuffer tmpbuf = buff;
        for(int i=0;i<battData_RT.MonCount;i++) {
            battData_RT.al_MonVol.get(i).monTmp = (float)FBS9100_ComBase.changeShortToDouble(tmpbuf.getShort())/10;
        }        
        return true;
    }
    /**
     *     读取组端数据
     * @param res
     * @param index
     * @param battData_RT
     * @return
     */
    public boolean putGroupBatchResult(BatchResults<Integer> res, int index, BattData_RT battData_RT) {
        if(null != res && index < BATT_MAXGOROUP_COUNT) {
            battState[index] = res.getIntValue(0);                            //电池状态
            groupVol[index] = (double)res.getIntValue(1)/1000;                //组端电压
            groupCurr[index] = (double)res.getIntValue(2)/1000;                //组端电流
            groupTmp[index] = MyModbusUtils.readShortToDouble(res.getValue(3), true)/10;                    //环境温度
            
            totalEndurance[index] = Long.signum(res.getLongValue(4));        //总续航时间
            remainEndurance[index] = Long.signum(res.getLongValue(5));        //剩余续航时间
            realCap[index] = (double)res.getIntValue(6)/1000;                //预估实际容量
            reCharAmount[index] = (double)res.getIntValue(7)/10;            //预估可充电量
            reDisAmount[index] = (double)res.getIntValue(8)/10;                //预估可放电量
            restCap[index] = (double)res.getIntValue(9)/10;                    //剩余容量SOC
            monCount[index] = res.getIntValue(10);                            //单体总数
            battCount[index] = res.getIntValue(11);                            //电池组总数
            capStd[index] = (double)res.getIntValue(12)/1000;                //标称容量
            battSoh[index] = (double)res.getIntValue(13)/10;                //电池组SOH
            
            groupCurr[index] = Math.abs(groupCurr[index]);
            if(BATTSTATE_DISCHARGE == battState[index]) {
                //放电状态
                groupCurr[index] = (-1)*groupCurr[index];
                if(BATTSTATE_FLOAT == dev_workstate) {
                    dev_workstate = BATTSTATE_DISCHARGE;
                    dev_testgroupnum = index+1;
                }else if(dev_testgroupnum == (index+1) && BATTSTATE_CHARGE == dev_workstate){
                    dev_workstate = BATTSTATE_DISCHARGE;
                }
                
            }else if(BATTSTATE_CHARGE == battState[index]) {
                //充电状态
                if(BATTSTATE_FLOAT == dev_workstate) {
                    dev_workstate = BATTSTATE_FLOAT;
                    dev_testgroupnum = index+1;
                }else if(dev_testgroupnum == (index+1) && BATTSTATE_DISCHARGE == dev_workstate) {
                    dev_workstate = BATTSTATE_DISCHARGE;
                }
            }else {
                if(dev_testgroupnum == (index+1)) {
                    dev_workstate = BATTSTATE_FLOAT;
                    dev_testgroupnum = 0;
                }
            }            
            battData_RT.mTestData.updateCurrFrom_FBSDev((float)groupCurr[index]);
            battData_RT.mTestData.updateGroupVolFrom_FBSDev((float)groupVol[index]);
            battData_RT.mTestData.updateGroupTempFrom_FBSDev((float)groupTmp[index]);
            battData_RT.mTestData.updateNewDataRCTime(new Date());
            
            return true;
        }
        return false;
    }
 
    /**
     *     读取单体电压
     * @param master
     * @param index
     * @param monCount
     * @return
     */
    public BatchRead<Integer> createMonVolBatchRead(MyModbusMaster master, int index,int monCount) {
        int offset = index*0x1000;
        BatchRead<Integer> batch = new BatchRead<Integer>();
        for(int i=0;i<monCount;i++) {            
            batch.addLocator(i,MyModbusUtils.createBaseLocator(0x0100+offset+i,DataType.TWO_BYTE_INT_UNSIGNED, master));        //单体电压                        
        }
        return batch;
    }
 
    /**
     *     读取单体电压
     * @param res
     * @param index
     * @param battData_RT
     * @return
     */
    public boolean putMonVolBatchResult(BatchResults<Integer> res, int index, BattData_RT battData_RT) {
        if(res != null) {
            for(int i=0;i<battData_RT.MonCount;i++) {
                battData_RT.al_MonVol.get(i).monVol = ((float)res.getIntValue(i))/1000;
            }        
            return true;
        }
        return false;
    }
    
    /**
     *     读取单体内阻
     * @param master
     * @param index
     * @param monCount
     * @return
     */
    public BatchRead<Integer> createMonResBatchRead(MyModbusMaster master, int index,int monCount) {
        int offset = index*0x1000;
        BatchRead<Integer> batch = new BatchRead<Integer>();
        for(int i=0;i<monCount;i++) {            
            batch.addLocator(i,MyModbusUtils.createBaseLocator(0x0200+offset+i,DataType.TWO_BYTE_INT_UNSIGNED, master));        //单体内阻                        
        }
        return batch;
    }
 
    /**
     *     读取单体内阻
     * @param res
     * @param index
     * @param battData_RT
     * @return
     */
    public boolean putMonResBatchResult(BatchResults<Integer> res, int index, BattData_RT battData_RT) {
        if(res != null) {
            for(int i=0;i<battData_RT.MonCount;i++) {
                battData_RT.al_MonVol.get(i).monRes = ((float)res.getIntValue(i))/1000;
            }        
            return true;
        }
        return false;
    }
    
    /**
     *     读取单体温度
     * @param master
     * @param index
     * @param monCount
     * @return
     */
    public BatchRead<Integer> createMonTmpBatchRead(MyModbusMaster master, int index,int monCount) {
        int offset = index*0x1000;
        BatchRead<Integer> batch = new BatchRead<Integer>();
        for(int i=0;i<monCount;i++) {            
            batch.addLocator(i,MyModbusUtils.createBaseLocator(0x0300+offset+i,DataType.TWO_BYTE_INT_UNSIGNED, master));        //单体温度                    
        }
        return batch;
    }
 
    /**
     *     读取单体温度
     * @param res
     * @param index
     * @param battData_RT
     * @return
     */
    public boolean putMonTmpBatchResult(BatchResults<Integer> res, int index, BattData_RT battData_RT) {
        if(res != null) {
            for(int i=0;i<battData_RT.MonCount;i++) {
                battData_RT.al_MonVol.get(i).monTmp = ((float)res.getIntValue(i))/10;    //单体温度
            }        
            
            return true;
        }
        return false;
    }
    
    /**
     *     读取单体剩余容量
     * @param master
     * @param index
     * @param monCount
     * @return
     */
    public BatchRead<Integer> createMonCapBatchRead(MyModbusMaster master, int index,int monCount) {
        int offset = index*0x1000;
        BatchRead<Integer> batch = new BatchRead<Integer>();
        for(int i=0;i<monCount;i++) {            
            batch.addLocator(i,MyModbusUtils.createBaseLocator(0x0400+offset+i,DataType.FOUR_BYTE_INT_SIGNED, master));        //单体剩余容量                
        }
        return batch;
    }
 
    /**
     *     读取单体剩余容量
     * @param res
     * @param index
     * @param battData_RT
     * @return
     */
    public boolean putMonCapBatchResult(BatchResults<Integer> res, int index, BattData_RT battData_RT) {
        if(res != null) {
            for(int i=0;i<battData_RT.MonCount;i++) {
                battData_RT.al_MonVol.get(i).monCap = ((float)res.getIntValue(i))/1000;    //单体温度
            }        
            return true;
        }
        return false;
    }
 
    public void setCommData(MyModbusMaster master) {
        this.com_count = master.getTolcommcount();
        this.com_err_count = master.getTotalerr();
        
    }
 
    public boolean putByteBuffer(ByteBuffer buffer) {
        boolean flag = false;
        if(buffer.limit() < BYTE_LEN) {
            return flag;
        }
        ByteBuffer tmpbuf = buffer;
        int crc0 = tmpbuf.getShort(BYTE_LEN-2) & 0xFFFF;
        int crc1 = FBS9100_Crc16.CalCRC16(tmpbuf, BYTE_LEN-2);
        if(crc0 != crc1) {
            return false;
        }
        tmpbuf.position(0);
        
        
        
        flag = true;
        tmpbuf.compact();
        tmpbuf.flip();    
        return flag;
    }
    
    public ByteBuffer crateControlByteBuffer(int value) {
        ByteBuffer tmpbuf = ByteBuffer.allocate(2);
        tmpbuf.order(ByteOrder.BIG_ENDIAN);        
        tmpbuf.putShort(FBS9100_ComBase.changeIntToShort(value));        
        tmpbuf.flip();    
        return tmpbuf;
    }
 
    public static void main(String[] args) {
        short ff = 12;
        System.out.println((float)ff);
    }
 
}