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