| | |
| | | import io.netty.buffer.ByteBufAllocator; |
| | | import io.netty.buffer.ByteBufUtil; |
| | | import lombok.Data; |
| | | |
| | | import java.nio.charset.StandardCharsets; |
| | | import org.springframework.cache.annotation.SpringCacheAnnotationParser; |
| | | |
| | | /** |
| | | * 心跳 pac |
| | |
| | | @Data |
| | | public class Fire_3030 implements IMessageBody { |
| | | |
| | | /** |
| | | * 机器号 |
| | | */ |
| | | private Integer no; |
| | | |
| | | /** |
| | | * 回路 |
| | | */ |
| | | private Integer loop; |
| | | |
| | | /** |
| | | * 部位号 |
| | | */ |
| | | private Integer partNo; |
| | | |
| | | private Integer year; |
| | | |
| | |
| | | // byteBuf.release(); |
| | | // System.out.println(byteBuf.refCnt()); |
| | | this.no = analyze(new byte[]{bytes[3], bytes[4]}); |
| | | this.loop = analyze(new byte[]{bytes[5], bytes[6]}); |
| | | this.partNo = analyze(new byte[]{bytes[7], bytes[8]}); //0100201 对应 30 31 0200201 对应 34 35 |
| | | this.year = analyze(new byte[]{bytes[11], bytes[12]}); |
| | | this.month = analyze(new byte[]{bytes[13], bytes[14]}); |
| | | this.day = analyze(new byte[]{bytes[15], bytes[16]}); |
| | |
| | | } |
| | | |
| | | public static Integer analyze(byte[] bytes) { |
| | | return Integer.parseInt(new String(bytes, StandardCharsets.US_ASCII), 16); |
| | | return Integer.parseInt(Integer.toString(bytes[0] & 0x0F, 16) + Integer.toString(bytes[1] & 0x0F, 16), 16); |
| | | } |
| | | |
| | | } |