新增仿真执行过程回放
结论:真实浏览器仿真页面新增 G-code 执行过程和刀具运动回放,支持 reset、step、play、finish,逐帧高亮 G-code 与 motion row,并渲染已执行刀路和移动 toolhead。
This commit is contained in:
@@ -3,6 +3,7 @@ import assert from "node:assert/strict";
|
||||
import {
|
||||
DEFAULT_SIMULATION_PROGRAM,
|
||||
DEFAULT_SIMULATION_PROGRAM_ID,
|
||||
createPlaybackFrame,
|
||||
createSimulationSummary,
|
||||
createToolpathPolylinePoints,
|
||||
getSimulationTestProgram,
|
||||
@@ -80,4 +81,27 @@ assert.ok(summary.motionTypes.includes("ARC_FEED"));
|
||||
assert.equal(summary.finalAxes.x, 0);
|
||||
assert.equal(summary.finalAxes.y, 0);
|
||||
|
||||
const playbackState = {
|
||||
motion: arcMotion,
|
||||
};
|
||||
const firstFrame = createPlaybackFrame(playbackState, 0);
|
||||
assert.equal(firstFrame.apiName, "real-browser-simulation-playback-frame");
|
||||
assert.equal(firstFrame.index, 0);
|
||||
assert.equal(firstFrame.step, 1);
|
||||
assert.equal(firstFrame.total, 3);
|
||||
assert.equal(firstFrame.activeLine, 1);
|
||||
assert.equal(firstFrame.visibleMotion.length, 1);
|
||||
|
||||
const arcFrame = createPlaybackFrame(playbackState, 1);
|
||||
assert.equal(arcFrame.index, 1);
|
||||
assert.equal(arcFrame.activeLine, 3);
|
||||
assert.equal(arcFrame.activeStatement, "G2 X1 Y1 I1 J0 F80");
|
||||
assert.equal(arcFrame.axes.x, 1);
|
||||
assert.equal(arcFrame.axes.y, 1);
|
||||
assert.equal(arcFrame.visibleMotion.length, 2);
|
||||
|
||||
const clampedFrame = createPlaybackFrame(playbackState, 99);
|
||||
assert.equal(clampedFrame.index, 2);
|
||||
assert.equal(clampedFrame.progress, 100);
|
||||
|
||||
console.log("real_simulation_programs_node_smoke=ok");
|
||||
|
||||
Reference in New Issue
Block a user