修改test_valve.py

This commit is contained in:
2026-09-01 09:14:16 +08:00
parent caf7642ba9
commit c2b288f4b0
6 changed files with 3219 additions and 5 deletions
+12 -3
View File
@@ -263,11 +263,17 @@ def main(argv=None):
print("连接失败。")
return 3
try:
opening, position = set_opening(hardware, opening)
except (ValueError, RuntimeError) as exc:
print(f"初始开度设置失败:{exc}")
return 4
recorder = ManualValveRecorder(OUTPUT_DIRECTORY)
print("手动阀门控制已启动:按 S 输入新开度,按 Ctrl+C 退出。")
print(
f"连接时按已知状态记录:开度 {opening:.2f}%(行程 {position:.1f});"
"未向电机写入位置"
f"初始开度已下发:{opening:.2f}%"
f"(行程 {position:.1f}"
)
print(f"CSV 将保存到:{recorder.csv_path}")
@@ -352,7 +358,10 @@ def main(argv=None):
except KeyboardInterrupt:
if input_mode:
print()
print("收到 Ctrl+C,正在保存数据并退出;不改变当前阀门开度。")
print(
"收到 Ctrl+C,正在保存数据并退出;退出前不再下发开度命令。"
"断开连接后的阀门位置由硬件决定。"
)
except Exception as exc:
if input_mode:
print()