package com.sandu.ximon.admin.manager.iot.frame.inner.report;
|
|
import cn.hutool.core.util.HexUtil;
|
import cn.hutool.core.util.StrUtil;
|
import com.sandu.ximon.admin.manager.iot.frame.inner.BaseResponseInnerFrame;
|
import com.sandu.ximon.admin.manager.iot.rrpc.util.CRC32Utils;
|
import com.sandu.ximon.admin.utils.LogUtils;
|
import lombok.Data;
|
import lombok.ToString;
|
|
/**
|
* @author chenjiantian
|
* @date 2021/12/6 14:46
|
* A5-81-42
|
* 单灯上报ampq 故障码
|
*/
|
@Data
|
@ToString(callSuper = true)
|
public class A5LightErrorCodeReportInnerFrame extends BaseResponseInnerFrame<A5LightErrorCodeReportInnerFrame> {
|
|
/**
|
* 目标地址 2
|
*/
|
private String destinationAddress;
|
/**
|
* 故障码
|
*/
|
private int errorCode;
|
|
@Override
|
public A5LightErrorCodeReportInnerFrame transformFrame(String hex) {
|
if (StrUtil.isBlank(hex)) {
|
return null;
|
}
|
// MQTT通信方式(1)
|
setConnectType(hex.substring(0, 2));
|
// 功能码(1)
|
setFunctionCode(hex.substring(2, 4));
|
// 负荷长度(2)
|
setPayloadLength(hex.substring(4, 8));
|
|
setDestinationAddress(hex.substring(8, 12));
|
|
String errorCodeHex = hex.substring(12, 16);
|
errorCode = HexUtil.hexToInt(errorCodeHex);
|
System.out.println("故障码:"+ errorCodeHex +" - " + errorCode);
|
|
setCrc32(hex.substring(hex.length() - 8));
|
// 校验CRC32
|
String frame = getFunctionCode() + getPayloadLength() + getDestinationAddress() + getErrorCode();
|
this.setValidate(CRC32Utils.validateFrame(frame, getCrc32()));
|
return this;
|
}
|
}
|