826220679@qq.com
2023-07-22 b39bd80a7fd5b88dd1d0e8b6540cae9c035a6b73
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
package baowen;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import frame.Index1;
import publicclass.JugeNumber;
 
 
public class Dell_AACC {
    static String HC_header;
    static String week;
    static String second;
    static String lat;
    static String lon;
    static String alt;
    static String undulation;
    static String ve;
    static String vn;
    static String vu;
    static String pitch;
    static String roll;
    static String yaw;
    static String std_lat;
    static String std_lon;
    static String std_alt;
    static String std_ve;
    static String std_vn;
    static String std_vu;
    static String std_pitch;
    static String std_roll;
    static String std_yaw;
    static String vgyro_x;
    static String vgyro_y;
    static String vgyro_z;
    static String vacccar_x;
    static String vacccar_y;
    static String vacccar_z;
    static String speed;
    static String heading;
    static String heading2;
    static String stat;
    static String age;
    static String ns;
    static String ns2;
    static String leaps;
    static String hdop;
    static String warning;
    static String sensor_used;
    static String vacc_x;
    static String vacc_y;
    static String vacc_z;
    static String TimeValid;
    static String receiver;
    static String CRC32;
    static int lenth;
    static String mess;
    private static String hexStr =  "0123456789ABCDEF";  
 
    public static void dell_AACC(String message,String ip,int port) {
        String[] gnggns=message.split("AACC");
        int size=gnggns.length;
        if(size>2) {                
            for(int i=0;i<size;i++) {
                if(gnggns[i].length()>80) {
                    jiexi_AACC("AACC"+gnggns[i],ip,port);
                }
            }
        }else {
            if(message.length()>80 && size==2) {
                jiexi_AACC("AACC"+gnggns[1],ip,port);
            }                
        }
    }
 
    public static void jiexi_AACC(String infom,String ip,int port) {        
        String[] hex=hex(infom);//ԭʼÊý¾Ý    
        String lenth0=hex[5]+hex[4];
        String lat0=hex[39]+hex[38]+hex[37]+hex[36]+hex[35]+hex[34]+hex[33]+hex[32];
        String lon0=hex[47]+hex[46]+hex[45]+hex[44]+hex[43]+hex[42]+hex[41]+hex[40];        
        String alt0=hex[51]+hex[50]+hex[49]+hex[48];
        String pitch0=hex[71]+hex[70]+hex[69]+hex[68];
        String roll0=hex[75]+hex[74]+hex[73]+hex[72];
        String yaw0=hex[79]+hex[78]+hex[77]+hex[76];
        String stat0=hex[153]+hex[152];
        String age0=hex[157]+hex[156]+hex[155]+hex[154];
        String ns0=hex[159]+hex[158];
//        String ns20=hex[161]+hex[160];
        lenth=decodeHEX(lenth0);        
        lat=doubelttohex(lat0);        
        lon=doubelttohex(lon0);        
        alt=hextofloat(alt0);
        pitch=hextofloat(pitch0);
        roll=hextofloat(roll0);
        yaw=hextofloat(yaw0);
        stat=String.valueOf(decodeHEX(stat0));
        age=hextofloat(age0);
        ns=String.valueOf(decodeHEX(ns0));        
        String stats=stat+":"+get_stat()+"-"+get_gnss_stat();
 
        if(Index1.isShoware() ) {            
            if(Index1.getXieyi_type().equals("2")) {
                mess="¾­¶È:"+lat+",γ¶È:"+lon+",¸ß³Ì:"+alt+",¸©Ñö½Ç:"+pitch
                        +",ºá¹ö½Ç:"+roll+",º½Ïò½Ç:"+yaw+",״̬:"+stats+",²î·ÖÁäÆÚ:"+age+",ÎÀÐÇ¿ÅÊý:"+ns;
                Index1.ara_show(mess);
            }else if(Index1.getXieyi_type().equals("3")) {
                mess="¾­¶È:"+lat0+",γ¶È:"+lon0+",¸ß³Ì:"+alt0+",¸©Ñö½Ç:"+pitch0
                        +",ºá¹ö½Ç:"+roll0+",º½Ïò½Ç:"+yaw0+",״̬:"+stat0+",²î·ÖÁäÆÚ:"+age0+",ÎÀÐÇ¿ÅÊý:"+ns0;
                Index1.ara_show(mess);
            }else if(Index1.getXieyi_type().equals("5")) {
                mess="$GNGGAD,"+lat+","+lon;
                Index1.ara_show_no_time(mess);
            }
            
        }        
 
    }
 
 
    /**16½øÖÆ×ªÎª10½øÖÆ*/
    public static int decodeHEX(String hexs){
        String hex=hexs.trim();
        boolean a=JugeNumber.isLetterDigit(hex);
        int numb=0;
        if(a) {
            BigInteger bigint=new BigInteger(hex,16);
            numb=bigint.intValue();
        }else {
            //ShowMessage.zidingyi("16½øÖÆ×ª10½øÖƳö´í,ÊÕµ½:"+hex);
        }
        return numb;
 
    }
 
 
    public static String[] hex(String message) {
        int size=message.length()/2;        
        String[] hex=new String[size];
        for(int i=0;i<size;i++) {
            hex[i]=message.substring(i*2, 2+i*2);
        }
 
        return hex;
    }
 
 
    /**16½øÖÆ×ªÎªdouble*/
    public static String doubelttohex(String hexString) {
        long longValue = Long.parseLong(hexString, 16);
        longValue = Long.parseUnsignedLong(hexString, 16);
        double doubleValue = Double.longBitsToDouble(longValue);
        byte[] bytes = hexStringToByteArray(hexString);
        doubleValue = ByteBuffer.wrap(bytes).getDouble();
        String a1=String.format("%.8f",doubleValue);
        return a1;
    }
 
    public static byte[] hexStringToByteArray(String s) {
        int len = s.length();
        byte[] data = new byte[len / 2];
        for (int i = 0; i < len; i += 2) {
            data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i + 1), 16));
        }
        return data;
    }
 
    /**16½øÖÆ×ªÎªfloat*/
    public static String hextofloat(String hex) {
        Float f = Float.intBitsToFloat(new BigInteger(hex, 16).intValue());
        String a1=String.format("%.4f",f);        
        return a1;
    }
 
    /** 
     *  
     * @param str 
     * @return ×ª»»Îª¶þ½øÖÆ×Ö·û´® 
     */  
    public static String bytes2BinaryStr(byte[] bArray){  
 
        String outStr = "";  
        int pos = 0;  
        for(byte b:bArray){  
            //¸ßËÄλ  
            pos = (b&0xF0)>>4;  
            outStr+=binaryArray[pos];  
            //µÍËÄλ  
            pos=b&0x0F;  
            outStr+=binaryArray[pos];  
        }  
        return outStr;  
 
    }
 
    private static String[] binaryArray =   
        {"0000","0001","0010","0011",  
                "0100","0101","0110","0111",  
                "1000","1001","1010","1011",  
                "1100","1101","1110","1111"
        }; 
 
    /** 
     *  
     * @param hexString 
     * @return ½«Ê®Áù½øÖÆ×ª»»Îª×Ö½ÚÊý×é 
     */  
    public static byte[] HexStringToBinary(String hexString){  
        //hexStringµÄ³¤¶È¶Ô2È¡Õû£¬×÷ΪbytesµÄ³¤¶È  
        int len = hexString.length()/2;  
        byte[] bytes = new byte[len];  
        byte high = 0;//×Ö½Ú¸ßËÄλ  
        byte low = 0;//×Ö½ÚµÍËÄλ  
 
        for(int i=0;i<len;i++){  
            //ÓÒÒÆËÄλµÃµ½¸ßλ  
            high = (byte)((hexStr.indexOf(hexString.charAt(2*i)))<<4);  
            low = (byte)hexStr.indexOf(hexString.charAt(2*i+1));  
            bytes[i] = (byte) (high|low);//¸ßµØÎ»×ö»òÔËËã  
        }  
        return bytes;  
    }  
 
    /**»ñÈ¡É豸µÄ״̬
     * 0£º³õʼ»¯;
     * 1£ºÎÀµ¼Ä£Ê½;
     * 2£º×éºÏµ¼º½Ä£Ê½;
     * 3£º´¿¹ßµ¼Ä£Ê½
     */
    public static String get_stat() {
        String hex=String.valueOf(stat);
        String sta1="³õʼ»¯";
        String value=hex.substring(1,2);
        switch(value){
        case "1":
            sta1="ÎÀµ¼Ä£Ê½";
            break; 
        case "2":
            sta1="×éºÏµ¼º½Ä£Ê½";
            break; 
        case "3":
            sta1="´¿¹ßµ¼Ä£Ê½";
            break; 
 
        }
        return sta1;
 
    }
 
    /** GNSS״̬£º
     * 0£º²»¶¨Î»²»¶¨Ïò£»
     * 1£ºµ¥µã¶¨Î»¶¨Ïò£»
     * 2£ºÎ±¾à²î·Ö¶¨Î»¶¨Ïò£»
     * 3£º×éºÏÍÆË㣻
     * 4£ºRTK Îȶ¨½â¶¨Î»¶¨Ïò£»
     * 5£ºRTK¸¡µã½â¶¨Î»¶¨Ïò£»
     * 6£ºµ¥µã¶¨Î»²»¶¨Ïò£»
     * 7£ºÎ±¾à²î·Ö¶¨Î»²»¶¨Ïò£»
     * 8£ºRTKÎȶ¨½â¶¨Î»²»¶¨Ïò£»
     * 9£ºRTK¸¡µã½â¶¨Î»²»¶¨Ïò*/
    public static String get_gnss_stat() {
        String hex=String.valueOf(stat);
        String sta1="²»¶¨Î»²»¶¨Ïò";
        String value=hex.substring(0,1);
        switch(value){
        case "1":
            sta1="µ¥µã¶¨Î»¶¨Ïò";
            break; 
        case "2":
            sta1="α¾à²î·Ö¶¨Î»¶¨Ïò";
            break; 
        case "3":
            sta1="×éºÏÍÆËã";
            break; 
        case "4":
            sta1="RTKÎȶ¨½â¶¨Î»¶¨Ïò";
            break;
        case "5":
            sta1="RTK¸¡µã½â¶¨Î»¶¨Ïò";
            break;
        case "6":
            sta1="µ¥µã¶¨Î»²»¶¨Ïò";
            break;
        case "7":
            sta1="α¾à²î·Ö¶¨Î»²»¶¨Ïò";
            break;
        case "8":
            sta1="RTKÎȶ¨½â¶¨Î»²»¶¨Ïò";
            break;
        case "9":
            sta1="RTK¸¡µã½â¶¨Î»²»¶¨Ïò";
            break;
 
        }
        return sta1;
    }
}