zsh_root
2024-01-02 7b595546af704983dbafcd0d385c8768ddacefc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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;
 
    }
}