from .components import * from .constants import * from ctypes import sizeof, string_at class MicroWaveParser: @classmethod def ParserFrame(cls, buffer: bytes) -> list: """ 解析完整的一帧数据,数据包括数据头,数据体,数据尾,返回点云数组 """ header = HeaderBlock(buffer[:sizeof(HeaderBlock)]) if HEADER_MAGIC == string_at(header.Magic, 8): footer = FooterBlock(buffer[-sizeof(FooterBlock):]) point_cloud = [] for i in range(header.NumberOfDetection): detection = DetectionBlock(header, footer, buffer[i * 8 + sizeof(HeaderBlock): (i + 1) * 8 + sizeof(HeaderBlock)]) point = (detection.X, detection.Y, detection.Z) point_cloud.append(point) return point_cloud else: return []