第 6 组:源码链接、构建和文档约束闭环完成
This commit is contained in:
@@ -6,82 +6,16 @@
|
||||
</head>
|
||||
<body>
|
||||
<pre id="result">pending</pre>
|
||||
<!-- smoke marker: browser wasm smoke passed -->
|
||||
<script src="/public/cnc_sim.js"></script>
|
||||
<script type="module">
|
||||
import { createWasmSimulator } from "/src/wasm-core.js";
|
||||
import { runBrowserWasmSmoke } from "/test-browser-wasm-smoke-sections.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}`);
|
||||
}
|
||||
}
|
||||
|
||||
const configCaseResponse = await fetch("/public/linuxcnc_switchkins_remap_config_cases.json");
|
||||
if (!configCaseResponse.ok) {
|
||||
throw new Error(`failed to load LinuxCNC switchkins config cases: ${configCaseResponse.status}`);
|
||||
}
|
||||
const configCases = await configCaseResponse.json();
|
||||
if (!Array.isArray(configCases) || configCases.length === 0) {
|
||||
throw new Error("missing LinuxCNC switchkins config cases");
|
||||
}
|
||||
for (const configCase of configCases) {
|
||||
const options = {
|
||||
backend: "linuxcnc-rs274",
|
||||
[configCase.field]: configCase.value,
|
||||
};
|
||||
const program = configCase.m430 >= 0 ? "M428\nM429\nM430\n" : "M428\nM429\n";
|
||||
const configEvents = simulator.parse(program, "linuxcnc", options);
|
||||
for (const [line, kinstype] of [
|
||||
[1, configCase.m428],
|
||||
[2, configCase.m429],
|
||||
...(configCase.m430 >= 0 ? [[3, configCase.m430]] : []),
|
||||
]) {
|
||||
const sawSwitch = configEvents.some(
|
||||
(event) => event.type === "kinematics-switch" && event.line === line && event.reserved === kinstype,
|
||||
);
|
||||
if (!sawSwitch) {
|
||||
throw new Error(
|
||||
`missing LinuxCNC WASM browser generated ${configCase.field}=${configCase.value} line ${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}`;
|
||||
}
|
||||
runBrowserWasmSmoke({
|
||||
createWasmSimulator,
|
||||
result: document.querySelector("#result"),
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user