* 比如,serial-channel提供的数据格式,是16进制格式的来表示通信报文,所以你要返回一个hex通信报文格式的String给外部
*/
@FoxEdgeOperate(name = "读取温湿度", polling = true, type = FoxEdgeOperate.encoder, timeout = 2000)
public static String packReadInputRegister(Map<String, Object> param) {
return (String) operateReadRegister("", param);
}
/**
* 解码函数
*
* @param hexString 该对象是由你使用的channnel从设备获得的报文,以hex格式文本输入给你。
* 如果你用的是其他channel,其他channel有自己的约定,那么你需要采用对应的格式。
* 目前各类channel支持的有常见的hexString,也有结构复杂一点的Map<String, Object>
*
* @param param 解码参数,它来自设备配置的参数和操作任务配置的参数的合并,到时候你知道该如何对设备返回报文进行解码
* @return 解码后的数据 必须为Map<String, Object>格式,表示一批key-value的设备数据对象和它的数值
*/
@FoxEdgeOperate(name = "读取温湿度", polling = true, type = FoxEdgeOperate.decoder, timeout = 2000)
public static Map<String, Object> unpackReadInputRegister(String hexString, Map<String, Object> param) {
return (Map<String, Object>) operateReadRegister(hexString, param);
}
}
#### [完整JAVA代码]( )
package cn.foxtech.device.protocol.zs.sht301t1h;
import cn.foxtech.device.protocol.core.annotation.FoxEdgeDeviceType;
import cn.foxtech.device.protocol.core.annotation.FoxEdgeOperate;
import cn.foxtech.device.protocol.core.exception.ProtocolException;
import cn.foxtech.device.protocol.core.utils.HexUtils;
import cn.foxtech.device.protocol.core.utils.MethodUtils;
import cn.foxtech.device.protocol.modbus.core.ModBusConstants;
import cn.foxtech.device.pro