17 lines
1.3 KiB
JavaScript
17 lines
1.3 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { AxisGateError, AxisOperationController } from "./axis-operation-controller.mjs";
|
|
|
|
const calls = [];
|
|
const client = { send: async (kind, payload, operationId) => { calls.push({ kind, payload, operationId }); return { kind: "COMMAND_RESULT", payload: { status: "verified" } }; } };
|
|
const controller = new AxisOperationController(client);
|
|
const ready = { task: { state: "READY", mode: "MANUAL" }, program: { path: "main.ngc", program_status: "loaded" } };
|
|
const run = await controller.execute("PROGRAM_RUN", {}, { state: ready });
|
|
assert.equal(run.operationId, "axis-program-run-000001");
|
|
assert.equal(run.gate.reason, "axis_run_available");
|
|
assert.equal(calls[0].operationId, run.operationId);
|
|
await assert.rejects(() => controller.execute("JOG_START", { axis: "x" }, { state: { task: { state: "ESTOP" } } }), AxisGateError);
|
|
const tick = await controller.execute("SIM_STEP", { cycles: 1 }, { state: ready, gate: false });
|
|
assert.equal(tick.operationId, "axis-sim-step-000003");
|
|
assert.deepEqual(controller.exportTrace().map((entry) => entry.phase), ["pending", "result", "blocked", "pending", "result"]);
|
|
console.log(JSON.stringify({ schema: "axis-operation-controller-sample.v1", status: "verified", calls: calls.length, phases: controller.exportTrace().map((entry) => entry.phase), last_operation: tick.operationId }));
|