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 baowenvec=new Vector(); 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(); } } } }