package zijisuan;
|
import java.util.Vector;
|
import BaoWen.Udp_Receive;
|
import BaoWen.Urt_7000_port;
|
import JNADell.Dell_usetaganchor;
|
import Method.BaoWenShow;
|
import PbuliClass.Systems;
|
import anchor.Anchor;
|
import anchor.Anchor_Dell;
|
import person.Person;
|
import person.person_Dell;
|
import tag.Tag;
|
import tag.Tag_Dell;
|
import tbDataModel_Dell.ReadPeizhiMessage;
|
import tbDataModel_Dell.Read_Write_Anchor_Message;
|
public class Zjsdo {
|
|
/**×Ô½âËãģʽ·¢ËÍXY×ø±ê¸øµ½»ùÕ¾*/
|
public static void sendxy(
|
Person per,
|
String tagid,
|
String baoxu,
|
int x,
|
int y,
|
double z,
|
String jd,
|
String wd,
|
String gc) {
|
|
int from=per.getPosfrom();
|
/** °üÐò+±êÇ©ID£¨Î¨Ò»£©+X×ø±ê+Y×ø±ê+Z×ø±ê£¨×ø±êµ¥Î»ÀåÃ×£©+¾¶È+ά¶È+¸ß³Ì+Êý¾ÝÀ´Ô´(1±íʾUWB£¬0±íʾÎÀÐÇ)*/
|
// String mes0="userdate"+","+baoxu+","+tagid+","+x+","+y+",,,,,1";
|
// if(from==0) {
|
// mes0="userdate"+","+baoxu+","+tagid+",,,,"+jd+","+wd+","+z+",0";
|
// }
|
|
String mes0="userdate"+","+baoxu+","+tagid+",,,,"+jd+","+wd+","+z+","+from;
|
if(from==1) {
|
mes0="userdate"+","+baoxu+","+tagid+",,,,"+jd+","+wd+",,"+from;
|
}
|
|
String message=Dell_usetaganchor.touchuan(mes0,tagid);
|
|
//½«Êý¾Ýͨ¹ý4G·¢Ë͸øÈں϶¨Î»ÖÕ¶Ë
|
if(Systems.getZijiesuan()==4) {
|
String mes1="$userdata,"+tagid+","+mes0;
|
byte[] byt=mes1.getBytes();
|
int size=byt.length;
|
String ip=per.getBaoliu8();
|
String port=per.getBaoliu9();
|
if(ip.length()>5) {
|
Urt_7000_port.udp_out(byt,size, ip, port,tagid,mes1);
|
}
|
}else if(Systems.getZijiesuan()==1) {//½«Êý¾Ýͨ¹ýÖ÷»ùÕ¾·¢×ß
|
Tag tag=Tag_Dell.get_tag(tagid);
|
String anchorid=tag.getAnchorid();
|
Anchor ac=Anchor_Dell.get_anchor(anchorid);
|
String datas="toanchorid,"+anchorid+","+message;
|
BaoWenShow.ok("2", "TOANC",datas, "","×Ô½âËã");
|
if(ac !=null) {
|
byte[] byt=ReadPeizhiMessage.toByteArray(message);
|
//½«Êý¾Ýfa¸øÖ÷»ùÕ¾
|
Udp_Receive.out(byt,byt.length,ac,"×Ô½âËã");
|
}else {
|
datas="ac is null,"+message;
|
BaoWenShow.ok("2", "TOANC",datas, "","×Ô½âËã");
|
}
|
}else if(Systems.getZijiesuan()==2){
|
Tag tag=Tag_Dell.get_tag(tagid);
|
String anchorid=tag.getAnchorid();
|
Anchor ac=Anchor_Dell.get_anchor(anchorid);
|
int zz=(int)z;
|
int baox=Integer.parseInt(baoxu);
|
byte[] byt=Read_Write_Anchor_Message .send_anc_xyold(tagid, baox, x, y, zz);
|
Udp_Receive.out(byt,byt.length,ac,"×Ô½âËã");//½«Êý¾Ýfa¸øÖ÷»ùÕ¾
|
}
|
}
|
|
/**¼ÆËãºÍËùÓбêÇ©µÄ¾àÀëͬʱ»ñÈ¡ºÍ×î½ü±êÇ©µÄ¾àÀë*/
|
public static int Nearest_distance(String tagid) {
|
int dis=65535;
|
int x=person_Dell.get_Person(tagid).getP_x();
|
int y=person_Dell.get_Person(tagid).getP_y();
|
|
Vector<Person> prv=person_Dell.getPerson_vector();
|
int size=prv.size();
|
if(size !=0) {
|
for(int i=0;i<size;i++) {
|
Person pr=prv.get(i);
|
String tagid1=pr.getP_tagid();
|
String onlie=pr.getP_online();
|
if(!tagid1.equals(tagid) && onlie.equals("1")) {
|
int x0=pr.getP_x();
|
int y0=pr.getP_y();
|
int a1=(x-x0)*(x-x0)+(y-y0)*(y-y0);
|
int d1=new Double(Math.sqrt(a1)).intValue();
|
if(d1<dis) {
|
dis=d1;
|
}
|
}
|
}
|
}
|
return dis;
|
|
}
|
}
|