package com.sandu.ximon.admin.manager.iot.frame.inner.report; 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 lombok.Data; import lombok.ToString; /** * @author van * A7-81-44 * PLC 手动开关动作上报。0x00-全关,0x64-全开 */ @Data @ToString(callSuper = true) public class A7PlcManualLightSwitchReportInnerFrame extends BaseResponseInnerFrame { /** * 目标地址 2 */ private String destinationAddress; /** * 0x00-全关,0x64-全开 */ private String responseStatus; @Override public A7PlcManualLightSwitchReportInnerFrame 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)); setResponseStatus(hex.substring(12, hex.length() - 8)); setCrc32(hex.substring(hex.length() - 8)); // 校验CRC32 String frame = getFunctionCode() + getPayloadLength() + getDestinationAddress() + getResponseStatus(); this.setValidate(CRC32Utils.validateFrame(frame, getCrc32())); return this; } }