zsh_root
2025-12-10 8d662de2fd262b3a485f16e197cb4d0ca2a61cdf
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
package jiexi;
 
import home.SatelliteDataPanel;
 
import java.util.Vector;
 
public class Dell_GNGGA {
 
    public static Vector<Dell_GNSS> GpsDevices = new Vector<>();
 
 
    public static Dell_GNSS findGpsDeviceById(String tagid) {
        Dell_GNSS dellGnss = null;
        for (Dell_GNSS gpsDevice : GpsDevices) {
            String deviceId = gpsDevice.getDeviceId();
            if (deviceId.equals(tagid)) {
                return gpsDevice;
            }
        }
        return dellGnss;
    }
 
    public static void run(byte[] bytes,String ip,int port) {
        String receivedData = new String(bytes);
        // ´¦Àí¿ÉÄܵÄÁ¬°üÇé¿ö
        String[] messages = receivedData.split("\\$");
 
        for (String message : messages) {
            if (message.isEmpty()) continue;
            // ÖØÐÂÌí¼Ó$·ûºÅÒÔ±ãͳһ´¦Àí
            String fullMessage = "$" + message;
            processMessage(fullMessage,ip,port);
        }
    }
 
    private static void processMessage(String message,String ip,int port) {
        String[] fields = message.split(",");
 
        // ¼ì²é°üÍ·ÊÇ·ñÕýÈ·
        if (fields[0].equals("$GNGGA")) {
            // ¼ì²é×Ö¶ÎÊýÁ¿ÊÇ·ñÍêÕû
            if (fields.length != 21) {
                return;
            }
           dell_gngga(fields,ip,port);
        } else if (fields[0].equals("$XTB")) {
            if (fields.length<7){
                return;
            }
            dell_xtb(ip, port, fields);
        }
 
 
    }
 
    private static void dell_xtb(String ip, int port, String[] fields) {
        String tagid = fields[1];
        String power = fields[2];
        String version = fields[3];
        String CCID = fields[4];
        String button = fields[5];
        String rtcmFrom = fields[6];
        Dell_GNSS gpsDeviceById = findGpsDeviceById(tagid);
        if (gpsDeviceById==null){
            gpsDeviceById = new Dell_GNSS();
            gpsDeviceById.setDeviceId(tagid);
            gpsDeviceById.setPower(power);
            gpsDeviceById.setCardNumber(CCID);
            gpsDeviceById.setIpaddr(ip);
            gpsDeviceById.setPort(port);
            GpsDevices.add(gpsDeviceById);
            SatelliteDataPanel.addDataRow(gpsDeviceById);
        }else {
            gpsDeviceById.setPower(power);
            gpsDeviceById.setCardNumber(CCID);
            gpsDeviceById.setIpaddr(ip);
            gpsDeviceById.setPort(port);
        }
    }
 
    private static void dell_gngga(String[] fields,String ip,int port) {
        String upperCase = fields[1].toUpperCase();//UTCʱ¼ä
        String upperCase1 = fields[2].toUpperCase();//γ¶È
        String upperCase2 = fields[3].toUpperCase();//γ¶È°ëÇò
        String upperCase3 = fields[4].toUpperCase();//¾­¶È
        String upperCase4 = fields[5].toUpperCase();//¾­¶È°ëÇò
        String upperCase5 = fields[6].toUpperCase();//¶¨Î»ÖÊÁ¿Ö¸Ê¾
        String upperCase6 = fields[7].toUpperCase();//ÎÀÐÇÊýÁ¿
        String upperCase7 = fields[8].toUpperCase();//ˮƽ¾«¶ÈÒò×Ó
        String upperCase8 = fields[9].toUpperCase();//º£°Î¸ß¶È
        String upperCase9 = fields[10].toUpperCase();//º£°Î¸ß¶Èµ¥Î»
        String upperCase10 = fields[11].toUpperCase();//´óµØË®×¼Ãæ¸ß¶È
        String upperCase11 = fields[12].toUpperCase();//´óµØË®×¼Ãæ¸ß¶Èµ¥Î»
        String upperCase12 = fields[13].toUpperCase();//²î·Öʱ¼ä
        String upperCase13 = fields[14].toUpperCase();//УÑéºÍ
        String upperCase14 = fields[15].toUpperCase();//É豸±àºÅ
        String upperCase15 = fields[16].toUpperCase();//É豸µçÁ¿
        String upperCase16 = fields[17].toUpperCase();//ÎÀÐÇÐźÅÇ¿¶È
        String upperCase17 = fields[18].toUpperCase();//±£Áôλ1
        String upperCase18 = fields[19].toUpperCase();//±£Áôλ2
        String upperCase19 = fields[20].toUpperCase();//±£Áôλ3
 
        Dell_GNSS gpsDeviceById = findGpsDeviceById(upperCase14);
        if (gpsDeviceById == null) {
            gpsDeviceById = new Dell_GNSS();
            gpsDeviceById.setDeviceId(upperCase14);
            gpsDeviceById.setUtcTime(upperCase);
            gpsDeviceById.setLatitude(upperCase1);
            gpsDeviceById.setLongitude(upperCase3);
            gpsDeviceById.setQuality(upperCase5);
            gpsDeviceById.setSatelliteCount(upperCase6);
            gpsDeviceById.setAltitude(upperCase8 + "m");
            gpsDeviceById.setGeoidHeight(upperCase10 + "m");
            gpsDeviceById.setDiffTime(upperCase12);
            gpsDeviceById.setPower(upperCase15);
            gpsDeviceById.setIpaddr(ip);
            gpsDeviceById.setPort(port);
            GpsDevices.add(gpsDeviceById);
            SatelliteDataPanel.addDataRow(gpsDeviceById);
        } else {
            gpsDeviceById.setDeviceId(upperCase14);
            gpsDeviceById.setUtcTime(upperCase);
            gpsDeviceById.setLatitude(upperCase1);
            gpsDeviceById.setLongitude(upperCase3);
            gpsDeviceById.setQuality(upperCase5);
            gpsDeviceById.setSatelliteCount(upperCase6);
            gpsDeviceById.setAltitude(upperCase8 + "m");
            gpsDeviceById.setGeoidHeight(upperCase10 + "m");
            gpsDeviceById.setDiffTime(upperCase12);
            gpsDeviceById.setPower(upperCase15);
            gpsDeviceById.setIpaddr(ip);
            gpsDeviceById.setPort(port);
        }
    }
 
}