| | |
| | | package baowen; |
| | | import java.math.BigInteger; |
| | | import java.nio.ByteBuffer; |
| | | |
| | | import frame.Index1; |
| | | import publicclass.GetNowTime; |
| | | import publicclass.JugeNumber; |
| | | |
| | | |
| | | public class Dell_AACC { |
| | | static String time; |
| | | static String HC_header; |
| | | static String week; |
| | | static String second; |
| | |
| | | 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) { |
| | | if(message.startsWith("AACC")) { |
| | | time=GetNowTime.gethm(); |
| | | String[] gnggns=message.split("AACC"); |
| | | int size=gnggns.length; |
| | | if(size>2) { |
| | |
| | | yaw=hextofloat(yaw0); |
| | | stat=String.valueOf(decodeHEX(stat0)); |
| | | age=hextofloat(age0); |
| | | ns=String.valueOf(decodeHEX(ns0)); |
| | | ns=String.valueOf(decodeHEX(ns0)); |
| | | String stats=stat+":"+get_stat()+"-"+get_gnss_stat(); |
| | | |
| | | if(Index1.isShoware() ) { |
| | | if(Index1.getXieyi_type().equals("2")) { |
| | | mess=time+",经度:"+lat+",纬度:"+lon+",高程:"+alt+",俯仰角:"+pitch |
| | | +",横滚角:"+roll+",航向角:"+yaw+",状态:"+stat+",差分龄期:"+age+",卫星颗数:"+ns; |
| | | mess="经度:"+lat+",纬度:"+lon+",高程:"+alt+",俯仰角:"+pitch |
| | | +",横滚角:"+roll+",航向角:"+yaw+",状态:"+stats+",差分龄期:"+age+",卫星颗数:"+ns; |
| | | }else if(Index1.getXieyi_type().equals("1")) { |
| | | mess=time+","+infom; |
| | | mess=infom; |
| | | }else if(Index1.getXieyi_type().equals("3")) { |
| | | mess=time+",经度:"+lat0+",纬度:"+lon0+",高程:"+alt0+",俯仰角:"+pitch0 |
| | | mess="经度:"+lat0+",纬度:"+lon0+",高程:"+alt0+",俯仰角:"+pitch0 |
| | | +",横滚角:"+roll0+",航向角:"+yaw0+",状态:"+stat0+",差分龄期:"+age0+",卫星颗数:"+ns0; |
| | | }else if(Index1.getXieyi_type().equals("5")) { |
| | | mess="$GNGGAD,"+lat+","+lon; |
| | | } |
| | | Index1.ara_show(mess); |
| | | } |
| | |
| | | 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; |
| | | } |
| | | } |