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.

31 lines
1.1 KiB

2 years ago
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 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);
}
}
}