Optimize XYZAC motion updates and persist power-off recovery
This commit is contained in:
@@ -7,6 +7,10 @@ const QUEUE_HEADER_BYTES = 32;
|
||||
const STATE_POSITION_BYTES = 72;
|
||||
const MOTION_QUEUE_SCHEMA = "sim_motion_queue_state.v1";
|
||||
const DEFAULT_CONTROLS = Object.freeze({ profile: 0, lookahead: 1, acceleration_limit: 1e9, jerk_limit: 1e12, paused: false });
|
||||
const MOTION_ERROR_REASONS = Object.freeze({
|
||||
[-600]: "wasm_motion_invalid_argument", [-601]: "wasm_motion_nonfinite_value", [-602]: "wasm_motion_limit_range",
|
||||
[-603]: "wasm_motion_invalid_state", [-604]: "wasm_motion_queue_full", [-605]: "wasm_motion_paused",
|
||||
});
|
||||
|
||||
function call(core, name, returnType, argTypes, args) {
|
||||
const fn = core[`_${name}`] ?? core[name];
|
||||
@@ -101,7 +105,7 @@ export class WasmMotionQueue {
|
||||
// Keep the WASM switchkins mode in the tag field; the C queue assigns id.
|
||||
ints[this.command / 4 + SEGMENT_INT_OFFSET + 3] = Number(segment.kinematics_mode ?? segment.tag ?? 0);
|
||||
const result = call(this.core, "sim_motion_enqueue", "number", ["number", "number", "number"], [this.queue, this.command, 0]);
|
||||
return result === 0 ? { status: "verified", source_line: segment.source_line ?? null } : { status: "error", code: `wasm_motion_enqueue_${result}` };
|
||||
return result === 0 ? { status: "verified", source_line: segment.source_line ?? null } : { status: "error", code: `wasm_motion_enqueue_${result}`, reason: MOTION_ERROR_REASONS[result] ?? `wasm_motion_enqueue_${result}`, message_key: MOTION_ERROR_REASONS[result] ?? `wasm_motion_enqueue_${result}`, source: "linuxcnc-wasm-motion" };
|
||||
}
|
||||
|
||||
reset() {
|
||||
@@ -183,7 +187,7 @@ export class WasmMotionQueue {
|
||||
if (!this.available) return { status: "error", code: "wasm_motion_step_-605" };
|
||||
if (this.controls.paused) return { status: "error", code: "wasm_motion_step_-605" };
|
||||
const result = call(this.core, "sim_motion_step", "number", ["number"], [this.queue]);
|
||||
if (result !== 0) return { status: "error", code: `wasm_motion_step_${result}` };
|
||||
if (result !== 0) return { status: "error", code: `wasm_motion_step_${result}`, reason: MOTION_ERROR_REASONS[result] ?? `wasm_motion_step_${result}`, message_key: MOTION_ERROR_REASONS[result] ?? `wasm_motion_step_${result}`, source: "linuxcnc-wasm-motion" };
|
||||
return this.read();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user