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
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
package baowen;
 
 
import index.JPanelMoudle.readParamsComp;
import tools.GetNowTime;
import tools.ShowMessage;
import tools.Tools;
 
 
/**
 * 基站的配置信息
 */
public class Dell_55AA39 {
    public static boolean readpeizhi_succ = false;
    static String[] hex = null;
    static String[] hex1 = null;
 
 
    /**
     * 55 AA 39 55 03 01 50 00 01 01 90 E8 03 0A 00 05 00 E1 FF 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000 00 71 04 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 43 00 02 00 78 00 01 00 00 00 01 00 00 00 0000 00 00 00 00 00 00 00 00 00 00 00 00 A9 FA
     */
    public static void dell(String ip, String message, int port) {
        hex = Tools.hex(message);//原始数据
        int length = message.length();
        int size = Tools.decodeHEX(hex[3]);
        int length2 = (size * 2) + 8;
        if (length2 == length) {
            ok_55AA39(ip, message, port, hex);
        } else {
            Dell_uanshi_byt.intsert(ip, message, GetNowTime.timestamp2(), GetNowTime.timestamp(), port);
        }
 
    }
 
 
    @SuppressWarnings("unused")
    public static void ok_55AA39(String ip, String message, int port, String[] hex) {
        String hex1 = hex[8];
        //读写标签
        if (hex1.equals("02")) {
            rwTag(ip, message, port,hex);
        } else if (hex1.equals("12") || hex1.equals("11")) {
            rwAnc(ip, message, port, hex1);
        }
    }
 
    //读写基站配置
    private static void rwAnc(String ip, String message, int port, String hexr0w) {
        String message1 = message.substring(22);
        hex1 = Tools.hex(message1);//原始数据
        String ancId = null;       //基站ID
        String version = null;     //基站版本
        String cejuNum = null;     //测距基站数量
        String sendTime = null;    //uwb信号发送时间
        String loraGongLv = null;  //lora发射功率
        String uwbGongLv = null;   //uwb功率
        String gatewayId = null;   //uwb功率
        if (hexr0w.equals("11")){
            System.out.println("修改基站成功");
        }else {
            try {
                gatewayId = hex[7] + hex[6];//网关ID
                version = "V" + Integer.parseInt(hex1[1], 16) + "." + Integer.parseInt(hex1[0], 16);//版本号
                ancId = diZhi(2);//基站ID
                cejuNum = Tools.decodeHEX(diZhi(5)) + "";//组ID
                loraGongLv = getLoraGonglV(6);//lora功率
                sendTime = Tools.decodeHEX(diZhi(10)) + "";//发送时间
                uwbGongLv = Tools.decodeHEX(diZhi(27)) + "";//uwb功率
 
            } catch (NumberFormatException e) {
                ShowMessage.zidingyi_24("信标返回参数错误");
                return;
            }
        }
    }
 
 
 
 
    //读写标签回复
    private static void rwTag(String ip, String message, int port,String[] hex) {
 
        String message1 = message.substring(22);
        hex1 = Tools.hex(message1);//原始数据
 
        String tagid = null;//模块ID
        String version = null;//版本号
        String groupId = null;//小组ID
        String distance = null;//lora功率
        String uwbGongLv = null;//uw功率
        try {
            version = "V" + Integer.parseInt(hex1[1], 16) + "." + Integer.parseInt(hex1[0], 16);//版本号
            tagid = diZhi(2);//标签ID
            groupId = Tools.decodeHEX(diZhi(5)) + "";//小组ID
            distance = Tools.decodeHEX(diZhi(6))+"";//校准距离
            uwbGongLv = Tools.decodeHEX(diZhi(27)) + "";//UWB功率
            readParamsComp.getAnchorId_jf().setText(tagid);
            readParamsComp.getAnchorVersion_jf().setText(version);
            readParamsComp.getGroupId_jf().setText(groupId);
            readParamsComp.getAnchorPower_jf().setText(uwbGongLv);
            readParamsComp.getJiaoZhunDis_jf().setText(distance);
        } catch (NumberFormatException e) {
            ShowMessage.zidingyi_24("信标参数错误...");
            return;
        }
 
 
 
    }
 
 
 
 
    private static String getLoraGonglV(int addr) {
        String loraGongl="-1";
        int loraPower = Tools.decodeHEX(diZhi(addr));
        byte loraPower1 = (byte) loraPower;
        loraGongl = loraPower1 + "";
        return loraGongl;
    }
 
 
    public static String diZhi(int addr) {
        String s = hex1[(addr * 2) - 1] + hex1[(addr * 2) - 2];
        return s;
    }
 
 
}