43 lines
2.2 KiB
JavaScript
43 lines
2.2 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
import { parseLinuxCncIni } from "../../app/src/runtime/linuxcnc-ini-runtime.js";
|
|
import { createSimulationStore } from "../../app/src/state/store.js";
|
|
|
|
const workspace = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../..");
|
|
const first = createSimulationStore();
|
|
const second = createSimulationStore();
|
|
const third = createSimulationStore();
|
|
for (const store of [first, second, third]) {
|
|
store.dispatch({ type: "RESET" });
|
|
store.dispatch({ type: "TOGGLE_POWER" });
|
|
}
|
|
first.dispatch({ type: "ADJUST_OVERRIDE", target: "feed", delta: -20 });
|
|
first.dispatch({ type: "ADJUST_SPINDLE_OVERRIDE", delta: 10 });
|
|
second.dispatch({ type: "ADJUST_OVERRIDE", target: "feed", delta: 10 });
|
|
second.dispatch({ type: "ADJUST_SPINDLE_OVERRIDE", delta: -10 });
|
|
third.dispatch({ type: "ADJUST_OVERRIDE", target: "feed", delta: -10 });
|
|
third.dispatch({ type: "ADJUST_SPINDLE_OVERRIDE", delta: 20 });
|
|
assert.equal(first.getState().feed.feedOverride, 80);
|
|
assert.equal(second.getState().feed.feedOverride, 110);
|
|
assert.equal(third.getState().feed.feedOverride, 90);
|
|
assert.equal(first.getState().spindle.override, 110);
|
|
assert.equal(second.getState().spindle.override, 90);
|
|
assert.equal(third.getState().spindle.override, 120);
|
|
|
|
const gantryRoot = path.join(workspace, "wasm-port/vendor/linuxcnc/configs/sim/axis/gantry");
|
|
const iniText = fs.readFileSync(path.join(gantryRoot, "gantry_mm.ini"), "utf8");
|
|
const halText = fs.readFileSync(path.join(gantryRoot, "gantry_mm.hal"), "utf8");
|
|
const ini = parseLinuxCncIni(iniText, { path: "configs/sim/axis/gantry/gantry_mm.ini", profileId: "gantry-mm" });
|
|
assert.equal(ini.traj.coordinates, "X Y Y Z");
|
|
assert.equal(ini.jointConfig.length, 4);
|
|
assert.equal(ini.jointConfig[1].homeSequence, -2);
|
|
assert.equal(ini.jointConfig[2].homeSequence, -2);
|
|
assert.ok(halText.includes("net Ypos joint.1.motor-pos-cmd => joint.1.motor-pos-fb"));
|
|
assert.ok(halText.includes("net Y2pos joint.2.motor-pos-cmd => joint.2.motor-pos-fb"));
|
|
console.log("multi_session_override_isolation=ok");
|
|
console.log("three_session_override_isolation=ok");
|
|
console.log("gantry_dual_drive_source_evidence=ok");
|