Optimize XYZAC motion updates and persist power-off recovery

This commit is contained in:
2026-08-29 04:52:44 +08:00
parent a97971ea19
commit f6e545018e
17 changed files with 479 additions and 74 deletions

View File

@@ -1,6 +1,11 @@
import { fnv1a64 } from "./replay.mjs";
const DEVICE_SCHEMA = "wasm_xyzac_device_io.v1";
const DEVICE_ERROR_REASONS = Object.freeze({
[-1000]: "wasm_device_invalid_argument", [-1001]: "wasm_device_invalid_state", [-1002]: "wasm_device_range_error",
[-1003]: "wasm_device_estop_active", [-1004]: "wasm_device_interlock_open", [-1005]: "wasm_device_fault_active",
[-1006]: "wasm_device_ack_missing", [-1007]: "wasm_device_ack_timeout", [-1008]: "wasm_device_ack_invalid",
});
function call(core, name, returnType, argTypes, args) {
const fn = core?.[`_${name}`] ?? core?.[name];
@@ -52,7 +57,8 @@ export class WasmXyzacDeviceIo {
invoke(name, args = []) {
if (!this.available) return { status: "blocked", code: "wasm_xyzac_device_io_unavailable" };
const result = call(this.core, name, "number", ["number", ...args.map(() => "number")], [this.pointer, ...args]);
return result === 0 ? { status: "verified", command: name } : { status: "error", code: `wasm_${name}_${result}`, result };
const reason = DEVICE_ERROR_REASONS[result] ?? `wasm_${name}_${result}`;
return result === 0 ? { status: "verified", command: name } : { status: "error", code: `wasm_${name}_${result}`, result, reason, message_key: reason, source: "linuxcnc-wasm-device-io" };
}
canonical() {