3.7
fxl
2023-03-07 52cffc4ab8e9787a6f233295502c7c9788dddae1
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
package com.hxzkoa.udp;
import java.util.List;
import java.util.Vector;
import javax.persistence.Query;
import org.springframework.beans.factory.annotation.Autowired;
import com.hxzkoa.json.Baowen;
import com.hxzkoa.json.tb_system;
import com.hxzkoa.json.tb_tag;
import com.hxzkoa.json.tb_warning;
import com.hxzkoa.services.SysSettingService;
import com.hxzkoa.util.Config;
import com.hxzkoa.util.HttpUtil;
 
import net.sf.json.JSONObject;
 
 
public class Yuanshibaowen implements Runnable {
    int sleeptime=0;
    static Vector<Baowen> baowenvec=new Vector<Baowen>();
    
    
    public static void intsert(String ip,String hex) {
        Baowen baowen=new Baowen();
        baowen.setHex(hex);
        baowen.setIp(ip);
        baowen.setAddtime(GetNowTime.timestamp2());
        baowen.setTimestamp(GetNowTime.timestamp());    
        baowenvec.add(baowen);
    }
    
    public void dellhex() {
        int size=baowenvec.size();
        if(size !=0) {
            sleeptime=0;
            Baowen baowen=baowenvec.get(0);
            String ip=baowen.getIp();
            String hex=baowen.getHex();
            String time=baowen.getAddtime();
            int timestamp=baowen.getTimestamp();
            int lenth=hex.length();
            //存、转发
//          Have_Yuanshi_Do.Dell_yuanshi(ip, hex,time);
            
            //测距数据
            if(hex.startsWith("55AA01") && lenth==42) {
                Have_55AA01_do.dell_55AA01(ip, hex, time, timestamp);
            
            //基站心跳包
            }else if(hex.startsWith("55AA02") && lenth==32){
//              Have_55AA02_do.dellrgs(hex);    
                        
            //注册报文
            }else if(hex.startsWith("55AA0A") && lenth==48) {
//              Dell_tag_reg_ms.dellrgs(hex,ip);    
                
            //基站信息返回
            }else if(hex.startsWith("55AA03") && lenth==202) {
                ReadPeizhiMessage.get_readpeizhi(ip, hex);
//              ReadPeizhiMessage.get_readpeizhi(ip,hex);
//              if(AnchorSet.isReadpeizhi()) {
//              ShowMessage.zidingyi(ip+" ��ȡ���óɹ���");
//              AnchorSet.jt_area.append("\n"+GetNowTime.timestamp2()+"\n"+ip+" ��ȡ���óɹ���");
//              }       
            //气体报文
            }else if(hex.startsWith("0103")|| hex.startsWith("0203")|| hex.startsWith("0303") ) {
                dell_gas(hex,ip);
            }
 
            baowenvec.removeElement(baowenvec.get(0));
            baowen=null;
            ip=null;
            hex=null;
            time=null;
            
        }else {
            sleeptime=100;
        }
    }
    
    /**处理气体数据*/
    public void dell_gas(String infom,String ip) {
            //如果开启气体监听
        String gasOpen = "0";
        String postUrl = Config.getPostUrl();
        String url_setting_bw = postUrl + "getSysSetting.do";
        JSONObject re_tb_setting = HttpUtil.doPost(url_setting_bw, "", Config.getCharset());
        tb_system re_setting = (tb_system) JSONObject.toBean(JSONObject.fromObject(re_tb_setting.get("result").toString()),
                tb_system.class);
        gasOpen = re_setting.getGas_open();
        if(gasOpen.equals("1") && infom.length()>140) { 
            ReadGas.dell_gas_data(ip,infom);
        }
    }
    
    
 
    
    public void startThread() {
        Thread t=new Thread(this);
        t.start();
    }
 
    public void run() {
        while(true) {
            try { 
                dellhex();
                
                Thread.sleep(sleeptime);
            } catch (InterruptedException e) {
                e.printStackTrace(); 
            }
        }
    }
 
 
}