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);
|
}
|
}
|
}
|