按规划继续工作
结论:补齐 INI 派生参数文件和刀具表 OPFS 会话加载,扩大浏览器解释器 file-path fixture 覆盖,并通过 host/WASM/browser 聚合验证。
This commit is contained in:
@@ -21,22 +21,35 @@ function requireIniSdk(iniSdk) {
|
||||
if (!iniSdk) {
|
||||
return;
|
||||
}
|
||||
for (const method of ["writeTextFile", "getBool"]) {
|
||||
for (const method of ["writeTextFile", "getString", "getBool"]) {
|
||||
if (typeof iniSdk[method] !== "function") {
|
||||
throw new Error(`INI SDK is missing ${method}().`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function resolveSessionPaths(machineId, options = {}) {
|
||||
function iniString(iniSdk, iniWasmPath, section, tag) {
|
||||
if (!iniSdk) {
|
||||
return undefined;
|
||||
}
|
||||
const value = iniSdk.getString(iniWasmPath, section, tag);
|
||||
return value === null || value === "" ? undefined : value;
|
||||
}
|
||||
|
||||
function resolveSessionPaths(machineId, options = {}, iniValues = {}) {
|
||||
return {
|
||||
iniOpfsPath: options.iniOpfsPath ?? machineIniPath(machineId, options.iniFilename),
|
||||
iniWasmPath: options.iniWasmPath ?? DEFAULT_WASM_INI_PATH,
|
||||
parameterOpfsPath:
|
||||
options.parameterOpfsPath ?? parameterFilePath(machineId, options.parameterFilename),
|
||||
options.parameterOpfsPath ??
|
||||
parameterFilePath(
|
||||
machineId,
|
||||
options.parameterFilename ?? iniValues.parameterFilename,
|
||||
),
|
||||
parameterWasmPath: options.parameterWasmPath ?? DEFAULT_WASM_PARAMETER_PATH,
|
||||
toolTableOpfsPath:
|
||||
options.toolTableOpfsPath ?? toolTablePath(machineId, options.toolTableFilename),
|
||||
options.toolTableOpfsPath ??
|
||||
toolTablePath(machineId, options.toolTableFilename ?? iniValues.toolTableFilename),
|
||||
toolTableWasmPath: options.toolTableWasmPath ?? DEFAULT_WASM_TOOL_TABLE_PATH,
|
||||
};
|
||||
}
|
||||
@@ -53,8 +66,18 @@ function randomToolChangerFromIni(iniSdk, iniWasmPath, iniText) {
|
||||
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);
|
||||
const iniPaths = resolveSessionPaths(machineId, options);
|
||||
const iniText = await loadTextFile(iniPaths.iniOpfsPath, options.storage);
|
||||
options.iniSdk?.writeTextFile(iniPaths.iniWasmPath, iniText);
|
||||
const paths = resolveSessionPaths(machineId, options, {
|
||||
parameterFilename: iniString(
|
||||
options.iniSdk,
|
||||
iniPaths.iniWasmPath,
|
||||
"RS274NGC",
|
||||
"PARAMETER_FILE",
|
||||
),
|
||||
toolTableFilename: iniString(options.iniSdk, iniPaths.iniWasmPath, "EMCIO", "TOOL_TABLE"),
|
||||
});
|
||||
interp.writeTextFile(paths.iniWasmPath, iniText);
|
||||
const randomToolChanger =
|
||||
typeof options.randomToolChanger === "boolean"
|
||||
|
||||
Reference in New Issue
Block a user