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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
package Method;
import java.util.Vector;
import BaoWen.Dell_55AA07;
import BaoWen.Udp_Receive;
import BaoWen.Urt_7000_port;
import Frame.Tag_IFrame;
import PbuliClass.Shi_jian_cha_sss;
import PbuliClass.Systems;
import person.Person;
import person.person_Dell;
import tag.Tag;
import tag.Tag_Dell;
import tbDataModel_Dell.Dell_Ip;
import tbDataModel_Dell.ReadPeizhiMessage;
import tbDataModel_Dell.Read_Write_Anchor_Message;
 
/**¸ÃÀàÓÃÓÚ¿ØÖƱêÇ©Ïà¹Ø²ÎÊý*/
public class ControTag {
    
    /**×Ô¶¯Ð޸ıêǩƵÂÊ*/
    public static void auto_alert_taghz(String pinlv,String tagid) {
//        int hz=getpinglvint(pinlv);        
        //byte[] byt=Read_Write_Anchor_Message.write_one_taghz(hz, tagid,(byte)0x06);
        //Dell_Ip.alert_one_ip(byt,tagid,"×Ô¶¯Ð޸ıêǩƵÂÊ");
    }
 
    /**Ð޸ıêÇ©µÄƵÂÊ*/
    public static int set_tag_hz(String pinlv,String tagid) {
        Dell_55AA07.setNum(0);
        Tag_IFrame.get_text_area().setText("");
        Tag_Dell.alert_succ();
        int succ=0;
        int needhz=Integer.parseInt(pinlv);
        int hz=getpinglvint(pinlv);        
        byte[] byt=Read_Write_Anchor_Message.write_one_taghz(hz, tagid,(byte)0x06);    
        //ÐèÒªÐ޸ĵıêÇ©
        if(tagid.equals("ËùÓбêÇ©")) {
            byt=Read_Write_Anchor_Message.write_taghz(hz, Tag_Dell.tagzu(),(byte)0x06);            
            Dell_Ip.alert_all_ip(byt,"ÐÞ¸ÄËùÓбêǩƵÂÊ");
            person_Dell.alert_all_tag_hz(hz,needhz);
            Tag_Dell.alert_all_tag_hz(pinlv);
        }else {
            Tag tag=Tag_Dell.get_tag(tagid);
            if(tag!=null) {
                if(pinlv.equals("0.1")) {
                    tag.setDoublehz(0.1);
                }
                tag.setTag_pinglv(pinlv);
                Dell_Ip.alert_one_ip(byt,tagid,"Ð޸ıêǩƵÂÊ");
                Person person=person_Dell.get_Person(tagid);
                person.setHz(hz);
                person.setTagneedhz(needhz);
            }
        }
        return succ;
    }
 
    /**»ñÈ¡ÆÀÂʶÔÓ¦µÄºÁÃëÊý*/
    public static int getpinglvint(String a) {
        int hz=1000;
        switch(a){
        case "0.1" :
            hz=1000;
            break;
        case "1" :
            hz=1000;
            break;
        case "2" :
            hz=500;
            break; 
        case "5" :
            hz=200;
            break;
        case "10" :
            hz=100;
            break;
        case "20" :
            hz=50;
            break;
        case "25" :
            hz=40;
            break;
        case "50" :
            hz=20;
            break;
        }
        return hz;
    }
 
 
 
    /**¿ØÖƱêÇ©´úÂë
     * @param int zhiÐèÒªÐ޸ĵÄÖµ
     * @param  String tagid ÐèÒªÐ޸ĵıêÇ©ID
     * @param byte dizhiÐèÒªÐ޸ĵĵØÖ·
     * @param String messageÐèÒª·µ»ØµÄÐÅÏ¢**/
 
    public static  int konghzitag(int zhi,String tagchoose,byte dizhi,String message,String datafrom) {
        Dell_55AA07.setNum(0);
        Tag_IFrame.get_text_area().setText("");
        Tag_Dell.alert_succ();
        int succ=0;
        byte[] byt=Read_Write_Anchor_Message.write_one_taghz(zhi, tagchoose,dizhi);    
        if(Systems.isWifi()) {
            wifi_urt_fengming(tagchoose,zhi);
        }else {
            //ÐèÒªÐ޸ĵıêÇ©
            if(tagchoose.equals("ËùÓбêÇ©")) {
                byt=Read_Write_Anchor_Message.write_taghz(zhi, Tag_Dell.tagzu(),dizhi);
                Dell_Ip.alert_all_ip(byt,datafrom);
            }else {
                Dell_Ip.alert_one_ip(byt,tagchoose,datafrom);
            }
            if(message.length()>1) {
                Tag_IFrame.get_text_area().setText(tagchoose+"ÒÑÍê³ÉÏ·¢ÐÞ¸Ä"+message+"Ö¸Áî...");
 
            }
        }
        return succ;
    }
 
    /**±äµçվģʽÏ¿ØÖƱêÇ©·äÃù*/
    public static void fengming_biandianzhan(int zhi,String tagid,String ip) {
        byte[] byt=Read_Write_Anchor_Message.write_one_taghz(zhi, tagid,(byte)0x10);
        Udp_Receive.biandianzout(byt,byt.length, ip);
    }
 
    /**ÖØÆôËùÓбêÇ©£¬ÔÚÈí¼þ¿ªÆôʱºò*/
    public static void restore_all_tag() {
        ControTag.konghzitag(1,"ËùÓбêÇ©",(byte)0x60,"","Èí¼þ¿ªÆôÖØÆô±êÇ©");
    }
 
    /**ÖØÆôij¸ö±êÇ©*/
    public static void restore_tag(String tagid) {
        byte[] byt=Read_Write_Anchor_Message.write_one_taghz(1, tagid,(byte)0x60);
        Dell_Ip.alert_one_ip(byt,tagid,"ÖØÆô±êÇ©");
    }
 
    /**×Ö·û´®×ª16½øÖÆbyt[]*/
    public static byte[] getbyt(String message) {
        byte[] byt=ReadPeizhiMessage.toByteArray(message);
        return byt;
    }
 
    /**¿ØÖÆÄ³¸ö±êÇ©ÏÔʾij¸öÎÄ×Ö*/
    public static void oled_onetag(String zhi0,String tagid) {
        int zhi=Integer.parseInt(zhi0);
        byte[] byt=Read_Write_Anchor_Message.write_one_taghz(zhi, tagid,(byte)0x29);        
        if(tagid.equals("ËùÓбêÇ©")) {
            byt=Read_Write_Anchor_Message.write_taghz(zhi, Tag_Dell.tagzu(),(byte)0x29);
            Dell_Ip.alert_all_ip(byt,"¿ØÖÆÏÔʾÎÄ×Ö");
        }else {
            Dell_Ip.alert_one_ip(byt,tagid,"¿ØÖÆÏÔʾÎÄ×Ö");
        }
    }
 
 
    /**δÌí¼ÓµÄ±êǩע²áµÄʱºòÐ޸IJÎÊý**/
    public static  void noinkonghzitag(int zhi,String tagchoose,byte dizhi,String ancrid) {
        byte[] byt=Read_Write_Anchor_Message.write_one_taghz(zhi, tagchoose,dizhi);    
        Dell_Ip.noinalert_one_ip(byt,tagchoose,ancrid);
    }
 
    /**¿ØÖÆ´øWIFIÉ豸·äÃù
     * 55 AA 03 06 02 46 01 01 AC ff*/
    public static void wifi_urt_fengming(String tagid,int value) {
        if(tagid.equals("ËùÓбêÇ©")) {
            Vector<Person> vcp=person_Dell.getPerson_vector();
            int size=vcp.size();
            for(int i=0;i<size;i++) {
                String tagid0=vcp.get(i).getP_tagid();
                wifi_urt_one_fengming( tagid0,value);
            }
 
        }else {
            wifi_urt_one_fengming( tagid,value);
        }
    }
 
    /**¿ØÖÆÄ³¸ö±êÇ©·äÃù*/
    public static void wifi_urt_one_fengming(String tagid,int value) {
        Person person=person_Dell.get_Person(tagid);
        String  time=person.getXinhaotime();
        if(time.length()<5) {
            return;
        }
        int b= Shi_jian_cha_sss.get_time_cha_s(GetNowTime.now(),time);
        if(b<10) {
            String ip=person.getBaoliu8();
            String port=person.getBaoliu9();
            if(port.length()>2) {
                String a0="0306024601";
                String lenth=Integer.toHexString(value);
                if(lenth.length()<2) {
                    lenth="0"+lenth;
                }
                String a1=a0+lenth;
                String jiaoyan=jiaoyan(a1);
                String mes="55AA"+a1+jiaoyan;    
                byte[] byt=ReadPeizhiMessage.toByteArray(mes);
                int size=byt.length;
                Urt_7000_port.udp_out(byt,size, ip, port,tagid,mes);
            }
        }
    }
 
 
    /**УÑé*/
    public static String jiaoyan(String a) {
        String[] hex=StringToHex.hex(a);
        int size=hex.length;
        int sum=0;
        for(int i=0;i<size;i++) {
            sum+=Integer.parseInt(hex[i],16);
        }         
        String hex16=Integer.toHexString(~sum);//È¡·´×ªÎª16½øÖÆ×Ö·û´®        
        int lenth=hex16.length();//×Ö·û´®µÄ³¤¶È    
        String hh=hex16.substring(lenth-4, lenth-2);
        String ens=hex16.substring(lenth-2, lenth)+hh;
        return ens;
    }
 
 
}