mxpopstar
2022-05-03 e75ef5f04f61aa5fbd89fd5c413dcee1819b7a91
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
package com.dev.bts.data;
 
public class FBS9100_ComBase 
{
    //----------------------------------------------------------------------------
    public static final int     BattGroupCountMax                =    4;
    public static final int     MonomerCountMax                    =    480;
    //----------------------------------------------------------------------------
    public static final int     BTS_DCDC_CountMax                =    8;
    //----------------------------------------------------------------------------
    public static final int     CMD_NULL                        =    0x00;
    //----------------------------------------------------------------------------
    //------------ ÖØÆôFBS9100É豸 ------------------------------------------------
    public static final int     CMD_ResetSystemAck                =     0x0F;
    public static final int     CMD_ResetSystem                    =     0x10;
    //------------ Éý¼¶FBS9100Èí¼þ ------------------------------------------------
    public static final int     CMD_SystemUpdate                =    0x11;
    public static final int     CMD_SystemUpdateAck                =    0x12;
    //----------------------------------------------------------------------------
    //------------ ¶ÁÈ¡É豸°æ±¾ºÅ¡¢ÊµÊ±ÈÎÎñÁбíµÈ ----------------------------------
    public static final int     CMD_GetDeviceInf                =    0x15;
    public static final int     CMD_GetDeviceTaskInfAck            =    0x16;
    public static final int     CMD_GetDeviceTaskInf            =    0x17;
    public static final int        CMD_GetSyslogFileLen            =    0x18;
    public static final int        CMD_GetSyslogFileStr            =    0x19;
    public static final int        CMD_ClearSyslogFile                =    0x1A;
 
    public static final int      CMD_Connect                     =    0x20;
    public static final int      CMD_GetState                     =    0x22;
    
    //public static final int     CMD_GETDEVID                  =   0x23;        //»ñÈ¡É豸id
    
    //----------------------------------------------------------------------------
    //------------ Æô¶¯·Åµç²âÊԺͶÁÈ¡ÉèÖòÎÊý,¶ÁÈ¡·Åµç²âÊÔ״̬----------------------
    public static final int     CMD_StartDischarge                =    0x25;
    public static final int     CMD_StartDischargeAck            =    0x26;
    public static final int     CMD_SetDischargeParmAck            =    0x27;
    public static final int     CMD_SetDischargeParm            =    0x28;
    public static final int     CMD_GetDischargeParm            =    0x29;
    public static final int     CMD_GetDischargeParmAck            =    0x30;
    public static final int     CMD_GetDischargeState            =    0x31;
    //----------------------------------------------------------------------------
    //------------ Æô¶¯ÄÚ×è²âÊԺͶÁÈ¡ÄÚ×è²âÊÔ״̬-----------------------------------
    public static final int     CMD_StartResDischarge            =    0x32;
    public static final int        CMD_GetResTestState                =    0x34;
    //-----------------------------------------------------------------------------
    //------------ ¶ÁÈ¡ºÍÉèÖÃµç³Ø²ÎÊý-----------------------------------------------
    public static final int        CMD_GetBattParam                =    0x36;
    public static final int        CMD_SetBattParam                =    0x37;
    public static final int        CMD_GetBattParamACK                =    0x38;
    public static final int        CMD_SetBattParamACK                =    0x39;
    //----------------------------------------------------------------------------
    //------------ Æô¶¯³äµç²âÊԺͶÁÈ¡ÉèÖòÎÊý,¶ÁÈ¡³äµç²âÊÔ״̬-----------------------
    public static final int     CMD_StartCharge                    =    0x40;
    public static final int      CMD_SetChargeParm                =    0x43;
    public static final int      CMD_GetChargeParm                =    0x44;
    public static final int     CMD_GetChargeState                =    0x46;
    
    public static final int     CMD_Set_BattOFFLine                =    0x4A;
    public static final int     CMD_Set_BattONLine                =    0x4B;
    //-----------------------------------------------------------------------------
    //------------ Í£Ö¹ÈκεIJâÊÔ --------------------------------------------------
    public static final int     CMD_Start                        =    0x51;
    public static final int     CMD_StartAck                    =    0x52;
    public static final int     CMD_Stop                        =    0x53;
    public static final int     CMD_StopAck                        =    0x54;
    //----------------------------------------------------------------------------
    //------------ ¶ÁÈ¡µçѹµçÁ÷¡¢³ä·Åµç²âÊÔ¡¢ÄÚ×è²âÊÔÊý¾Ý ---------------------------
    public static final int     CMD_GetVIData                    =    0x60;
    public static final int      CMD_GetMonomerData                =    0x61;
    public static final int     CMD_GetMonomerRES                =    0x62;
    public static final int      CMD_GetMonomerCAP                =    0x63;
    public static final int      CMD_GetMonomerChargeCAP            =    0x64;
    public static final int      CMD_GetMonomerTMP                =    0x65;
    public static final int      CMD_GetMonomerJHcurr            =    0x66;
    public static final int     CMD_Get_DCDC_Data                =    0x67;
    public static final int     CMD_Get_K_D_TestData            =     0x68;
    //-----------------------------------------------------------------------------
    //------------ ÔÚÏßµçѹУ׼ ----------------------------------------------------
    public static final int     CMD_GetOnlineVolAdjParam        =    0x6A;
    public static final int     CMD_SetOnlineVolAdjParam        =    0x6B;
    //------------ ×é¶ËµçѹУ׼ ----------------------------------------------------
    public static final int     CMD_GetBattGroupVolAdjParam        =    0x6C;
    public static final int     CMD_SetBattGroupVolAdjParam        =    0x6D;
    //------------ ·ÅµçµçÁ÷У׼ ----------------------------------------------------
    public static final int     CMD_GetDischargeCurrAdjParam    =    0x6E;
    public static final int     CMD_SetDischargeCurrAdjParam    =    0x6F;
    //------------ ³äµçµçÁ÷У׼ ----------------------------------------------------
    public static final int     CMD_GetChargeCurrAdjParam        =    0x70;
    public static final int     CMD_SetChargeCurrAdjParam        =    0x71;
    //------------ µ¥ÌåÄÚ×èУ׼ ----------------------------------------------------
    public static final int     CMD_GetBattResAdjParam            =   0x72;
    public static final int     CMD_SetBattResAdjParam            =    0x73;
    //------------ µ¥ÌåµçÑ¹Æ«ÒÆ/бÂÊУ׼ --------------------------------------------
    public static final int     CMD_GetMonVolAdjParam            =    0x74;
    public static final int     CMD_SetMonVolAdjOffset            =    0x75;
    public static final int     CMD_SetMonVolAdjSlope            =    0x76;
    public static final int     CMD_ResetMonVolAdjParam            =    0x77;
    //-----------------------------------------------------------------------------
    //------------ ÉèÖÃÈÕÆÚʱ¼ä ----------------------------------------------------
    public static final int     CMD_SetDateTime                    =   0x7A;
    //------------ ¶ÁÈ¡ÉèÖÃϵͳ²ÎÊýºÍ¸æ¾¯²ÎÊý ---------------------------------------
    public static final int     CMD_GetSYSSetParamAck            =    0x7E;
    public static final int     CMD_SetSYSSetParamAck            =    0x7F;
    public static final int     CMD_GetSYSSetParam                =    0x80;
    public static final int     CMD_SetSYSSetParam                =    0x81;
    
    public static final int     CMD_GetAlarmParam                =    0x82;
    public static final int     CMD_SetAlarmParam                =    0x83;
    public static final int     CMD_GetAlarmParamAck            =    0x84;
    public static final int     CMD_SetAlarmParamAck            =    0x85;
    //------------------------------------------------------------------------------
    //------------ DFU ÃüÁî ---------------------------------------------------------
    public static final int     CMD_FBS9100_WriteDFU            =     0x86;
    public static final int     CMD_FBS9100_ReadDFU             =     0x87;
    //------------------------------------------------------------------------------
    //¶ÁÈ¡cmccµÄµçѹµçÁ÷
    public static final int     CMD_ReadCMCCVolCurr             =   0x8A;
    
    //¶ÁÈ¡GPRSÄ£¿éµÄÐźÅÖÊÁ¿
    public static final int     CMD_ReadGPRSCSQ                 =   0x91;
    public static final int     CMD_ReadGPRSCSQAck                 =   0x92;
    
    //------------ ²âÊÔÀàÐÍ ---------------------------------------------------------
    public static final int        TestType_NULL                    =    0x00;
    public static final int        TestType_VOL                    =    0xF9;
    public static final int        TestType_MDISCHARGE                =    0xFA;
    public static final int        TestType_MCHARGE                =    0xFB;
    public static final int        TestType_Charge                    =    0xFC;
    public static final int        TestType_CAP                    =    0xFD;    //Õý³£ºËÈݷŵç²âÊÔÀàÐÍ
    public static final int        TestType_RES                    =    0xFE;
    public static final int        TestType_Charge_HELUQI            =    0xBC;
    public static final int        TestType_CAP_HELUQI                =    0xBD;    //ÉýÑ¹Ðøº½·Åµç²âÊÔÀàÐÍ
    public static final int        TestType_SwitchDiode            =     0xD1;    //KD²âÊÔ
    //------------------------------------------------------------------------------
    //------------ µç³Ø×´Ì¬ ---------------------------------------------------------
    public static final int        BattState_Float                    =    0x00;
    public static final int        BattState_Discharge                =    0x01;
    public static final int        BattState_Charge                =    0x02;
    //------------------------------------------------------------------------------
    //------------ Êý¾ÝÀàÐÍ ---------------------------------------------------------
    public static final int        DataType_Null                    =    0x00;
    public static final int        DataType_MonVol                    =    0x01;
    public static final int        DataType_MonCap                    =    0x02;
    public static final int        DataType_MonRes                    =    0x03;
    public static final int        DataType_Temp                    =    0x04;
    public static final int        DataType_GrpVol                    =    0x05;
    public static final int        DataType_Curr                    =    0x06;
    public static final int        DataType_MonTmp                    =    0x07;
    public static final int        DataType_MonJHcurr                =    0x08;
    //------------------------------------------------------------------------------
    //------------------------------------------------------------------------------
    public static final int     BTSE_DevType_TieTa                =    0x08;
    //------------------------------------------------------------------------------
    public static final int     SYS_STATE_STOPPED                =    0x00;
    public static final int     SYS_STATE_DISCHARGING            =    0x01;
    public static final int     SYS_STATE_CHARGING                =    0x02;
    public static final int     SYS_STATE_HELUQI_DISCHARGING    =    0x03;
    //------------------------------------------------------------------------------
    //-------------------------------------------------------------------------------------------
    public static final int     ALARM_NULL                         =    0;        //ÎÞ
    public static final int     ALARM_PAUSED                    =    1;        //ÔÝÍ£
    public static final int     ALARM_DISCHARGING                =    2;        //ÕýÔڷŵç²âÊÔ
    public static final int     ALARM_DISCHARGEWAIT                =    3;        //ÕýÔڵȴý·Åµç
    public static final int     ALARM_LimitCHARGING                =    4;        //ÕýÔÚÏÞÁ÷³äµç
    public static final int     ALARM_LargeCHARGING                =    5;        //ÕýÔÚÖ±Á¬³äµç
    public static final int     ALARM_CHARGEWAIT                   =    6;        //ÕýÔڵȴý³äµç
    public static final int     ALARM_TIMESTOP                     =    7;        //·Åµçʱ¼äµ½Í£Ö¹
    public static final int     ALARM_CAPSTOP                     =    8;        //·ÅµçÈÝÁ¿µ½Í£Ö¹
    public static final int     ALARM_MVLLSTOP                     =    9;        //µ¥ÌåµçѹÏÂÏÞµ½Í£Ö¹
    public static final int     ALARM_SVLLSTOP                     =    10;        //×é¶ËµçѹÏÂÏÞµ½Í£Ö¹
    public static final int     ALARM_POWERBREAKSTOP             =    11;        //ÊеçÖжÏÍ£Ö¹
    public static final int     ALARM_FLASHUPSTOP                 =    12;        //´æ´¢Êý¾ÝÂúÍ£Ö¹
    public static final int     ALARM_TEMPHIGHSTOP               =    13;        //»úÄÚζÈÒ쳣ֹͣ
    public static final int     ALARM_CURRSTOP                    =    14;        //·ÅµçµçÁ÷¹ýÁ÷Í£Ö¹
    public static final int     ALARM_PCCOMMBREAKSTOP             =    15;        //ºǫ́ͨÐÅÖжÏÍ£Ö¹
    public static final int     ALARM_LoaderCOMMBREAKSTOP         =    16;        //¸ºÔØÄ£¿éͨÐÅÖжÏÍ£Ö¹
    public static final int     ALARM_Sel2TO1COMMBREAKSTOP         =    17;        //Ñ¡ÔñÄ£¿éͨÐÅÖжÏÍ£Ö¹
    public static final int     ALARM_LoaderPowerError             =    18;        //¸ºÔØÄ£¿é·Åµç¹ý¹¦ÂÊÍ£Ö¹
    public static final int     ALARM_Malloc_ERROR                 =    19;        //ÄÚ²¿³ÌÐòÒ쳣ֹͣ
    public static final int     ALARM_POWERRESUMESTOP_HELUQI     =    20;        //ºÏ·Æ÷·Åµç¹¦ÄÜ,Êеç»Ö¸´Í£Ö¹Éýѹ·Åµç
    public static final int     ALARM_POWERBREAKSTOP_HELUQI     =    21;        //ºÏ·Æ÷·Åµç¹¦ÄÜ,³äµç¹ý³ÌÖÐÊеçÖжÏ
    public static final int     ALARM_SVLLSTOP_HELUQI             =    22;        //ºÏ·Æ÷·Åµç¹¦ÄÜ×é¶ËµçѹÏÂÏÞ
    public static final int     ALARM_MOMTEMP_HL_STOP             =    23;        //µ¥ÌåζÈÉÏÏÞµ½Í£Ö¹
    public static final int     ALARM_ONLINEVOL_HL_STOP         =    24;        //ÔÚÏßµçѹÒì³£¸ßÍ£Ö¹
    public static final int     ALARM_XIEZHUANG_COMM_ERR_STOP    =    25;        //ЭתͨÐÅÒ쳣ֹͣ
    public static final int     ALARM_MONOMER_COMM_ERR_STOP        =    26;        //µ¥ÌåͨÐÅÒ쳣ֹͣ
    public static final int     ALARM_UNKOWN                     =    27;        //δ֪
    //-------------------------------------------------------------------------------------------
    public static byte changeIntToByte(int data)
    {
        return (byte)(data & 0xFF);
    }
    //------------------------------------------------------------------------------
    public static short changeIntToShort(int data)
    {
        return (short)(data & 0xFFFF);
    }
    //------------------------------------------------------------------------------
    public static byte changeShortToByte(short data)
    {
        return (byte)(data & 0xFF);
    }
    //------------------------------------------------------------------------------
    public static int changeByteToInt(byte data)
    {
        int tmp = data;
        return (tmp & 0xFF);
    }
    //------------------------------------------------------------------------------
    public static int changeShortToInt(short data)
    {
        int tmp = data;
        return (tmp & 0xFFFF);
    }
    //------------------------------------------------------------------------------
    public static double changeShortToDouble(short data)
    {
        int tmp = data & 0xFFFF;
        return (double)(tmp);
    }
    //------------------------------------------------------------------------------
    public static short changeDoubleToShort(double data)
    {
        int tmp = (int)data;
        return (short)(tmp & 0xFFFF);
    }
    //------------------------------------------------------------------------------
    public static String changeIntToHH_MM(int preset_distimelong)
    {
        return String.format("%02d:%02d", preset_distimelong/60, preset_distimelong%60);
    }
    //------------------------------------------------------------------------------
    public static int changeHH_MMToInt(String str)
    {
        int data = 0;
        data = Integer.valueOf(str.substring(0, str.indexOf(":")));
        data *= 60;
        data += Integer.valueOf(str.substring(str.indexOf(":")+1, str.length()));
        
        return data;
    }
    //------------------------------------------------------------------------------
    //------------------------------------------------------------------------------
    public static double GetFDCurrent(double stdcap, int hourrate)
    {
        double res = 0.055;
        switch(hourrate)
        {
            case 1: res = 0.514; break;
            case 2: res = 0.306; break;
            case 3: res = 0.250; break;
            case 4: res = 0.200; break;
            case 5: res = 0.166; break;
            case 6: res = 0.146; break;
            case 7: res = 0.131; break;
            case 8: res = 0.118; break;
            case 9: res = 0.108; break;
            case 10: res = 0.100; break;
            case 20: res = 0.055; break;
            default: res = 0.055; break;
        }
        
        return (stdcap * res);
    }
    //------------------------------------------------------------------------------
    //------------------------------------------------------------------------------
    public static int GetHourRate(int stdah, int current)
    {
        int index = 0;
        int value[]={514, 306, 250, 200, 166, 146, 131, 118, 108, 100, 55};
        int res;
        res = (current*100)/(stdah/10);
        if(res>=514) return 1;
        else if(res<=55) return 20;
        else
        {
            for(index=0; index<10; index++)
            {
                if((res<=value[index]) && (res>value[index+1]))    break;
                else continue;
            }
            if((value[index]-res) < (res-value[index+1]))
            {
                return (index+1);
            }
            else
            {
                if(index+2 > 10) return (20);
                else return (index+2);
            }
        }  
    }
    //------------------------------------------------------------------------------
    //------------------------------------------------------------------------------
    public static double N_TO_10H(int n_H)
    {
        switch(n_H)
        {
            case  1 : return(1/0.55);
            case  2 : return(1/0.61);
            case  3 : return(1/0.75);
            case  4 : return(1/0.79);
            case  5 : return(1/0.833);
            case  6 : return(1/0.876);
            case  7 : return(1/0.917);
            case  8 : return(1/0.944);
            case  9 : return(1/0.974);
            case  10: return(1/1);
            case  20: return(1/1.1);
        }
        return 1.0;
    }
    //-------------------------------------------------------------------------------
    /*
    //-------------------------------------------------------------------------------
    double GetMonomerCap(double STDAH, int HourRate, double SumAH, double MaxMonomerVol,
                        double MonomerVol, double MonomerVolType, int CapType)
    {
        if(MaxMonomerVol - MonomerVolType*0.9 == 0)
            return 0;
 
        if(SumAH < 0)
            SumAH *= (-1);
 
        double tmp_cap;
        tmp_cap = MonomerVol - MonomerVolType * 0.9;
        tmp_cap *= (STDAH - SumAH * N_TO_10H(HourRate));
        tmp_cap = tmp_cap/(MaxMonomerVol - MonomerVolType*0.9);
        if(tmp_cap < 0)
            tmp_cap = 0;
 
        if(CapType == CapType_Rest)
            return tmp_cap;
        else if(CapType == CapType_Sum)
            return (tmp_cap + SumAH * N_TO_10H(HourRate));
        else
            return ((tmp_cap + SumAH * N_TO_10H(HourRate))*100 / STDAH);
    }
    //----------------------------------------------------------------------------------
    */
}
 
/***************************************************************************************
******************************* end of file (FBS_ComBase)*******************************
***************************************************************************************/