按规划持续工作

结论:浏览器 interpreter smoke 和 INI panel UI 已接入 vendored LinuxCNC 五轴 switchkins remap 执行路径,只复制 LinuxCNC sample machine 文件到 WASM FS 并调用 SDK C ABI;host 聚合 smoke 通过,未新增 JavaScript M428/M429/M430 或运动学语义。
This commit is contained in:
2026-06-08 18:12:27 +08:00
parent 149095274c
commit 7cdfc458f9
8 changed files with 211 additions and 13 deletions

View File

@@ -39,6 +39,7 @@ vendored LinuxCNC RS274NGC sources and exposes:
- `runProgramWithIni(programText, iniPath)`
- `runFile(path)`
- `runFileWithIni(path, iniPath)`
- `runFiveAxisRemapFile(path, iniPath)`
- `restoreParameters(path)`
- `saveParameters(path, values)`
- `loadToolTable(path, options)`
@@ -49,3 +50,8 @@ vendored LinuxCNC RS274NGC sources and exposes:
`loadToolTable()` accepts `{ randomToolChanger: true }` to select the
LinuxCNC random-toolchanger branch before calling vendored
`tooldata_load()`. The SDK only forwards that runtime boundary flag.
`runFiveAxisRemapFile()` is a narrow host boundary for vendored LinuxCNC
sample-machine remap validation. Callers provide INI/remap/demo files in the
WASM filesystem; the C ABI runs vendored LinuxCNC `REMAP`, O-word, file
execution, and HAL adapter paths.

View File

@@ -20,6 +20,19 @@ import {
const SAMPLE_PATH =
"../../../vendor/linuxcnc/configs/sim/axis/vismach/5axis/table-dual-rotary/xyzab-tdr.ini";
const FIVEAXIS_TRT_SOURCE_PATH =
"../../../vendor/linuxcnc/configs/sim/axis/vismach/5axis/table-rotary-tilting";
const FIVEAXIS_TRT_WASM_DIR = "/work/ui-fiveaxis/table-rotary-tilting";
const FIVEAXIS_REMAP_FILES = [
"428remap.ngc",
"429remap.ngc",
"430remap.ngc",
"centering.ngc",
"helix_ac.ngc",
"helix_bc.ngc",
"xyzac_switchkins_sub.ngc",
"xyzbc_switchkins_sub.ngc",
];
const MACHINE_ID = "xyzab-tdr";
const MACHINE_PATHS = machineFilePaths(MACHINE_ID);
const OPFS_FILE = MACHINE_PATHS.ini;
@@ -68,6 +81,7 @@ const fields = {
sessionToolTable: document.getElementById("field-session-tool-table"),
sessionGcode: document.getElementById("field-session-gcode"),
runStatus: document.getElementById("field-run-status"),
fiveaxisRemap: document.getElementById("field-fiveaxis-remap"),
};
let iniSdk = null;
@@ -133,6 +147,38 @@ async function loadSample() {
setLog("Loaded LinuxCNC sample INI into the standalone editor.");
}
async function fetchTextFile(path) {
const response = await fetch(path);
if (!response.ok) {
throw new Error(`Cannot fetch ${path} (${response.status})`);
}
return response.text();
}
async function writeFetchedTextFile(interp, sourcePath, wasmPath) {
interp.writeTextFile(wasmPath, await fetchTextFile(sourcePath));
}
async function writeFiveAxisTrtMachineFiles(interp) {
await writeFetchedTextFile(
interp,
`${FIVEAXIS_TRT_SOURCE_PATH}/xyzac-trt.ini`,
`${FIVEAXIS_TRT_WASM_DIR}/xyzac-trt.ini`,
);
for (const filename of FIVEAXIS_REMAP_FILES) {
await writeFetchedTextFile(
interp,
`${FIVEAXIS_TRT_SOURCE_PATH}/remap_subs/${filename}`,
`${FIVEAXIS_TRT_WASM_DIR}/remap_subs/${filename}`,
);
}
await writeFetchedTextFile(
interp,
`${FIVEAXIS_TRT_SOURCE_PATH}/demos/xyzac_switchkins.ngc`,
`${FIVEAXIS_TRT_WASM_DIR}/demos/xyzac_switchkins.ngc`,
);
}
async function boot() {
try {
iniSdk = await createLinuxCncIniSdk();
@@ -255,6 +301,30 @@ document.getElementById("run-gcode").addEventListener("click", async () => {
}
});
document.getElementById("run-fiveaxis-remap").addEventListener("click", async () => {
try {
const interp = requireInterpSdk();
await writeFiveAxisTrtMachineFiles(interp);
const iniPath = `${FIVEAXIS_TRT_WASM_DIR}/xyzac-trt.ini`;
const programPath = `${FIVEAXIS_TRT_WASM_DIR}/demos/xyzac_switchkins.ngc`;
const result = interp.runFiveAxisRemapFile(programPath, iniPath);
setField("fiveaxisRemap", "ok");
setCanonicalEvents(result.trim());
setLog(
[
"Ran LinuxCNC 5-axis switchkins remap demo through interpreter WASM.",
`Program: ${programPath}`,
`INI: ${iniPath}`,
result.trim(),
].join("\n"),
);
} catch (error) {
setField("fiveaxisRemap", "failed");
setCanonicalEvents("");
setLog(`5-axis remap run failed: ${error.message}`, true);
}
});
document.getElementById("load-opfs").addEventListener("click", async () => {
try {
editor.value = await loadTextFile(OPFS_FILE);

View File

@@ -180,6 +180,7 @@
<button id="query" class="secondary">Query LinuxCNC Fields</button>
<button id="load-session" class="secondary">Load Machine Session</button>
<button id="run-gcode" class="secondary">Run G-code</button>
<button id="run-fiveaxis-remap" class="secondary">Run 5-Axis Remap</button>
</div>
<textarea id="ini-editor" spellcheck="false"></textarea>
</section>
@@ -221,6 +222,8 @@
<dd id="field-session-gcode">-</dd>
<dt>Run Status</dt>
<dd id="field-run-status">-</dd>
<dt>5-Axis Remap</dt>
<dd id="field-fiveaxis-remap">-</dd>
</dl>
<div class="log" id="log"></div>