按规划继续工作
结论:接入 LinuxCNC iniFindBool 到 INI WASM/SDK,并让 machine-session bridge 通过 vendored INI 解析 [EMCIO]RANDOM_TOOLCHANGER 后透传给 tooldata;native、WASM、OPFS 和浏览器 smoke 验证已通过。
This commit is contained in:
@@ -17,6 +17,17 @@ function requireSessionSdk(interp) {
|
||||
}
|
||||
}
|
||||
|
||||
function requireIniSdk(iniSdk) {
|
||||
if (!iniSdk) {
|
||||
return;
|
||||
}
|
||||
for (const method of ["writeTextFile", "getBool"]) {
|
||||
if (typeof iniSdk[method] !== "function") {
|
||||
throw new Error(`INI SDK is missing ${method}().`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function resolveSessionPaths(machineId, options = {}) {
|
||||
return {
|
||||
iniOpfsPath: options.iniOpfsPath ?? machineIniPath(machineId, options.iniFilename),
|
||||
@@ -30,11 +41,25 @@ function resolveSessionPaths(machineId, options = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
function randomToolChangerFromIni(iniSdk, iniWasmPath, iniText) {
|
||||
if (!iniSdk) {
|
||||
return false;
|
||||
}
|
||||
|
||||
iniSdk.writeTextFile(iniWasmPath, iniText);
|
||||
return iniSdk.getBool(iniWasmPath, "EMCIO", "RANDOM_TOOLCHANGER") === true;
|
||||
}
|
||||
|
||||
export async function loadMachineSessionFromOpfs(interp, machineId, options = {}) {
|
||||
requireSessionSdk(interp);
|
||||
requireIniSdk(options.iniSdk);
|
||||
const paths = resolveSessionPaths(machineId, options);
|
||||
const iniText = await loadTextFile(paths.iniOpfsPath, options.storage);
|
||||
interp.writeTextFile(paths.iniWasmPath, iniText);
|
||||
const randomToolChanger =
|
||||
typeof options.randomToolChanger === "boolean"
|
||||
? options.randomToolChanger
|
||||
: randomToolChangerFromIni(options.iniSdk, paths.iniWasmPath, iniText);
|
||||
|
||||
const parameters = await restoreMachineParametersFromOpfs(interp, machineId, {
|
||||
storage: options.storage,
|
||||
@@ -45,7 +70,7 @@ export async function loadMachineSessionFromOpfs(interp, machineId, options = {}
|
||||
storage: options.storage,
|
||||
opfsPath: paths.toolTableOpfsPath,
|
||||
wasmPath: paths.toolTableWasmPath,
|
||||
randomToolChanger: options.randomToolChanger === true,
|
||||
randomToolChanger,
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user