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