From def1eb8623e1444164ae4bce9179d011a89b8c5e Mon Sep 17 00:00:00 2001 From: 严智鑫 <test> Date: 星期二, 03 十二月 2024 09:15:27 +0800 Subject: [PATCH] 现场对接批量更新 --- JiuMuMesParent/common/servicebase/src/main/java/com/mes/utils/HexUtil.java | 53 ----------------------------------------------------- 1 files changed, 0 insertions(+), 53 deletions(-) diff --git a/JiuMuMesParent/common/servicebase/src/main/java/com/mes/utils/HexUtil.java b/JiuMuMesParent/common/servicebase/src/main/java/com/mes/utils/HexUtil.java index 861aaa7..d6854c9 100644 --- a/JiuMuMesParent/common/servicebase/src/main/java/com/mes/utils/HexUtil.java +++ b/JiuMuMesParent/common/servicebase/src/main/java/com/mes/utils/HexUtil.java @@ -262,59 +262,6 @@ return String.format("%4s", HexString).replace(' ', '0'); } - public static void main(String[] args) { -// System.out.println(HexUtil.hexToAscii("3c5354413e48656c6c6f20576f726c64217c5468697320697320746865206669727374207369676e616c2066726f6d20646576696365213c454f463e")); -// System.out.println(HexUtil.asciiToHex("<STA>Hello World!|This is the first signal from device!<EOF>")); -// -// System.out.println(String.format("%4S", HexUtil.intToHex(55)).replace(' ', '0')); -// System.out.println(HexUtil.hexToInt("00d2")); -// -// System.out.println(HexUtil.formatHex("3c5354413e")); - String message = "Hello World!|This is the first signal from device!"; - int length = message.length() * 2 + 10; // 闀垮害鍖呮嫭缁撳熬鐨�<EOF>锛屼竴涓瓧绗﹀湪淇″彿涓敱涓や釜瀛楄妭琛ㄧず銆� - - String command = HexUtil.asciiToHex("<STA>"); // 娣诲姞寮�濮嬫爣璇� - - command += (String.format("%4s", HexUtil.intToHex(length)).replace(' ', '0')); // 娣诲姞闀垮害鏍囪瘑 - command += "01"; // 娣诲姞璁惧绫诲瀷 0x01琛ㄧず鍒囧壊鏈猴紝0x02琛ㄧず閽㈠寲鐐� - command += "0001"; // 娣诲姞璁惧鍨嬪彿锛�0x0001琛ㄧず鍩烘湰娆撅紝0x0002琛ㄧず涓骇娆� - command += "0000"; // 鍔熻兘鍙凤紝0x0000鏄笅浣嶆満涓诲姩鍙戠粰涓婁綅鏈猴紱0x0001鏄笂浣嶆満淇敼涓嬩綅鏈篟TC - command += "00"; // 鍔犲瘑鏂瑰紡锛�0x00琛ㄧず涓嶅姞瀵� - - Calendar c = Calendar.getInstance(); - - // 娣诲姞鏃堕棿锛屽苟灏嗘椂闂磋浆鎹负16杩涘埗琛ㄧず - command += (String.format("%4s", HexUtil.intToHex(c.get(Calendar.YEAR))).replace(' ', '0')); - command += (String.format("%2s", HexUtil.intToHex(c.get(Calendar.MONTH) + 1)).replace(' ', '0')); - command += (String.format("%2s", HexUtil.intToHex(c.get(Calendar.DAY_OF_MONTH))).replace(' ', '0')); - command += (String.format("%2s", HexUtil.intToHex(c.get(Calendar.HOUR_OF_DAY))).replace(' ', '0')); - command += (String.format("%2s", HexUtil.intToHex(c.get(Calendar.MINUTE))).replace(' ', '0')); - command += (String.format("%2s", HexUtil.intToHex(c.get(Calendar.SECOND))).replace(' ', '0')); - - command += ("00000001"); // 鍞竴鏍囪瘑锛屼娇鐢ㄥ簭鍒楀彿 - - command += (HexUtil.asciiToHex(message)); // 娣诲姞涓昏淇℃伅鍐呭 - - command += (HexUtil.asciiToHex("<EOF>")); // 娣诲姞缁撳熬鏍囪瘑 - - System.out.println(command); - - System.out.println(String.format("%4s", "1")); - - Date time = new Date(); - System.out.println(new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss").format(time)); - - String timeHex = timeToHex(time); - System.out.println(timeHex); - System.out.println(hexToTime(timeHex)); - - System.out.println("3c5354413e001a00000000000000000000000000010007e0021500152800000000000000005041001d017c017c01017c3c454f463e".length()); - - System.out.println(hexToBinary("0c0a")); - - System.out.println(Integer.MAX_VALUE); - } - public static String hexTo2Binary(String hexString) { String binaryString = Integer.toBinaryString(hexToInt(hexString)); return String.format("%8s", binaryString).replace(' ', '0'); -- Gitblit v1.8.0