public class ValueEncoder extends Object
| 构造器和说明 |
|---|
ValueEncoder() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
byteArray2HexString(byte[] arrBytes,
int count,
boolean blank)
将数组转换为16进制文本
|
static String |
byteArrayToHexString(byte[] array)
将数值转换为十六进制文本格式
|
static int |
byteArrayToInt(byte[] bytes)
将报文转换为整数
|
static short |
byteArrayToShort(byte[] bytes)
将报文转换为short
|
static Date |
decodeCP56Time2a(byte[] dataByte)
CP56Time2a的解码
|
static Map<Integer,byte[]> |
decodeInfoBody(byte[] data,
int infoSize)
分拆连续性的信息体
|
static byte[] |
encodeCP56Time2a(Date date)
CP56Time2a的编码
|
static byte[] |
encodeInfoBody(int address,
List<byte[]> bodys)
连续性的信息体
格式特点:【地址(3字节)】+【数据1】+【数据2】+【数据3】......
|
static byte[] |
encodeInfoBody(Map<Integer,byte[]> bodys)
非连续性的信息体
格式特点:【地址1(3字节)+数据1】+【地址2(3字节)+数据2】+【地址3(3字节)+数据3】......
|
static byte[] |
getByte(byte[] bytes,
int start,
int length)
返回指定位置的数组
|
static byte[] |
hexStringToBytes(String hexStr)
十六进制字符串转换成byte数组
|
static byte[] |
intToByteArray(int i)
将整数转换为报文
|
static byte[] |
shortToByteArray(short val)
将short转换为报文
|
public static byte[] encodeInfoBody(int address,
List<byte[]> bodys)
address - 地址bodys - 已经经过编码的数据public static byte[] encodeInfoBody(Map<Integer,byte[]> bodys)
bodys - 已经经过编码的数据public static Map<Integer,byte[]> decodeInfoBody(byte[] data, int infoSize)
data - 报文数据infoSize - 每个信息体的尺寸大小public static byte[] encodeCP56Time2a(Date date)
date - 报文数据public static Date decodeCP56Time2a(byte[] dataByte)
dataByte - 报文编码public static byte[] intToByteArray(int i)
i - 整数public static byte[] shortToByteArray(short val)
val - 参数public static int byteArrayToInt(byte[] bytes)
bytes - 报文public static short byteArrayToShort(byte[] bytes)
bytes - 报文public static String byteArrayToHexString(byte[] array)
array - 数组public static String byteArray2HexString(byte[] arrBytes, int count, boolean blank)
arrBytes - 二进制报文count - 部分数据的长度blank - 大小写public static byte[] getByte(byte[] bytes,
int start,
int length)
bytes - 数据start - 开始位置length - 截取长度public static byte[] hexStringToBytes(String hexStr)
hexStr - 16进制文本Copyright © 2024. All rights reserved.