package rtkanchor;
|
import java.math.BigInteger;
|
import Netty.SendMessageToClient;
|
import PbuliClass.ShowMessage;
|
import person.Person;
|
import person.person_Dell;
|
import urt.xytognss;
|
public class SendMessage implements Runnable {
|
static boolean jishi=false;
|
static int jishu1=1;
|
static int jishu2=1;
|
|
/*** ½«16½øÖÆ×Ö·û´®×ª»»Îªbyte[]
|
** @param str
|
* @return
|
*/
|
public static byte[] toBytes(String str) {
|
if (str == null || str.trim().equals("")) {
|
return new byte[0];
|
}
|
|
byte[] bytes = new byte[str.length() / 2];
|
for (int i = 0; i < str.length() / 2; i++) {
|
String subStr = str.substring(i * 2, i * 2 + 2);
|
bytes[i] = (byte) Integer.parseInt(subStr, 16);
|
}
|
|
return bytes;
|
}
|
|
|
|
public static void setJishi(boolean jishi) {
|
SendMessage.jishi = jishi;
|
}
|
|
|
|
public static int getJishu2() {
|
return jishu2;
|
}
|
|
|
|
public static void setJishu2(int jishu2) {
|
SendMessage.jishu2 = jishu2;
|
}
|
|
|
/**B5 62 ;°üÍ·
|
* 06 ;Àà
|
* 71 ;ID
|
* 28 ;length
|
* 00 ;°æ±¾ºÅ
|
* 00 ;±£Áôλ
|
* 00 02 01
|
* 80 4F 50 49 (4-7×Ö½Ú)γ¶È
|
* 00 14 CC 0F(8-11×Ö½Ú)¾¶È
|
* 10 27 00 00 (12-15×Ö½Ú)¸ß¶ÈÀåÃ×
|
* 00 00 00 00 E8 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1B 17
|
* B562067128000000020108584B455481C2171027000000000000E80300000000000000000000000000000000000062B3
|
* */
|
|
public static void send_info_to_anchor(Jizhan ac,String wd,String jd,String gd) {
|
StringBuffer a0=new StringBuffer();
|
StringBuffer a1=new StringBuffer();
|
a0.append("B5620671280000000201");
|
a1.append("0671280000000201");
|
double[] jwd=xytognss.dd2d_double(wd,jd);
|
double wd0= jwd[1]*10000000;
|
double jd0= jwd[0]*10000000;
|
int wd1=new Double(wd0).intValue();
|
int jd1=new Double(jd0).intValue();
|
double gd0=Double.parseDouble(gd)*100;
|
int gd1=(int)gd0;
|
String wdhex=Bytes2HexString(int2hex(wd1));
|
String jdhex=Bytes2HexString(int2hex(jd1));
|
String gdhex=Bytes2HexString(int2hex(gd1));
|
a0.append(wdhex+jdhex+gdhex);
|
a1.append(wdhex+jdhex+gdhex);
|
String a2="000000006400000000000000000000000000000000000000";
|
a0.append(a2);
|
a1.append(a2);
|
byte[] byt2=toBytes(a1.toString());
|
String jiaoyanzhi=jiaoyan(byt2);
|
a0.append(jiaoyanzhi);
|
if(ac !=null) {
|
byte[] data=toBytes(a0.toString());
|
String ip=ac.getBaoliu1();//»ù×¼Õ¾µØÖ·
|
if(ip !=null) {
|
SendMessageToClient.send(data, ip);
|
ShowMessage.zidingyi_24(ip+":·¢Ëͳɹ¦");
|
}else {
|
ShowMessage.zidingyi_24("·¢ËÍʧ°Ü£¬ipµØÖ·´íÎó£º"+ip);
|
|
}
|
}
|
}
|
|
|
/**·¢ËÍÐÅÏ¢¸øURT±êÇ©*/
|
public static void sendmessage_to_urt(Jizhan jz,String a1) {
|
if(!Rtkac_manage.isPeizhijizhan()) {//µ±»ùÕ¾²»ÔÚÅäÖÃģʽʱºò
|
if(a1.length()>5) {
|
int size1=Dell_jizhan.getJizhan_vector().size();//»ñÈ¡²î·Ö»ù×¼Õ¾µÄÊýÁ¿
|
int size2=person_Dell.getPerson_vector().size();
|
for(int i=0;i<size2;i++) {
|
Person prs=person_Dell.getPerson_vector().get(i);
|
String onlie=prs.getP_online();
|
if(onlie.equals("0")) {//»ùÕ¾²»ÔÚÏß·µ»Ø
|
return;
|
}
|
if(size1==1) {
|
String ip=prs.getBaoliu8();//±êÇ©µ±Ç°µÄIPµØÖ·
|
byte[] data=toBytes(a1);
|
SendMessageToClient.send(data, ip);
|
}else {
|
String needbasid=prs.getNeedbaseid();
|
String jzacid=jz.getAcid();
|
if(needbasid.equals(jzacid)) {//Èç¹ûÈËÔ±ÔÚÏßͬʱÐèÒªµÄ»ùÕ¾IDµÈÓÚµ±Ç°»ùÕ¾ID
|
String ip=prs.getBaoliu8();//±êÇ©µ±Ç°µÄIPµØÖ·
|
byte[] data=toBytes(a1);
|
SendMessageToClient.send(data, ip);
|
//System.out.println(jzacid+"·¢Ëͳɹ¦"+ip+"needbasid"+needbasid);
|
}
|
}
|
}
|
}
|
}
|
}
|
|
|
public static boolean isJishi() {
|
return jishi;
|
}
|
|
|
|
/**½«¶È·ÖÃë¸ñʽתΪ¶È¸ñʽ*/
|
public static String todufen(String Du,String Fen,String Miao){
|
double strDu = Double.parseDouble(Du);
|
double strFen = Double.parseDouble(Fen) / 60;
|
double strMiao = Double.parseDouble(Miao) / 60;
|
double dufenmiao = strDu+strFen+strMiao;
|
String format = String.format("%.7f", dufenmiao);
|
return format;
|
}
|
|
public static byte[] intToRegisters(int v) {
|
byte[] registers = new byte[4];
|
registers[0] = (byte) (0xff & (v >> 24));
|
registers[1] = (byte) (0xff & (v >> 16));
|
registers[2] = (byte) (0xff & (v >> 8));
|
registers[3] = (byte) (0xff & v);
|
return registers;
|
}
|
|
/**½«intתΪ4×Ö½Ú16½øÖƵÍλÔÚǰ¸ßλÔÚºó*/
|
public static byte[] int2hex(int n) {
|
byte[] ba = new byte[4];
|
ba[0] = (byte)(n & 0xff);
|
ba[1] = (byte)((n>>8) & 0xff);
|
ba[2] = (byte)((n>>16) & 0xff);
|
ba[3] = (byte)((n>>24) & 0xff);
|
return ba;
|
}
|
|
/**½«×Ö½ÚÊý×éתΪ16½øÖÆ×Ö·û´®*/
|
public static String Bytes2HexString(byte[] b) {
|
String ret = "";
|
for (int i = 0; i < b.length; i++) {
|
String hex = Integer.toHexString(b[i] & 0xFF);
|
if (hex.length() == 1) {
|
hex = '0' + hex;
|
}
|
ret += hex.toUpperCase();
|
}
|
return ret;
|
}
|
|
|
|
/**УÑé*/
|
public static String jiaoyan(byte[] byt) {
|
String hexa=null;
|
//×Ö½ÚÊý×éתΪ16½øÖÆ×Ö·û´®/2ºóµÄ³¤¶È
|
int size=Bytes2HexString(byt).length()/2;
|
String[] hex=hex(Bytes2HexString(byt));
|
//ÇóºÍ
|
int CK_A=0;
|
int CK_B=0;
|
for(int i=0;i<size;i++) {
|
CK_A=CK_A+decodeHEX(hex[i]);
|
CK_B=CK_B+CK_A;
|
}
|
|
String a1= Integer.toHexString(CK_A);
|
String b1= Integer.toHexString(CK_B);
|
String cka=CK_AB(a1);
|
String ckb=CK_AB(b1);
|
hexa=cka+ckb;
|
return hexa;
|
|
}
|
|
public static String CK_AB(String a) {
|
String ck="";
|
int size=a.length();
|
if(size>=2) {
|
ck=a.substring(size-2, size);
|
}else if(size==1) {
|
ck=0+a;
|
}
|
return ck;
|
|
}
|
|
/**½«16½øÖÆ×Ö·û´®×ªÎªhex×Ö·û´®Êý×é2¸ö×Ö·û´®Ò»¸ö*/
|
public static String[] hex(String message) {
|
int size=message.length()/2;
|
String[] hex=new String[size];
|
for(int i=0;i<size;i++) {
|
hex[i]=message.substring(i*2, 2+i*2);
|
}
|
|
return hex;
|
}
|
|
/**16½øÖÆ×ªÎª10½øÖÆ*/
|
public static int decodeHEX(String hexs){
|
BigInteger bigint=new BigInteger(hexs, 16);
|
int numb=bigint.intValue();
|
return numb;
|
|
}
|
|
|
@Override
|
public void run() {
|
// TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
|
|
}
|
|
}
|