新增仿真执行过程回放

结论:真实浏览器仿真页面新增 G-code 执行过程和刀具运动回放,支持 reset、step、play、finish,逐帧高亮 G-code 与 motion row,并渲染已执行刀路和移动 toolhead。
This commit is contained in:
2026-06-16 21:31:50 +08:00
parent ddd5b78999
commit 9e149107dc
8 changed files with 345 additions and 16 deletions

View File

@@ -1683,3 +1683,68 @@ browser_real_simulation_page_smoke=ok
- JS 没有解释 G-code也没有实现 planner、kinematics、tool、parameter、remap 语义;
- JS 只保存测试程序文本、调用 LinuxCNC WASM、解析 LinuxCNC-produced canonical output 以渲染
UI 状态和刀路终点。
八十、2026-06-16 继续执行记录G-code 和刀具执行过程可视化
用户反馈当前页面只能看到执行后的结果,看不到 G-code 执行过程和刀具执行过程。本批直接补齐
真实 browser simulation page 的回放能力。
本批新增实质能力:
- `runtime/ui/simulation/index.html` 新增 playback controls
- Reset
- Step Back
- Play/Pause
- Step Forward
- Finish
- Speed
- `runtime/ui/simulation/simulation-app.js` 新增 playback frame API
- `createPlaybackFrame(state, index)`
- `renderSimulationPlaybackFrame(documentRef, state, index)`
- `clampPlaybackIndex(motion, index)`
- 页面现在按 LinuxCNC canonical motion event 逐帧渲染执行过程:
- 当前 G-code 行高亮;
- 当前 motion row 高亮;
- 已执行 motion row 标记;
- XYZ/ABC live readout 随 frame 更新;
- SVG 中全路径为浅色预览;
- 已执行路径逐步增长;
- toolhead 圆点随当前 motion frame 移动;
- 页面 API 新增:
- `linuxCncRealSimulationApi.getPlaybackFrame()`
- `linuxCncRealSimulationApi.resetPlayback()`
- `linuxCncRealSimulationApi.stepPlayback(delta)`
- `linuxCncRealSimulationApi.play()`
- `linuxCncRealSimulationApi.pause()`
- `linuxCncRealSimulationApi.finishPlayback()`
- browser smoke 新增回放验证:
- reset 后 playback index 为 0
- step 后 executed toolpath 增长;
- toolhead 坐标变化;
- G-code line 和 motion row active 状态同步变化;
- finish 后 playback complete
- Node smoke 新增 playback frame contract 验证。
本批新增/更新可执行验证:
```bash
wasm-port/tests/ui/node/verify_real_simulation_programs.sh
wasm-port/tests/ui/node/verify_ui_node_smokes.sh
SKIP_INTERP_BUILD=1 wasm-port/tests/browser/verify_real_simulation_browser.sh
wasm-port/tests/docs/node/verify_real_browser_simulation_priority_docs.sh
```
关键通过输出:
```text
real_simulation_programs_node_smoke=ok
ui_node_smokes=ok
browser_real_simulation_page_smoke=ok
real_browser_simulation_priority_docs_node_smoke=ok
```
本批仍保持 LinuxCNC 语义边界:
- 回放基于 LinuxCNC WASM 输出的 canonical motion events
- JS 不解释 G-code不规划刀路不计算 CNC 语义;
- JS 只做播放索引、DOM 高亮、坐标显示、已执行路径和 toolhead 渲染。