Author SHA1 Message Date
louis c2b288f4b0 修改test_valve.py 2026-09-01 09:14:16 +08:00
6 changed files with 3219 additions and 5 deletions
+2 -2
View File
@@ -16,7 +16,7 @@
- **闭环 `main.py`**:启动时不再预先下发关闭位置,PID 内部输出由 `INITIAL_OPENING_PCT=100%` 开始;故障或退出时停止控制并断开 MT2-AM8,不主动下发关阀命令。当前系统按“执行机构失驱后回到全开”设计,现场必须确认实际硬件确实如此。
- **开环 `open_loop.py`**:连接成功后先主动设置 `0%` 开度,实验结束、异常或 `Ctrl+C` 时再次尝试设置 `0%` 开度,然后断开设备。
- **手动测试 `test_valve.py`**:连接时仅按已知状态记录 `100%` 开度,不向电机写入初始位置;退出时不主动下发新开度,仅断开设备。该脚本不执行流量/压力越限和连续读取失败保护,只适合在具备独立安全措施的受控测试中使用。
- **手动测试 `test_valve.py`**:连接成功后立即下发 `--opening` 指定的初始开度(默认 `100%`),写入失败则终止,不会开始采样;退出时不主动下发新开度,仅断开设备。该脚本不执行流量/压力越限和连续读取失败保护,只适合在具备独立安全措施的受控测试中使用。
因此,README 中的“关闭”或“全开”均指当前代码定义的逻辑位置,不能代替现场对阀门真实动作方向的确认。
@@ -225,7 +225,7 @@ CSV 同时记录 `is_ratio_smaller_than_0.528`:压力比小于临界值 `0.528
python test_valve.py
```
连接成功后,脚本把当前已知状态记为 `100%` 开度、行程 `800`,但不会立即向电机写入该位置。运行期间:
连接成功后,脚本立即把 `--opening` 指定的初始开度(默认 `100%`)换算为电机行程并写入;只有写入成功后才开始采样和记录,写入失败则终止。运行期间:
- 每秒读取并显示一次流量、压力、逻辑开度和映射后的电机行程;
-`S` 进入输入模式,输入 `0~100` 的新开度后按回车下发,按 `Esc` 取消;
+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()
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 259 KiB

File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 275 KiB