DELL
2024-12-18 4e6a319d3a023cd57b1bb3f5afd47df0763e57b7
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
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
package com.fgkj.mcp;
 
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
 
import com.fgkj.bres.FileDataParseInfo_Interface;
import com.fgkj.bres.RES_Crc16;
import com.fgkj.data.ComBase;
 
/**
 *     FBS充放电数据解析
 * @author LiJun
 *
 */
public class TestDataInfo implements FileDataParseInfo_Interface{
 
    public int parse_result = PARSE_RESULT_NULL;            //文件解析结果
    public int file_type = FILE_TYPE_NULL;                    //文件类型
    
    public MonitorDataInfo testDataInfo;
    public List<FBSData> FBSDatas;
    
    public TestDataInfo() {
        testDataInfo = new MonitorDataInfo();
        FBSDatas = new ArrayList<TestDataInfo.FBSData>();
    }
    
    
    @Override
    public void readFileData(String filePath) {
        FileInputStream fis = null;
        try {
            File f = new File(filePath);
            if((!filePath.endsWith(".MCP") && !filePath.endsWith(".mcp")) && (!filePath.endsWith(".MCH") && !filePath.endsWith(".mch"))) {
                System.out.println("文件格式错误");
                parse_result = PARSE_RESULT_FILETYPEERR;
                return;
            }
            if(!f.exists()) {
                parse_result = PARSE_RESULT_NOTFOUNDFILE;
                System.out.println("文件不存在..........");
                return;
            }
            fis = new FileInputStream(f);
            byte[] buf = new byte[MonitorDataInfo.BYTE_LEN];
            if(fis.read(buf, 0, buf.length) == MonitorDataInfo.BYTE_LEN)
            {
                if(this.testDataInfo.setHeadData(buf)) {
                    parse_result = PARSE_RESULT_SUCCESS;
                }else {
                    parse_result = PARSE_RESULT_FILEERROR;
                }
                while(true)
                {                    
                    if(testDataInfo.checkDataHead(fis))
                    {
                        byte[] databuf = new byte[FBSData.BYTE_LEN - MVolData.BYTE_LEN +(testDataInfo.battparam.eachGroupBattCount*testDataInfo.battparam.battGroupCount)*2];
                        //System.out.println("databuf.length:"+databuf.length);
                        if(fis.read(databuf) == databuf.length)
                        {
                            FBSData fbsData = new FBSData(testDataInfo.monitorstate.testType);
                            if(fbsData.setData(databuf)) {
                                System.out.println(fbsData);
                                FBSDatas.add(fbsData);
                            }
                        }
                    }
                    if(fis.available() <1) {
                        //System.out.println("解析完成");
                        break;
                        
                    }
                }
            }else {
                parse_result = PARSE_RESULT_FILEERROR;
            }
                
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if(null != fis)
            {
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        
    }
    
    
    /**
     *     测试时长
     * @author LiJun
     *
     */
    public class TestTime{
        public static final int BYTE_LEN = 3;
        
        public int hour;            //时
        public int minute;            //分
        public int second;            //秒
        public void setTestTime(ByteBuffer bf) {
            if(bf.limit() < BYTE_LEN) {
                return;
            }
            this.hour = ComBase.changeByteToInt(bf.get());
            this.minute = ComBase.changeByteToInt(bf.get());
            this.second = ComBase.changeByteToInt(bf.get());
        }
    }
    
    
    public class VolCurrData{
        public static final int BYTE_LEN = 80;
        
        public static final int GROUP_COUNT_MAX = 4;
        public float onlinevol[]  = new float[GROUP_COUNT_MAX];//在线电压    分辨率0.1V
        public float groupvol[]   = new float[GROUP_COUNT_MAX];//组端电压 分辨率0.1V
        public int battstate[]    = new int[GROUP_COUNT_MAX];//电池状态,见表2
        public float  battcurr[]  = new float[GROUP_COUNT_MAX];//电流 分辨率0.1A
        public int battcap[]      = new int[GROUP_COUNT_MAX];//已测容量 AH
        public float  batttemp[]  = new float[GROUP_COUNT_MAX];//温度,预留,没使用
        public int monMAX_num[]   = new int[GROUP_COUNT_MAX];//最高单体索引号
        public int monMIN_num[]   = new int[GROUP_COUNT_MAX];//最低单体索引号
        public float  monvolMAX[] = new float[GROUP_COUNT_MAX];//最高单体电压 0.001V
        public float  monvolMIN[] = new float[GROUP_COUNT_MAX];//最低单体电压 0.001V
        
        public boolean puByteBuffer(ByteBuffer bf) {
            //System.err.println(ComFn.bytesToHexString(bf.array(), bf.array().length));
            bf.position(0);
            if(bf.remaining() < BYTE_LEN) {
                return false;
            }
            for(int i=0;i<onlinevol.length;i++) {
                onlinevol[i]  = ComBase.changeShortToFloat(bf.getShort())*0.1f;    //在线电压    分辨率0.1V
            }
            for(int i=0;i<groupvol.length;i++) {
                groupvol[i]   = ComBase.changeShortToFloat(bf.getShort())*0.1f;    //组端电压 分辨率0.1V
            }
            for(int i =0;i<battstate.length;i++) {
                battstate[i] = ComBase.changeShortToInt(bf.getShort());            //电池状态,见表2
            }
            for(int i = 0;i<battcurr.length;i++) {                
                battcurr[i]  = ComBase.changeShortToFloat(bf.getShort())*0.1f;    //电流 分辨率0.1A
            }
            for(int i=0;i<battcap.length;i++) {
                battcap[i] = ComBase.changeShortToInt(bf.getShort());            //已测容量 AH
            }
            for(int i=0;i<batttemp.length;i++) {                
                batttemp[i]  = ComBase.changeShortToFloat(bf.getShort());        //温度,预留,没使用
            }
            for(int i=0;i<monMAX_num.length;i++) {                
                monMAX_num[i]   = ComBase.changeShortToInt(bf.getShort());        //最高单体索引号
            }
            for(int i=0;i<monMIN_num.length;i++) {                
                monMIN_num[i]   = ComBase.changeShortToInt(bf.getShort());//最低单体索引号
            }
            for(int i=0;i<monvolMAX.length;i++) {                
                monvolMAX[i] = ComBase.changeShortToFloat(bf.getShort())*0.001f;//最高单体电压 0.001V
            }
            for(int i=0;i<monvolMIN.length;i++) {
                monvolMIN[i] = ComBase.changeShortToFloat(bf.getShort())*0.001f;//最低单体电压 0.001V
            }
            bf.compact();
            //System.out.println(this);
            return true;
        }
 
        @Override
        public String toString() {
            return "VolCurrData [onlinevol=" + Arrays.toString(onlinevol) + ", groupvol=" + Arrays.toString(groupvol)
                    + ", battstate=" + Arrays.toString(battstate) + ", battcurr=" + Arrays.toString(battcurr)
                    + ", battcap=" + Arrays.toString(battcap) + ", batttemp=" + Arrays.toString(batttemp)
                    + ", monMAX_num=" + Arrays.toString(monMAX_num) + ", monMIN_num=" + Arrays.toString(monMIN_num)
                    + ", monvolMAX=" + Arrays.toString(monvolMAX) + ", monvolMIN=" + Arrays.toString(monvolMIN) + "]";
        }
        
    }
    
    public class MVolData{
        public static final int BYTE_LEN = 1000;
        
        public static final int MONOMER_COUNT_MAX = 500;
        public float vol[];//单体电压 偏移20000 分辨率0.001V 
        public MVolData(int count) {
            vol = new float[count];
        }
        public boolean puByteBuffer(ByteBuffer bf) {
            bf.position(0);
            if(bf.remaining() < vol.length*2) {
                return false;
            }
            for(int i=0;i<vol.length;i++) {
                //System.out.println(ComBase.changeShortToFloat(bf.getShort())*0.001);
                vol[i] = (float)(ComBase.changeShortToFloat(bf.getShort())*0.001);//单体电压 偏移20000 分辨率0.001V 
            }            
            bf.compact();
            //System.out.println(this);
            return true;
        }
        @Override
        public String toString() {
            return "MVolData [vol=" + Arrays.toString(vol) + "]";
        }
    }
    
    public class FBSData{
        public static final int BYTE_LEN = 5 + TestTime.BYTE_LEN+VolCurrData.BYTE_LEN + MVolData.BYTE_LEN;
        
        public int dataType[] = new int[4];        //数据类型 见表1
        public int CRC16;
        public TestTime testTime;                //已测试时间(HMS)
        public int battGroup;                    //组数
        public int battSum;                        //单体个数
        public VolCurrData vcData;
        public MVolData mVol;
        
        public FBSData(int dataType) {
            testTime = new TestTime();
            vcData = new VolCurrData();
            for(int i=0;i<this.dataType.length;i++) {
                this.dataType[i] = dataType;
            }
        }
        
        public boolean setData(byte[] databuf) {
            boolean flag = true;
            //System.out.println(databuf.length + "===" + BYTE_LEN);
            //System.out.println(ComFn.bytesToHexString(databuf, databuf.length));
            ByteBuffer bf = ByteBuffer.allocate(databuf.length + dataType.length);
            bf.order(ByteOrder.LITTLE_ENDIAN);
            bf.position(0);
            if(databuf.length < (BYTE_LEN-MVolData.BYTE_LEN)) {                
                return flag;
            }
            for(int i = 0;i<dataType.length;i++) {
                bf.put(ComBase.changeIntToByte(this.dataType[i]));
            }
            bf.put(databuf);
            //System.out.println(ComFn.bytesToHexString(bf.array(), bf.array().length));
            bf.flip();
            
            CRC16 = ComBase.changeShortToInt(bf.getShort(4));
            bf.putShort(4, ComBase.changeIntToShort(0));
            int crc1 = RES_Crc16.CalCRC16(bf, bf.limit());
            if(CRC16 != crc1) {
                System.err.println(CRC16 +"!="+ crc1);
                return false;
            }
            bf.position(6);
            
            testTime.setTestTime(bf);                            //已测试时间(HMS)
            battGroup = ComBase.changeByteToInt(bf.get());        //组数
            battSum = ComBase.changeShortToInt(bf.getShort());    //单体个数
            
            mVol = new MVolData(battGroup*battSum);
            bf.compact();
            
            flag &= vcData.puByteBuffer(bf);
            flag &= mVol.puByteBuffer(bf);
            
            return flag;
            
        }
 
        @Override
        public String toString() {
            return "FBSData [dataType=" + Arrays.toString(dataType) + ", CRC16=" + CRC16 + ", testTime=" + testTime
                    + ", battGroup=" + battGroup + ", battSum=" + battSum + ", vcData=" + vcData + ", mVol=" + mVol
                    + "]";
        }
        
        
    }
 
    public class BattParam{
        public static final int BYTE_LEN = 44;
        
        public int STD_CAP;                    //标称容量 分辨率 1AH
        public float STD_RES;                //标称内阻 分辨率0.001mΩ
        public int battGroupCount;            //组数
        public int eachGroupBattCount;        //每组单体个数
        public float monomerVol;            //单体标称电压 分辨率0.1V
        public float groupVol;                //未使用
        public float battTemp;                ////未使用
        public float floatChargeVol;        //未使用
        public float floatChargeCurr;        //未使用
        public float onlineVolLow;            //未使用
        public int groupConnType;            //未使用
        
        public int bakeup1;
        public int bakeup2;
        public int bakeup3;
        public int bakeup4;
        public int bakeup5;
        public int bakeup6;
        public int bakeup7;
        public int bakeup8;
        public int bakeup9;
        public int bakeup10;
        
        public int CRC;                        //未使用
 
        public boolean putByteBuffer(ByteBuffer bf) {
            if(bf.remaining() < BYTE_LEN) {
                return false;
            }
            bf.position(0);
            
            STD_CAP = ComBase.changeShortToInt(bf.getShort());                    //标称容量 分辨率 1AH
            STD_RES = ComBase.changeShortToFloat(bf.getShort()) * 0.001f;        //标称内阻 分辨率0.001mΩ
            battGroupCount = ComBase.changeShortToInt(bf.getShort());            //组数
            eachGroupBattCount = ComBase.changeShortToInt(bf.getShort());        //每组单体个数
            monomerVol = ComBase.changeShortToFloat(bf.getShort())*0.1f;        //单体标称电压 分辨率0.1V
            groupVol = ComBase.changeShortToFloat(bf.getShort());                //未使用
            battTemp = ComBase.changeShortToFloat(bf.getShort());                ////未使用
            floatChargeVol = ComBase.changeShortToFloat(bf.getShort());            //未使用
            floatChargeCurr = ComBase.changeShortToFloat(bf.getShort());        //未使用
            onlineVolLow = ComBase.changeShortToFloat(bf.getShort());            //未使用
            groupConnType = ComBase.changeShortToInt(bf.getShort());            //未使用
            
            bakeup1 = ComBase.changeShortToInt(bf.getShort());
            bakeup2 = ComBase.changeShortToInt(bf.getShort());
            bakeup3 = ComBase.changeShortToInt(bf.getShort());
            bakeup4 = ComBase.changeShortToInt(bf.getShort());
            bakeup5 = ComBase.changeShortToInt(bf.getShort());
            bakeup6 = ComBase.changeShortToInt(bf.getShort());
            bakeup7 = ComBase.changeShortToInt(bf.getShort());
            bakeup8 = ComBase.changeShortToInt(bf.getShort());
            bakeup9 = ComBase.changeShortToInt(bf.getShort());
            bakeup10 = ComBase.changeShortToInt(bf.getShort());
            
            CRC = ComBase.changeShortToInt(bf.getShort());
            
            //System.out.println(this);
            //System.out.println("bf.limit()"+bf.limit());
            bf.compact();
            //System.out.println("bf.limit()"+bf.limit());
            return true;
        }
 
        @Override
        public String toString() {
            return "BattParam [STD_CAP=" + STD_CAP + ", STD_RES=" + STD_RES + ", battGroupCount=" + battGroupCount
                    + ", eachGroupBattCount=" + eachGroupBattCount + ", monomerVol=" + monomerVol + ", groupVol="
                    + groupVol + ", battTemp=" + battTemp + ", floatChargeVol=" + floatChargeVol + ", floatChargeCurr="
                    + floatChargeCurr + ", onlineVolLow=" + onlineVolLow + ", groupConnType=" + groupConnType
                    + ", bakeup1=" + bakeup1 + ", bakeup2=" + bakeup2 + ", bakeup3=" + bakeup3 + ", bakeup4=" + bakeup4
                    + ", bakeup5=" + bakeup5 + ", bakeup6=" + bakeup6 + ", bakeup7=" + bakeup7 + ", bakeup8=" + bakeup8
                    + ", bakeup9=" + bakeup9 + ", bakeup10=" + bakeup10 + ", CRC=" + CRC + "]";
        }
        
        
    }
    
    public class SYSMonitorParam{
        public static final int BYTE_LEN = 46;
        
        public int monitorEN;
        public float disCurr;
        public float disCap;
        public int disTime;
        public float groupVol_LOW;
        public float monomerVol_LOW;
        public int monomerLowCount;
        public int battGroupCount;
        public int onlineVolLowAction;
        public float chrCurr;
        public float chrCap;
        public int chrTime;
 
        public int bakeup1;
        public int bakeup2;
        public int bakeup3;
        public int bakeup4;
        public int bakeup5;
        public int bakeup6;
        public int bakeup7;
        public int bakeup8;
        public int bakeup9;
        public int bakeup10;
 
        public int CRC;
 
        public boolean putByteBuffer(ByteBuffer bf) {
            if(bf.remaining() < BYTE_LEN) {
                return false;
            }
            bf.position(0);
            
            monitorEN = ComBase.changeShortToInt(bf.getShort());
            disCurr = ComBase.changeShortToFloat(bf.getShort());
            disCap = ComBase.changeShortToFloat(bf.getShort());
            disTime = ComBase.changeShortToInt(bf.getShort());
            groupVol_LOW = ComBase.changeShortToFloat(bf.getShort());
            monomerVol_LOW = ComBase.changeShortToFloat(bf.getShort());
            monomerLowCount = ComBase.changeShortToInt(bf.getShort());
            battGroupCount = ComBase.changeShortToInt(bf.getShort());
            onlineVolLowAction = ComBase.changeShortToInt(bf.getShort());
            chrCurr = ComBase.changeShortToFloat(bf.getShort());
            chrCap = ComBase.changeShortToInt(bf.getShort());
            chrTime = ComBase.changeShortToInt(bf.getShort());
 
            bakeup1 = ComBase.changeShortToInt(bf.getShort());
            bakeup2 = ComBase.changeShortToInt(bf.getShort());
            bakeup3 = ComBase.changeShortToInt(bf.getShort());
            bakeup4 = ComBase.changeShortToInt(bf.getShort());
            bakeup5 = ComBase.changeShortToInt(bf.getShort());
            bakeup6 = ComBase.changeShortToInt(bf.getShort());
            bakeup7 = ComBase.changeShortToInt(bf.getShort());
            bakeup8 = ComBase.changeShortToInt(bf.getShort());
            bakeup9 = ComBase.changeShortToInt(bf.getShort());
            bakeup10 = ComBase.changeShortToInt(bf.getShort());
 
            CRC = ComBase.changeShortToInt(bf.getShort());
            
            //System.out.println(this);
            bf.compact();
            return true;
        }
 
        @Override
        public String toString() {
            return "SYSMonitorParam [monitorEN=" + monitorEN + ", disCurr=" + disCurr + ", disCap=" + disCap
                    + ", disTime=" + disTime + ", groupVol_LOW=" + groupVol_LOW + ", monomerVol_LOW=" + monomerVol_LOW
                    + ", monomerLowCount=" + monomerLowCount + ", battGroupCount=" + battGroupCount
                    + ", onlineVolLowAction=" + onlineVolLowAction + ", chrCurr=" + chrCurr + ", chrCap=" + chrCap
                    + ", chrTime=" + chrTime + ", bakeup1=" + bakeup1 + ", bakeup2=" + bakeup2 + ", bakeup3=" + bakeup3
                    + ", bakeup4=" + bakeup4 + ", bakeup5=" + bakeup5 + ", bakeup6=" + bakeup6 + ", bakeup7=" + bakeup7
                    + ", bakeup8=" + bakeup8 + ", bakeup9=" + bakeup9 + ", bakeup10=" + bakeup10 + ", CRC=" + CRC + "]";
        }
    }
    
    
    public class SYSMonitorState{
        public static final int BYTE_LEN = 46;
        
         public DateTime startDT;                        //启动放电的日期时间
         public DateTime stopDT;                            //终止放电的日期时间
        public TestTime     test_Time;                        //已测试时间(HMS)
        public int testState;                              //监测状态(MONITOR_STATE_)    //0:停止监测 1:放电监测 2:充电监测
        public int testType;                            //测试类型 0xFA:放电  0xFB:充电
        public int testGroupCount;                      //unused
        public int saveDataEN;                          //保存数据标识
        public int backUp;                              //reserved
        public int restTest_Time[] = new int[4];           //剩余容量可放电时间(HMS)
        public double testCap[] = new double[4];        //每组已测试容量 单位AH 显示一位小数
        public double groupCap[] = new double[4];        //每组实际容量 单位AH 显示一位小数
        public double groupRestCap[] = new double[4];    //每组剩余容量 单位AH 显示一位小数
 
        public int CRC;                                    //未使用
 
        public SYSMonitorState() {
            startDT = new DateTime();                        //启动放电的日期时间
             stopDT = new DateTime();                            //终止放电的日期时间
            test_Time = new TestTime();                        //已测试时间(HMS)
        }
        
        public boolean putByteBuffer(ByteBuffer bf) {
            //System.err.println("bf.remaining():"+bf.remaining());
            if(bf.remaining() < BYTE_LEN) {
                return false;
            }
            bf.position(0);
            
             startDT.setDateTime(bf);                            //启动放电的日期时间
             stopDT.setDateTime(bf);                                //终止放电的日期时间
            test_Time.setTestTime(bf);                            //已测试时间(HMS)
            testState = ComBase.changeByteToInt(bf.get());         //监测状态(MONITOR_STATE_)    //0:停止监测 1:放电监测 2:充电监测
            testType = ComBase.changeByteToInt(bf.get());       //测试类型 0xFA:放电  0xFB:充电
            testGroupCount = ComBase.changeByteToInt(bf.get()); //unused
            saveDataEN = ComBase.changeByteToInt(bf.get());        //保存数据标识
            backUp = ComBase.changeByteToInt(bf.get());                              //reserved
            for(int i=0;i<restTest_Time.length;i++) {
                restTest_Time[i] = bf.getInt();                    //剩余容量可放电时间(HMS)
            }
            for(int i=0;i<testCap.length;i++) {
                testCap[i] = bf.getDouble();                    //每组已测试容量 单位AH 显示一位小数
                
            }
            
            for(int i=0;i<groupCap.length;i++) {
                groupCap[i] = bf.getDouble();                    //每组实际容量 单位AH 显示一位小数
            }
            
            for(int i=0;i<groupRestCap.length;i++) {
                groupRestCap[i] = bf.getDouble();                //每组剩余容量 单位AH 显示一位小数
            }
            
            CRC = ComBase.changeShortToInt(bf.getShort());
            //System.out.println(this);
            return true;
        }
 
        @Override
        public String toString() {
            return "SYSMonitorState [startDT=" + startDT + ", stopDT=" + stopDT + ", test_Time=" + test_Time
                    + ", testState=" + testState + ", testType=" + testType + ", testGroupCount=" + testGroupCount
                    + ", saveDataEN=" + saveDataEN + ", backUp=" + backUp + ", restTest_Time="
                    + Arrays.toString(restTest_Time) + ", testCap=" + Arrays.toString(testCap) + ", groupCap="
                    + Arrays.toString(groupCap) + ", groupRestCap=" + Arrays.toString(groupRestCap) + ", CRC=" + CRC
                    + "]";
        }
    }
    
    /**
     * 测试数据数据头
     * @author LiJun
     *
     */
    public class MonitorDataInfo{
        public static final int BYTE_LEN = BattParam.BYTE_LEN + SYSMonitorParam.BYTE_LEN + SYSMonitorState.BYTE_LEN;
        
        public BattParam battparam;                                //电池参数
        public SYSMonitorParam monitorparam;                    //未使用
        public SYSMonitorState monitorstate;
        
        public MonitorDataInfo() {
            battparam = new BattParam();
            monitorparam = new SYSMonitorParam();
            monitorstate = new SYSMonitorState();
        }
        
        public boolean checkDataHead(FileInputStream fis)
        {
            boolean check_ok = false;
            boolean file_end = false;
            byte[] tag = new byte[1];        
            try {
                while(true)
                {
                    int n = 0;
                    for(n=0; n<4; n++)
                    {
                        if(1 != fis.read(tag, 0, 1))
                        {
                            file_end = true;
                            break;
                        }
                        if((0xFA != (tag[0]&0xFF)) && (0xFB != (tag[0]&0xFF)))
                        {
                            break;
                        }
                    }
                    
                    if(n >= 4)
                    {
                        if(tag[0] == 0xFA) {
                            file_type = FILE_TYPE_MCP;
                        }
                        if(tag[0] == 0xFB) {
                            file_type = FILE_TYPE_MCH;
                        }
                        check_ok = true;
                        break;
                    }
                    if(true == file_end)
                    {
                        break;
                    }
                }
            } catch (IOException e) {
                //e.printStackTrace();
            }        
            return check_ok;
        }
 
        public boolean setHeadData(byte[] buf) {
            boolean flag = false;
            if(buf.length < BYTE_LEN) {
                return flag;
            }
            ByteBuffer bf = ByteBuffer.allocate(buf.length);
            bf.order(ByteOrder.LITTLE_ENDIAN);
            bf.position(0);
            bf.put(buf);
            bf.flip();
            //System.out.println("bf len:"+bf.remaining());
            flag = battparam.putByteBuffer(bf);
            //System.out.println(battparam);
            bf.position(0);
            //System.out.println("bf len:"+bf.remaining());
            flag &= monitorparam.putByteBuffer(bf);
            bf.position(0);
            flag &= monitorstate.putByteBuffer(bf);
            
            return flag;
        }
    }
    public class DateTime{
        private static final int BYTE_LEN = 6;
        public int year;
        public int month;
        public int day;
        public int hour;
        public int minute;
        public int second;
        
        public Date time;
        
        public DateTime() {
        }
        
        public void setDateTime(ByteBuffer bf) {
            if(bf.remaining()< BYTE_LEN) {
                return;
            }
            this.year = ComBase.changeByteToInt(bf.get());
            this.month = ComBase.changeByteToInt(bf.get());
            this.day = ComBase.changeByteToInt(bf.get());
            this.hour = ComBase.changeByteToInt(bf.get());
            this.minute = ComBase.changeByteToInt(bf.get());
            this.second = ComBase.changeByteToInt(bf.get());
            
            time = getFBODateTime();
            //System.out.println(year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second);
        }
        
        public Date getFBODateTime() {
            Calendar c = Calendar.getInstance();
            c.set(2000+year, month, day, hour, minute, second);
            return c.getTime();
            //return Com.get_DT_FromStr(year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second, Com.DTF_YMDhms);
        }
    }
    
    public static void main(String[] args) {
        TestDataInfo info = new TestDataInfo();
        info.readFileData("D:\\桌面文件备份\\公司各种设备资料\\FBS存储文件解析/M2021-06-22 13.08.40.MCP");
        //info.readFileData("D:\\桌面文件备份\\公司各种设备资料\\FBS存储文件解析/M2021-06-22 13.12.45.MCH");
        //info.readFileData("D:\\桌面文件备份\\公司各种设备资料\\FBS存储文件解析/M2021-08-13 09.40.06.MCP");
        
    }
}