按规划持续工作
结论:浏览器 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:
@@ -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);
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user