|
|
@@ -331,7 +331,12 @@ class Model:
|
|
|
explanation["summary"] = "单板返回全量状态、各通道温度与限位信息"
|
|
|
state = self.state(payload)
|
|
|
if not self.motor:
|
|
|
- fields.append(f"PTC 生效占空比 (24路): {state.get('ptc', [])}")
|
|
|
+ ptc_duties = state.get("ptc", [])
|
|
|
+ fields.append(f"PTC 生效占空比 (共 24 路):")
|
|
|
+ for chunk_idx in range(0, len(ptc_duties), 8):
|
|
|
+ chunk = ptc_duties[chunk_idx : chunk_idx + 8]
|
|
|
+ chunk_str = " | ".join(f"PTC{chunk_idx+j:02d}: {val}%" for j, val in enumerate(chunk))
|
|
|
+ fields.append(f" {chunk_str}")
|
|
|
fields.append(f"Front 生效占空比 (4路): {state.get('front', [])}")
|
|
|
fields.append(f"Rear 生效占空比 (4路): {state.get('rear', [])}")
|
|
|
else:
|
|
|
@@ -529,6 +534,9 @@ def run_gui(product: str) -> int:
|
|
|
lbl_realtime_stat = ttk.Label(stat_summary_frame, text="等待查询或接收单板响应...", font=("", 10))
|
|
|
lbl_realtime_stat.pack(anchor="w")
|
|
|
|
|
|
+ lbl_realtime_ptc = ttk.Label(stat_summary_frame, text="【PTC 生效占空比】: 待查询", font=("Consolas", 9), foreground="#003366")
|
|
|
+ lbl_realtime_ptc.pack(anchor="w", pady=2)
|
|
|
+
|
|
|
# Serial Log area
|
|
|
log_frame = ttk.LabelFrame(tab_serial, text="通信原始报文日志 (TX / RX 流)", padding=8)
|
|
|
log_frame.pack(fill="both", expand=True, pady=6)
|
|
|
@@ -568,13 +576,40 @@ def run_gui(product: str) -> int:
|
|
|
for grp, cnt, default in model.groups():
|
|
|
frame_grp = ttk.LabelFrame(tab_set, text=f"{grp} 通道 ({cnt} 路)", padding=6)
|
|
|
frame_grp.pack(fill="x", pady=4)
|
|
|
+
|
|
|
+ grp_vars = []
|
|
|
+ # Batch preset bar for large channel groups (e.g. PTC 24 channels)
|
|
|
+ if cnt >= 8:
|
|
|
+ preset_bar = ttk.Frame(frame_grp)
|
|
|
+ preset_bar.pack(fill="x", pady=2)
|
|
|
+ ttk.Label(preset_bar, text=f"快捷预设全部 {grp}:", font=("", 9, "bold")).pack(side="left", padx=4)
|
|
|
+
|
|
|
+ def make_set_all_fn(vs, val):
|
|
|
+ def fn():
|
|
|
+ for v in vs:
|
|
|
+ v.set(str(val))
|
|
|
+ return fn
|
|
|
+
|
|
|
+ for p_val in (0, 20, 50, 100):
|
|
|
+ ttk.Button(preset_bar, text=f"全设 {p_val}%", width=8,
|
|
|
+ command=make_set_all_fn(grp_vars, p_val)).pack(side="left", padx=2)
|
|
|
+
|
|
|
+ # Multi-column grid for channels (8 cols for 24 channels -> 3 rows of 8)
|
|
|
+ grid_frame = ttk.Frame(frame_grp)
|
|
|
+ grid_frame.pack(fill="x", pady=2)
|
|
|
+ cols = 8 if cnt >= 16 else (4 if cnt <= 4 else 6)
|
|
|
for i in range(cnt):
|
|
|
- row_frame = ttk.Frame(frame_grp)
|
|
|
- row_frame.pack(side="left", padx=4, pady=2)
|
|
|
- ttk.Label(row_frame, text=f"{grp}{i}:").pack(side="left")
|
|
|
+ row = i // cols
|
|
|
+ col = i % cols
|
|
|
+ cell = ttk.Frame(grid_frame)
|
|
|
+ cell.grid(row=row, column=col, padx=4, pady=2, sticky="w")
|
|
|
+ label_text = f"{grp}{i:02d}:" if cnt > 9 else f"{grp}{i}:"
|
|
|
+ ttk.Label(cell, text=label_text, width=7, font=("Consolas", 9)).pack(side="left")
|
|
|
var = tk.StringVar(value=str(default))
|
|
|
set_vars.append(var)
|
|
|
- ttk.Spinbox(row_frame, from_=0, to=100, width=4, textvariable=var).pack(side="left")
|
|
|
+ grp_vars.append(var)
|
|
|
+ ttk.Spinbox(cell, from_=0, to=100, width=4, textvariable=var).pack(side="left")
|
|
|
+ ttk.Label(cell, text="%", font=("Consolas", 8), foreground="gray").pack(side="left")
|
|
|
|
|
|
axis_slots = []
|
|
|
if model.motor:
|
|
|
@@ -688,7 +723,21 @@ def run_gui(product: str) -> int:
|
|
|
groups = model.groups()
|
|
|
for grp, cnt, _ in groups:
|
|
|
duties = state.get(grp.lower(), [])
|
|
|
- text_get_resp_out.insert("end", f"【{grp} 实际生效占空比】: {duties}\n")
|
|
|
+ if cnt >= 8:
|
|
|
+ text_get_resp_out.insert("end", f"【{grp} 实际生效占空比 (共 {len(duties)} 路)】:\n")
|
|
|
+ line = ""
|
|
|
+ for i, val in enumerate(duties):
|
|
|
+ line += f" {grp}{i:02d}: {val:3d} %"
|
|
|
+ if (i + 1) % 6 == 0:
|
|
|
+ text_get_resp_out.insert("end", line + "\n")
|
|
|
+ line = ""
|
|
|
+ else:
|
|
|
+ line += " | "
|
|
|
+ if line:
|
|
|
+ text_get_resp_out.insert("end", line.rstrip(" | ") + "\n")
|
|
|
+ else:
|
|
|
+ ch_strs = [f"{grp}{i}: {v}%" for i, v in enumerate(duties)]
|
|
|
+ text_get_resp_out.insert("end", f"【{grp} 实际生效占空比 ({len(duties)} 路)】: {' | '.join(ch_strs)}\n")
|
|
|
if model.motor:
|
|
|
lm = state.get("lower_limit_mask", 0)
|
|
|
um = state.get("upper_limit_mask", 0)
|
|
|
@@ -870,6 +919,19 @@ def run_gui(product: str) -> int:
|
|
|
lm = st.get("lower_limit_mask", 0)
|
|
|
um = st.get("upper_limit_mask", 0)
|
|
|
summary += f" | 下限位=0x{lm:03X} | 上限位=0x{um:03X}"
|
|
|
+ fan_d = st.get("fan", [])
|
|
|
+ ptc_d = st.get("ptc", [])
|
|
|
+ lbl_realtime_ptc.config(text=f"【FAN 4路占空比】: {fan_d} | 【PTC 4路占空比】: {ptc_d}")
|
|
|
+ else:
|
|
|
+ ptc_d = st.get("ptc", [])
|
|
|
+ if ptc_d:
|
|
|
+ lines = []
|
|
|
+ for c in range(0, len(ptc_d), 8):
|
|
|
+ chunk = ptc_d[c : c + 8]
|
|
|
+ lines.append(" | ".join(f"PTC{c+j:02d}:{v:3d}%" for j, v in enumerate(chunk)))
|
|
|
+ front_d = st.get("front", [])
|
|
|
+ rear_d = st.get("rear", [])
|
|
|
+ lbl_realtime_ptc.config(text=f"【PTC 生效占空比 (共24路)】:\n " + "\n ".join(lines) + f"\n【风扇占空比】: Front={front_d} | Rear={rear_d}")
|
|
|
lbl_realtime_stat.config(text=summary)
|
|
|
# Also update TAB 3 output
|
|
|
do_parse_get_resp(frame_hex(frame_data))
|