fix: 继电器输出状态解析改为完整的 有/无 描述格式
旧格式: '存在信号; 脉冲信号' (仅显示置位的 bit) 新格式: '存在继电器有输出,脉冲继电器有输出' (始终显示两个 bit 的状态) bit 0 (x & 0x01): 存在继电器有/无输出 bit 1 (x & 0x02): 脉冲继电器有/无输出
This commit is contained in:
16
src/dg430.py
16
src/dg430.py
@@ -280,12 +280,16 @@ def decode_fault_info(fault: int) -> str:
|
||||
|
||||
|
||||
def decode_relay_info(relay: int) -> str:
|
||||
"""解码继电器 bitmask"""
|
||||
items = []
|
||||
for bit, desc in RELAY_BITS.items():
|
||||
if relay & (1 << bit):
|
||||
items.append(desc)
|
||||
return "; ".join(items) if items else "无输出"
|
||||
"""解码继电器输出状态为可读字符串
|
||||
|
||||
0xB2 继电器输出状态原始值 x 的解析规则:
|
||||
- x & 0x01 为真 → "存在继电器有输出",否则 "存在继电器无输出"
|
||||
- x & 0x02 为真 → "脉冲继电器有输出",否则 "脉冲继电器无输出"
|
||||
汇总格式: "存在继电器有输出,脉冲继电器有输出"
|
||||
"""
|
||||
exist = "存在继电器有输出" if (relay & 0x01) else "存在继电器无输出"
|
||||
pulse = "脉冲继电器有输出" if (relay & 0x02) else "脉冲继电器无输出"
|
||||
return f"{exist},{pulse}"
|
||||
|
||||
|
||||
# ─── 0x4A 获取设备版本号响应 ──────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user