From 674747e1ccde2707bf4d4c02d52b7ef5af5a97dc Mon Sep 17 00:00:00 2001
From: 826220679@qq.com <826220679@qq.com>
Date: 星期六, 22 七月 2023 14:25:36 +0800
Subject: [PATCH] 修改了解析

---
 src/baowen/Dell_AACC.java |  171 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 171 insertions(+), 0 deletions(-)

diff --git a/src/baowen/Dell_AACC.java b/src/baowen/Dell_AACC.java
new file mode 100644
index 0000000..50a5afc
--- /dev/null
+++ b/src/baowen/Dell_AACC.java
@@ -0,0 +1,171 @@
+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 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;
+
+	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) {				
+				for(int i=0;i<size;i++) {
+					if(gnggns[i].length()>5) {
+						jiexi_AACC("AACC"+gnggns[i],ip,port);
+					}
+				}
+			}else {
+				jiexi_AACC(message,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[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));
+
+		if(Index1.isShoware() ) {			
+			if(Index1.getXieyi_type().equals("2")) {
+				mess=time+",经度:"+lat+",纬度:"+lon+",高程:"+alt+",俯仰角:"+pitch
+						+",横滚角:"+roll+",航向角:"+yaw+",状态:"+stat+",差分龄期:"+age+",卫星颗数:"+ns;
+			}else if(Index1.getXieyi_type().equals("1")) {
+				mess=time+","+infom;
+			}else if(Index1.getXieyi_type().equals("3")) {
+				mess=time+",经度:"+lat0+",纬度:"+lon0+",高程:"+alt0+",俯仰角:"+pitch0
+						+",横滚角:"+roll0+",航向角:"+yaw0+",状态:"+stat0+",差分龄期:"+age0+",卫星颗数:"+ns0;
+			}
+			Index1.ara_show(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;
+
+	}
+
+}

--
Gitblit v1.9.3