package com.wsm.common.util; public class DeviceUtil { public static String[] turnToArray(String replace) { String regex = "(.{2})"; replace = replace.replaceAll(regex, "$1,"); return replace.split(","); } public static String getOKFeedback(String[] str){ StringBuffer startBitBuffer = new StringBuffer(str[0]).append(str[1]).append(str[2]).append(str[3]); StringBuffer okBuffer = new StringBuffer(startBitBuffer).append(ByteUtil.numToHex16(11)).append(str[6]).append("00").append(ByteUtil.strTo16("OK")); okBuffer.append(ByteUtil.makeChecksum(okBuffer.toString())); return okBuffer.toString(); } public static String getErrFeedback(String[] str){ StringBuffer startBitBuffer = new StringBuffer(str[0]).append(str[1]).append(str[2]).append(str[3]); StringBuffer errorBuffer = new StringBuffer(startBitBuffer).append(ByteUtil.numToHex16(13)).append(str[6]).append("00").append(ByteUtil.strTo16("ERR")).append("00"); errorBuffer.append(ByteUtil.makeChecksum(errorBuffer.toString())); return errorBuffer.toString(); } public static String getYGDeviceID(String[] str){ return new StringBuffer(str[8]).append(str[9]).append(str[10]).append(str[11]).append(str[12]).append(str[13]).append(str[14]).append(str[15]).toString(); } public static String getJGDeviceID(String[] str){ return new StringBuffer(str[8]).append(str[7]).append(str[10]).append(str[9]).toString(); } public static String getFeedBackJGDeviceID(String[] str){ return new StringBuffer(str[7]).append(str[8]).append(str[9]).append(str[10]).toString(); } }