接续上一轮:推进浏览器验证与M428配置收拢
结论:已完成浏览器侧真实加载验证,M428/M429/M430 的配置入口进一步从 LinuxCNC INI/HALFILE/REMAP 来源生成,native 与 source-link 验证通过。
This commit is contained in:
@@ -74,17 +74,20 @@ function readEvent(module, ptr) {
|
||||
}
|
||||
|
||||
async function loadModuleFactory() {
|
||||
if (globalThis.createCncSimModule) {
|
||||
return globalThis.createCncSimModule;
|
||||
}
|
||||
const module = await import("/cnc_sim.js");
|
||||
return module.default ?? module.createCncSimModule ?? globalThis.createCncSimModule;
|
||||
}
|
||||
|
||||
export async function createWasmSimulator() {
|
||||
export async function createWasmSimulator(moduleOptions = {}) {
|
||||
const createModule = await loadModuleFactory();
|
||||
if (!createModule) {
|
||||
throw new Error("cnc_sim.js did not export createCncSimModule");
|
||||
}
|
||||
|
||||
const module = await createModule();
|
||||
const module = await createModule(moduleOptions);
|
||||
const create = module.cwrap("cnc_sim_create", "number", []);
|
||||
const destroy = module.cwrap("cnc_sim_destroy", null, ["number"]);
|
||||
const reset = module.cwrap("cnc_sim_reset", null, ["number"]);
|
||||
@@ -104,8 +107,25 @@ export async function createWasmSimulator() {
|
||||
setDialect(handle, DIALECT[dialect] ?? DIALECT.linuxcnc);
|
||||
|
||||
const config = JSON.stringify({
|
||||
backend: options.backend ?? "smoke",
|
||||
backend: options.backend ?? "linuxcnc-rs274",
|
||||
...(options.rtcp ? { rtcp: options.rtcp } : {}),
|
||||
...(options.blockDelete !== undefined ? { blockDelete: options.blockDelete } : {}),
|
||||
...(options.block_delete !== undefined ? { block_delete: options.block_delete } : {}),
|
||||
...(options.switchkins ? { switchkins: options.switchkins } : {}),
|
||||
...(options.remap ? { remap: options.remap } : {}),
|
||||
...(options.kinematics ? { kinematics: options.kinematics } : {}),
|
||||
...(options.trt ? { trt: options.trt } : {}),
|
||||
...(options.pivotLength !== undefined ? { pivotLength: options.pivotLength } : {}),
|
||||
...(options.pivot_length !== undefined ? { pivot_length: options.pivot_length } : {}),
|
||||
...(options.kinematicsType !== undefined ? { kinematicsType: options.kinematicsType } : {}),
|
||||
...(options.kinematics_type !== undefined ? { kinematics_type: options.kinematics_type } : {}),
|
||||
...(options.fiveaxisKinematicsType !== undefined
|
||||
? { fiveaxisKinematicsType: options.fiveaxisKinematicsType }
|
||||
: {}),
|
||||
...(options.fiveaxis_kinematics_type !== undefined
|
||||
? { fiveaxis_kinematics_type: options.fiveaxis_kinematics_type }
|
||||
: {}),
|
||||
...(options.xyzbcTrt ? { xyzbcTrt: options.xyzbcTrt } : {}),
|
||||
});
|
||||
const configBytes = module.lengthBytesUTF8(config) + 1;
|
||||
const configPtr = module._malloc(configBytes);
|
||||
|
||||
Reference in New Issue
Block a user