package tbDataModel_Dell;
|
import java.util.Vector;
|
import java.util.regex.Pattern;
|
import BaoWen.Udp_Receive;
|
import Frame.S2Manage;
|
import Method.GetNowTime;
|
import PbuliClass.ShowMessage;
|
import PbuliClass.Systems;
|
import tbDataModel.S2data;
|
|
/**´¦ÀíÍøÂçÄ£¿é·µ»ØµÄÐÅÏ¢*/
|
public class DellS2 {
|
|
static String ip="255.255.255.255";
|
static String port="1500";
|
static Vector<S2data> row=new Vector<>();
|
static String mac="";
|
|
|
/**ËÑË÷ÃüÁî*/
|
public static void serch(String ip2) {
|
String data="FF010102";
|
ip=ip2;
|
byte[] byt=Tools.hexStrToBinaryStr(data);
|
Udp_Receive.udp_serch(byt, byt.length,ip,port);
|
|
}
|
|
/**´¦ÀíËÑË÷ÃüÁî·µ»ØµÄ½á¹û*/
|
public static void serch_fanhui(String hex) {
|
String[] hexs=gethex(hex);
|
String s2_ip=gi(hexs[5])+"."+gi(hexs[6])+"."+gi(hexs[7])+"."+gi(hexs[8]);;
|
String s2_mac=hexs[9]+hexs[10]+hexs[11]+hexs[12]+hexs[13]+hexs[14];
|
|
String s2_version1=hexs[18]+hexs[17]+hexs[16]+hexs[15];
|
String s2_version=gi(s2_version1)+"";
|
|
StringBuffer name=new StringBuffer();
|
for(int i=19;i<35;i++) {
|
name.append(hexs[i]);
|
}
|
|
String s2_name=toStringHex2(name.toString());
|
|
if(gets2(s2_mac) ==null) {
|
Vector<String> rowData=new Vector<>();
|
S2data s2=new S2data();
|
s2.setIp(s2_ip);
|
s2.setName(s2_name);
|
s2.setMac(s2_mac);
|
s2.setVersion(s2_version);
|
row.add(s2);
|
rowData.add(s2_ip);
|
rowData.add(s2_name);
|
rowData.add(s2_mac);
|
rowData.add(s2_version);
|
if(S2Manage.getTableModel() !=null) {
|
S2Manage.getTableModel().addRow(rowData);
|
}
|
|
}else {
|
gets2(s2_mac).setIp(s2_ip);
|
gets2(s2_mac).setName(s2_name);
|
gets2(s2_mac).setVersion(s2_version);
|
}
|
|
name=null;
|
hexs=null;
|
|
}
|
|
/**ͨ¹ýMACµØÖ·ÕÒµ½S2*/
|
public static S2data gets2(String mac) {
|
S2data s2=null;
|
if(row.size() !=0) {
|
for(int i=0;i<row.size();i++) {
|
S2data news2=row.get(i);
|
if(news2.getMac().equals(mac)) {
|
s2=news2;
|
break;
|
}
|
}
|
}
|
return s2;
|
}
|
|
|
public static String[] gethex(String hex) {
|
int lenth=hex.length()/2;
|
String[] hexs=new String[lenth];
|
for(int i=0;i<lenth;i++) {
|
hexs[i]=hex.substring(i*2, 2+i*2);
|
}
|
return hexs;
|
}
|
|
|
/**ת»¯Ê®Áù½øÖƱàÂëΪ×Ö·û´®*/
|
public static String toStringHex2(String s) {
|
byte[] baKeyword = new byte[s.length() / 2];
|
for (int i = 0; i < baKeyword.length; i++) {
|
try {
|
baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(
|
i * 2, i * 2 + 2), 16));
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
try {
|
s = new String(baKeyword, "gb2312");// UTF-16le:Not
|
} catch (Exception e1) {
|
e1.printStackTrace();
|
}
|
return s;
|
}
|
|
public static Vector<S2data> getRow() {
|
return row;
|
}
|
|
|
|
/**¶ÁÈ¡ÅäÖÃÐÅÏ¢
|
* @param typeÃüÁîÀàÐÍ
|
* @param lenth³¤¶È
|
* ·¢ËÍ(22 ×Ö½Ú FF 13 03 D8 B0 4C 46 35 CA 61 64 6D 69 6E 00 61 64 6D 69 6E 00 41 £¬
|
* ºÍУÑé 41 =13 + 03 + ... + 6E + 00 £¬µÚ 4 λµ½µÚ 9 λÊÇ S2 µÄ MAC µØÖ·£¬
|
* УÑéλǰµÄ×îºóµÄ 12 ¸ö×Ö½ÚΪ S2 µÄÓû§ÃûÓëÃÜÂ룬¾ùΪ 6 ×Ö½Ú£¬²»×㣬²¹ 0 ¡£*/
|
public static void reads2peizhi(byte type,String mac) {
|
byte[] buf =new byte[22];
|
byte[] buf1 =new byte[20];
|
//°üÍ·
|
buf[0]=(byte) 0xFF;
|
//Êý¾Ý³¤¶È
|
buf1[0]=(byte) 0x13;
|
|
//ÃüÁîÀàÐÍ1×Ö½Ú
|
buf1[1]=type;
|
|
//macµØÖ·6×Ö½Ú
|
byte[] bytmac=Tools.hexStrToBinaryStr(mac);
|
for(int i=0;i<6;i++) {
|
buf1[i+2]=bytmac[i];
|
}
|
|
//Óû§ÃûºÍÃÜÂë12×Ö½Úadmin,admin
|
byte[] bytnp=Tools.hexStrToBinaryStr("61 64 6D 69 6E 00 61 64 6D 69 6E 00");
|
for(int i=0;i<12;i++) {
|
buf1[i+8]=bytnp[i];
|
}
|
|
|
for(int i=0;i<buf1.length;i++) {
|
buf[i+1]=buf1[i];
|
}
|
|
//УÑéÂë
|
buf[21]=Jiaoyan.checkqiuhe(buf1)[0];
|
Udp_Receive.udp_serch(buf, buf.length,ip,port);
|
S2Manage.get_text_area().append(GetNowTime.now()+" ·¢: "+Tools.Bytes2HexString(buf)+"\n");
|
}
|
|
|
|
/**´¦Àí·µ»ØµÄ²ÎÊý£¬Ò»¹²ÊÇ576×Ö½Ú£¬·ÖΪ4¸ö°ü·µ»Ø£¬130×Ö½Ú»ù´¡²ÎÊý±í
|
* 50×Ö½Ú£¬85×Ö½Ú£¬302×Ö½Ú
|
* ·µ»ØµÄÊÇ´®¿Ú·þÎñÆ÷µÄËùÓвÎÊý£¬Ò»¹²ÊÇ576 ×Ö½Ú£¬²»´øÐ£Ñ飬ûÓÐÐÒ飬ֱ½Ó·µ»Ø²ÎÊý¡£
|
* ¶ÁÈ¡·½Ê½²Î¿¼¡°»ù´¡²ÎÊý±í¡±ºÍ¡°´®¿Ú²ÎÊý±í¡±ÒÔ¼°Í¸´«Ôƹ¦ÄÜ£¬ÐÄÌø×¢²á°ü¹¦ÄÜºÍ Httpd Client °üÍ· ÉèÖà ¡£
|
* ·ÖΪËĸö°ü·µ»Ø£¬·Ö±ðΪ 130 ×Ö½ÚºÍ 50 ×Ö½Ú£¬ 85 ×Ö½Ú£¬ 302 ×Ö½Ú ¡£
|
* »ØÓ¦¾ÙÀý£º95 63 03 00 00 00 50 00 00 07 00 A8 C0 01 00 A8 C0 00 FF FF FF 55
|
* 53 52 2D 54 43 50 32 33 322D 33 31 30 00 00 61 64 6D 69 6E 00 61 64 6D 69
|
* 6E 00 00 01 00 A4 AC CF 23 20 FE 10 00 00 00 00 00 0000 00 80 25 00 00 08
|
* ÃÜÂë´íÎó»ØÓ¦£ºFF 01 03 50 £¬·µ»ØµÄÊý¾ÝÊDz»´øÐ£ÑéµÄ¡£*/
|
public static void dell_readpeiz(String hex) {
|
int lenth=hex.length()/2;
|
String[] hexs=gethex(hex);
|
if(lenth==130) {
|
//IPµØÖ·
|
String s2_ip=gi(hexs[12])+"."+gi(hexs[11])+"."+gi(hexs[10])+"."+gi(hexs[9]);
|
|
//Íø¹Ø
|
String wangguan=gi(hexs[16])+"."+gi(hexs[15])+"."+gi(hexs[14])+"."+gi(hexs[13]);
|
|
//×ÓÍøÑÚÂë
|
String ziwang=gi(hexs[20])+"."+gi(hexs[19])+"."+gi(hexs[18])+"."+gi(hexs[17]);
|
|
//Ä£¿éÃû³Æ
|
String s2_name1=getname(21,35,hexs);
|
|
//Óû§Ãû
|
String s2_name2=getname(37,43,hexs);
|
|
//ÃÜÂë
|
String s2_name3=getname(43,49,hexs);
|
|
//²¨ÌØÂÊ
|
String botelv=gi(hexs[70]+hexs[69]+hexs[68]+hexs[67])+"";
|
|
//macµØÖ·
|
mac=hexs[53]+hexs[54]+hexs[55]+hexs[56]+hexs[57]+hexs[58];
|
|
//±¾µØ¶Ë¿Ú
|
String bendiport=gi(hexs[80]+hexs[79])+"";
|
|
//Ô¶³Ì¶Ë¿Ú
|
String port=gi(hexs[82]+hexs[81])+"";
|
|
//·þÎñÆ÷ipµØÖ·
|
String adress=getname(83,113,hexs);
|
|
//¹¤×÷·½Ê½
|
String type="TCP Client";
|
if(hexs[118].equals("00")) {
|
type="UDP-Client";
|
}else if(hexs[118].equals("01")) {
|
type="TCP-Client";
|
}else if(hexs[118].equals("02")) {
|
type="UDP-Server";
|
}else if(hexs[118].equals("03")) {
|
type="TCP-Server";
|
}else if(hexs[118].equals("04")) {
|
type="HTTPD Client";
|
}
|
|
S2data s2=gets2(mac);
|
|
if( s2!=null) {
|
s2.setIp(s2_ip);
|
s2.setWangguan(wangguan);
|
s2.setZiwang(ziwang);
|
s2.setShebeiid(s2_name1);
|
s2.setName(s2_name2);
|
s2.setPass(s2_name3);
|
s2.setAdress(adress);
|
s2.setPort(port);
|
s2.setModel(type);
|
s2.setBendiport(bendiport);
|
s2.setBotelv(botelv);
|
|
if(!S2Manage.isAlertall()) {
|
String udpoutport=s2.getBendiport();
|
String fuwuip=Pattern.compile("[^0-9]").matcher(adress).replaceAll("").trim();//·þÎñÆ÷ipµØÖ·
|
String fuwuip2=Pattern.compile("[^0-9]").matcher(Systems.sys().getUdpAdress()).replaceAll("").trim();//ϵͳÉèÖÃÖеķþÎñÆ÷IPµØÖ·
|
S2Manage.getJt_name().setText(s2.getName());
|
S2Manage.getJt_pass().setText(s2.getPass());
|
S2Manage.getJt_shebeiname().setText(s2.getShebeiid());
|
S2Manage.getJt_ip().setText(s2.getIp());
|
S2Manage.getJt_wangguan().setText(s2.getWangguan());
|
S2Manage.getJt_ziwang().setText(s2.getZiwang());
|
S2Manage.getJt_MAC().setText(mac);
|
S2Manage.getJt_bendiport().setText(s2.getBendiport());
|
S2Manage.getJt_botelv().setText(s2.getBotelv());
|
|
//Èç¹û±¾µØ¶Ë¿ÚºÍϵͳÉèÖõķ¢ËͶ˿ڲ»Ò»ÑùÔòÐèÒªÌáʾ
|
if(!udpoutport.equals(Systems.sys().getUdp_out())) {
|
ShowMessage.zidingyi_24("±¾µØ¶Ë¿Ú:"+udpoutport+"£¬ºÍϵͳÉèÖõÄUDP·¢ËͶ˿ڣº"+Systems.sys().getUdp_out()+
|
"²»Ò»Ö£¬ÇëÐ޸ģ¡");
|
}
|
|
S2Manage.getJt_port().setText(s2.getPort());
|
S2Manage.getJb_xieyi().setSelectedItem(s2.getModel());
|
S2Manage.getJt_fuwuip().setText(s2.getAdress());
|
|
//Èç¹û·þÎñÆ÷ipµØÖ·ºÍϵͳÉèÖõķþÎñÆ÷ipµØÖ·²»Ò»Ñù
|
if(!fuwuip.equals(fuwuip2) ){
|
ShowMessage.zidingyi_24("Ä¿±êip:"+adress+"£¬ºÍϵͳÉèÖ÷þÎñÆ÷µØÖ·£º"+Systems.sys().getUdpAdress()+
|
"²»Ò»Ö£¬ÇëÐ޸ģ¡");
|
}
|
}
|
}
|
}
|
|
}
|
|
|
/**½«16½øÖÆ×ªÎª10½øÖÆ*/
|
public static int gi(String hex){
|
int a1=Integer.parseInt(hex, 16);
|
return a1;
|
}
|
|
/**½«hexתΪASCLL*/
|
public static String getname(int start,int stop,String[] hexs) {
|
StringBuffer name=new StringBuffer();
|
for(int i=start;i<stop;i++) {
|
name.append(hexs[i]);
|
}
|
String s2_name=toStringHex2(name.toString());
|
return s2_name;
|
}
|
|
/**ÅäÖûù´¡²ÎÊýÍøÂçÉèÖÃ
|
* »ù´¡²ÎÊýÅäÖÃÖ¸Á
|
* »ù´¡ÉèÖÃÖ¸Áî¹²°üÀ¨67 ¸ö»ù´¡²ÎÊý¡£Îª¸üºÃÉèÖÃʹÓã¬
|
* ÌØ¾ÙÀýÈçÏ£º
|
* ·¢ËÍ£º FF 56 05 D8 B0 4C 46 35 CA61 64 6D 69 6E 00 61 64 6D 6 9 6E 00 95 63
|
* 03 00 00 00 50 00 00 07 00 A8 C0 01 00 A8 C0 00 FF FF FF55 53 52 2D 4B 32
|
* 00 00 00 00 00 00 00 00 00 00 61 64 6D 69 6E 00 61 64 6D 69 6E 00 00 01 00
|
* E0 D8B0 4C 46 35 CA 00 00 00 00 03 00 00 00 59 £¬
|
* УÑé×Ö½ÚÈÔΪºÍУÑéËã·¨ 59 = 56 + 05 + D8 + ... + 03µÚ 4 λµ½ µÚ 9 λÊÇ S2 µÄ MAC µØÖ·£¬
|
* 10 λµ½ 22 λÊÇÓû§Ãû + ÃÜÂ룬ºóÃæµÄ×Ö½Ú¾ÍÊǹ̶¨³¤¶ÈµÄ»ù´¡ÅäÖòÎÊý£¬×îºóÒ»¸ö×Ö½ÚΪºÍУÑé×Ö½Ú¡£*/
|
public static void alert_s2(String ips,String wangguan,String ziwang,String mokuaiid,String macid) {
|
byte[] buf =new byte[89];
|
byte[] buf1 =new byte[87];
|
//°üÍ·
|
buf[0]=(byte) 0xFF;
|
//Êý¾Ý³¤¶È
|
buf1[0]=(byte) 0x56;
|
|
//ÃüÁîÀàÐÍ1×Ö½Ú
|
buf1[1]=(byte) 0x05;
|
|
//macµØÖ·6×Ö½Ú£¬µÚ4µ½µÚ9λ
|
byte[] bytmac=Tools.hexStrToBinaryStr(mac);
|
if(S2Manage.isAlertall()) {
|
bytmac=Tools.hexStrToBinaryStr(macid);
|
}
|
|
for(int i=0;i<6;i++) {
|
buf1[i+2]=bytmac[i];
|
}
|
|
//Óû§ÃûºÍÃÜÂë12×Ö½Úadmin,admin£¬µÚ10µ½22λ
|
byte[] bytnp=Tools.hexStrToBinaryStr("61 64 6D 69 6E 00 61 64 6D 69 6E 00");
|
for(int i=0;i<12;i++) {
|
buf1[i+8]=bytnp[i];
|
}
|
|
//Ô¤Áô°üÍ·
|
buf1[20]=(byte) 0x95;
|
|
//Ô¤Áô°üÍ·2
|
buf1[21]=(byte) 0x63;
|
|
//Ô¤Áô°üÍ·3
|
buf1[22]=(byte) 0x03;
|
|
//ucFlags
|
buf1[23]=(byte) 0x90;
|
|
//usLocationURLport
|
buf1[24]=(byte) 0x00;
|
buf1[25]=(byte) 0x00;
|
|
//HTTP·þÎñ¶Ë¿ÚusHTTPServerPort
|
buf1[26]=(byte) 0x50;
|
buf1[27]=(byte) 0x00;
|
|
//ucUserFlag²»ÆðÓÃÔ¤ÁôÐÒé
|
buf1[28]=(byte) 0x00;
|
|
//¾²Ì¬IPµØÖ·4¸ö×Ö½Ú
|
for(int i=0;i<4;i++) {
|
buf1[29+i]=getip(ips)[i];
|
}
|
|
//Íø¹Ø4¸ö×Ö½Ú
|
for(int i=0;i<4;i++) {
|
buf1[33+i]=getip(wangguan)[i];
|
}
|
|
//×ÓÍøÑÚÂë4¸ö×Ö½Ú
|
for(int i=0;i<4;i++) {
|
buf1[37+i]=getip(ziwang)[i];
|
}
|
|
//Ä£¿éÃû³Æ14¸ö×Ö½Ú
|
for(int i=0;i<14;i++) {
|
buf1[41+i]=idname(mokuaiid)[i];
|
}
|
|
//Ô¤Áô2×Ö½Ú
|
buf1[55]=(byte) 0x00;
|
buf1[56]=(byte) 0x00;
|
|
//Óû§Ãû£¬ÃÜÂë
|
byte[] namepass=Tools.hexStrToBinaryStr("61 64 6D 69 6E 00 61 64 6D 69 6E 00");
|
for(int i=0;i<12;i++) {
|
buf1[i+57]=namepass[i];
|
}
|
|
//Ô¤ÁôucNetSendTime
|
buf1[69]=(byte) 0x00;
|
|
//uiId
|
buf1[70]=(byte) 0x01;
|
buf1[71]=(byte) 0x00;
|
|
//UCTIYPE
|
buf1[72]=(byte) 0x80;
|
|
//macµØÖ·
|
byte[] mac1=Tools.hexStrToBinaryStr(macid);
|
for(int i=0;i<6;i++) {
|
buf1[i+73]=mac1[i];
|
}
|
|
//DNS·þÎñÆ÷µØÖ·
|
byte[] data1=Tools.hexStrToBinaryStr("DE DE 43 D0 03 00 00 00");
|
for(int i=0;i<8;i++) {
|
buf1[i+79]=data1[i];
|
}
|
|
|
for(int i=0;i<buf1.length;i++) {
|
buf[i+1]=buf1[i];
|
}
|
|
//УÑéÂë
|
buf[88]=Jiaoyan.checkqiuhe(buf1)[0];
|
|
Udp_Receive.udp_serch(buf, buf.length,ip,port);
|
|
}
|
|
/**´®¿Ú²ÎÊýÅäÖÃ
|
* ÓÃÀ´ÅäÖÃÍø¿Ú¼°´®¿ÚµÄÖÚ¶à²ÎÊý£¬¹²ÓÐ63 ¸ö×Ö½Ú£¬Òò´ËÕâÌõÃüÁîµÄÖØÒªÐÔ²»ÑÔ¶øÓ÷¡£
|
* ÏÂÃæ¾ÙÀý˵Ã÷¸ÃÃüÁîµÄʹÓ㺷¢ËÍ£¨ 63 ×Ö½Ú£©£º
|
*FF 52 06 D8 B0 4C 46 35 CA 61 64 6D 69 6E 00 61 64 6D 69 6 E 00 00 C2 01 00
|
*08 01 01 01 00 00 00 00 8C 4E 2A 20 31 39 32 2E 31 36 38 2E 31 2E 31 33 33
|
*00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 85 01 A8 C0 01 03 00 04
|
*10 0E 00 00 00 00 00 00 00 16 £¬Ð£Ñé×Ö½ÚËã·¨16 = 52 + 06 + ... + 00 £»
|
*µÚ 4 λµ½µÚ 9 λÊÇ S2 µÄ MAC µØÖ·£¬ 10 λµ½ 22 λÊÇÓû§Ãû + ÃÜÂë£¬ËæºóµÄÊǶ˿ڲÎÊý + 1 ×Ö½ÚºÍУÑéλ¡£*/
|
public static void alert_s2_chuankou(String adress,String macid,String model,String mbport,String botelv) {
|
byte[] buf =new byte[85];
|
byte[] buf1 =new byte[83];
|
//°üÍ·
|
buf[0]=(byte) 0xFF;
|
//Êý¾Ý³¤¶È
|
buf1[0]=(byte) 0x52;
|
|
//ÃüÁîÀàÐÍ1×Ö½Ú
|
buf1[1]=(byte) 0x06;
|
|
//macµØÖ·6×Ö½Ú£¬µÚ4µ½µÚ9λ
|
byte[] bytmac=Tools.hexStrToBinaryStr(macid);
|
for(int i=0;i<6;i++) {
|
buf1[i+2]=bytmac[i];
|
}
|
|
//Óû§ÃûºÍÃÜÂë12×Ö½Úadmin,admin£¬µÚ10µ½22λ
|
byte[] bytnp=Tools.hexStrToBinaryStr("61 64 6D 69 6E 00 61 64 6D 69 6E 00");
|
for(int i=0;i<12;i++) {
|
buf1[i+8]=bytnp[i];
|
}
|
|
|
//Ô¶³Ì¶Ë¿Ú֮ǰµÄ²ÎÊý0-13×Ö½Ú
|
String b0="00 C2 01 00";
|
if(botelv.equals("921600")) {
|
b0="00 10 0E 00";
|
}
|
String a1=b0+" 08 01 01 01 00 00 00 00 29 20";
|
byte[] data1=Tools.hexStrToBinaryStr(a1);
|
for(int i=0;i<14;i++) {
|
buf1[i+20]=data1[i];
|
}
|
|
//Ô¶³Ì¶Ë¿Ú
|
int pot=Integer.parseInt(mbport);
|
buf1[34]=intToRegisters(pot)[3];
|
buf1[35]=intToRegisters(pot)[2];
|
|
//·þÎñÆ÷IPµØÖ·ÉèÖÃ
|
for(int i=0;i<30;i++) {
|
buf1[36+i]=adress(adress)[i];
|
}
|
|
//·þÎñÆ÷ºóµÄ×Ö½Ú17
|
|
String a="64 01 A8 C0 20 "+model+" 00 04 10 0E 00 00 00 00 00 00 00";
|
|
byte[] data2=Tools.hexStrToBinaryStr(a);
|
for(int i=0;i<17;i++) {
|
buf1[i+66]=data2[i];
|
}
|
|
|
|
for(int i=0;i<buf1.length;i++) {
|
buf[i+1]=buf1[i];
|
}
|
|
//УÑéÂë
|
buf[84]=Jiaoyan.checkqiuhe(buf1)[0];
|
Udp_Receive.udp_serch(buf, buf.length,ip,port);
|
|
}
|
|
|
/**½«IPµØÖ·×ªÎª×Ö½ÚÊý×é*/
|
public static byte[] getip(String ipss) {
|
byte[] byt=null;
|
if(ipss !=null) {
|
byt=new byte[4];
|
String[] ips=ipss.split("\\.");
|
String hex3= Integer.toHexString(Integer.parseInt(ips[3]));
|
if(hex3.length()<2) {
|
hex3="0"+hex3;
|
}
|
String hex2= Integer.toHexString(Integer.parseInt(ips[2]));
|
if(hex2.length()<2) {
|
hex2="0"+hex2;
|
}
|
String hex1= Integer.toHexString(Integer.parseInt(ips[1]));
|
if(hex1.length()<2) {
|
hex1="0"+hex1;
|
}
|
String hex0= Integer.toHexString(Integer.parseInt(ips[0]));
|
if(hex0.length()<2) {
|
hex0="0"+hex0;
|
}
|
String hex=hex3+hex2+hex1+hex0;
|
byt=Tools.hexStrToBinaryStr(hex);
|
|
}
|
return byt;
|
}
|
|
/**ASCLLתΪHEX*/
|
private static String asciiToHex(String asciiStr) {
|
char[] chars = asciiStr.toCharArray();
|
StringBuilder hex = new StringBuilder();
|
for (char ch : chars) {
|
hex.append(Integer.toHexString((int) ch));
|
}
|
return hex.toString();
|
}
|
|
/**Ä£¿éÃû³Æ×ªÎª×Ö½ÚÊý×é*/
|
public static byte[] idname(String name) {
|
StringBuffer hexstr=new StringBuffer(asciiToHex(name));
|
int size=hexstr.length();
|
if(size<28) {
|
for(int i=0;i<(28-size);i++) {
|
hexstr.append("0");
|
}
|
}
|
byte[] byt=Tools.hexStrToBinaryStr(hexstr.toString());
|
|
return byt;
|
}
|
|
/**·þÎñÆ÷µØÖ·Ãû³Æ×ªÎª×Ö½ÚÊý×é*/
|
public static byte[] adress(String name) {
|
StringBuffer hexstr=new StringBuffer(asciiToHex(name));
|
int size=hexstr.length();
|
if(size<60) {
|
for(int i=0;i<(60-size);i++) {
|
hexstr.append("0");
|
}
|
}
|
byte[] byt=Tools.hexStrToBinaryStr(hexstr.toString());
|
|
return byt;
|
}
|
|
/**ÐÞ¸ÄËùÓÐS2µÄÐÅÏ¢
|
* @param ip S2µÄ¾²Ì¬IPµØÖ·
|
* @param wangguanÍø¹ØµØÖ·
|
* @param adress·þÎñÆ÷µÄµØÖ·*/
|
public static void alertall_S2(String ipd,String wangguan,String adress,String port,String botelv) {
|
|
for(int i=0;i<row.size();i++) {
|
S2data s2=row.get(i);
|
String macid=s2.getMac();
|
String ip1=s2.getIp();
|
String ziwang=s2.getZiwang();
|
String mokuaiid=s2.getShebeiid();
|
String adress1=s2.getAdress();
|
String model="00";
|
if(s2.getModel().equals("TCP-Client")) {
|
model="01";
|
}
|
|
|
if(ip1==null) {
|
ShowMessage.zidingyi(macid+"ûÓÐÐ޸ijɹ¦£¡");
|
return;
|
}
|
|
//Èç¹ûÐÞ¸ÄÄ¿±êipµØÖ·±»Ñ¡ÖÐÖ»ÐÞ¸ÄÄ¿±êip
|
if(!adress.equals("1") && wangguan.equals("1") && ipd.equals("1")) {
|
if(!adress1.equals(adress) ){
|
DellS2.alert_s2_chuankou(adress,macid,model,port,botelv);
|
}
|
|
//¶¼ÐÞ¸Ä
|
}else if(!adress.equals("1") && !wangguan.equals("1") && !ipd.equals("1")) {
|
|
String[] ips=ipd.split("\\.");
|
String[] ip1s=ip1.split("\\.");
|
ip1=ip1s[0]+"."+ip1s[1]+"."+ips[2]+"."+ip1s[3];
|
DellS2.alert_s2(ip1, wangguan, ziwang, mokuaiid, macid);
|
|
if(!adress1.equals(adress) ){
|
DellS2.alert_s2_chuankou(adress,macid,model,port,botelv);
|
}
|
|
ips=null;
|
ip1s=null;
|
|
//Ö»ÐÞ¸ÄÍø¹ØºÍÄ¿±êip
|
}else if(!adress.equals("1") && !wangguan.equals("1") && ipd.equals("1")) {
|
DellS2.alert_s2(ip1, wangguan, ziwang, mokuaiid, macid);
|
DellS2.alert_s2_chuankou(adress,macid,model,port,botelv);
|
}
|
|
}
|
|
}
|
|
/**»ñÈ¡ËùÓÐS2µÄÐÅÏ¢*/
|
public static void getalls2() {
|
if(row.size() !=0) {
|
for(int i=0;i<row.size();i++) {
|
S2data s2=row.get(i);
|
reads2peizhi((byte)0x03,s2.getMac());
|
}
|
}
|
}
|
|
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;
|
}
|
}
|