package com.hxzkoa.udp;
|
import java.math.BigInteger;
|
import java.util.Arrays;
|
import java.util.Iterator;
|
import java.util.Vector;
|
|
import com.hxzkoa.json.tb_achor;
|
import com.hxzkoa.json.tb_person;
|
import com.hxzkoa.json.tb_suanfa;
|
import com.hxzkoa.json.tb_system;
|
import com.hxzkoa.json.tb_tag;
|
import com.hxzkoa.util.Config;
|
import com.hxzkoa.util.HttpUtil;
|
import com.hxzkoa.util.ModifyConfig;
|
|
import net.sf.json.JSONObject;
|
|
|
public class DataToJnaDell {
|
static int jianzhi=0;
|
|
|
// public static void do_dell_JAN(Vector<Ceju> vccj, int lenth,String baoxu) {
|
// int[] an_x=new int[lenth];
|
// int[] an_y=new int[lenth];
|
// int[] an_z=new int[lenth];
|
// int[] distance =new int[lenth];
|
// int[] anchorid=new int[lenth];
|
// int[] anchordistance=new int[lenth];
|
// //基站维度
|
// int[] dimension=new int[lenth];
|
// //基站所在的组
|
// int[] zu=new int[lenth];
|
// int i=0;
|
// String layer="0000";
|
//
|
// //标签的高度
|
// int tag_heigh=0;
|
//
|
// String tagidstr="0000";
|
//
|
// int tagid=0;
|
// @SuppressWarnings("unused")
|
// String tag_heighstr="";
|
//
|
// //信号强度
|
// int signal_power=0;
|
//
|
// //电量
|
// String batarry="0";
|
//
|
// //速度限制
|
// int tagspeed_limit=0;
|
//
|
// //标签静止状态
|
// int stationary_flag=0;
|
//
|
// //时间戳
|
// int timestamp=GetNowTime.timestamp();
|
//
|
// //标签频率
|
// int taghz=0;
|
//
|
// //第1路信号强度
|
// int[] power=new int[lenth];
|
//
|
// //第2路信号强度
|
// int[] power_diff=new int[lenth];
|
//
|
// String sos="0";
|
//
|
// Iterator<Ceju> it=vccj.iterator();
|
//
|
// while(it.hasNext()) {
|
//
|
// Ceju tag_raw=it.next();
|
//
|
// //标签id
|
// tagidstr=tag_raw.getCe_tagid();
|
//
|
// //判断标签id中是否含有字母
|
// if(JugeHaveZimu.haszimu(tag_raw.getCe_tagid())) {
|
//
|
// tagid=Have_55AA03_do.decodeHEX(tag_raw.getCe_tagid());
|
// }else {
|
// tagid=Integer.parseInt(tag_raw.getCe_tagid());
|
// }
|
//
|
// //标签频率
|
// taghz=tag_raw.getCe_taghz();
|
//
|
//
|
// //标签电量
|
// batarry=tag_raw.getCe_battery();
|
//
|
// //基站id
|
// String anchoid=tag_raw.getCe_anchorid();
|
// String postUrl = Config.getPostUrl();
|
// String anchor_search_Url = postUrl + "anchorManagement_search.do";
|
// String messageJson = "{\"input\":\"" + anchorid + "\"}";
|
// JSONObject jsonObject = JSONObject.fromObject(messageJson);
|
// JSONObject re_tb_anchor = HttpUtil.doPost(anchor_search_Url, jsonObject.toString(), Config.getCharset());
|
// tb_achor re_anchor = (tb_achor) JSONObject.toBean(JSONObject.fromObject(re_tb_anchor.get("result").toString()),
|
// tb_achor.class);
|
// //基站x坐标
|
// an_x[i]=Integer.parseInt(re_anchor.getPOSX());
|
//
|
// //基站y坐标
|
// an_y[i]=Integer.parseInt(re_anchor.getPOSY());
|
//
|
// //基站z坐标
|
// an_z[i]=Integer.parseInt(re_anchor.getPOSZ());
|
//
|
// //基站的量程
|
// String liangcheng=re_anchor.getJiaozhundistance();
|
// if(liangcheng.equals("无限制")) {
|
// liangcheng="1000000";
|
// }
|
//
|
// anchordistance[i]=Integer.parseInt(liangcheng);
|
//
|
// //判断基站id中是否含有字母
|
// int inanchorid=Integer.parseInt(anchoid);
|
//
|
// if(JugeHaveZimu.haszimu(anchoid)) {
|
//
|
// inanchorid=Have_55AA03_do.decodeHEX(anchoid);
|
// }
|
//
|
// //基站的id
|
// anchorid[i]=inanchorid;
|
//
|
// //基站和标签的距离
|
// distance[i]=Integer.parseInt(tag_raw.getCe_distance());
|
//
|
// String suanfaUrl = postUrl + "anchorManagement_search.do";
|
// String suanfaJson = "{\"input\":\"" + anchorid + "\"}";
|
// JSONObject suanfaObject = JSONObject.fromObject(suanfaJson);
|
// JSONObject re_tb_suanfa = HttpUtil.doPost(suanfaUrl, suanfaObject.toString(), Config.getCharset());
|
// tb_suanfa re_suanfa = (tb_suanfa) JSONObject.toBean(JSONObject.fromObject(re_tb_suanfa.get("result").toString()),
|
// tb_suanfa.class);
|
//
|
// //基站的维度
|
// int anchor_suanfa=2;
|
// if(re_suanfa !=null) {
|
// if(re_suanfa.getAnchor_num().equals("1")) {
|
// anchor_suanfa=1;
|
// }else if(re_suanfa.getAnchor_num().equals("0")){
|
// anchor_suanfa=0;
|
// }
|
// }
|
// dimension[i]=anchor_suanfa;
|
//
|
// //基站所在的组
|
// zu[i]=Integer.parseInt(re_suanfa.getZu());
|
//
|
// String url_tag_bw = postUrl + "labelManagement_search.do";
|
// tb_tag tag = new tb_tag();
|
// tag.setTag_id(tagidstr);
|
// JSONObject tagObject = JSONObject.fromObject(tag);
|
// JSONObject re_tag_bw = HttpUtil.doPost(url_tag_bw, tagObject.toString(), Config.getCharset());
|
// tb_tag re_tag = (tb_tag) JSONObject.toBean(JSONObject.fromObject(re_tag_bw.get("result").toString()),
|
// tb_tag.class);
|
//
|
// //标签高度
|
// tag_heigh=Integer.parseInt(re_tag.getGaodu());
|
//
|
// //标签静止状态
|
// stationary_flag=Integer.parseInt(tag_raw.getCe_jingzhi());
|
//
|
// //标签高度字符串
|
// tag_heighstr=String.valueOf(tag_heigh);
|
//
|
// //标签速度限制
|
//
|
// if(re_tag.getSudu().equals("无")) {
|
// tagspeed_limit=100000;
|
// }else {
|
// tagspeed_limit=Integer.parseInt(re_tag.getSudu());
|
// }
|
//
|
// //sos
|
// sos=tag_raw.getCe_button();
|
// //
|
// String url_person_bw = postUrl + "personManagement_search.do";
|
// JSONObject re_person_bw = HttpUtil.doPost(url_person_bw, tagObject.toString(), Config.getCharset());
|
// tb_person person = (tb_person) JSONObject.toBean(JSONObject.fromObject(re_person_bw.get("result").toString()),
|
// tb_person.class);
|
// //层
|
// layer=person.getP_floor();
|
//
|
// //第一路信号强度
|
// power[i]=Integer.parseInt(tag_raw.getCe_power());
|
//
|
// //第二路信号强度
|
// power_diff[i]=Integer.parseInt(tag_raw.getCe_power_diff());
|
//
|
// i++;
|
// }
|
//
|
// 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);
|
//
|
// //静止时输出固定坐标如果没勾选
|
// if(re_setting.getQuiet().equals("0")) {
|
// stationary_flag=0;
|
// }
|
//
|
//
|
// /**包序,时间戳,(基站X坐标集合),(基站Y坐标集合),(基站z坐标集合),(基站标签距离),基站数量,(基站ID),标签ID,标签高度,
|
// * 信号强度,标签速度限制,(基站量程),(基站维度),标签静止状态,(第一路信号强度),(第二路信号强度),标签频率**/
|
// /**如果调试模式开启*/
|
// String filePath = Config.getBaowenConfig();
|
// String baowenSwitch = ModifyConfig.readData(filePath,"baowenSwitch").toString(); //进入查看报文页面打开开关
|
// String debugSwitch = ModifyConfig.readData(filePath,"debugSwitch").toString();;//调试页面打开
|
// if(baowenSwitch.contentEquals("1")&& debugSwitch.contentEquals("1")) {
|
// StringBuffer text_str=new StringBuffer();
|
// text_str.append(" "+
|
// baoxu+","//包序
|
// +timestamp+","//时间戳
|
// +getbuf(an_x)+","//基站X坐标
|
// +getbuf(an_y)+","//基站Y坐标
|
// +getbuf(an_z)+","//基站Z坐标
|
// +getbuf(distance)+","//基站和标签距离
|
// +lenth+","//基站数量
|
// +getbuf(anchorid)+","//基站ID
|
// +tagidstr+","//标签ID
|
// +tag_heigh+","//标签高度
|
// +taghz+","//标签频率
|
// +tagspeed_limit+","//速度限制100000代表无限制
|
// +getbuf(anchordistance)+","//基站量程限制100000代表不限制(超出量程不参与计算)
|
// +getbuf(dimension)+","//基站的维度
|
// +stationary_flag+","//标签静止状态,1代表静止,0代表没静止
|
// +getbuf(power)+","//第一路信号强度
|
// +getbuf(power_diff)+","
|
// +taghz+","
|
// +getbuf(zu)
|
// );// 第二路信号强度
|
// String debugUrl=postUrl+"debugMessage.do";
|
// String messageJson = "{\"result\":\""+ text_str + "\"}";
|
// JSONObject json = JSONObject.fromObject(messageJson);
|
// HttpUtil.doPost(debugUrl, json, "UTF-8");
|
// }
|
//
|
//
|
//
|
// /**将数据给到动态库JNA处理*/
|
//
|
// int[] pos=DellJAN.get_tag_pos(
|
// timestamp,
|
// an_x,
|
// an_y,
|
// an_z,
|
// distance,
|
// lenth,
|
// anchorid,
|
// tagid,
|
// tag_heigh,
|
// taghz,
|
// tagspeed_limit,
|
// anchordistance,
|
// dimension,
|
// stationary_flag,
|
// power,
|
// power_diff,
|
// zu);
|
//
|
//
|
//
|
// //如果是有效的位置信息
|
// if(DellJAN.getYouxiao()==1) {
|
//
|
// HaveOkPosDo.do_something(tagidstr.toString(), baoxu, pos[0], pos[1], "0", String.valueOf(tag_heigh));
|
// Have_55AA01_do.dell_gui();
|
//
|
// //UDP转发位置报文
|
//
|
// /**
|
// * UWB标签上传的位置报文
|
// * display,[lenth],[tagid],[baoxu],[timestamp],[layer],[x],[y],[z], [vbat],[state],[sos],[mark]
|
// * 示例:
|
// * display,64,2012,70,2020-12-14 13:08:33.479,0,648,367,150,32,0,0,1
|
// * 说明:
|
// * 1 display:包头
|
// * 2 [length]:报文长度
|
// * 3 [tagid] :标签的ID号,唯一编号
|
// * 4 [baoxu] :包序(0~255循环)
|
// * 5 [timestamp] :时间戳(这条报文发出的时间)
|
// * 6 [layer] :标签所在的层
|
// * 7 [x] :标签的X坐标,单位厘米
|
// * 8 [y] :标签的Y坐标,单位厘米
|
// * 9 [z] :标签的Z坐标,单位厘米
|
// * 10 [vbat] :标签的电量信息,(0~100)
|
// * 11 [state] :标签的状态,静止为1,运动为0
|
// * 12 [sos] :标签的SOS按键状态,按下为1,没有按下为0
|
// * 13 [mark] :标志位,区别从哪个引擎上传数据,适用于多个项目传入一个平台,默认为0**/
|
//
|
// int len=0;
|
// StringBuffer addtime=new StringBuffer(GetNowTime.timestamp2());
|
// StringBuffer display0=new StringBuffer("display,"
|
// +len+","
|
// +tagidstr+","
|
// +baoxu+","
|
// +addtime+","
|
// +layer+","
|
// +pos[0]+","
|
// +pos[1]+","
|
// +tag_heigh+","
|
// +batarry+","
|
// +stationary_flag+","
|
// +sos+","
|
// +Systems.sys().getBiaozhi()
|
// );
|
//
|
// len=display0.length()+1;
|
//
|
//
|
//
|
// StringBuffer display=new StringBuffer("display,"
|
// +len+","
|
// +tagidstr+","
|
// +baoxu+","
|
// +addtime+","
|
// +layer+","
|
// +pos[0]+","
|
// +pos[1]+","
|
// +tag_heigh+","
|
// +batarry+","
|
// +stationary_flag+","
|
// +sos+","
|
// +Systems.sys().getBiaozhi()
|
// );
|
//
|
// int length=display.toString().getBytes().length;
|
//
|
// /**如果存在需要UDP转发位置信息**/
|
// if((ForwardDatas.have_udp("位置数据") || ForwardDatas.have_udp("全部数据") )
|
// && length>20) {
|
//
|
// if(ForwardDatas.have_udp("位置数据")) {
|
// Udp_Out.udp_out(display.toString().getBytes(), length,"位置数据");
|
//
|
// }else if(ForwardDatas.have_udp("全部数据")) {
|
//
|
// Udp_Out.udp_out(display.toString().getBytes(),length,"全部数据");
|
//
|
// }
|
//
|
// //显示UDP转发的数据
|
// if(TcpIpManage.getStar()&& TcpIpManage.getDatatypeis().equals("UDP转发")) {
|
//
|
// //显示UDP转发的数据
|
// BaoWenShow.show(display.toString(), "UDP转发");
|
// }
|
//
|
// }
|
//
|
// /**如果存在需要TCP转发位置信息**/
|
// if((ForwardDatas.have_tcp("位置数据") || ForwardDatas.have_tcp("全部数据") )&& length>20) {
|
// TcpClientOneToMany.send(display.toString());
|
// }
|
//
|
// //实时保存位置报文
|
// if(Systems.sys().getOpensave().equals("1") && Systems.sys().getDatatype().equals("UDP转发")) {
|
// SaveFIleInTxt.insert_intxt(display.toString());
|
// }
|
//
|
// addtime=new StringBuffer();
|
// display0=new StringBuffer();
|
// display=new StringBuffer();
|
//
|
// //如果没有计算得到位置执行下面的操作
|
// }else {
|
//
|
// //status2: [LEN],[tagid],[SEQ],[TimeStamp],[ANCHORID],[distance]
|
// /**:该 类报文仅在无法计算出位置且启用该状态上功能时,
|
// * 在位置数据类型中输出 在位置数据类型中输出 !
|
// * 上述示例中表D345 标签与 69A6基站最近,且距离值为 437cm。**/
|
//
|
// if(distance.length>0) {
|
//
|
//
|
//
|
// for(int h=0;i<anchorid.length;i++) {
|
// Dell_AnchorAndDistance.insert_anc_dis(distance[h], String.valueOf(anchorid[h]));
|
// }
|
//
|
// //实现数组从大到小排序
|
// Arrays.sort(distance);
|
//
|
// int distances=distance[distance.length-1];
|
// String anchoid=Dell_AnchorAndDistance.get_anchorid(distances);
|
//
|
// int len=0;
|
// String status="status2: "+len+","+tagidstr+","+baoxu+","+GetNowTime.timestamp2()+","+anchoid+","+distances;
|
//
|
// len=status.length()+1;
|
//
|
// String status2="status2: "+len+","+tagidstr+","+baoxu+","+GetNowTime.timestamp2()+","+anchoid+","+distances;
|
//
|
// int length1=status2.toString().getBytes().length;
|
//
|
// if((ForwardDatas.have_udp("位置数据") || ForwardDatas.have_udp("全部数据") ) && length1>20) {
|
//
|
// if(ForwardDatas.have_udp("位置数据")) {
|
// Udp_Out.udp_out(status2.toString().getBytes(), length1,"位置数据");
|
// }else {
|
// Udp_Out.udp_out(status2.toString().getBytes(), length1,"全部数据");
|
// }
|
//
|
// //显示UDP转发的数据
|
// if(TcpIpManage.getStar()&& TcpIpManage.getDatatypeis().equals("UDP转发")) {
|
//
|
// //显示UDP转发的数据
|
// BaoWenShow.show(status2.toString(), "UDP转发");
|
// }
|
//
|
// }
|
//
|
// /**如果存在需要TCP转发位置信息**/
|
// if((ForwardDatas.have_tcp("位置数据") || ForwardDatas.have_tcp("全部数据") )&& length1>20) {
|
// TcpClientOneToMany.send(status2.toString());
|
// }
|
//
|
// //实时保存位置报文
|
// if(Systems.sys().getOpensave().equals("1") && Systems.sys().getDatatype().equals("UDP转发")) {
|
// SaveFIleInTxt.insert_intxt(status2.toString());
|
// }
|
//
|
// }
|
//
|
// tagidstr=null;
|
//
|
// Dell_AnchorAndDistance.delete_all();
|
// }
|
// }
|
//
|
//
|
// /*16进制转为10进制*/
|
// public static int decodeHEX(String hexs){
|
// BigInteger bigint=new BigInteger(hexs, 16);
|
// int numb=bigint.intValue();
|
// return numb;
|
// }
|
//
|
// /**此函数用于输出整形数组中的值*/
|
// public static StringBuffer getbuf(int[] mes) {
|
// StringBuffer strbuf=new StringBuffer();
|
// int size=mes.length;
|
//
|
// if(size>2) {
|
// for(int h=0;h<size;h++) {
|
// if(h==0) {
|
// strbuf.append("("+mes[h]+",");
|
// }else if(h !=0 && h !=mes.length-1) {
|
// strbuf.append(mes[h]+",");
|
// }else {
|
// strbuf.append(mes[h]+")");
|
// }
|
// }
|
// }
|
//
|
// if(size==2) {
|
// for(int h=0;h<size;h++) {
|
// if(h==0) {
|
// strbuf.append("("+mes[h]+",");
|
// }else {
|
// strbuf.append(mes[h]+")");
|
// }
|
// }
|
// }
|
//
|
// if(size==1) {
|
// for(int h=0;h<size;h++) {
|
// if(h==0) {
|
// strbuf.append("("+mes[h]+")");
|
// }
|
// }
|
// }
|
//
|
// return strbuf;
|
// }
|
//
|
//
|
// public static int getJianzhi() {
|
// return jianzhi;
|
// }
|
//
|
//
|
// public static void setJianzhi(int jianzhi) {
|
// DataToJnaDell.jianzhi = jianzhi;
|
// }
|
|
|
|
|
|
}
|