From 992ec9bd29cb874777aac24b1e0a5e65e32e0a80 Mon Sep 17 00:00:00 2001 From: 826220679@qq.com <826220679@qq.com> Date: 星期六, 22 七月 2023 19:32:05 +0800 Subject: [PATCH] 新增解析AACC华测数据 --- bin/frame/Index1$3.class | 0 src/baowen/Dell_AACC.java | 139 +++++++++++++++++++++++++++++++++++++++++++--- src/frame/Index1.java | 10 ++- 3 files changed, 136 insertions(+), 13 deletions(-) diff --git a/bin/frame/Index1$3.class b/bin/frame/Index1$3.class index 169b65b..0a48982 100644 --- a/bin/frame/Index1$3.class +++ b/bin/frame/Index1$3.class Binary files differ diff --git a/src/baowen/Dell_AACC.java b/src/baowen/Dell_AACC.java index 50a5afc..de59d11 100644 --- a/src/baowen/Dell_AACC.java +++ b/src/baowen/Dell_AACC.java @@ -1,14 +1,11 @@ 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; @@ -56,10 +53,10 @@ 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) { @@ -95,17 +92,20 @@ 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); } @@ -165,7 +165,128 @@ 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; + } } diff --git a/src/frame/Index1.java b/src/frame/Index1.java index 61a72da..6b2112c 100644 --- a/src/frame/Index1.java +++ b/src/frame/Index1.java @@ -84,7 +84,7 @@ static boolean start_jiexi=false; static String tagid="0"; JComboBox<String> box=null; - static String xieyi_type="1";//协议类型选择 + static String xieyi_type="2";//协议类型选择 public Index1() {//构造方法 Toolkit toolkit = getToolkit();// 获得窗体工具包 @@ -366,7 +366,7 @@ } public static void ara_show(String message) { - are.append(GetNowTime.sss()+":"+message+"\n"); + are.append(GetNowTime.sss()+","+message+"\n"); are.setCaretPosition(are.getText().length()); } @@ -541,11 +541,11 @@ public JComboBox<String> getBox() { if(box==null) { box=new JComboBox<String>(); - String[] neixing= {"原始数据","解析后数据","HEX显示","ASCLL显示"}; + String[] neixing= {"原始数据","解析后数据","HEX显示","ASCLL显示","定制格式"}; ComboBoxModel<String > coModel=new DefaultComboBoxModel<>(neixing);//下拉列表模型 box.setModel(coModel); box.setBackground(Color.white); - box.setSelectedIndex(2); + box.setSelectedIndex(1); box.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(box.getSelectedIndex()==0) { @@ -556,6 +556,8 @@ xieyi_type="3"; }else if(box.getSelectedIndex()==3) { xieyi_type="4"; + }else if(box.getSelectedIndex()==4) { + xieyi_type="5"; } } -- Gitblit v1.9.3