lxw
2020-07-11 9db52f2f2dd3665fe9da1ae5657e0167c3a34d40
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
package com.fgkj.fbo;
 
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.GregorianCalendar;
 
public class FboDataInf {
    public FboDateTime TestStartTime = new FboDateTime();        //放电开始的时间
    public int Device;                      //仪表类型
    public int DataVersion;                //数据版本
    public int DataType;                   //数据类型;0xFD表示放电,0xFC表示充电
    public int HourRate;                   //小时率
    public int SaveInterval;               //采集间隔
    public int MonomerVol;                 //单体电压类型
    public int  STDCap;                   //标称容量
    public float  TestCur;              //测试电流
    public float  MVLLimit;             //单体下限
    public float  SumVLLimit;           //组端下限
    public int  BattSum;                  //单体数量
    public int  BattGroup;                //电池组数
    public float  MVLLimitCount;        //单体下限个数
    
    public FboTestTime TestTimeLong = new FboTestTime();               //测试时长
    public int StopType;                       //结束方式
    public int BlockSum;                      //保存数据的总块数
    public int StandBy;                          //保留备用
    public int[] SMaxIndex = new int[4];       //最高单体索引
    public int[] SMinIndex = new int[4];       //最低单体索引
    public float[]  SMaxVol = new float[4]; //最高单体
    public float[]  SMinVol = new float[4]; //最低单体
    public float  TestCap;                    //测试容量
    
    public void setDataInf(byte[] inf_data)
    {
        ByteBuffer bf = ByteBuffer.allocate(2048);
        bf.order(ByteOrder.LITTLE_ENDIAN);
        bf.put(inf_data);
        bf.position(0);
        
        TestStartTime.year = (int) (bf.get()&0xFF);
        TestStartTime.month = (int) (bf.get()&0xFF)-1;
        //System.out.println(TestStartTime.month+"  setDataInf(byte[] inf_data)");
        TestStartTime.day = (int) (bf.get()&0xFF);
        TestStartTime.hour = (int) (bf.get()&0xFF);
        TestStartTime.minute = (int) (bf.get()&0xFF);
        TestStartTime.second = (int) (bf.get()&0xFF);
        
        Device = (int) (bf.get()&0xFF);
        DataVersion = (int) (bf.get()&0xFF);                    //数据版本
        DataType = (int) (bf.get()&0xFF);                       //数据类型;0xFD表示放电,0xFC表示充电
        HourRate = (int) (bf.get()&0xFF);                       //小时率
        SaveInterval = (int) (bf.get()&0xFF);                   //采集间隔
        MonomerVol = (int) (bf.get()&0xFF);                     //单体电压类型
        STDCap = (int) (bf.getShort()&0xFFFF);                   //标称容量
        TestCur = (float) (bf.getShort()&0xFFFF);                  //测试电流
        MVLLimit = ((float) (bf.getShort()&0xFFFF)) / 1000;     //单体下限
        SumVLLimit = ((float) (bf.getShort()&0xFFFF)) / 10;       //组端下限
        BattSum = (int) (bf.getShort()&0xFFFF);                 //单体数量
        BattGroup = (int) (bf.getShort()&0xFFFF);               //电池组数
        MVLLimitCount = (int) (bf.getShort()&0xFFFF);            //单体下限个数
        
        TestTimeLong.hour = (int) (bf.get()&0xFF);
        TestTimeLong.minute = (int) (bf.get()&0xFF);
        TestTimeLong.second = (int) (bf.get()&0xFF);
        StopType = (int) (bf.get()&0xFF);
        BlockSum = (int) (bf.get()&0xFF);
        StandBy = (int) (bf.get()&0xFF);
        for(int n=0; n<4; n++)
        {
            SMaxIndex[n] = (int) (bf.getShort()&0xFFFF);
        }
        for(int n=0; n<4; n++)
        {
            SMinIndex[n] = (int) (bf.getShort()&0xFFFF);
        }
        for(int n=0; n<4; n++)
        {
            SMaxVol[n] = ((float) (bf.getShort()&0xFFFF)) / 1000;
        }
        for(int n=0; n<4; n++)
        {
            SMinVol[n] = ((float) (bf.getShort()&0xFFFF)) / 1000;
        }
        
        TestCap = (float) (bf.getShort()&0xFFFF);
    }
    
    public void setDataInf(IdcDataInf d_inf)
    {
        GregorianCalendar gc = (GregorianCalendar) GregorianCalendar.getInstance();
        gc.setTime(d_inf.m_TestTime);
        
        TestStartTime.year = gc.get(GregorianCalendar.YEAR);
        TestStartTime.month = gc.get(GregorianCalendar.MONTH)-1;
        //System.out.println(TestStartTime.month+"  IdcDataInf d_inf ");
        TestStartTime.day = gc.get(GregorianCalendar.DATE);
        TestStartTime.hour = gc.get(GregorianCalendar.HOUR);
        TestStartTime.minute = gc.get(GregorianCalendar.MINUTE);
        TestStartTime.second = gc.get(GregorianCalendar.SECOND);
        
        Device = IdcDataInf.DevType_Idc;
        DataVersion = 0;                                        //数据版本
        DataType = d_inf.m_TestType;                               //数据类型;0xFD表示放电,0xFC表示充电
        HourRate = d_inf.m_HourRate;                               //小时率
        SaveInterval = 0;                                       //采集间隔
        MonomerVol = (int) d_inf.m_MonomerVol;                     //单体电压类型
        STDCap = d_inf.m_STDAH;                                   //标称容量
        TestCur = 0;                                              //测试电流
        MVLLimit = d_inf.m_MonomerVolLL;                         //单体下限
        SumVLLimit = d_inf.m_SumVolLL;                           //组端下限
        BattSum = d_inf.m_EachBattSum * d_inf.m_BattGroup;         //单体数量
        BattGroup = d_inf.m_BattGroup;                           //电池组数
        MVLLimitCount = 1;                                        //单体下限个数
        
        TestTimeLong.hour = 0;
        TestTimeLong.minute = 0;
        TestTimeLong.second = 0;
        StopType = 0;
        BlockSum = 0;
        StandBy = 0;
        for(int n=0; n<4; n++)
        {
            SMaxIndex[n] = 0;
        }
        for(int n=0; n<4; n++)
        {
            SMinIndex[n] = 0;
        }
        for(int n=0; n<4; n++)
        {
            SMaxVol[n] = 0;
        }
        for(int n=0; n<4; n++)
        {
            SMinVol[n] = 0;
        }
        
        TestCap = 0;
    }
    
    public static String getDeviceType(int type)
    {
        String dev_type = "未知";
        switch(type)                       //测试仪表类型
        {
             case 0xFB : dev_type = "FBO4815-CT"; break;
             case 0xDC : dev_type = "IDCE4815-CT";break;
             case 0x2F : dev_type = "FBO2205-CT"; break;
             case 0x2E : dev_type = "IDCE2205-CT";break;
             case 0x26 : dev_type = "FBO2206-CT"; break;
             case 0x25 : dev_type = "IDCE2206-CT";break;
             case 0x3F : dev_type = "FBO4830-CT"; break;
             case 0x3E : dev_type = "IDCE4830-CT";break;
             case 0x6F : dev_type = "FBO6003-CT"; break;
             case 0x6E : dev_type = "IDCE6003-CT";break;
             case 0x66 : dev_type = "FBO6006-CT"; break;
             case 0x67 : dev_type = "IDCE6006-CT";break;
             case 0x60 : dev_type = "FBO60010-CT";break;
             case 0x61 : dev_type = "IDCE60010-CT";break;
             case 0x0F : dev_type = "FBO1101-CT"; break;
             case 0x0E : dev_type = "IDCE1101-CT";break;
             case 0x1F : dev_type = "FBO1110-CT"; break;
             case 0x1E : dev_type = "IDCE1110-CT";break;
             case 0xF2 : dev_type = "FBI-4548CT";break;
             case 0xF3 : dev_type = "FBI-3048CT";break;
             case 0xF1 : dev_type = "FBI-3015CT";break;
             case 0xF4 : dev_type = "FBI-10480CT";break;
             case 0xF5 : dev_type = "FBI-05480CT";break;
             case 0xF6 : dev_type = "FBI-15480CT";break;
             case 0xF7 : dev_type = "FBI-20480CT";break;
             case 0xE1 : dev_type = "FBI-05240CT";break;
             case 0xE2 : dev_type = "FBI-10240CT";break;
             case 0xE3 : dev_type = "FBI-15240CT";break;
             case 0xE4 : dev_type = "FBI-20240CT";break;
             case 0x22 : dev_type = "FBO2210-CT"; break;
             case 0x21 : dev_type = "IDCE2210-CT";break;
             case 0x15 : dev_type = "FBO2415-CT"; break;
             case 0x16 : dev_type = "IDCE2415-CT";break;
             case 0x12 : dev_type = "FBO1230-CT";break;
             case 0x11 : dev_type = "IDCE1230-CT";break;
             case 0x84 : dev_type = "FBO840-CT";break;
             case 0x85 : dev_type = "IDCE840-CT";break;
             case 0x13 : dev_type = "IDC_DEV";break;
             case 0x45 : dev_type = "Ser_DEV";break;
             case 0x46 : dev_type="DevType_FBR";break;
        }
        
        return dev_type;
    }
    
    public static String getTestType(int type)
    {
        String test_type = "未知";
        switch(type)
        {
             case 0xFD : test_type = "放电"; break;
             case 0xFC : test_type = "充电"; break;
             case 0xCD : test_type = "充放电"; break;
             case CsvData.DevType_Csv : test_type = "电导"; break;
             case CsvData.DevType_FBR :    test_type = "内阻"; break;
        }
        return test_type;
    }
    
    public static String getStopType(int type)
    {
        String stop_type = "未知";
        switch(type)
        {
             case 0 : stop_type = "手动停止"; break;
             case 1 : stop_type = "放电时间到"; break;
             case 2 : stop_type = "放电容量到"; break;
             case 3 : stop_type = "单体下限到"; break;
             case 4 : stop_type = "组端下限到"; break;
             case 5 : stop_type = "市电中断"; break;
             case 6 : stop_type = "内存不足"; break;
             case 7 : stop_type = "温度异常"; break;
        }
        return stop_type;
    }
}