Optimize XYZAC motion updates and persist power-off recovery
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user