package monitorGas;
|
import java.math.BigInteger;
|
import java.util.Iterator;
|
|
import DataBase.DatabaseManagement;
|
import Method.BaoWenShow;
|
import Method.GetNowTime;
|
import Method.StringToHex;
|
import Netty.GroupChatServerHandler;
|
import PbuliClass.Get_Tb_Gass;
|
import PbuliClass.Get_collectors;
|
import PbuliClass.Music;
|
import PbuliClass.ShowMessage;
|
import VectroData.ForwardDatas;
|
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.Unpooled;
|
import tbDataModel.TbGas;
|
import tbDataModel.Tb_Collector;
|
import tbDataModel_Dell.Tb_Warnig_Dell;
|
import tcp.TcpClientOneToMany;
|
|
/**¶ÁÈ¡ÆøÌå´«¸ÐÆ÷Êý¾Ý*/
|
public class ReadGas {
|
static String strtip=null;//ÌáʾÐÅÏ¢
|
static String timetip=null;//ÌáʾÐÅÏ¢
|
static boolean waring=false;
|
static String prefix = "INSERT INTO tb_gas_history(macid,name,type,x,y,deep,waring,addtime) VALUES ";
|
static StringBuffer suffix = new StringBuffer(); // ±£´æsqlºó׺
|
static int jishu=0;
|
|
public static void read_gas() {
|
Iterator<Tb_Collector> it=Get_collectors.get_collectors().iterator();
|
while (it.hasNext()) {//µü´úÆ÷´æÔÚÔªËØ
|
Tb_Collector collec = it.next();//½«µü´úÆ÷ÀïÃæµÄÔªËØ¸øµ½info¼¯ºÏ
|
int gasip=collec.getMacid();
|
String ip=collec.getIp();
|
byte[] redagas=read_data2(gasip);
|
ByteBuf buf = Unpooled.wrappedBuffer(redagas);
|
if(GroupChatServerHandler.get_chanel(ip) !=null) {
|
GroupChatServerHandler.get_chanel(ip).writeAndFlush(buf);
|
BaoWenShow.show(GetNowTime.now()+"·¢£º "+ip+", "+redagas, "ÆøÌ屨ÎÄ","Ñ¡Ôñ±êÇ©");
|
}
|
}
|
}
|
|
/**
|
* 01 ´Ó»úµØÖ·
|
* 03 ¹¦ÄÜÂë
|
* 27 14 Êý¾ÝµØÖ·
|
* 00 50 ¶ÁÈ¡Êý¾Ý¸öÊý
|
* D5 CA CRC УÑé*/
|
public static byte[] redagas2() {
|
String hex="0103271400500F46";
|
byte[] byt=toBytes(hex);
|
return byt;
|
}
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
/** 01 03 48 00 08 00 00 00 00 00 00 00 00 00 03 BF 80 00 00 00 00 00 03 BF 80
|
00 00 00 00 00 03 BF 80 00 00 00 00 00 03 BF 80 00 00 00 00 00 03 BF 80 00 00 00
|
00 00 03 BF 80 00 00 00 00 00 03 BF 80 00 00 00 00 00 03 BF 80 00 00 08 2A
|
½âÎö£º
|
00 08 ΪÏÔʾͨµÀÊýÁ¿
|
00 00 ΪÐéÄâͨµÀÊýÁ¿
|
00 00 00 00 Ϊ±£Áô
|
00 00 00 03 ΪͨµÀ״̬
|
BF 80 00 00 Ϊ¸¡µãÊý-1£¬¼´ÎªÍ¨µÀ 1 µÄʵʱŨ¶È£¨-1 ±íʾ¹ÊÕÏ£©
|
|
ºóÃæÒÔ´ËÀàÍÆÎªÍ¨µÀ 2~8 µÄͨµÀ״̬¡¢ÊµÊ±Êý¾Ý¡£
|
**/
|
public static void dell_gas_data(String ip,String infom) {
|
|
|
BaoWenShow.show(GetNowTime.now()+"ÊÕ£º "+ip+", "+infom, "ÆøÌ屨ÎÄ","Ñ¡Ôñ±êÇ©");
|
|
int size=infom.length()/2;
|
String[] hex=StringToHex.hex(infom);
|
|
//Ö÷»úµØÖ·
|
int adress=Integer.parseInt(hex[0]);
|
|
//¹¦ÄÜÂë
|
String gongnengma=hex[1];
|
|
//Êý¾Ý³¤¶È
|
int lenth=Get_Tb_Gass.get_gasnum(adress);
|
|
//Ũ¶ÈÖµµÄ¼¯ºÏ
|
int[] nongduzhi=new int[lenth];//16,17,18,19
|
|
for(int i=0;i<lenth;i++) {
|
//Ũ¶ÈÖµ¸¡µãÊý
|
nongduzhi[i]=getnongdu(hex[15+i*8]+hex[16+i*8]+hex[17+i*8]+hex[18+i*8]);
|
int tongdao=i+1;
|
TbGas gas=Get_Tb_Gass.get_gas(String.valueOf(tongdao), ip);
|
if(gas==null) {
|
ShowMessage.zidingyi_24("ͨµÀ"+tongdao+"ÆøÌåÖµ²»´æÔÚ£¡ ipµØÖ·£º"+ip);
|
return;
|
}
|
|
String id=String.valueOf(gas.getId());
|
String type=gas.getGas_type();//ÆøÌåÀàÐÍ
|
String tong_dao=gas.getTong_dao();
|
String wei_zhi=gas.getWei_zhi();
|
String posx=gas.getX();
|
String posy=gas.getY();
|
int warning=Integer.parseInt(gas.getWaring_zhi());
|
warning(warning,type,nongduzhi[i],wei_zhi,tong_dao,ip, id,posx,posy);
|
|
}
|
|
|
}
|
|
/** 01 03 A0
|
0A 10 00 05 00 00 00 00
|
08 B0 00 05 40 4A 3D 71
|
19 50 00 05 41 A7 33 33
|
08 B0 00 05 00 00 00 00
|
0A 10 00 05 00 00 00 00
|
08 B0 00 05 00 00 00 00
|
19 50 00 05 41 A7 33 33
|
08 B0 00 05 00 00 00 00
|
0A 10 00 05 00 00 00 00
|
08 B0 00 05 00 00 00 00
|
19 50 00 05 41 A1 EB 85
|
08 B0 00 05 00 00 00 00
|
0A 10 00 05 00 00 00 00
|
08 B0 00 05 00 00 00 00
|
19 50 00 05 41 A7 33 33
|
08 B0 00 05 00 00 00 00
|
0A 10 00 05 00 00 00 00
|
08 B0 00 05 00 00 00 00
|
19 50 00 05 41 A7 33 33
|
08 B0 00 05 00 00 00 00
|
38 01 */
|
public static void dell_gas2_data(String ip,String infom) {
|
String[] hex=StringToHex.hex(infom);
|
|
//Ö÷»úµØÖ·
|
int adress=Integer.parseInt(hex[0]);
|
|
int tongdaonum=decodeHEX(hex[2])/8;
|
String msg=GetNowTime.now()+"ÊÕµ½£º"+tongdaonum+"¸öͨµÀÆøÌåÖµ\n"+ip+", "+infom;
|
BaoWenShow.show(msg, "ÆøÌ屨ÎÄ","Ñ¡Ôñ±êÇ©");
|
//¹¦ÄÜÂë
|
// String gongnengma=hex[1];
|
|
//Êý¾Ý³¤¶È
|
int lenth=Get_Tb_Gass.get_gasnum(adress);
|
|
//Ũ¶ÈÖµµÄ¼¯ºÏ
|
int[] nongduzhi=new int[lenth];//16,17,18,19
|
|
for(int i=0;i<lenth;i++) {
|
//Ũ¶ÈÖµ¸¡µãÊý
|
nongduzhi[i]=getnongdu(hex[7+i*8]+hex[8+i*8]+hex[9+i*8]+hex[10+i*8]);
|
int tongdao=i+1;
|
TbGas gas=Get_Tb_Gass.get_gas(String.valueOf(tongdao), ip);
|
if(gas==null) {
|
ShowMessage.zidingyi("ͨµÀ"+tongdao+"ÆøÌåÖµ²»´æÔÚ£¡ ipµØÖ·£º"+ip);
|
return;
|
}
|
|
String id=String.valueOf(gas.getId());
|
String type=gas.getGas_type();//ÆøÌåÀàÐÍ
|
String tong_dao=gas.getTong_dao();
|
String wei_zhi=gas.getWei_zhi();
|
String posx=gas.getX();
|
String posy=gas.getY();
|
int warning=Integer.parseInt(gas.getWaring_zhi());
|
warning(warning,type,nongduzhi[i],wei_zhi,tong_dao,ip, id,posx,posy);
|
|
}
|
}
|
|
|
/**
|
* 01 03 14
|
* 0000 0003
|
* 0001 0021
|
* 0000 0000
|
* 0000 0005
|
* 0100 0053 62B7
|
*/
|
public static void dell_gas2_data_new(String ip,String infom) {
|
String[] hex=StringToHex.hex(infom);
|
//Ö÷»úµØÖ·
|
int adress=Integer.parseInt(hex[0]);
|
int tongdao1=Integer.parseInt(hex[5]+hex[6]);
|
int tongdao2=Integer.parseInt(hex[9]+hex[10]);
|
int tongdao3=Integer.parseInt(hex[13]+hex[14]);
|
int tongdao4=Integer.parseInt(hex[17]+hex[18]);
|
int tongdao5=Integer.parseInt(hex[21]+hex[22]);
|
|
int tongdaonum=(Integer.parseInt(hex[2])-4)/2;
|
String msg=GetNowTime.now()+"ÊÕµ½£º"+tongdaonum+"¸öͨµÀÆøÌåÖµ\n"+ip+", "+infom;
|
BaoWenShow.show(msg, "ÆøÌ屨ÎÄ","Ñ¡Ôñ±êÇ©");
|
//¹¦ÄÜÂë
|
// String gongnengma=hex[1];
|
|
//Êý¾Ý³¤¶È
|
int lenth=Get_Tb_Gass.get_gasnum(adress);
|
|
//Ũ¶ÈÖµµÄ¼¯ºÏ
|
int[] nongduzhi={tongdao1,tongdao2,tongdao3,tongdao4,tongdao5,0,0};//16,17,18,19
|
|
for(int i=0;i<lenth;i++) {
|
//Ũ¶ÈÖµ¸¡µãÊý
|
;
|
int tongdao=i+1;
|
TbGas gas=Get_Tb_Gass.get_gas(String.valueOf(tongdao), ip);
|
if(gas==null) {
|
ShowMessage.zidingyi("ͨµÀ"+tongdao+"ÆøÌåÖµ²»´æÔÚ£¡ ipµØÖ·£º"+ip);
|
return;
|
}
|
|
String id=String.valueOf(gas.getId());
|
String type=gas.getGas_type();//ÆøÌåÀàÐÍ
|
String tong_dao=gas.getTong_dao();
|
String wei_zhi=gas.getWei_zhi();
|
String posx=gas.getX();
|
String posy=gas.getY();
|
int warning=Integer.parseInt(gas.getWaring_zhi());
|
warning(warning,type,nongduzhi[i],wei_zhi,tong_dao,ip, id,posx,posy);
|
|
}
|
}
|
|
|
|
public static int getnongdu(String a) {
|
int num=0;
|
if(a.length()>1) {
|
BigInteger b = new BigInteger(a,16);
|
float f = Float.intBitsToFloat(b.intValue());
|
String str = String.valueOf(f);//¸¡µã±äÁ¿aת»»Îª×Ö·ûbai´®str
|
int idx = str.lastIndexOf(".");//²éÕÒСÊýµãµÄλÖÃ
|
String strNum = str.substring(0,idx);//½ØÈ¡´Ó×Ö·û´®¿ªÊ¼µ½Ð¡ÊýµãλÖõÄ×Ö·û´®£¬¾ÍÊÇÕûÊý²¿·Ö
|
num=Integer.valueOf(strNum);//°ÑÕûÊý²¿·Öͨ¹ýInteger.valueof·½·¨×ª»»ÎªÊý×Ö
|
|
}
|
return num;
|
}
|
|
/**16½øÖÆ×ªÎª10½øÖÆ*/
|
public static int decodeHEX(String hexs){
|
BigInteger bigint=new BigInteger(hexs, 16);
|
int numb=bigint.intValue();
|
return numb;
|
|
}
|
|
/**ÆøÌåŨ¶È³¬¸ß»òÕß³¬µÍ±¨¾¯*/
|
public static void warning(
|
int warning,
|
String type,
|
int tdz,
|
String wei_zhi,
|
String tong_dao,
|
String collect_ip,
|
String id,
|
String posx,
|
String posy) {
|
String str=null;
|
String warning_state="Õý³£";
|
|
if(tdz>warning) {
|
warning_state="³¬¸ß";
|
strtip=wei_zhi+type+"Ũ¶ÈÖµ "+tdz+" ¹ý¸ß±¨¾¯£¡";
|
waring=true;
|
}
|
|
Get_Tb_Gass.alert_gas_status(id, warning_state);
|
|
if(GassWaringFrame.husuo && waring) {
|
timetip="±¨¾¯Ê±¼ä:"+GetNowTime.now();
|
new Music("systemFiles/voice/gaswarning.wav").start();//µ÷ÓÃÒôƵÎļþ
|
new GassWaringFrame("±¨¾¯ÐÅÏ¢");
|
GassWaringFrame.warningstr.setText(strtip);
|
Tb_Warnig_Dell.add_tb_warning("ÆøÌåŨ³¬¸ß", id, "δ´¦Àí", GetNowTime.now2());
|
GassWaringFrame.husuo=false;
|
waring=false;
|
}
|
|
|
//¸üÐÂtb_gasÊý¾Ý±íÊý¾Ý
|
|
Get_Tb_Gass.alert_gas_nongdu(id, String.valueOf(tdz),warning_state);
|
|
StringBuffer updateSQL=new StringBuffer("UPDATE tb_gas SET nong_du='"+tdz+
|
"',addtime='"+GetNowTime.now()+"',status='"+warning_state+
|
"'where ( collect_ip='"+collect_ip+"') and (tong_dao='"+tong_dao+"')");
|
DatabaseManagement.update(updateSQL.toString());
|
updateSQL=null;
|
|
str=" É豸±àºÅ£º"+id+" λÖãº"+wei_zhi+" IP£º"+collect_ip+" ÆøÌ壺"+type+" Ũ¶È£º"+tdz;
|
|
//Èç¹ûtcpµã»÷¿ªÊ¼²¢ÇÒÐÒéÀàÐÍΪTCPSERVER
|
BaoWenShow.show(GetNowTime.now()+"ÊÕ£º "+str, "ÆøÌ屨ÎÄ","Ñ¡Ôñ±êÇ©");
|
|
//TCPת·¢ÆøÌåÊý¾Ý´æÔÚ
|
if(ForwardDatas.have_tcp("ÆøÌåÊý¾Ý")) {
|
TcpClientOneToMany.send(str);
|
}
|
|
}
|
|
|
|
|
|
/**@param unitidÆøÌå²É¼¯ÒǵØÖ·
|
* @param refÆðʼµØÖ·Ò»°ãΪ1
|
*@param ¶ÁÈ¡µÄÊý¾Ý³¤¶ÈÓм¸¸ö´«¸ÐÆ÷¾Í¶Á¼¸*/
|
|
@SuppressWarnings("unused")
|
public static byte[] read_data(int unitid,int ref ,int num ) {
|
byte[] buf =new byte[8];
|
//É豸µØÖ·1¸ö×Ö½Ú
|
buf[0]=(byte) unitid;
|
//¹¦ÄÜÂë1¸ö×Ö½Ú
|
buf[1]=(byte) 0x03;
|
|
//¿ªÊ¼µØÖ·2¸ö×Ö½Ú
|
byte[] registers= intToRegisters(ref);
|
buf[2]=(byte)0x27;
|
buf[3]=(byte)0x10;
|
|
//¶ÁÈ¡ÊýÁ¿
|
byte[] registers1=intToRegisters(num);
|
buf[4]=(byte)0x00;
|
buf[5]=(byte)0x24;
|
//¼ÆËãcrcÊýÖµ
|
int crc[]=calculateCRC(buf, 0, buf.length-2);
|
buf[buf.length-2]=(byte)0x4E;
|
buf[buf.length-1]=(byte) 0xA0;
|
|
return buf;
|
}
|
|
/**
|
* 0103 0000 000A C5CD
|
* @param unitid
|
* @return
|
*/
|
public static byte[] read_data2(int unitid) {
|
byte[] buf =new byte[8];
|
//É豸µØÖ·1¸ö×Ö½Ú
|
buf[0]=(byte) unitid;
|
//¹¦ÄÜÂë1¸ö×Ö½Ú
|
buf[1]=(byte) 0x03;
|
|
//¿ªÊ¼µØÖ·2¸ö×Ö½Ú
|
buf[2]=(byte)0x00;
|
buf[3]=(byte)0x00;
|
|
//¶ÁÈ¡ÊýÁ¿
|
buf[4]=(byte)0x00;
|
buf[5]=(byte)0x0A;
|
|
buf[6]=(byte)0xc5;
|
buf[7]=(byte)0xcd;
|
|
return buf;
|
}
|
|
public static final 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;
|
}
|
|
|
public static final int[] calculateCRC(byte[] data, int offset, int len) {
|
int[] crc = {0xFF, 0xFF};
|
int nextByte = 0;
|
int uIndex; /* will index into CRC lookup*/ /* table */
|
/* pass through message buffer */
|
for (int i = offset; i < len && i < data.length; i++) {
|
nextByte = 0xFF & ((int) data[i]);
|
uIndex = crc[0] ^ nextByte; //*puchMsg++; /* calculate the CRC */
|
crc[0] = crc[1] ^ auchCRCHi[uIndex];
|
crc[1] = auchCRCLo[uIndex];
|
}
|
|
return crc;
|
}
|
|
/* Table of CRC values for high-order byte */
|
private final static short[] auchCRCHi = {
|
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
|
0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
|
0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
|
0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
|
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
|
0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
|
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
|
0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
|
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
|
0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,
|
0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
|
0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
|
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
|
0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,
|
0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
|
0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
|
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
|
0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
|
0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
|
0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
|
0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
|
0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,
|
0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
|
0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
|
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
|
0x80, 0x41, 0x00, 0xC1, 0x81, 0x40
|
};
|
|
/* Table of CRC values for low-order byte */
|
private final static short[] auchCRCLo = {
|
0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06,
|
0x07, 0xC7, 0x05, 0xC5, 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD,
|
0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09,
|
0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A,
|
0x1E, 0xDE, 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC, 0x14, 0xD4,
|
0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3,
|
0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3,
|
0xF2, 0x32, 0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35, 0x34, 0xF4,
|
0x3C, 0xFC, 0xFD, 0x3D, 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A,
|
0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38, 0x28, 0xE8, 0xE9, 0x29,
|
0xEB, 0x2B, 0x2A, 0xEA, 0xEE, 0x2E, 0x2F, 0xEF, 0x2D, 0xED,
|
0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26,
|
0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60,
|
0x61, 0xA1, 0x63, 0xA3, 0xA2, 0x62, 0x66, 0xA6, 0xA7, 0x67,
|
0xA5, 0x65, 0x64, 0xA4, 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F,
|
0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68,
|
0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA, 0xBE, 0x7E,
|
0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5,
|
0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71,
|
0x70, 0xB0, 0x50, 0x90, 0x91, 0x51, 0x93, 0x53, 0x52, 0x92,
|
0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C,
|
0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, 0x5A, 0x9A, 0x9B, 0x5B,
|
0x99, 0x59, 0x58, 0x98, 0x88, 0x48, 0x49, 0x89, 0x4B, 0x8B,
|
0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C,
|
0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42,
|
0x43, 0x83, 0x41, 0x81, 0x80, 0x40
|
};
|
|
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 bubbleSort(int[] arr) {
|
//Íâ²ãÑ»·ÓÃÀ´¿ØÖÆÊý×éÑ»·µÄȦÊý
|
for(int i=0;i<arr.length-1;i++) {
|
//ÄÚ²ãÑ»·ÓÃÀ´Íê³ÉÔªËØÖµ±È½Ï£¬°Ñ´óµÄÔªËØÖµ»¥»»µ½ºóÃæ
|
for(int j=0;j<arr.length-1-i;j++) {
|
if(arr[j] > arr[j+1]) {
|
int temp = arr[j];
|
arr[j] = arr[j+1];
|
arr[j+1] = temp;
|
}
|
}
|
}
|
}
|
|
}
|