package JNADell;
|
import java.math.BigInteger;
|
import java.util.Arrays;
|
import java.util.Iterator;
|
import java.util.Vector;
|
import BaoWen.HaveOkPosDo;
|
import BaoWen.Udp_Out;
|
import Frame.DebugManage;
|
import Frame.TcpIpManage;
|
import Method.BaoWenShow;
|
import Method.GetNowTime;
|
import Method.JugeHaveZimu;
|
import PbuliClass.Systems;
|
import Tag_Ceju.Ceju;
|
import VectroData.ForwardDatas;
|
import anchor.Anchor_Dell;
|
import circle.Dell_ResultYuang;
|
import circle.Dell_yuang;
|
import circle.Yuang;
|
import person.person_Dell;
|
import tag.Tag_Dell;
|
import tbDataModel_Dell.Dell_AnchorAndDistance;
|
import tbDataModel_Dell.ReadPeizhiMessage;
|
import tcp.TcpClientOneToMany;
|
|
public class DataToJnaDell {
|
static int jianzhi=0;
|
public static void do_dell_JAN(Vector<Ceju> vccj, int lenth,String baoxu) {
|
int[] an_x=new int[lenth];
|
int[] an_y=new int[lenth];
|
int[] an_z=new int[lenth];
|
int[] distance =new int[lenth];
|
int[] anchorid=new int[lenth];
|
int[] anchordistance=new int[lenth];
|
//»ùվά¶È
|
int[] dimension=new int[lenth];
|
//»ùÕ¾ËùÔÚµÄ×é
|
int[] zu=new int[lenth];
|
int i=0;
|
String layer="0";
|
|
int baoxuint=Integer.parseInt(baoxu);
|
|
//±êÇ©µÄ¸ß¶È
|
int tag_heigh=0;
|
|
String tagidstr="0000";
|
|
int tagid=0;
|
@SuppressWarnings("unused")
|
String tag_heighstr="";
|
|
//ÐźÅÇ¿¶È
|
int signal_power=0;
|
|
//µçÁ¿
|
String batarry="0";
|
|
//ËÙ¶ÈÏÞÖÆ
|
int tagspeed_limit=0;
|
|
//±êÇ©¾²Ö¹×´Ì¬
|
int stationary_flag=0;
|
|
//ʱ¼ä´Á
|
int timestamp=GetNowTime.timestamp();
|
|
//±êǩƵÂÊ
|
int taghz=0;
|
|
//µÚ1·ÐźÅÇ¿¶È
|
int[] power=new int[lenth];
|
|
//µÚ2·ÐźÅÇ¿¶È
|
int[] power_diff=new int[lenth];
|
|
String sos="0";
|
|
Iterator<Ceju> it=vccj.iterator();
|
|
while(it.hasNext()) {
|
|
Ceju tag_raw=it.next();
|
|
//±êÇ©id
|
tagidstr=tag_raw.getCe_tagid();
|
|
//ÅжϱêÇ©idÖÐÊÇ·ñº¬ÓÐ×Öĸ
|
if(JugeHaveZimu.haszimu(tag_raw.getCe_tagid())) {
|
|
tagid=ReadPeizhiMessage.decodeHEX(tag_raw.getCe_tagid());
|
}else {
|
tagid=Integer.parseInt(tag_raw.getCe_tagid());
|
}
|
|
//±êǩƵÂÊ
|
taghz=tag_raw.getCe_taghz();
|
|
|
//±êÇ©µçÁ¿
|
batarry=tag_raw.getCe_battery();
|
|
//»ùÕ¾id
|
String anchoid=tag_raw.getCe_anchorid();
|
|
//»ùÕ¾x×ø±ê
|
an_x[i]=Integer.parseInt(Anchor_Dell.get_anchor(anchoid).getAnc_x());
|
|
//»ùÕ¾y×ø±ê
|
an_y[i]=Integer.parseInt(Anchor_Dell.get_anchor(anchoid).getAnc_y());
|
|
//»ùÕ¾z×ø±ê
|
an_z[i]=Integer.parseInt(Anchor_Dell.get_anchor(anchoid).getAnc_z());
|
|
//»ùÕ¾µÄÁ¿³Ì
|
String liangcheng=Anchor_Dell.get_anchor(anchoid).getAnc_distance();
|
if(liangcheng.equals("ÎÞÏÞÖÆ")) {
|
liangcheng="1000000";
|
}
|
|
anchordistance[i]=Integer.parseInt(tag_raw.getCe_distance());
|
|
//ÅжϻùÕ¾idÖÐÊÇ·ñº¬ÓÐ×Öĸ
|
|
int inanchorid=0;
|
if(JugeHaveZimu.haszimu(anchoid)) {
|
|
inanchorid=ReadPeizhiMessage.decodeHEX(anchoid);
|
}else {
|
inanchorid=Integer.parseInt(anchoid);
|
}
|
|
//»ùÕ¾µÄid
|
anchorid[i]=inanchorid;
|
|
//»ùÕ¾ºÍ±êÇ©µÄ¾àÀë
|
distance[i]=Integer.parseInt(tag_raw.getCe_distance());
|
|
|
|
//»ùÕ¾ËùÔÚµÄ×é
|
zu[i]=Integer.parseInt(Anchor_Dell.get_anchor(anchoid).getAnc_zu());
|
|
//±êÇ©¸ß¶È
|
tag_heigh=Integer.parseInt(Tag_Dell.get_tag(tagidstr).getTag_pos_z());
|
|
//±êÇ©¾²Ö¹×´Ì¬
|
stationary_flag=Integer.parseInt(tag_raw.getCe_jingzhi());
|
|
//±êÇ©¸ß¶È×Ö·û´®
|
tag_heighstr=String.valueOf(tag_heigh);
|
|
//±êÇ©ËÙ¶ÈÏÞÖÆ
|
|
if(Tag_Dell.get_tag(tagidstr).getTag_sulv().equals("ÎÞ")) {
|
tagspeed_limit=100000;
|
}else {
|
tagspeed_limit=Integer.parseInt(Tag_Dell.get_tag(tagidstr).getTag_sulv());
|
}
|
|
//sos
|
sos=tag_raw.getCe_button();
|
|
//²ã
|
layer=Tag_Dell.get_tag(tagidstr).getTag_floor();
|
|
//µÚһ·ÐźÅÇ¿¶È
|
power[i]=Integer.parseInt(tag_raw.getCe_power());
|
|
//µÚ¶þ·ÐźÅÇ¿¶È
|
power_diff[i]=Integer.parseInt(tag_raw.getCe_power_diff());
|
|
i++;
|
}
|
|
|
|
//¾²Ö¹Ê±Êä³ö¹Ì¶¨×ø±êÈç¹ûû¹´Ñ¡
|
if(Systems.sys().getQuiet().equals("0")) {
|
stationary_flag=0;
|
}
|
|
|
/**°üÐò,ʱ¼ä´Á,(»ùÕ¾X×ø±ê¼¯ºÏ)£¬(»ùÕ¾Y×ø±ê¼¯ºÏ)£¬(»ùÕ¾z×ø±ê¼¯ºÏ)£¬(»ùÕ¾±êÇ©¾àÀë)£¬»ùÕ¾ÊýÁ¿£¬(»ùÕ¾ID)£¬±êÇ©ID£¬±êÇ©¸ß¶È£¬
|
* ÐźÅÇ¿¶È£¬±êÇ©ËÙ¶ÈÏÞÖÆ£¬(»ùÕ¾Á¿³Ì)£¬(»ùվά¶È)£¬±êÇ©¾²Ö¹×´Ì¬£¬(µÚһ·ÐźÅÇ¿¶È)£¬(µÚ¶þ·ÐźÅÇ¿¶È),±êǩƵÂÊ**/
|
/**Èç¹ûµ÷ÊÔģʽ¿ªÆô*/
|
if(TcpIpManage.getStar() && TcpIpManage.getDatatypeis().equals("µ÷ÊÔÊý¾Ý")) {
|
StringBuffer text_str=new StringBuffer();
|
text_str.append(" "+
|
baoxu+","//°üÐò
|
+timestamp+","//ʱ¼ä´Á
|
+getbuf(an_x)+","//»ùÕ¾X×ø±ê
|
+getbuf(an_y)+","//»ùÕ¾Y×ø±ê
|
+getbuf(an_z)+","//»ùÕ¾Z×ø±ê
|
+getbuf(distance)+","//»ùÕ¾ºÍ±êÇ©¾àÀë
|
+lenth+","//»ùÕ¾ÊýÁ¿
|
+getbuf(anchorid)+","//»ùÕ¾ID
|
+tagidstr+","//±êÇ©ID
|
+tag_heigh+","//±êÇ©¸ß¶È
|
+taghz+","//±êǩƵÂÊ
|
+tagspeed_limit+","//ËÙ¶ÈÏÞÖÆ100000´ú±íÎÞÏÞÖÆ
|
+getbuf(anchordistance)+","//»ùÕ¾Á¿³ÌÏÞÖÆ100000´ú±í²»ÏÞÖÆ£¨³¬³öÁ¿³Ì²»²ÎÓë¼ÆË㣩
|
+getbuf(dimension)+","//»ùÕ¾µÄά¶È
|
+stationary_flag+","//±êÇ©¾²Ö¹×´Ì¬£¬1´ú±í¾²Ö¹£¬0´ú±íû¾²Ö¹
|
+getbuf(power)+","//µÚһ·ÐźÅÇ¿¶È
|
+getbuf(power_diff)+","//µÚ¶þ·ÐźÅÇ¿¶È
|
+taghz+","//±êÇ©µÄƵÂÊ
|
+getbuf(zu)+","//»ùÕ¾ËùÔÚµÄ×é
|
+getbuf(Anchor_Dell.anchor_floor(anchorid))+","//»ùÕ¾ËùÔڵIJã
|
+"0"//ÆøÑ¹¼Æ¸ß¶È
|
);
|
|
TcpIpManage.get_text_area().append(text_str+"\n");
|
TcpIpManage.get_text_area().setCaretPosition(TcpIpManage.get_text_area().getText().length());
|
text_str=new StringBuffer();
|
}
|
|
int[] pos= {0,0,0,0};
|
|
/**½«Êý¾Ý¸øµ½¶¯Ì¬¿âJNA´¦Àí
|
* @param baoxu°üÐò
|
* @param timestampʱ¼ä´Á £¨Ð¡Ê±*3600+·ÖÖÓ*60£©*1000
|
* @param an_x[]»ùÕ¾X×ø±ê
|
* @param an_y[]»ùÕ¾y×ø±ê
|
* @param an_z[]»ùÕ¾z×ø±ê
|
* @param dis[] ±êÇ©µ½»ùÕ¾¾àÀë
|
* @param anchor_num »ùÕ¾ÊýÁ¿
|
* @param anchor_id»ùÕ¾id
|
* @param tag_id ±êÇ©id
|
* @param tag_heigt ±êÇ©¸ß¶È s
|
* @param tag_hz±êǩƵÂÊ
|
* @param tagspeed_limitËÙ¶ÈÏÞÖÆ
|
* @param anchour_distance[]»ùÕ¾µÄÁ¿³Ì
|
* @param dimension[] Ë㷨ѡÔñ1ÊÇ1ά2ÊǶþά
|
* @param stationary_flag¾²Ö¹×´Ì¬
|
* @param tag_pos ·µ»ØµÄ±êÇ©×ø±ê
|
* @param power[]µÚһ·¾¶ÐźÅÇ¿¶È¼¯ºÏ
|
* @param power_diff[]µÚ¶þ·ÐźÅÇ¿¶È¼¯ºÏ
|
* @param zu[]»ùÕ¾ËùÔÚµÄ×é
|
* @param foor[]»ùÕ¾ËùÔڵIJã
|
* @param qiya±êÇ©ÆøÑ¹¼ÆÖµ*/
|
pos=DellJAN.get_tag_pos(
|
baoxuint, // °üÐò
|
timestamp, // ʱ¼ä´Á
|
tagid, // ±êÇ©id
|
tag_heigh, // ±êÇ©¸ß¶È
|
taghz, // ±êǩƵÂÊ
|
tagspeed_limit, // ±êÇ©×î´óËÙ¶È
|
stationary_flag, // ±êÇ©¾²Ö¹×´Ì¬flag
|
0, // ÆøÑ¹¸ß¶È, ÔÀ´µÄ¸ß¶ÈÐÅÏ¢Ïȱ£Áô²»¶¯
|
lenth, // »ùÕ¾ÊýÄ¿
|
anchorid, // »ùÕ¾id, Óëannum¶ÔÓ¦
|
anchordistance, // ²â¾à, Óëannum¶ÔÓ¦
|
power, // ÐźÅÇ¿¶È, Óëannum¶ÔÓ¦
|
power_diff // ÐźÅÇ¿¶È²î, Óëannum¶ÔÓ¦
|
);
|
|
//Èç¹û¿ªÆô»È¦Ä£Ê½
|
if(DebugManage.isStart_test()) {
|
StringBuffer text=null;
|
String choosetag=DebugManage.getTagid_str();
|
if(choosetag.equals("Ñ¡Ôñ±êÇ©") || choosetag.equals(tagidstr)) {
|
int size=anchorid.length;
|
for(int k=0;k<size;k++) {
|
Yuang circle=new Yuang();
|
circle.setJianzhi(jianzhi);
|
circle.setTagid(tagidstr.toString());
|
circle.setAnchorid(String.valueOf(anchorid[k]));
|
circle.setFloor(Anchor_Dell.anchor_floor(anchorid)[k]);
|
circle.setX(an_x[k]);
|
circle.setY(an_y[k]);
|
circle.setAnchor_h(an_z[k]);
|
circle.setTag_h(tag_heigh);
|
circle.setWidth(distance[k]);
|
circle.setTagid(tagidstr);
|
Dell_yuang.add_ayvc(jianzhi, String.valueOf(Anchor_Dell.anchor_floor(anchorid)[k]), circle,baoxu,pos);
|
}
|
|
text=new StringBuffer(GetNowTime.timestamp2()+", tagid:"
|
+tagidstr+", seq: "
|
+baoxu+", anchorid: "
|
+getbuf(anchorid)+", distance: "
|
+getbuf(distance)+", posx: "
|
+getbuf(an_x)+", posy: "
|
+getbuf(an_y)+", posz: "
|
+getbuf(an_z)+", tagheight: "
|
+String.valueOf(tag_heigh)+", signal_power: "
|
+String.valueOf(signal_power)+", tagspeed_limit: "
|
+String.valueOf(tagspeed_limit)+", dimension: "
|
+getbuf(dimension)+", anchordistance: "
|
+getbuf(anchordistance)+", power:"
|
+getbuf(power)+", power_diff:"
|
+getbuf(power_diff)+", taghz:"
|
+taghz+", zu:"
|
+getbuf(zu)
|
);
|
|
}
|
if(text !=null) {
|
Dell_ResultYuang.add_resty(pos[0],pos[1],pos[2],pos[3], jianzhi,text.toString(),baoxu);
|
jianzhi++;
|
}
|
|
}
|
|
//Èç¹ûÊÇÓÐЧµÄλÖÃÐÅÏ¢
|
if(!(DellJAN.getYouxiao()<0)) {
|
int x=pos[0];
|
int y=pos[1];
|
String floor=String.valueOf(pos[3]);
|
String zz=String.valueOf(tag_heigh);
|
String time=GetNowTime.now();
|
HaveOkPosDo.do_something(
|
tagidstr,
|
baoxu,
|
x,
|
y,
|
pos[2],
|
floor,
|
zz,
|
batarry
|
);
|
person_Dell.alert_person_UWBxyfpo(tagidstr, x, y,zz,floor,time);
|
|
//UDPת·¢Î»Öñ¨ÎÄ
|
|
/**
|
* UWB±êÇ©ÉÏ´«µÄλÖñ¨ÎÄ
|
* display,[lenth],[tagid],[baoxu],[timestamp],[layer],[x],[y],[z], [vbat],[state],[sos],[mark]
|
* ʾÀý£º
|
* display,64,2012,70,2020-12-14 13:08:33.479,0,648,367,150,32,0,0,1
|
* ˵Ã÷£º
|
* 1 display:°üÍ·
|
* 2 [length]£º±¨Îij¤¶È
|
* 3 [tagid] £º±êÇ©µÄIDºÅ£¬Î¨Ò»±àºÅ
|
* 4 [baoxu] £º°üÐò£¨0~255Ñ»·£©
|
* 5 [timestamp] £ºÊ±¼ä´Á£¨ÕâÌõ±¨ÎÄ·¢³öµÄʱ¼ä£©
|
* 6 [layer] £º±êÇ©ËùÔڵIJã
|
* 7 [x] £º±êÇ©µÄX×ø±ê£¬µ¥Î»ÀåÃ×
|
* 8 [y] £º±êÇ©µÄY×ø±ê£¬µ¥Î»ÀåÃ×
|
* 9 [z] £º±êÇ©µÄZ×ø±ê£¬µ¥Î»ÀåÃ×
|
* 10 [vbat] £º±êÇ©µÄµçÁ¿ÐÅÏ¢£¬£¨0~100£©
|
* 11 [state] £º±êÇ©µÄ״̬£¬¾²Ö¹Îª1£¬Ô˶¯Îª0
|
* 12 [sos] £º±êÇ©µÄSOS°´¼ü״̬£¬°´ÏÂΪ1£¬Ã»Óа´ÏÂΪ0
|
* 13 [mark] £º±ê־λ£¬Çø±ð´ÓÄĸöÒýÇæÉÏ´«Êý¾Ý£¬ÊÊÓÃÓÚ¶à¸öÏîÄ¿´«ÈëÒ»¸öƽ̨£¬Ä¬ÈÏΪ0**/
|
|
String baotou=Systems.sys().getBaowentou()+"display,";
|
int len=0;
|
StringBuffer addtime=new StringBuffer(GetNowTime.timestamp2());
|
StringBuffer display0=new StringBuffer(baotou
|
+len+","
|
+tagidstr+","
|
+baoxu+","
|
+addtime+","
|
+layer+","
|
+pos[0]+","
|
+pos[1]+","
|
+tag_heigh+","
|
+batarry+","
|
+stationary_flag+","
|
+sos+","
|
+Systems.sys().getBiaozhi()
|
);
|
|
len=display0.length()+1;
|
|
|
|
StringBuffer display=new StringBuffer(baotou
|
+len+","
|
+tagidstr+","
|
+baoxu+","
|
+addtime+","
|
+layer+","
|
+pos[0]+","
|
+pos[1]+","
|
+tag_heigh+","
|
+batarry+","
|
+stationary_flag+","
|
+sos+","
|
+Systems.sys().getBiaozhi()
|
);
|
|
|
/**Èç¹û´æÔÚÐèÒªUDP/TCPת·¢Î»ÖÃÐÅÏ¢**/
|
Udp_Out.udp_tcp_out_display(display.toString(), tagidstr);
|
addtime.setLength(0);
|
display0.setLength(0);
|
display.setLength(0);
|
|
//Èç¹ûûÓмÆËãµÃµ½Î»ÖÃÖ´ÐÐÏÂÃæµÄ²Ù×÷
|
}else {
|
|
//status2: [LEN],[tagid],[SEQ],[TimeStamp],[ANCHORID],[distance]
|
/**£º¸Ã À౨ÎĽöÔÚÎÞ·¨¼ÆËã³öλÖÃÇÒÆôÓøÃ״̬ÉϹ¦ÄÜʱ£¬
|
* ÔÚλÖÃÊý¾ÝÀàÐÍÖÐÊä³ö ÔÚλÖÃÊý¾ÝÀàÐÍÖÐÊä³ö £¡
|
* ÉÏÊöʾÀýÖбíD345 ±êÇ©Óë 69A6»ùÕ¾×î½ü£¬ÇÒ¾àÀëֵΪ 437cm¡£**/
|
|
if(distance.length>0) {
|
|
|
|
int size1=anchorid.length;
|
for(int h=0;i<size1;i++) {
|
Dell_AnchorAndDistance.insert_anc_dis(distance[h], String.valueOf(anchorid[h]));
|
}
|
|
//ʵÏÖÊý×é´Ó´óµ½Ð¡ÅÅÐò
|
Arrays.sort(distance);
|
|
int distances=distance[distance.length-1];
|
String anchoid=Dell_AnchorAndDistance.get_anchorid(distances);
|
|
int len=0;
|
String status="status2: "+len+","+tagidstr+","+baoxu+","+GetNowTime.timestamp2()+","+anchoid+","+distances;
|
|
len=status.length()+1;
|
|
String status2="status2: "+len+","+tagidstr+","+baoxu+","+GetNowTime.timestamp2()+","+anchoid+","+distances;
|
|
int length1=status2.toString().getBytes().length;
|
|
if((ForwardDatas.have_udp("λÖÃÊý¾Ý") || ForwardDatas.have_udp("È«²¿Êý¾Ý") ) && length1>20) {
|
|
if(ForwardDatas.have_udp("λÖÃÊý¾Ý")) {
|
Udp_Out.udp_out(status2.toString().getBytes(), length1,"λÖÃÊý¾Ý");
|
}else {
|
Udp_Out.udp_out(status2.toString().getBytes(), length1,"È«²¿Êý¾Ý");
|
}
|
|
//ÏÔʾUDPת·¢µÄÊý¾Ý
|
if(TcpIpManage.getStar()&& TcpIpManage.getDatatypeis().equals("UDPת·¢")) {
|
|
//ÏÔʾUDPת·¢µÄÊý¾Ý
|
BaoWenShow.show(status2.toString(), "UDPת·¢","Ñ¡Ôñ±êÇ©");
|
}
|
|
}
|
|
/**Èç¹û´æÔÚÐèÒªTCPת·¢Î»ÖÃÐÅÏ¢**/
|
if((ForwardDatas.have_tcp("λÖÃÊý¾Ý") || ForwardDatas.have_tcp("È«²¿Êý¾Ý") )&& length1>20) {
|
TcpClientOneToMany.send(status2.toString());
|
}
|
|
}
|
|
tagidstr=null;
|
|
Dell_AnchorAndDistance.delete_all();
|
}
|
}
|
|
|
/*16½øÖÆ×ªÎª10½øÖÆ*/
|
public static int decodeHEX(String hexs){
|
BigInteger bigint=new BigInteger(hexs, 16);
|
int numb=bigint.intValue();
|
return numb;
|
}
|
|
/**´Ëº¯ÊýÓÃÓÚÊä³öÕûÐÎÊý×éÖеÄÖµ*/
|
public static StringBuffer getbuf(int[] mes) {
|
StringBuffer strbuf=new StringBuffer();
|
int size=mes.length;
|
|
if(size>2) {
|
for(int h=0;h<size;h++) {
|
if(h==0) {
|
strbuf.append("("+mes[h]+",");
|
}else if(h !=0 && h !=mes.length-1) {
|
strbuf.append(mes[h]+",");
|
}else {
|
strbuf.append(mes[h]+")");
|
}
|
}
|
}
|
|
if(size==2) {
|
for(int h=0;h<size;h++) {
|
if(h==0) {
|
strbuf.append("("+mes[h]+",");
|
}else {
|
strbuf.append(mes[h]+")");
|
}
|
}
|
}
|
|
if(size==1) {
|
for(int h=0;h<size;h++) {
|
if(h==0) {
|
strbuf.append("("+mes[h]+")");
|
}
|
}
|
}
|
|
return strbuf;
|
}
|
|
|
/**´Ëº¯ÊýÓÃÓÚÊä³öÕûÐÎÊý×éÖеÄÖµ*/
|
public static StringBuffer getbufString(String[] mes) {
|
StringBuffer strbuf=new StringBuffer();
|
int size=mes.length;
|
|
if(size>2) {
|
for(int h=0;h<size;h++) {
|
if(h==0) {
|
strbuf.append("("+mes[h]+",");
|
}else if(h !=0 && h !=mes.length-1) {
|
strbuf.append(mes[h]+",");
|
}else {
|
strbuf.append(mes[h]+")");
|
}
|
}
|
}
|
|
if(size==2) {
|
for(int h=0;h<size;h++) {
|
if(h==0) {
|
strbuf.append("("+mes[h]+",");
|
}else {
|
strbuf.append(mes[h]+")");
|
}
|
}
|
}
|
|
if(size==1) {
|
for(int h=0;h<size;h++) {
|
if(h==0) {
|
strbuf.append("("+mes[h]+")");
|
}
|
}
|
}
|
|
return strbuf;
|
}
|
|
|
public static int getJianzhi() {
|
return jianzhi;
|
}
|
|
|
public static void setJianzhi(int jianzhi) {
|
DataToJnaDell.jianzhi = jianzhi;
|
}
|
|
|
|
|
|
}
|