结论:已完成浏览器侧真实加载验证,M428/M429/M430 的配置入口进一步从 LinuxCNC INI/HALFILE/REMAP 来源生成,native 与 source-link 验证通过。
57 lines
2.0 KiB
HTML
57 lines
2.0 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<title>CNC WASM Browser Smoke</title>
|
|
</head>
|
|
<body>
|
|
<pre id="result">pending</pre>
|
|
<script src="/public/cnc_sim.js"></script>
|
|
<script type="module">
|
|
import { createWasmSimulator } from "/src/wasm-core.js";
|
|
|
|
const result = document.querySelector("#result");
|
|
const near = (actual, expected) => Math.abs(actual - expected) < 1e-6;
|
|
|
|
try {
|
|
const simulator = await createWasmSimulator({
|
|
locateFile: (file) => `/public/${file}`,
|
|
print: () => {},
|
|
printErr: () => {},
|
|
});
|
|
try {
|
|
const events = simulator.parse("G21 G90\nG0 X0\nG1 X5 F100\nM30\n", "linuxcnc", {
|
|
backend: "linuxcnc-rs274",
|
|
});
|
|
const sawFeed = events.some((event) => event.type === "linear-feed" && near(event.end.x, 5));
|
|
const sawEnd = events.some((event) => event.type === "program-end");
|
|
if (!sawFeed || !sawEnd) {
|
|
throw new Error("missing expected LinuxCNC WASM browser events");
|
|
}
|
|
const switchEvents = simulator.parse("M428\nM429\nM430\n", "linuxcnc", {
|
|
backend: "linuxcnc-rs274",
|
|
switchkins: "scara",
|
|
});
|
|
for (const [line, kinstype] of [
|
|
[1, 0],
|
|
[2, 1],
|
|
[3, 2],
|
|
]) {
|
|
const sawSwitch = switchEvents.some(
|
|
(event) => event.type === "kinematics-switch" && event.line === line && event.reserved === kinstype,
|
|
);
|
|
if (!sawSwitch) {
|
|
throw new Error(`missing LinuxCNC WASM browser M${427 + line} switchkins type ${kinstype}`);
|
|
}
|
|
}
|
|
result.textContent = "browser wasm smoke passed";
|
|
} finally {
|
|
simulator.dispose();
|
|
}
|
|
} catch (error) {
|
|
result.textContent = `browser wasm smoke failed: ${error && error.stack ? error.stack : error}`;
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|