zsh_root
2025-01-06 7857a444de69124e9f7fb45f98b0ae818b107f23
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
package baowen;
 
import Anchor.anchor_Dell;
import tools.GetNowTime;
import tools.Tools;
 
public class Dell_55AA40 {
 
    static String[] hex;//字节数组
 
    static int[] distance;//获取距离的集合
    static String[] anchorid;//获取基站的集合
 
    public static void dellrgs(String ip,String message,  int port) {
        message = message.replaceAll("\r\n|\r|\n", "");//取出所有換行和回车
        int lenth = message.length();
        hex = Tools.hex(message);//原始数据
        //int datalenth1 = Tools.decodeHEX(hex[3]);//数据长度
      /*  datalenth1 = datalenth1 * 2 + 8;
        if (lenth == datalenth1) {*/
            String baoTou = diZhi(2);//包头
            int anchorNum = Tools.decodeHEXToInt8(hex[3]);
            get_anchorids(anchorNum);
            get_distance_int(anchorNum);
            addAnchor(anchorNum);
      /*  }else {
            Dell_uanshi_byt.intsert(ip, message, GetNowTime.timestamp2(), GetNowTime.timestamp(), port);
        }*/
    }
 
 
    //添加基站对象
    private static void addAnchor(int anchorNum) {
        for (int i = 0; i < anchorNum; i++) {
            String anchorID = anchorid[i];
            int dis = distance[i];
            anchor_Dell.addAnchor(anchorID,dis+"");
        }
    }
 
 
    //获取基站的ID集合
    public static void get_anchorids(int anchornum) {
        anchorid = new String[anchornum];
        for (int i = 0; i < anchornum; i++) {
            anchorid[i] = hex[5 + i * 2] + hex[4 + i * 2];
        }
    }
 
 
    //获取测距距离
    public static void get_distance_int(int anchornum) {
        int dis1 = anchornum * 2 +4 ;
        int dis2 = dis1 + 1;
        distance = new int[anchornum];
        for (int j = 0; j < anchornum; j++) {
            distance[j] = Tools.decodeHEXToInt8( hex[dis2 + j * 2] + hex[dis1 + j * 2]);
        }
    }
 
    public static String diZhi(int addr) {
        String s = hex[(addr * 2) - 1] + hex[(addr * 2) - 2];
        return s;
    }
}