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 ++++++++++++++++++++++++++++++++++++++++++
src/frame/Index1.java | 45 ++++++++++-
2 files changed, 211 insertions(+), 5 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;
+
+ }
+
+}
diff --git a/src/frame/Index1.java b/src/frame/Index1.java
index d9c4866..61a72da 100644
--- a/src/frame/Index1.java
+++ b/src/frame/Index1.java
@@ -12,6 +12,9 @@
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.Vector;
+
+import javax.swing.ComboBoxModel;
+import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.JFrame;
@@ -21,7 +24,6 @@
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
-
import data_model.Dell_lixian;
import data_model.Dell_shebei;
import data_model.Dell_system;
@@ -78,10 +80,11 @@
static int num=0;
JComboBox<String> datatype=null;//数据类型
JComboBox<String> baseanchor=null;//选择基准站ID
- static String datatypeis="全部数据类型";
static boolean chushi_enhd=false;
static boolean start_jiexi=false;
static String tagid="0";
+ JComboBox<String> box=null;
+ static String xieyi_type="1";//协议类型选择
public Index1() {//构造方法
Toolkit toolkit = getToolkit();// 获得窗体工具包
@@ -125,6 +128,7 @@
//mb.add(getTcpnum());
mb.add(getUdpnum());
mb.add(getBut_shuaxin1());
+ mb.add(getBox());
jl_UDP.setBounds(x+3, y,140,30);
//jl_tcp.setBounds(x+140, y,120,30);
//getTcpnum().setBounds(x+140+120+10, y,100,30);
@@ -152,6 +156,7 @@
getBut_start().setBounds(x, y2+h1+20,100,40);
getBut_clear().setBounds(x+120, y2+h1+20,100,40);
+ getBox().setBounds(x+240, y2+h1+20,120,40);
@@ -349,10 +354,10 @@
public static void baowen_show(String message,String ip,String datatype) {
if(showare) {
if(chooseip.equals("1") || ip.equals(chooseip)) {
- if(datatypeis.equals("全部数据类型")) {//
+ if(xieyi_type.equals("1")) {//
are.append(GetNowTime.sss()+":"+message+"\n");
are.setCaretPosition(are.getText().length());
- }else if(datatype.equals(datatypeis)) {
+ }else if(datatype.equals(xieyi_type)) {
are.append(message+"\n");
are.setCaretPosition(are.getText().length());
}
@@ -533,7 +538,37 @@
}
-
+ public JComboBox<String> getBox() {
+ if(box==null) {
+ box=new JComboBox<String>();
+ String[] neixing= {"原始数据","解析后数据","HEX显示","ASCLL显示"};
+ ComboBoxModel<String > coModel=new DefaultComboBoxModel<>(neixing);//下拉列表模型
+ box.setModel(coModel);
+ box.setBackground(Color.white);
+ box.setSelectedIndex(2);
+ box.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ if(box.getSelectedIndex()==0) {
+ xieyi_type="1";
+ }else if(box.getSelectedIndex()==1) {
+ xieyi_type="2";
+ }else if(box.getSelectedIndex()==2) {
+ xieyi_type="3";
+ }else if(box.getSelectedIndex()==3) {
+ xieyi_type="4";
+ }
+
+ }
+ });
+
+ }
+ return box;
+ }
+
+ public static String getXieyi_type() {
+ return xieyi_type;
+ }
+
}
--
Gitblit v1.9.3