import struct import logging class Command0A: def __init__(self): self.command = 0x0A # 0AH命令码 def parse_0ah(self, data): """ 解析0AH遥测命令 :param data: 完整的0AH命令报文 :return: 解析后的字典或None """ try: # 验证基本帧格式 if len(data) < 14 or data[0:2] != b'JX' or data[2] != 0x0A: logging.warning("0AH命令帧格式不正确") return None # 提取桩号 pile_id_bytes = data[3:11] # 提取时间标识 time_bytes = data[14:20] year = time_bytes[0] + 2000 month, day, hour, minute, second = time_bytes[1:6] timestamp = f"{year:04d}-{month:02d}-{day:02d} {hour:02d}:{minute:02d}:{second:02d}" # 解析总体电气参数 current_index = 20 power_params = { "A相电压": struct.unpack("