You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.4 KiB

package UnitTest;
import com.dsideal.FengHuang.Util.SocketUtil;
public class SocketUtilTest {
public static void Open(String host, int port, String sb_id) throws Exception {
//开
String hexData = "16 00 34 F5 41 11 FE 82 0D 02 ? 00 00 00 00 00 00 01 00 00 01".replace("?", sb_id).replace(" ", "");
SocketUtil sender = new SocketUtil(host, port);
sender.sendHexData(hexData);
}
public static void Close(String host, int port, String sb_id) throws Exception {
//关
String hexData = "16 00 34 F5 41 11 FE 82 0D 02 ? 00 00 00 00 00 00 01 00 00 00".replace("?", sb_id).replace(" ", "");
SocketUtil sender = new SocketUtil(host, port);
sender.sendHexData(hexData);
}
public static void getList(String host, int port) throws Exception {
//String gateWay = "1141f534";
String hexData = "08 00 34 f5 41 11 FE 81";
hexData=hexData.replace(" ","");
SocketUtil sender = new SocketUtil(host, port);
sender.sendHexData(hexData);
}
public static void main(String[] args) throws Exception {
String HOST = "10.10.21.18";
int PORT = 8001;
String sb_id = "6D FF";
for (int i = 1; ; i++) {
if (i % 2 == 1) Open(HOST, PORT, sb_id);
else Close(HOST, PORT, sb_id);
Thread.sleep(1000);
}
// getList(HOST,PORT);
}
}