package BaoWen;
|
import java.math.BigInteger;
|
import java.util.Vector;
|
import Frame.TcpIpManage;
|
import Judge.JugeNumber;
|
import Method.GetNowTime;
|
import Method.StringToHex;
|
import PbuliClass.ShowMessage;
|
import Tag_Ceju.Ceju;
|
import Tag_Ceju.Dell_Ceju;
|
import anchor.Anchor;
|
import anchor.Anchor_Dell;
|
import buju.dell_buju;
|
import jiekou.Warnig;
|
import person.Person;
|
import person.person_Dell;
|
import tag.Tag;
|
import tag.Tag_Dell;
|
import tbDataModel_Dell.Dell_tb_suanfa2;
|
|
public class DellMessage {
|
|
static Vector<String> vector=new Vector<>();
|
|
private static String hexStr = "0123456789ABCDEF";
|
private static String[] binaryArray =
|
{"0000","0001","0010","0011",
|
"0100","0101","0110","0111",
|
"1000","1001","1010","1011",
|
"1100","1101","1110","1111"};
|
|
|
@SuppressWarnings("unused")
|
/**´¦ÀíÔʼ²â¾àÐÅÏ¢*/
|
public static void dell_info(String ip,String infom,String addtime,int timestamp,int port) {
|
|
if(infom.startsWith("55AA01")) {
|
String[] hex=StringToHex.hex(infom);//ÔʼÊý¾Ý
|
String zhilingtype=hex[2] ;//Ö¸ÁîÀàÐÍ
|
String lenth= String.valueOf(decodeHEX(hex[3]));//Êý¾Ý³¤¶È
|
String receive_baoxu=String.valueOf(decodeHEX(hex[4]));//°üÐò
|
String receive_tagid=hex[6]+hex[5];//Ä£¿éID receive_tagid
|
String receive_anchorid=hex[8]+hex[7];//Ä£¿éID receive_anchorid
|
Anchor ac=Anchor_Dell.get_anchor(receive_anchorid);
|
int receive_distance=decodeHEX(hex[12]+hex[11]+hex[10]+hex[9]);
|
String distance=String.valueOf(receive_distance);//¾àÀë
|
String battery=String.valueOf(decodeHEX(hex[13]));//µçÁ¿
|
int batteryint=decodeHEX(hex[13]);
|
|
//°´¼ü
|
String button=bytes2BinaryStr(HexStringToBinary(hex[14])).substring(7, 8);
|
|
//±êÇ©¾²Ö¹
|
String jingzhi=bytes2BinaryStr(HexStringToBinary(infom.substring(28, 30))).substring(6, 7);
|
|
//±êÇ©ÐÝÃß
|
String xiumian=bytes2BinaryStr(HexStringToBinary(infom.substring(28, 30))).substring(5, 6);
|
|
|
//ÐźÅÇ¿¶È1
|
String Strong1="-"+decodeHEX(hex[15]);
|
|
//ÐźÅÇ¿¶È²î
|
String Strong2="-"+decodeHEX(hex[16]);
|
|
//±êǩƵÂÊ
|
String taghz=String.valueOf(decodeHEX(hex[17]));
|
|
int int_taghz=decodeHEX(hex[17]);
|
|
//±êǩʱ¼äƬ
|
String time_pian=String.valueOf(decodeHEX(hex[18]));
|
|
//ÏÔʾ°´¼ü°´ÏµÄÐÅÏ¢
|
if(button.toString().equals("1")) {
|
ShowMessage.zidingyi(GetNowTime.now2()+": "+receive_tagid+" °´¼ü°´ÏÂ"+button);
|
}
|
Tag tag=Tag_Dell.get_tag(receive_tagid);
|
|
//µÍµçÁ¿¸æ¾¯
|
// Tag_Dell.alert_tag_low_power(receive_tagid.toString(), batteryint);
|
|
//±êÇ©±»²ð³ý
|
String tagoff="0";
|
|
if(TcpIpManage.getStar()) {
|
StringBuffer data=new StringBuffer(GetNowTime.now()+":"+"ÊÕ:"+ip+":"+port+",°üÐò:"+receive_baoxu+",±êÇ©:"
|
+receive_tagid+",»ùÕ¾:"+receive_anchorid
|
+",¾àÀë:"+receive_distance+",µçÁ¿:"+battery+"%"+",°´¼ü:"+button+",¾²Ö¹:"
|
+jingzhi+",ÐÝÃß:"+xiumian+",ÐźÅÇ¿¶È1:"+Strong1+",ÐźÅÇ¿¶È2:"+Strong2+",ƵÂÊ:"+taghz+",ʱ¼äƬ:"+time_pian);
|
if(TcpIpManage.getDatatypeis().equals("±¨ÎÄÊý¾Ý")) {//ÏÔʾ×Ö·û´®¸ñʽ
|
if(TcpIpManage.getNeed_guo_lv_tag().equals("Ñ¡Ôñ±êÇ©")) {
|
TcpIpManage.get_text_area().append(data+"\n");
|
}else if(receive_tagid.toString().equals(TcpIpManage.getNeed_guo_lv_tag())){
|
TcpIpManage.get_text_area().append(data+"\n");
|
}
|
}else if(TcpIpManage.getDatatypeis().equals("HEXÏÔʾ")) {
|
TcpIpManage.get_text_area().append("ÊÕ:"+ip+":"+port+","+infom+","+addtime+"\n");
|
}
|
TcpIpManage.get_text_area().setCaretPosition(TcpIpManage.get_text_area().getText().length());
|
data.setLength(0);
|
}
|
|
Person person=person_Dell.get_Person(receive_tagid);
|
if(person==null || ac==null) {
|
return;
|
}
|
/**SOS¸æ¾¯**/
|
Warnig.sos(tag,tagoff,button, jingzhi, xiumian, receive_tagid, addtime, receive_baoxu,person);
|
|
//¸üлùվ״̬ΪÔÚÏß
|
Anchor_Dell.set_anchor_mode(ac,receive_anchorid,ip,port);
|
|
//¸ü¸Ä±êÇ©µÄ״̬ºÍµçÁ¿ÐÅÏ¢
|
Tag_Dell.set_tagpower(receive_tagid, battery);
|
|
//Ð޸ıêÇ©µÄÈËÔ±µÄSOS״̬
|
person_Dell.alert_sos(receive_tagid, button);
|
|
//ÐÞ¸ÄÈËÔ±µÄµçÁ¿ÐÅÏ¢,
|
person_Dell.alert_person_power(receive_tagid, battery,receive_anchorid);
|
|
//Ð޸IJ½¾àÐÅÏ¢
|
if(dell_buju.getBuju_vector().size() !=0) {
|
dell_buju.alert(receive_anchorid, receive_tagid, receive_distance);
|
};
|
person.setHave_uwbxinhao(1);//2023.07.12 zsh
|
//½«Êý¾Ý¸øµ½JNA¶¯Ì¬¿â´¦Àí
|
dellforJNA(
|
ip,//ip
|
receive_baoxu, //°üÐò
|
receive_tagid, //±êÇ©ID
|
receive_anchorid, //»ùÕ¾ID
|
distance,//²â¾à¾àÀë
|
jingzhi,//¾²Ö¹×´Ì¬
|
"0",//ÐźÅÇ¿¶È
|
timestamp,//ʱ¼ä´Á
|
button,//SOSÇé¿ö
|
battery,//µçÁ¿
|
ac.getAnc_floor(),//²ã
|
Strong1,//µÚ1·ÐźÅÇ¿¶È
|
Strong2,//µÚ2·ÐźÅÇ¿¶È
|
int_taghz//±êÇ©µÄƵÂÊ
|
);
|
}
|
|
|
}
|
|
|
|
|
|
/**Êý¾Ý¸øµ½JNA´¦Àí
|
* @param receive_baoxu½ÓÊÕµ½µÄ°üÐò
|
* @param receive_tagid½ÓÊÕµ½µÄ±êÇ©id
|
* @param receive_anchorid½ÓÊÕµ½µÄ»ùÕ¾id¼¯ºÏ
|
* @param receive_distance½ÓÊÕµ½µÄ¾àÀ뼯ºÏ
|
* @param stationary_flag ¾²Ö¹×´Ì¬
|
* @param signal_powerÐźÅÇ¿¶È
|
* @param timestampʱ¼ä´Á
|
* @param int_taghz±êÇ©µÄƵÂÊ
|
* @param button SOS״̬*/
|
public static void dellforJNA(
|
String ip,
|
String receive_baoxu,
|
String receive_tagid,
|
String receive_anchorid,
|
String receive_distance,
|
String stationary_flag,
|
String signal_power,
|
int timestamp,
|
String sos,
|
String battery,
|
String layer,
|
String power,
|
String power_diff,
|
int int_taghz
|
) {
|
|
Ceju cej=new Ceju();
|
cej.setCe_baoxu(receive_baoxu);
|
cej.setCe_ip(ip);
|
cej.setCe_tagid(receive_tagid);
|
cej.setCe_timestamp(timestamp);
|
cej.setCe_anchorid(receive_anchorid);
|
cej.setCe_distance(receive_distance);
|
cej.setCe_battery(battery);//µçÁ¿
|
cej.setCe_power(power);
|
cej.setCe_power_diff(power_diff);
|
cej.setCe_taghz(int_taghz);
|
cej.setCe_jingzhi(stationary_flag);
|
cej.setCe_button(sos);
|
Dell_Ceju.dell_ceju(ip,receive_tagid,cej,Integer.parseInt(receive_baoxu),receive_anchorid);
|
|
}
|
|
|
/**16½øÖÆ×ªÎª10½øÖÆ*/
|
public static int decodeHEX(String hexs){
|
String hex=hexs.trim();
|
boolean a=JugeNumber.isLetterDigit(hex);
|
int numb=0;
|
if(a) {
|
BigInteger bigint=new BigInteger(hex,16);
|
numb=bigint.intValue();
|
}else {
|
ShowMessage.zidingyi("16½øÖÆ×ª10½øÖƳö´í,ÊÕµ½£º"+hex);
|
}
|
return numb;
|
|
}
|
|
/**32½øÖÆ×ªÎª10½øÖÆ*/
|
public static String change32To10(String num) {
|
int f=32;
|
int t=10;
|
return new BigInteger(num, f).toString(t);
|
}
|
|
|
/**
|
* ½«byte[]תΪ¸÷ÖÖ½øÖƵÄ×Ö·û´®
|
* @param bytes byte[]
|
* @param radix »ùÊý¿ÉÒÔת»»½øÖƵķ¶Î§£¬´ÓCharacter.MIN_RADIXµ½Character.MAX_RADIX£¬³¬³ö·¶Î§ºó±äΪ10½øÖÆ
|
* @return ת»»ºóµÄ×Ö·û´®
|
*/
|
public static String binary(byte[] bytes, int radix){
|
return new BigInteger(1, bytes).toString(radix);// ÕâÀïµÄ1´ú±íÕýÊý
|
}
|
|
|
private static final char[] HEXES = {
|
'0', '1', '2', '3',
|
'4', '5', '6', '7',
|
'8', '9', 'a', 'b',
|
'c', 'd', 'e', 'f'
|
};
|
|
/**
|
* byteÊý×é ת»»³É 16½øÖÆÐ¡Ð´×Ö·û´®
|
*/
|
public static String bytes2Hex(byte[] bytes) {
|
if (bytes == null || bytes.length == 0) {
|
return null;
|
}
|
|
StringBuilder hex = new StringBuilder();
|
|
for (byte b : bytes) {
|
hex.append(HEXES[(b >> 4) & 0x0F]);
|
hex.append(HEXES[b & 0x0F]);
|
}
|
|
return hex.toString();
|
}
|
|
|
|
|
|
/**½ØÈ¡Ö¸¶¨³¤¶ÈµÄBYTEÊý×é
|
* @param srcÔ×Ö½ÚÊý×é
|
* @param ¿ªÊ¼Î»ÖÃ
|
* @param ½ØÈ¡³¤¶È*/
|
public static byte[] subBytes(byte[] src, int begin, int count) {
|
byte[] bs = new byte[count];
|
System.arraycopy(src, begin, bs, 0, count);
|
return bs;
|
}
|
|
|
/**
|
*
|
* @param hexString
|
* @return ½«Ê®Áù½øÖÆ×ª»»Îª×Ö½ÚÊý×é
|
*/
|
public static byte[] HexStringToBinary(String hexString){
|
//hexStringµÄ³¤¶È¶Ô2È¡Õû£¬×÷ΪbytesµÄ³¤¶È
|
int len = hexString.length()/2;
|
byte[] bytes = new byte[len];
|
byte high = 0;//×Ö½Ú¸ßËÄλ
|
byte low = 0;//×Ö½ÚµÍËÄλ
|
|
for(int i=0;i<len;i++){
|
//ÓÒÒÆËÄλµÃµ½¸ßλ
|
high = (byte)((hexStr.indexOf(hexString.charAt(2*i)))<<4);
|
low = (byte)hexStr.indexOf(hexString.charAt(2*i+1));
|
bytes[i] = (byte) (high|low);//¸ßµØÎ»×ö»òÔËËã
|
}
|
return bytes;
|
}
|
|
/**
|
*
|
* @param str
|
* @return ת»»Îª¶þ½øÖÆ×Ö·û´®
|
*/
|
public static String bytes2BinaryStr(byte[] bArray){
|
|
String outStr = "";
|
int pos = 0;
|
for(byte b:bArray){
|
//¸ßËÄλ
|
pos = (b&0xF0)>>4;
|
outStr+=binaryArray[pos];
|
//µÍËÄλ
|
pos=b&0x0F;
|
outStr+=binaryArray[pos];
|
}
|
return outStr;
|
|
}
|
|
|
|
public static Vector<String> getVector() {
|
return vector;
|
}
|
|
/**±£´æ±¨ÎÄyang20230725±¨Îı¨ÎÄÊý¾Ý*/
|
public static void save_log(String message) {
|
if(Dell_tb_suanfa2.isJnalog_open()){
|
vector.add(message);//yang20230725±¨Îı¨ÎÄÊý¾Ý
|
}
|
}
|
|
}
|