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
package baowen;
 
import tools.GetNowTime;
 
import java.util.Vector;
 
public class Dell_Baowen implements Runnable {
 
    static Thread t;
 
    static Vector<Baowen> baowenvec = new Vector<Baowen>();
    static int sleeptime = 1;
 
    public void startThread() {
        t = new Thread(this);
        t.start();
    }
 
    public static void intsert(String ip, String hex, String time, int port) {
        Baowen baowen = new Baowen();
        baowen.setHex(hex);
        baowen.setIp(ip);
        baowen.setAddtime(time);
        baowen.setTimestamp(GetNowTime.timestamp());
        baowen.setPort(port);
        baowenvec.add(baowen);
    }
 
 
    public void run() {
        while (true) {
            try {
                dellhex();
                Thread.sleep(sleeptime);//休眠时间
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
 
    public void dellhex() {
        int size = baowenvec.size();
        if (size == 0) {
            sleeptime = 10;
            return;
        }
        if (size > 100000) {//如果数据大于10万条没有处理则清空
            baowenvec.removeAllElements();
        } else {
            sleeptime = 0;
            Baowen baowen0 = baowenvec.get(0);
            String ip = baowen0.getIp();
            int port = baowen0.getPort();
            String hex = baowen0.getHex();
            String time = baowen0.getAddtime();
            int timestamp = baowen0.getTimestamp();
            int lenth = hex.length();
            try {
                dellhex2(ip, port, hex, time, timestamp, lenth);//处理原始数据
            } catch (Exception e) {
                e.printStackTrace();
            }
            baowenvec.remove(baowen0);//删除处理过的报文
        }
    }
    public static void dellhex2(String ip, int port, String hex, String time, int timestamp, int lenth) {
        if (hex.startsWith("55AA39")) {
            Dell_55AA39.dell(ip, hex,port);
        }else if (hex.startsWith("55AA40")){
            Dell_55AA40.dellrgs(ip, hex,port);
        }else if (hex.startsWith("55AA03")){
            Dell_55AA03.dell(ip, hex,port);
        }else if (hex.startsWith("55AA34")){
            Dell_55AA34.dellrgs(ip, hex,port);
        }else {
            Dell_uanshi_byt.intsert(ip, hex, time, timestamp, port);
        }
    }
}