1975 lines
59 KiB
JavaScript
1975 lines
59 KiB
JavaScript
import { readdirSync, readFileSync } from "node:fs";
|
|
import { fileURLToPath } from "node:url";
|
|
import { dirname, resolve } from "node:path";
|
|
import assert from "node:assert/strict";
|
|
|
|
import { createLinuxCncInterpSdk } from "../../../runtime/sdk/src/index.js";
|
|
import {
|
|
INTERP_BASELINE_INI_FIXTURE,
|
|
INTERP_COORDINATE_OFFSETS_FILE_FIXTURE,
|
|
INTERP_ERROR_FIXTURES,
|
|
INTERP_FILE_FIXTURES,
|
|
INTERP_INI_FIXTURE,
|
|
INTERP_MDI_FIXTURES,
|
|
INTERP_POSITION_PARAMS_FILE_FIXTURE,
|
|
INTERP_SPINDLE_ORIENT_OFFSET_FIXTURE,
|
|
} from "../../fixtures/interp-fixture-matrix.mjs";
|
|
|
|
function verifyExpectedOutput(fixtureName, output, expectedText) {
|
|
const expectedLines = expectedText.split("\n").filter(Boolean);
|
|
|
|
for (const expectedLine of expectedLines) {
|
|
if (expectedLine.startsWith("absent=")) {
|
|
const forbidden = expectedLine.slice("absent=".length);
|
|
assert.equal(
|
|
output.includes(forbidden),
|
|
false,
|
|
`${fixtureName}: unexpected ${forbidden}`,
|
|
);
|
|
continue;
|
|
}
|
|
|
|
assert.equal(
|
|
output.includes(expectedLine),
|
|
true,
|
|
`${fixtureName}: ${expectedLine}`,
|
|
);
|
|
}
|
|
}
|
|
|
|
function verifyExpectedFileError(fixtureName, output, expectedText) {
|
|
assert.equal(
|
|
output.includes("file_open=0"),
|
|
true,
|
|
`${fixtureName}: file open`,
|
|
);
|
|
|
|
const expectedLines = expectedText.split("\n").filter(Boolean);
|
|
for (const expectedLine of expectedLines) {
|
|
if (expectedLine.startsWith("absent=")) {
|
|
const forbidden = expectedLine.slice("absent=".length);
|
|
assert.equal(
|
|
output.includes(forbidden),
|
|
false,
|
|
`${fixtureName}: unexpected ${forbidden}`,
|
|
);
|
|
continue;
|
|
}
|
|
|
|
if (expectedLine.startsWith("error_text=")) {
|
|
const message = expectedLine.slice("error_text=".length);
|
|
assert.equal(
|
|
output.includes(`file_error_text=${message}`),
|
|
true,
|
|
`${fixtureName}: ${message}`,
|
|
);
|
|
continue;
|
|
}
|
|
|
|
if (expectedLine.startsWith("canon_event=")) {
|
|
assert.equal(
|
|
output.includes(expectedLine),
|
|
true,
|
|
`${fixtureName}: ${expectedLine}`,
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = dirname(__filename);
|
|
const rootDir = resolve(__dirname, "../../..");
|
|
const wasmPath = resolve(rootDir, "build/wasm/core/linuxcnc_interp.wasm");
|
|
const interpPrints = [];
|
|
|
|
const interp = await createLinuxCncInterpSdk({
|
|
wasmBinary: readFileSync(wasmPath),
|
|
print(message) {
|
|
interpPrints.push(message);
|
|
},
|
|
printErr(message) {
|
|
console.error(message);
|
|
},
|
|
});
|
|
|
|
function runWithCapturedPrints(operation) {
|
|
interpPrints.length = 0;
|
|
const output = operation();
|
|
return { output, prints: interpPrints.join("\n") };
|
|
}
|
|
|
|
function writeVendorTextFile(sourcePath, wasmPath) {
|
|
interp.writeTextFile(wasmPath, readFileSync(sourcePath, "utf8"));
|
|
}
|
|
|
|
function writeFiveAxisTrtMachineFiles() {
|
|
const sourceDir = resolve(
|
|
rootDir,
|
|
"vendor/linuxcnc/configs/sim/axis/vismach/5axis/table-rotary-tilting",
|
|
);
|
|
const wasmDir = "/work/fiveaxis/table-rotary-tilting";
|
|
|
|
writeVendorTextFile(resolve(sourceDir, "xyzac-trt.ini"), `${wasmDir}/xyzac-trt.ini`);
|
|
writeVendorTextFile(resolve(sourceDir, "xyzbc-trt.ini"), `${wasmDir}/xyzbc-trt.ini`);
|
|
writeVendorTextFile(resolve(sourceDir, "xyzac-trt.tbl"), `${wasmDir}/xyzac-trt.tbl`);
|
|
writeVendorTextFile(resolve(sourceDir, "xyzbc-trt.tbl"), `${wasmDir}/xyzbc-trt.tbl`);
|
|
|
|
for (const filename of readdirSync(resolve(sourceDir, "remap_subs"))) {
|
|
if (filename.endsWith(".ngc")) {
|
|
writeVendorTextFile(
|
|
resolve(sourceDir, "remap_subs", filename),
|
|
`${wasmDir}/remap_subs/${filename}`,
|
|
);
|
|
}
|
|
}
|
|
|
|
writeVendorTextFile(
|
|
resolve(sourceDir, "demos/xyzac_switchkins.ngc"),
|
|
`${wasmDir}/demos/xyzac_switchkins.ngc`,
|
|
);
|
|
writeVendorTextFile(
|
|
resolve(sourceDir, "demos/xyzbc_switchkins.ngc"),
|
|
`${wasmDir}/demos/xyzbc_switchkins.ngc`,
|
|
);
|
|
writeVendorTextFile(
|
|
resolve(sourceDir, "demos/xyzac_switchkins_test_1.ngc"),
|
|
`${wasmDir}/demos/xyzac_switchkins_test_1.ngc`,
|
|
);
|
|
writeVendorTextFile(
|
|
resolve(sourceDir, "demos/xyzac_switchkins_test_2.ngc"),
|
|
`${wasmDir}/demos/xyzac_switchkins_test_2.ngc`,
|
|
);
|
|
writeVendorTextFile(
|
|
resolve(sourceDir, "demos/xyzac_switchkins_test_3.ngc"),
|
|
`${wasmDir}/demos/xyzac_switchkins_test_3.ngc`,
|
|
);
|
|
writeVendorTextFile(
|
|
resolve(sourceDir, "demos/boat-xyzac.ngc"),
|
|
`${wasmDir}/demos/boat-xyzac.ngc`,
|
|
);
|
|
writeVendorTextFile(
|
|
resolve(sourceDir, "demos/boat-xyzbc.ngc"),
|
|
`${wasmDir}/demos/boat-xyzbc.ngc`,
|
|
);
|
|
writeVendorTextFile(
|
|
resolve(sourceDir, "demos/impeller-7bl-xyzac.ngc"),
|
|
`${wasmDir}/demos/impeller-7bl-xyzac.ngc`,
|
|
);
|
|
|
|
return wasmDir;
|
|
}
|
|
|
|
function writeFiveAxisTdrMachineFiles() {
|
|
const sourceDir = resolve(
|
|
rootDir,
|
|
"vendor/linuxcnc/configs/sim/axis/vismach/5axis/table-dual-rotary",
|
|
);
|
|
const wasmDir = "/work/fiveaxis/table-dual-rotary";
|
|
|
|
writeVendorTextFile(resolve(sourceDir, "xyzab-tdr.ini"), `${wasmDir}/xyzab-tdr.ini`);
|
|
writeVendorTextFile(resolve(sourceDir, "xyzab-tdr.tbl"), `${wasmDir}/xyzab-tdr.tbl`);
|
|
for (const filename of readdirSync(resolve(sourceDir, "remap_subs"))) {
|
|
if (filename.endsWith(".ngc")) {
|
|
writeVendorTextFile(
|
|
resolve(sourceDir, "remap_subs", filename),
|
|
`${wasmDir}/remap_subs/${filename}`,
|
|
);
|
|
}
|
|
}
|
|
writeVendorTextFile(
|
|
resolve(sourceDir, "demos/xyzab-tdr-demo.ngc"),
|
|
`${wasmDir}/demos/xyzab-tdr-demo.ngc`,
|
|
);
|
|
|
|
return wasmDir;
|
|
}
|
|
|
|
function writeFiveAxisBridgeMillMachineFiles() {
|
|
const sourceDir = resolve(
|
|
rootDir,
|
|
"vendor/linuxcnc/configs/sim/axis/vismach/5axis/bridgemill",
|
|
);
|
|
const wasmDir = "/work/fiveaxis/bridgemill";
|
|
|
|
writeVendorTextFile(resolve(sourceDir, "5axis.ini"), `${wasmDir}/5axis.ini`);
|
|
writeVendorTextFile(resolve(sourceDir, "5axis.tbl"), `${wasmDir}/5axis.tbl`);
|
|
for (const filename of readdirSync(resolve(sourceDir, "remap_subs"))) {
|
|
if (filename.endsWith(".ngc")) {
|
|
writeVendorTextFile(
|
|
resolve(sourceDir, "remap_subs", filename),
|
|
`${wasmDir}/remap_subs/${filename}`,
|
|
);
|
|
}
|
|
}
|
|
writeVendorTextFile(resolve(sourceDir, "5axisgui.ngc"), `${wasmDir}/5axisgui.ngc`);
|
|
|
|
return wasmDir;
|
|
}
|
|
|
|
function writeRemapRegressionFiles(name, files) {
|
|
const sourceDir = resolve(rootDir, "vendor/linuxcnc/tests/remap", name);
|
|
const wasmDir = `/work/remap/${name}`;
|
|
|
|
for (const filename of files) {
|
|
writeVendorTextFile(resolve(sourceDir, filename), `${wasmDir}/${filename}`);
|
|
}
|
|
|
|
return wasmDir;
|
|
}
|
|
|
|
function writeInterpRegressionFile(name, filename) {
|
|
const sourceDir = resolve(rootDir, "vendor/linuxcnc/tests/interp", name);
|
|
const wasmDir = `/work/interp/${name}`;
|
|
|
|
writeVendorTextFile(resolve(sourceDir, filename), `${wasmDir}/${filename}`);
|
|
|
|
return `${wasmDir}/${filename}`;
|
|
}
|
|
|
|
function writeInterpRegressionFiles(name, files) {
|
|
const sourceDir = resolve(rootDir, "vendor/linuxcnc/tests/interp", name);
|
|
const wasmDir = `/work/interp/${name}`;
|
|
|
|
for (const filename of files) {
|
|
writeVendorTextFile(resolve(sourceDir, filename), `${wasmDir}/${filename}`);
|
|
}
|
|
|
|
return wasmDir;
|
|
}
|
|
|
|
function writeUserMCodeFixture(name, code) {
|
|
const wasmDir = `/work/user-m/${name}`;
|
|
const iniPath = `${wasmDir}/test.ini`;
|
|
const programPath = `${wasmDir}/test.ngc`;
|
|
const mcodePath = `${wasmDir}/${code}`;
|
|
|
|
interp.writeTextFile(
|
|
iniPath,
|
|
[
|
|
"[DISPLAY]",
|
|
"PROGRAM_PREFIX = .",
|
|
"",
|
|
"[RS274NGC]",
|
|
"USER_M_PATH = .",
|
|
"",
|
|
"[TRAJ]",
|
|
"COORDINATES = XYZ",
|
|
].join("\n"),
|
|
);
|
|
interp.writeTextFile(programPath, `${code}\nM2\n`);
|
|
interp.writeTextFile(mcodePath, "#!/bin/sh\nexit 0\n");
|
|
interp.module.FS.chmod(mcodePath, 0o755);
|
|
|
|
return { iniPath, programPath };
|
|
}
|
|
|
|
const namedParamIniPath = "/work/namedparams.ini";
|
|
interp.writeTextFile(
|
|
namedParamIniPath,
|
|
readFileSync(resolve(rootDir, "tests/fixtures/ini/namedparams.ini"), "utf8"),
|
|
);
|
|
|
|
verifyExpectedOutput(
|
|
"probe_init_and_synch",
|
|
interp.probeInitAndSynch(),
|
|
[
|
|
"init=0",
|
|
"setup.length_units=2",
|
|
"setup.origin_index=1",
|
|
"setup.distance_mode=0",
|
|
"setup.feed_mode=0",
|
|
"setup.motion_mode=800",
|
|
"canon_event=INIT_CANON",
|
|
"canon_event=USE_LENGTH_UNITS units=2",
|
|
"canon_event=SET_G5X_OFFSET index=1",
|
|
"canon_event=SET_G92_OFFSET x=0 y=0 z=0",
|
|
"canon_event=SET_XY_ROTATION rotation=0",
|
|
"canon_event=SET_FEED_REFERENCE reference=2",
|
|
"inch_init=0",
|
|
"inch_setup.length_units=1",
|
|
"inch_external_length_units=0.0393701",
|
|
"inch_canon_event=USE_LENGTH_UNITS units=1",
|
|
"synch=0",
|
|
"synch.current_pocket=2",
|
|
"synch.selected_pocket=2",
|
|
"synch.tool_0=2",
|
|
"synch.tool_2=2",
|
|
].join("\n"),
|
|
);
|
|
|
|
verifyExpectedOutput(
|
|
"probe_indexer",
|
|
interp.probeIndexer(),
|
|
[
|
|
"execute=0",
|
|
"post_a=90",
|
|
"canon_event=SET_MOTION_CONTROL_MODE mode=2 tolerance=0",
|
|
"canon_event=UNLOCK_ROTARY line=1 joint=0",
|
|
"canon_event=STRAIGHT_TRAVERSE line=1 x=0 y=0 z=0 a=90 b=0 c=0 u=0 v=0 w=0",
|
|
"canon_event=LOCK_ROTARY line=1 joint=0",
|
|
"canon_event=SET_MOTION_CONTROL_MODE mode=1 tolerance=0",
|
|
"canon_event=SET_NAIVECAM_TOLERANCE tolerance=0",
|
|
"canon_event=UPDATE_TAG line=1",
|
|
].join("\n"),
|
|
);
|
|
|
|
verifyExpectedOutput(
|
|
"probe_named_parameters",
|
|
interp.probeNamedParameters(namedParamIniPath),
|
|
[
|
|
"init_named_parameters=0",
|
|
"global_named_count=57",
|
|
"_metric_machine: rc=0 found=1 value=1",
|
|
"_motion_mode: rc=0 found=1 value=10",
|
|
"_metric: rc=0 found=1 value=1",
|
|
"_feed: rc=0 found=1 value=123.45",
|
|
"_rpm: rc=0 found=1 value=678.9",
|
|
"_x: rc=0 found=1 value=1.25",
|
|
"_current_tool: rc=0 found=1 value=12",
|
|
"_ini[traj]max_linear_velocity: rc=0 found=1 value=35",
|
|
"_hal[standalone.pin-bit]: rc=0 found=1 value=1",
|
|
"_hal[standalone.signal-float]: rc=0 found=1 value=98.25",
|
|
"_hal[standalone.param-s32]: rc=0 found=1 value=-17",
|
|
"_hal[standalone.pin-u32]: rc=0 found=1 value=1.23457e+08",
|
|
"_hal[standalone.signal-s64]: rc=0 found=1 value=-9e+09",
|
|
"_hal[standalone.param-u64]: rc=0 found=1 value=9e+09",
|
|
"_hal[standalone.disconnected-float]: rc=0 found=1 value=12.5",
|
|
"_hal[standalone.missing]: rc=0 found=0 value=0",
|
|
].join("\n"),
|
|
);
|
|
|
|
for (const fixtureName of INTERP_MDI_FIXTURES) {
|
|
const programText = readFileSync(
|
|
resolve(rootDir, `tests/fixtures/gcode/${fixtureName}.ngc`),
|
|
"utf8",
|
|
);
|
|
const expectedEvents = readFileSync(
|
|
resolve(rootDir, `tests/fixtures/canon/${fixtureName}.events`),
|
|
"utf8",
|
|
).trimEnd();
|
|
|
|
verifyExpectedOutput(fixtureName, interp.runProgram(programText), expectedEvents);
|
|
}
|
|
|
|
const namedParamProgramText = readFileSync(
|
|
resolve(rootDir, `tests/fixtures/gcode/${INTERP_INI_FIXTURE}.ngc`),
|
|
"utf8",
|
|
);
|
|
const namedParamExpected = readFileSync(
|
|
resolve(rootDir, `tests/fixtures/canon/${INTERP_INI_FIXTURE}.events`),
|
|
"utf8",
|
|
).trimEnd();
|
|
verifyExpectedOutput(
|
|
INTERP_INI_FIXTURE,
|
|
interp.runProgramWithIni(namedParamProgramText, namedParamIniPath),
|
|
namedParamExpected,
|
|
);
|
|
|
|
const baselineIniProgramText = readFileSync(
|
|
resolve(rootDir, `tests/fixtures/gcode/${INTERP_BASELINE_INI_FIXTURE}.ngc`),
|
|
"utf8",
|
|
);
|
|
const baselineIniExpected = readFileSync(
|
|
resolve(rootDir, `tests/fixtures/canon/${INTERP_BASELINE_INI_FIXTURE}.events`),
|
|
"utf8",
|
|
).trimEnd();
|
|
verifyExpectedOutput(
|
|
INTERP_BASELINE_INI_FIXTURE,
|
|
interp.runProgramWithIni(baselineIniProgramText, namedParamIniPath),
|
|
baselineIniExpected,
|
|
);
|
|
|
|
const spindleOrientOffsetProgramText = readFileSync(
|
|
resolve(rootDir, `tests/fixtures/gcode/${INTERP_SPINDLE_ORIENT_OFFSET_FIXTURE}.ngc`),
|
|
"utf8",
|
|
);
|
|
const spindleOrientOffsetExpected = readFileSync(
|
|
resolve(rootDir, `tests/fixtures/canon/${INTERP_SPINDLE_ORIENT_OFFSET_FIXTURE}.events`),
|
|
"utf8",
|
|
).trimEnd();
|
|
const spindleOrientOffsetIniPath = "/work/spindle-orient-offset.ini";
|
|
interp.writeTextFile(
|
|
spindleOrientOffsetIniPath,
|
|
readFileSync(resolve(rootDir, "tests/fixtures/ini/spindle_orient_offset.ini"), "utf8"),
|
|
);
|
|
const disableFanucStyleSubIniPath = "/work/disable-fanuc-style-sub.ini";
|
|
interp.writeTextFile(
|
|
disableFanucStyleSubIniPath,
|
|
readFileSync(resolve(rootDir, "tests/fixtures/ini/disable_fanuc_style_sub.ini"), "utf8"),
|
|
);
|
|
verifyExpectedOutput(
|
|
INTERP_SPINDLE_ORIENT_OFFSET_FIXTURE,
|
|
interp.runProgramWithIni(spindleOrientOffsetProgramText, spindleOrientOffsetIniPath),
|
|
spindleOrientOffsetExpected,
|
|
);
|
|
|
|
for (const fixtureName of INTERP_ERROR_FIXTURES) {
|
|
const programText = readFileSync(
|
|
resolve(rootDir, `tests/fixtures/gcode_errors/${fixtureName}.ngc`),
|
|
"utf8",
|
|
);
|
|
const expectedOutput = readFileSync(
|
|
resolve(rootDir, `tests/fixtures/canon_errors/${fixtureName}.expected`),
|
|
"utf8",
|
|
).trimEnd();
|
|
|
|
verifyExpectedOutput(fixtureName, interp.runProgram(programText), expectedOutput);
|
|
}
|
|
|
|
for (const fixtureName of INTERP_ERROR_FIXTURES) {
|
|
const programPath = `/work/${fixtureName}-error.ngc`;
|
|
const programText = readFileSync(
|
|
resolve(rootDir, `tests/fixtures/gcode_errors/${fixtureName}.ngc`),
|
|
"utf8",
|
|
);
|
|
const expectedOutput = readFileSync(
|
|
resolve(rootDir, `tests/fixtures/canon_errors/${fixtureName}.expected`),
|
|
"utf8",
|
|
).trimEnd();
|
|
|
|
interp.writeTextFile(programPath, programText);
|
|
verifyExpectedFileError(fixtureName, interp.runFile(programPath), expectedOutput);
|
|
}
|
|
|
|
for (const fixtureName of INTERP_FILE_FIXTURES) {
|
|
const programPath = `/work/${fixtureName}.ngc`;
|
|
const programText = readFileSync(
|
|
resolve(rootDir, `tests/fixtures/gcode/${fixtureName}.ngc`),
|
|
"utf8",
|
|
);
|
|
const expectedEvents = readFileSync(
|
|
resolve(rootDir, `tests/fixtures/canon/${fixtureName}.events`),
|
|
"utf8",
|
|
).trimEnd();
|
|
|
|
interp.writeTextFile(programPath, programText);
|
|
verifyExpectedOutput(fixtureName, interp.runFile(programPath), expectedEvents);
|
|
}
|
|
|
|
verifyExpectedOutput(
|
|
"minimal_linear_run_steps",
|
|
interp.runFile("/work/minimal_linear.ngc"),
|
|
[
|
|
"run_step phase=read step=1 rc=0 line=1",
|
|
"run_step phase=execute step=1 rc=0 line=1 x=1 y=2 z=0",
|
|
"statement_uri=G0%20X1.0%20Y2.0%20%28Comment%29",
|
|
"run_step phase=execute step=2 rc=0 line=2 x=3 y=4 z=0",
|
|
"statement_uri=G1%20X3.0%20Y4.0%20F120.0",
|
|
].join("\n"),
|
|
);
|
|
|
|
const namedParamFilePath = `/work/${INTERP_INI_FIXTURE}.ngc`;
|
|
interp.writeTextFile(namedParamFilePath, namedParamProgramText);
|
|
verifyExpectedOutput(
|
|
"namedparam_semantics_file",
|
|
interp.runFileWithIni(namedParamFilePath, namedParamIniPath),
|
|
namedParamExpected,
|
|
);
|
|
|
|
const iniToolTableDir = "/work/ini-tool-table";
|
|
const iniToolTableIniPath = `${iniToolTableDir}/ini_tool_table.ini`;
|
|
const iniToolTableProgramPath = `${iniToolTableDir}/ini_tool_table.ngc`;
|
|
interp.writeTextFile(
|
|
iniToolTableIniPath,
|
|
readFileSync(resolve(rootDir, "tests/fixtures/ini/ini_tool_table.ini"), "utf8"),
|
|
);
|
|
interp.writeTextFile(
|
|
`${iniToolTableDir}/ini_tool_table.tbl`,
|
|
readFileSync(resolve(rootDir, "tests/fixtures/ini/ini_tool_table.tbl"), "utf8"),
|
|
);
|
|
interp.writeTextFile(
|
|
iniToolTableProgramPath,
|
|
readFileSync(resolve(rootDir, "tests/fixtures/gcode/ini_tool_table.ngc"), "utf8"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"ini_tool_table_file",
|
|
interp.runFileWithIni(iniToolTableProgramPath, iniToolTableIniPath),
|
|
readFileSync(resolve(rootDir, "tests/fixtures/canon/ini_tool_table.events"), "utf8").trimEnd(),
|
|
);
|
|
|
|
const baselineIniFilePath = `/work/${INTERP_BASELINE_INI_FIXTURE}.ngc`;
|
|
interp.writeTextFile(baselineIniFilePath, baselineIniProgramText);
|
|
verifyExpectedOutput(
|
|
`${INTERP_BASELINE_INI_FIXTURE}_file`,
|
|
interp.runFileWithIni(baselineIniFilePath, namedParamIniPath),
|
|
baselineIniExpected,
|
|
);
|
|
|
|
const spindleOrientOffsetFilePath = `/work/${INTERP_SPINDLE_ORIENT_OFFSET_FIXTURE}.ngc`;
|
|
interp.writeTextFile(spindleOrientOffsetFilePath, spindleOrientOffsetProgramText);
|
|
verifyExpectedOutput(
|
|
`${INTERP_SPINDLE_ORIENT_OFFSET_FIXTURE}_file`,
|
|
interp.runFileWithIni(spindleOrientOffsetFilePath, spindleOrientOffsetIniPath),
|
|
spindleOrientOffsetExpected,
|
|
);
|
|
|
|
const disableFanucStyleSubFilePath = "/work/disable_fanuc_style_sub_m98.ngc";
|
|
interp.writeTextFile(
|
|
disableFanucStyleSubFilePath,
|
|
readFileSync(resolve(rootDir, "tests/fixtures/gcode/disable_fanuc_style_sub_m98.ngc"), "utf8"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"disable_fanuc_style_sub_m98_file_wasm",
|
|
interp.runFileWithIni(disableFanucStyleSubFilePath, disableFanucStyleSubIniPath),
|
|
[
|
|
"file_open=0",
|
|
"file_saw_error=1",
|
|
"file_error_text=DISABLE_FANUC_STYLE_SUB set in INI file, but found m98",
|
|
].join("\n"),
|
|
);
|
|
|
|
const coordinateOffsetsFilePath = `/work/${INTERP_COORDINATE_OFFSETS_FILE_FIXTURE}.ngc`;
|
|
interp.writeTextFile(
|
|
coordinateOffsetsFilePath,
|
|
readFileSync(
|
|
resolve(rootDir, `tests/fixtures/gcode/${INTERP_COORDINATE_OFFSETS_FILE_FIXTURE}.ngc`),
|
|
"utf8",
|
|
),
|
|
);
|
|
verifyExpectedOutput(
|
|
`${INTERP_COORDINATE_OFFSETS_FILE_FIXTURE}_file`,
|
|
interp.runFile(coordinateOffsetsFilePath),
|
|
readFileSync(
|
|
resolve(
|
|
rootDir,
|
|
`tests/fixtures/canon_file/${INTERP_COORDINATE_OFFSETS_FILE_FIXTURE}.events`,
|
|
),
|
|
"utf8",
|
|
).trimEnd(),
|
|
);
|
|
|
|
const positionParamsFilePath = "/work/position_params.ngc";
|
|
interp.writeTextFile(
|
|
positionParamsFilePath,
|
|
readFileSync(
|
|
resolve(rootDir, `tests/fixtures/gcode/${INTERP_POSITION_PARAMS_FILE_FIXTURE}.ngc`),
|
|
"utf8",
|
|
),
|
|
);
|
|
verifyExpectedOutput(
|
|
`${INTERP_POSITION_PARAMS_FILE_FIXTURE}_file`,
|
|
interp.runFile(positionParamsFilePath),
|
|
readFileSync(
|
|
resolve(
|
|
rootDir,
|
|
`tests/fixtures/canon_file/${INTERP_POSITION_PARAMS_FILE_FIXTURE}.events`,
|
|
),
|
|
"utf8",
|
|
).trimEnd(),
|
|
);
|
|
|
|
const fiveAxisTrtDir = writeFiveAxisTrtMachineFiles();
|
|
verifyExpectedOutput(
|
|
"fiveaxis_xyzac_switchkins_wasm",
|
|
interp.runFiveAxisRemapFile(
|
|
`${fiveAxisTrtDir}/demos/xyzac_switchkins.ngc`,
|
|
`${fiveAxisTrtDir}/xyzac-trt.ini`,
|
|
),
|
|
[
|
|
"fiveaxis_ini_open=1",
|
|
"fiveaxis_tool_table_load=0",
|
|
"fiveaxis_parse_remap_1=0",
|
|
"fiveaxis_parse_remap_2=0",
|
|
"fiveaxis_parse_remap_3=0",
|
|
"fiveaxis_parsed_remap_count=3",
|
|
"fiveaxis_remaps_ready=1",
|
|
"fiveaxis_file_open=0",
|
|
"fiveaxis_file_read_count=620",
|
|
"fiveaxis_file_execute_count=620",
|
|
"fiveaxis_file_finish_count=21",
|
|
"fiveaxis_file_final_rc=1",
|
|
"fiveaxis_file_reached_exit=1",
|
|
"fiveaxis_hal_switchkins: rc=0 found=1 value=0",
|
|
"fiveaxis_linuxcnc_remap_file_execute=1",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"fiveaxis_xyzbc_switchkins_wasm",
|
|
interp.runFiveAxisRemapFile(
|
|
`${fiveAxisTrtDir}/demos/xyzbc_switchkins.ngc`,
|
|
`${fiveAxisTrtDir}/xyzbc-trt.ini`,
|
|
),
|
|
[
|
|
"fiveaxis_ini_open=1",
|
|
"fiveaxis_tool_table_load=0",
|
|
"fiveaxis_parse_remap_1=0",
|
|
"fiveaxis_parse_remap_2=0",
|
|
"fiveaxis_parse_remap_3=0",
|
|
"fiveaxis_parsed_remap_count=3",
|
|
"fiveaxis_remaps_ready=1",
|
|
"fiveaxis_file_open=0",
|
|
"fiveaxis_file_read_count=620",
|
|
"fiveaxis_file_execute_count=620",
|
|
"fiveaxis_file_finish_count=21",
|
|
"fiveaxis_file_final_rc=1",
|
|
"fiveaxis_file_reached_exit=1",
|
|
"fiveaxis_hal_switchkins: rc=0 found=1 value=0",
|
|
"fiveaxis_linuxcnc_remap_file_execute=1",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"fiveaxis_xyzac_switchkins_test_1_wasm",
|
|
interp.runFiveAxisRemapFile(
|
|
`${fiveAxisTrtDir}/demos/xyzac_switchkins_test_1.ngc`,
|
|
`${fiveAxisTrtDir}/xyzac-trt.ini`,
|
|
),
|
|
[
|
|
"fiveaxis_ini_open=1",
|
|
"fiveaxis_tool_table_load=0",
|
|
"fiveaxis_parse_remap_1=0",
|
|
"fiveaxis_parse_remap_2=0",
|
|
"fiveaxis_parse_remap_3=0",
|
|
"fiveaxis_parsed_remap_count=3",
|
|
"fiveaxis_remaps_ready=1",
|
|
"fiveaxis_file_open=0",
|
|
"fiveaxis_file_read_count=248",
|
|
"fiveaxis_file_execute_count=248",
|
|
"fiveaxis_file_finish_count=9",
|
|
"fiveaxis_file_final_rc=1",
|
|
"fiveaxis_file_reached_exit=1",
|
|
"fiveaxis_hal_switchkins: rc=0 found=1 value=0",
|
|
"fiveaxis_linuxcnc_remap_file_execute=1",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"fiveaxis_xyzac_switchkins_test_2_wasm",
|
|
interp.runFiveAxisRemapFile(
|
|
`${fiveAxisTrtDir}/demos/xyzac_switchkins_test_2.ngc`,
|
|
`${fiveAxisTrtDir}/xyzac-trt.ini`,
|
|
),
|
|
[
|
|
"fiveaxis_ini_open=1",
|
|
"fiveaxis_tool_table_load=0",
|
|
"fiveaxis_parse_remap_1=0",
|
|
"fiveaxis_parse_remap_2=0",
|
|
"fiveaxis_parse_remap_3=0",
|
|
"fiveaxis_parsed_remap_count=3",
|
|
"fiveaxis_remaps_ready=1",
|
|
"fiveaxis_file_open=0",
|
|
"fiveaxis_file_read_count=120",
|
|
"fiveaxis_file_execute_count=120",
|
|
"fiveaxis_file_finish_count=3",
|
|
"fiveaxis_file_final_rc=1",
|
|
"fiveaxis_file_reached_exit=1",
|
|
"fiveaxis_hal_switchkins: rc=0 found=1 value=0",
|
|
"fiveaxis_linuxcnc_remap_file_execute=1",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"fiveaxis_xyzac_switchkins_test_3_wasm",
|
|
interp.runFiveAxisRemapFile(
|
|
`${fiveAxisTrtDir}/demos/xyzac_switchkins_test_3.ngc`,
|
|
`${fiveAxisTrtDir}/xyzac-trt.ini`,
|
|
),
|
|
[
|
|
"fiveaxis_ini_open=1",
|
|
"fiveaxis_tool_table_load=0",
|
|
"fiveaxis_parse_remap_1=0",
|
|
"fiveaxis_parse_remap_2=0",
|
|
"fiveaxis_parse_remap_3=0",
|
|
"fiveaxis_parsed_remap_count=3",
|
|
"fiveaxis_remaps_ready=1",
|
|
"fiveaxis_file_open=0",
|
|
"fiveaxis_file_read_count=86",
|
|
"fiveaxis_file_execute_count=86",
|
|
"fiveaxis_file_finish_count=3",
|
|
"fiveaxis_file_final_rc=1",
|
|
"fiveaxis_file_reached_exit=1",
|
|
"fiveaxis_hal_switchkins: rc=0 found=1 value=0",
|
|
"fiveaxis_linuxcnc_remap_file_execute=1",
|
|
].join("\n"),
|
|
);
|
|
|
|
verifyExpectedOutput(
|
|
"fiveaxis_boat_xyzac_wasm",
|
|
interp.runFiveAxisRemapFile(
|
|
`${fiveAxisTrtDir}/demos/boat-xyzac.ngc`,
|
|
`${fiveAxisTrtDir}/xyzac-trt.ini`,
|
|
),
|
|
[
|
|
"fiveaxis_ini_open=1",
|
|
"fiveaxis_tool_table_load=0",
|
|
"fiveaxis_parse_remap_1=0",
|
|
"fiveaxis_parse_remap_2=0",
|
|
"fiveaxis_parse_remap_3=0",
|
|
"fiveaxis_file_open=0",
|
|
"fiveaxis_file_read_count=1927",
|
|
"fiveaxis_file_execute_count=1927",
|
|
"fiveaxis_file_finish_count=3",
|
|
"fiveaxis_file_final_rc=1",
|
|
"fiveaxis_file_reached_exit=1",
|
|
"fiveaxis_hal_switchkins: rc=0 found=1 value=0",
|
|
"fiveaxis_linuxcnc_remap_file_execute=1",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"fiveaxis_boat_xyzbc_wasm",
|
|
interp.runFiveAxisRemapFile(
|
|
`${fiveAxisTrtDir}/demos/boat-xyzbc.ngc`,
|
|
`${fiveAxisTrtDir}/xyzbc-trt.ini`,
|
|
),
|
|
[
|
|
"fiveaxis_ini_open=1",
|
|
"fiveaxis_tool_table_load=0",
|
|
"fiveaxis_parse_remap_1=0",
|
|
"fiveaxis_parse_remap_2=0",
|
|
"fiveaxis_parse_remap_3=0",
|
|
"fiveaxis_file_open=0",
|
|
"fiveaxis_file_read_count=1913",
|
|
"fiveaxis_file_execute_count=1913",
|
|
"fiveaxis_file_finish_count=3",
|
|
"fiveaxis_file_final_rc=1",
|
|
"fiveaxis_file_reached_exit=1",
|
|
"fiveaxis_hal_switchkins: rc=0 found=1 value=0",
|
|
"fiveaxis_linuxcnc_remap_file_execute=1",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"fiveaxis_impeller_7bl_xyzac_wasm",
|
|
interp.runFiveAxisRemapFile(
|
|
`${fiveAxisTrtDir}/demos/impeller-7bl-xyzac.ngc`,
|
|
`${fiveAxisTrtDir}/xyzac-trt.ini`,
|
|
),
|
|
[
|
|
"fiveaxis_ini_open=1",
|
|
"fiveaxis_tool_table_load=0",
|
|
"fiveaxis_parse_remap_1=0",
|
|
"fiveaxis_parse_remap_2=0",
|
|
"fiveaxis_parse_remap_3=0",
|
|
"fiveaxis_file_open=0",
|
|
"fiveaxis_file_read_count=4558",
|
|
"fiveaxis_file_execute_count=4558",
|
|
"fiveaxis_file_finish_count=2",
|
|
"fiveaxis_file_final_rc=1",
|
|
"fiveaxis_file_reached_exit=1",
|
|
"fiveaxis_hal_switchkins: rc=0 found=1 value=0",
|
|
"fiveaxis_linuxcnc_remap_file_execute=1",
|
|
].join("\n"),
|
|
);
|
|
|
|
const fiveAxisTdrDir = writeFiveAxisTdrMachineFiles();
|
|
verifyExpectedOutput(
|
|
"fiveaxis_xyzab_tdr_demo_wasm",
|
|
interp.runFiveAxisRemapFile(
|
|
`${fiveAxisTdrDir}/demos/xyzab-tdr-demo.ngc`,
|
|
`${fiveAxisTdrDir}/xyzab-tdr.ini`,
|
|
),
|
|
[
|
|
"fiveaxis_ini_open=1",
|
|
"fiveaxis_tool_table_load=0",
|
|
"fiveaxis_parse_remap_1=0",
|
|
"fiveaxis_parse_remap_2=0",
|
|
"fiveaxis_parsed_remap_count=2",
|
|
"fiveaxis_remaps_ready=1",
|
|
"fiveaxis_file_open=0",
|
|
"fiveaxis_file_read_count=97",
|
|
"fiveaxis_file_execute_count=97",
|
|
"fiveaxis_file_finish_count=3",
|
|
"fiveaxis_file_final_rc=1",
|
|
"fiveaxis_file_reached_exit=1",
|
|
"fiveaxis_hal_switchkins: rc=0 found=1 value=1",
|
|
"fiveaxis_linuxcnc_remap_file_execute=1",
|
|
].join("\n"),
|
|
);
|
|
|
|
const fiveAxisBridgeMillDir = writeFiveAxisBridgeMillMachineFiles();
|
|
verifyExpectedOutput(
|
|
"fiveaxis_bridgemill_5axisgui_wasm",
|
|
interp.runFiveAxisRemapFile(
|
|
`${fiveAxisBridgeMillDir}/5axisgui.ngc`,
|
|
`${fiveAxisBridgeMillDir}/5axis.ini`,
|
|
),
|
|
[
|
|
"fiveaxis_ini_open=1",
|
|
"fiveaxis_tool_table_load=0",
|
|
"fiveaxis_parse_remap_1=0",
|
|
"fiveaxis_parse_remap_2=0",
|
|
"fiveaxis_parse_remap_3=0",
|
|
"fiveaxis_parsed_remap_count=3",
|
|
"fiveaxis_remaps_ready=1",
|
|
"fiveaxis_file_open=0",
|
|
"fiveaxis_file_read_count=2197",
|
|
"fiveaxis_file_execute_count=2197",
|
|
"fiveaxis_file_finish_count=137",
|
|
"fiveaxis_file_final_rc=1",
|
|
"fiveaxis_file_reached_exit=1",
|
|
"fiveaxis_hal_switchkins: rc=0 found=1 value=0",
|
|
"fiveaxis_linuxcnc_remap_file_execute=1",
|
|
].join("\n"),
|
|
);
|
|
|
|
const duplicateOwordDir = writeRemapRegressionFiles("duplicate-o-word", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
"rm207.ngc",
|
|
"rm208.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"duplicate_oword_remap_wasm",
|
|
interp.runRemapFile(
|
|
`${duplicateOwordDir}/test.ngc`,
|
|
`${duplicateOwordDir}/test.ini`,
|
|
),
|
|
[
|
|
"remap_ini_open=1",
|
|
"remap_subroutine_path_count=1",
|
|
"remap_parse_remap_1=0",
|
|
"remap_parse_remap_2=0",
|
|
"remap_parsed_remap_count=2",
|
|
"remap_remaps_ready=1",
|
|
"remap_file_open=0",
|
|
"remap_file_read_count=31",
|
|
"remap_file_execute_count=31",
|
|
"remap_file_finish_count=0",
|
|
"remap_file_final_rc=3",
|
|
"remap_file_reached_endfile=1",
|
|
"remap_canon_event=MESSAGE: executing m207: run remapped m208 before o<problem>",
|
|
"remap_canon_event=MESSAGE: rm207 running remapped m208",
|
|
"remap_canon_event=MESSAGE: rm208 starting and done",
|
|
"remap_canon_event=FINISH",
|
|
"remap_linuxcnc_file_execute=1",
|
|
].join("\n"),
|
|
);
|
|
|
|
const failArgs0Dir = writeRemapRegressionFiles("fail/args.0", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
"rm400.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"fail_args_0_remap_wasm",
|
|
interp.runRemapFile(
|
|
`${failArgs0Dir}/test.ngc`,
|
|
`${failArgs0Dir}/test.ini`,
|
|
),
|
|
[
|
|
"remap_ini_open=1",
|
|
"remap_subroutine_path_count=1",
|
|
"remap_parse_remap_1=0",
|
|
"remap_parsed_remap_count=1",
|
|
"remap_remaps_ready=1",
|
|
"remap_file_open=0",
|
|
"remap_file_saw_error=0",
|
|
"remap_canon_event=MESSAGE: M400 call_level= 1.000000 remap_level=1.000000",
|
|
"remap_canon_event=MESSAGE: P word set: 47.110000",
|
|
"remap_canon_event=MESSAGE: Q word set: 8.150000",
|
|
"remap_canon_event=PROGRAM_END",
|
|
"remap_linuxcnc_file_execute=1",
|
|
].join("\n"),
|
|
);
|
|
|
|
const failArgs1Dir = writeRemapRegressionFiles("fail/args.1", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
"rm400.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"fail_args_1_remap_wasm",
|
|
interp.runRemapFileContinueOnError(
|
|
`${failArgs1Dir}/test.ngc`,
|
|
`${failArgs1Dir}/test.ini`,
|
|
),
|
|
[
|
|
"remap_ini_open=1",
|
|
"remap_subroutine_path_count=1",
|
|
"remap_parse_remap_1=0",
|
|
"remap_file_execute_1=5",
|
|
"remap_file_error_text=user-defined M400: missing: Q",
|
|
"remap_file_saw_error=1",
|
|
"remap_canon_event=PROGRAM_END",
|
|
"remap_linuxcnc_file_execute=1",
|
|
].join("\n"),
|
|
);
|
|
|
|
const failArgs2Dir = writeRemapRegressionFiles("fail/args.2", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
"rm400.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"fail_args_2_remap_wasm",
|
|
interp.runRemapFileContinueOnError(
|
|
`${failArgs2Dir}/test.ngc`,
|
|
`${failArgs2Dir}/test.ini`,
|
|
),
|
|
[
|
|
"remap_ini_open=1",
|
|
"remap_subroutine_path_count=1",
|
|
"remap_parse_remap_1=0",
|
|
"remap_file_execute_1=5",
|
|
"remap_file_error_text=user-defined M400: missing: P,Q",
|
|
"remap_file_saw_error=1",
|
|
"remap_canon_event=PROGRAM_END",
|
|
"remap_linuxcnc_file_execute=1",
|
|
].join("\n"),
|
|
);
|
|
|
|
const failBodyNgcDir = writeRemapRegressionFiles("fail/body-ngc", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
"rm400.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"fail_body_ngc_remap_wasm",
|
|
interp.runRemapFileContinueOnError(
|
|
`${failBodyNgcDir}/test.ngc`,
|
|
`${failBodyNgcDir}/test.ini`,
|
|
),
|
|
[
|
|
"remap_ini_open=1",
|
|
"remap_subroutine_path_count=1",
|
|
"remap_parse_remap_1=0",
|
|
"remap_file_read_5=5",
|
|
"remap_file_error_text=Attempt to divide by zero",
|
|
"remap_file_saw_error=1",
|
|
"remap_canon_event=MESSAGE: before M400: call_level= 0.000000 remap_level=0.000000",
|
|
"remap_canon_event=MESSAGE: in rm400: call_level= 1.000000 remap_level=1.000000",
|
|
"remap_canon_event=MESSAGE: after failed M400: call_level= 0.000000 remap_level=0.000000",
|
|
"remap_canon_event=PROGRAM_END",
|
|
"remap_linuxcnc_file_execute=1",
|
|
].join("\n"),
|
|
);
|
|
|
|
const m30InteractionDir = writeRemapRegressionFiles("m30-interaction", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
"rm400.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"m30_interaction_remap_wasm",
|
|
interp.runRemapFile(
|
|
`${m30InteractionDir}/test.ngc`,
|
|
`${m30InteractionDir}/test.ini`,
|
|
),
|
|
[
|
|
"remap_ini_open=1",
|
|
"remap_subroutine_path_count=1",
|
|
"remap_parse_remap_1=0",
|
|
"remap_parsed_remap_count=1",
|
|
"remap_remaps_ready=1",
|
|
"remap_file_open=0",
|
|
"remap_file_read_count=4",
|
|
"remap_file_execute_count=4",
|
|
"remap_file_finish_count=0",
|
|
"remap_file_final_rc=1",
|
|
"remap_file_reached_exit=1",
|
|
"remap_canon_event=MESSAGE: m400 call_level=1.000000 remap_level=1.000000 line=2.000000",
|
|
"remap_canon_event=PROGRAM_END",
|
|
"remap_linuxcnc_file_execute=1",
|
|
].join("\n"),
|
|
);
|
|
|
|
const nestedRemapsOwordDir = writeRemapRegressionFiles("nested-remaps-oword", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
"rm400.ngc",
|
|
"rm401.ngc",
|
|
"rm402.ngc",
|
|
"rm403.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"nested_remaps_oword_remap_wasm",
|
|
interp.runRemapFile(
|
|
`${nestedRemapsOwordDir}/test.ngc`,
|
|
`${nestedRemapsOwordDir}/test.ini`,
|
|
),
|
|
[
|
|
"remap_ini_open=1",
|
|
"remap_subroutine_path_count=1",
|
|
"remap_parse_remap_1=0",
|
|
"remap_parse_remap_2=0",
|
|
"remap_parse_remap_3=0",
|
|
"remap_parse_remap_4=0",
|
|
"remap_parsed_remap_count=4",
|
|
"remap_remaps_ready=1",
|
|
"remap_file_open=0",
|
|
"remap_file_read_count=21",
|
|
"remap_file_execute_count=21",
|
|
"remap_file_finish_count=0",
|
|
"remap_file_final_rc=3",
|
|
"remap_file_reached_endfile=1",
|
|
"remap_canon_event=MESSAGE: main call_level=0.000000 remap_level=0.000000 line=2.000000",
|
|
"remap_canon_event=MESSAGE: m400 handler pre call_level=1.000000 remap_level=1.000000 line=2.000000",
|
|
"remap_canon_event=MESSAGE: m401 handler pre call_level=2.000000 remap_level=2.000000 line=2.000000",
|
|
"remap_canon_event=MESSAGE: m402 handler pre call_level=3.000000 remap_level=3.000000 line=2.000000",
|
|
"remap_canon_event=MESSAGE: m403 handler pre call_level=4.000000 remap_level=4.000000 line=2.000000",
|
|
"remap_canon_event=MESSAGE: m400 handler post call_level=1.000000 remap_level=1.000000 line=4.000000",
|
|
"remap_canon_event=FINISH",
|
|
"remap_linuxcnc_file_execute=1",
|
|
].join("\n"),
|
|
);
|
|
|
|
const posargs0Dir = writeRemapRegressionFiles("posargs.0", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
"rg881.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"posargs_0_remap_wasm",
|
|
interp.runRemapFile(
|
|
`${posargs0Dir}/test.ngc`,
|
|
`${posargs0Dir}/test.ini`,
|
|
),
|
|
[
|
|
"remap_ini_open=1",
|
|
"remap_subroutine_path_count=1",
|
|
"remap_parse_remap_1=0",
|
|
"remap_parsed_remap_count=1",
|
|
"remap_remaps_ready=1",
|
|
"remap_file_open=0",
|
|
"remap_file_read_count=19",
|
|
"remap_file_execute_count=19",
|
|
"remap_file_finish_count=0",
|
|
"remap_file_final_rc=1",
|
|
"remap_file_reached_exit=1",
|
|
"remap_canon_event=MESSAGE: in rg881: n_args=3.000000 [1.000000] [2.000000] [3.000000] [0.000000] [0.000000]",
|
|
"remap_canon_event=MESSAGE: in rg881: n_args=4.000000 [1.000000] [2.000000] [3.000000] [4.000000] [0.000000]",
|
|
"remap_canon_event=MESSAGE: in rg881: n_args=4.000000 [1.000000] [2.000000] [3.000000] [5.000000] [0.000000]",
|
|
"remap_canon_event=MESSAGE: in rg881: n_args=5.000000 [1.000000] [2.000000] [3.000000] [4.000000] [5.000000]",
|
|
"remap_canon_event=PROGRAM_END",
|
|
"remap_linuxcnc_file_execute=1",
|
|
].join("\n"),
|
|
);
|
|
|
|
const sequencingDir = writeRemapRegressionFiles("sequencing", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
"rg881.ngc",
|
|
"rm405.ngc",
|
|
"rm406.ngc",
|
|
"rm407.ngc",
|
|
"rm408.ngc",
|
|
"rm409.ngc",
|
|
"rm410.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"sequencing_remap_wasm",
|
|
interp.runRemapFile(
|
|
`${sequencingDir}/test.ngc`,
|
|
`${sequencingDir}/test.ini`,
|
|
),
|
|
[
|
|
"remap_ini_open=1",
|
|
"remap_subroutine_path_count=1",
|
|
"remap_parse_remap_1=0",
|
|
"remap_parse_remap_2=0",
|
|
"remap_parse_remap_3=0",
|
|
"remap_parse_remap_4=0",
|
|
"remap_parse_remap_5=0",
|
|
"remap_parse_remap_6=0",
|
|
"remap_parse_remap_7=0",
|
|
"remap_parsed_remap_count=7",
|
|
"remap_remaps_ready=1",
|
|
"remap_file_open=0",
|
|
"remap_file_read_count=10084",
|
|
"remap_file_execute_count=10084",
|
|
"remap_file_final_rc=1",
|
|
"remap_file_reached_exit=1",
|
|
"remap_canon_event=MESSAGE: seq=1.000000",
|
|
"remap_canon_event=MESSAGE: seq=5.000000",
|
|
"remap_canon_event=MESSAGE: seq=6.000000",
|
|
"remap_canon_event=MESSAGE: seq=7.000000",
|
|
"remap_canon_event=MESSAGE: seq=8.000000 - reset to 1",
|
|
"remap_canon_event=MESSAGE: seq=8.000000",
|
|
"remap_canon_event=MESSAGE: seq=9.000000",
|
|
"remap_canon_event=MESSAGE: seq=10.000000 - reset to 1",
|
|
"remap_canon_event=PROGRAM_END",
|
|
"remap_linuxcnc_file_execute=1",
|
|
].join("\n"),
|
|
);
|
|
|
|
const remapIoDir = writeRemapRegressionFiles("remap-io", [
|
|
"test-ngc.ini",
|
|
"io_input_m66.ngc",
|
|
"io_output_m62.ngc",
|
|
"io_output_m63.ngc",
|
|
"io_output_m64.ngc",
|
|
"io_output_m65.ngc",
|
|
"io_output_m67.ngc",
|
|
"io_output_m68.ngc",
|
|
]);
|
|
interp.writeTextFile(`${remapIoDir}/simpockets.tbl`, "T2 P2 Z0 ;remap-io tool\n");
|
|
verifyExpectedOutput(
|
|
"remap_io_ngc_mdi_wasm",
|
|
interp.runRemapIoMdiSequence(`${remapIoDir}/test-ngc.ini`),
|
|
[
|
|
"remap_ini_open=1",
|
|
"remap_subroutine_path_count=1",
|
|
"remap_parse_remap_1=0",
|
|
"remap_parse_remap_7=0",
|
|
"remap_parsed_remap_count=7",
|
|
"remap_remaps_ready=1",
|
|
"remap_mdi_M62 P1_execute_0=0",
|
|
"remap_mdi_M66 P1_execute_0=2",
|
|
"remap_mdi_M66 P1_execute_1=0",
|
|
"remap_mdi_M66 E1 L0_execute_0=2",
|
|
"remap_mdi_M66 E1 L0_execute_1=0",
|
|
"remap_mdi_parameter_5399=42.13",
|
|
"remap_mdi_parameter_5399=-13.42",
|
|
"remap_mdi_canon_event=SET_MOTION_OUTPUT_BIT index=0",
|
|
"remap_mdi_canon_event=CLEAR_MOTION_OUTPUT_BIT index=0",
|
|
"remap_mdi_canon_event=SET_AUX_OUTPUT_BIT index=0",
|
|
"remap_mdi_canon_event=CLEAR_AUX_OUTPUT_BIT index=0",
|
|
"remap_mdi_canon_event=WAIT index=0 input_type=1 wait_type=0 timeout=0",
|
|
"remap_mdi_canon_event=WAIT index=0 input_type=0 wait_type=0 timeout=0",
|
|
"remap_mdi_canon_event=SET_MOTION_OUTPUT_VALUE index=0 value=42.13",
|
|
"remap_mdi_canon_event=SET_AUX_OUTPUT_VALUE index=0 value=-13.42",
|
|
"remap_io_ngc_linuxcnc_mdi_sequence=1",
|
|
].join("\n"),
|
|
);
|
|
|
|
const doWhileBreakPath = writeInterpRegressionFile("do-while-break", "test.ngc");
|
|
verifyExpectedOutput(
|
|
"interp_do_while_break_wasm",
|
|
interp.runFile(doWhileBreakPath),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=30",
|
|
"file_execute_count=30",
|
|
"canon_event=MESSAGE: must-execute-outer",
|
|
"canon_event=MESSAGE: must-execute-nested",
|
|
"canon_event=MESSAGE: must-execute-inner",
|
|
"canon_event=MESSAGE: post-inner-while",
|
|
"canon_event=MESSAGE: post-nested-while",
|
|
"canon_event=MESSAGE: post-outer-while",
|
|
"canon_event=PROGRAM_END",
|
|
"absent=canon_event=MESSAGE: do-not-execute",
|
|
].join("\n"),
|
|
);
|
|
|
|
const owordBug315Path = writeInterpRegressionFile("oword-bug315", "test.ngc");
|
|
verifyExpectedOutput(
|
|
"interp_oword_bug315_wasm",
|
|
interp.runFile(owordBug315Path),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=23",
|
|
"file_execute_count=23",
|
|
"canon_event=MESSAGE: running sub",
|
|
"canon_event=MESSAGE: breaking out of sub",
|
|
"canon_event=MESSAGE: done",
|
|
"canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
|
|
const owordBug315P2Path = writeInterpRegressionFile("oword-bug315-p2", "test.ngc");
|
|
verifyExpectedOutput(
|
|
"interp_oword_bug315_p2_wasm",
|
|
interp.runFile(owordBug315P2Path),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=26",
|
|
"file_execute_count=26",
|
|
"canon_event=STRAIGHT_TRAVERSE line=7 x=2 y=2 z=2",
|
|
"canon_event=MESSAGE: executing this one",
|
|
"canon_event=PROGRAM_END",
|
|
"absent=canon_event=MESSAGE: not executing this one",
|
|
].join("\n"),
|
|
);
|
|
|
|
const existsPath = writeInterpRegressionFile("exists", "test.ngc");
|
|
verifyExpectedOutput(
|
|
"interp_exists_wasm",
|
|
interp.runFile(existsPath),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=7",
|
|
"file_execute_count=7",
|
|
"canon_event=STRAIGHT_TRAVERSE line=2 x=1 y=0 z=1",
|
|
"canon_event=COMMENT: comment",
|
|
"canon_event=STRAIGHT_TRAVERSE line=6 x=1 y=0 z=0",
|
|
"canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
|
|
const returnValuePath = writeInterpRegressionFile("return-value", "test.ngc");
|
|
verifyExpectedOutput(
|
|
"interp_return_value_wasm",
|
|
interp.runFile(returnValuePath),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=75",
|
|
"file_execute_count=75",
|
|
"canon_event=MESSAGE: line 6.000000: _value: - expected 0.000000, got 0.000000",
|
|
"canon_event=MESSAGE: line 28.000000: call with arg1=2.000000 expect 246.000000, got 246.000000",
|
|
"canon_event=MESSAGE: line 37.000000: call with arg1=-1.000000 expect 0.000000, got 0.000000",
|
|
"canon_event=MESSAGE: line 47.000000: call with arg1=0.000000 expect 4712.000000, got 4712.000000",
|
|
"canon_event=MESSAGE: line 53.000000: _value=4712.000000 - expected 4712.000000",
|
|
"canon_event=PROGRAM_END",
|
|
"absent=fail:",
|
|
].join("\n"),
|
|
);
|
|
|
|
const subsFollowMainPath = writeInterpRegressionFile("subs-follow-main", "test.ngc");
|
|
verifyExpectedOutput(
|
|
"interp_subs_follow_main_wasm",
|
|
interp.runFile(subsFollowMainPath),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=9",
|
|
"file_execute_count=9",
|
|
"canon_event=COMMENT: Subs may follow main program ",
|
|
"canon_event=PALLET_SHUTTLE",
|
|
"canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
|
|
const fractionalLinenumbersPath = writeInterpRegressionFile(
|
|
"fractional-linenumbers",
|
|
"test.ngc",
|
|
);
|
|
verifyExpectedOutput(
|
|
"interp_fractional_linenumbers_wasm",
|
|
interp.runFile(fractionalLinenumbersPath),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=4",
|
|
"file_execute_count=4",
|
|
"canon_event=SET_SPINDLE_SPEED spindle=0 speed=300",
|
|
"canon_event=SET_SPINDLE_SPEED spindle=0 speed=600",
|
|
"canon_event=SET_SPINDLE_SPEED spindle=0 speed=1200",
|
|
"canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
|
|
const namedparamBug424Path = writeInterpRegressionFile("namedparam-bug424", "test.ngc");
|
|
verifyExpectedOutput(
|
|
"interp_namedparam_bug424_wasm",
|
|
interp.runFile(namedparamBug424Path),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=6",
|
|
"file_execute_count=6",
|
|
"setup.current_x=2",
|
|
"setup.current_y=3",
|
|
"setup.current_z=4",
|
|
"canon_event=USE_LENGTH_UNITS units=1",
|
|
"canon_event=STRAIGHT_TRAVERSE line=5 x=2 y=3 z=4",
|
|
"canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
|
|
const g33_1Path = writeInterpRegressionFile("g33.1", "g33.1.ngc");
|
|
verifyExpectedOutput(
|
|
"interp_g33_1_wasm",
|
|
interp.runFile(g33_1Path),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=5",
|
|
"file_execute_count=5",
|
|
"file_saw_error=0",
|
|
"run_step phase=execute step=4 rc=0 line=4",
|
|
"statement_uri=g33.1%20z-1.2%20k0.1",
|
|
"canon_event=START_SPINDLE_CLOCKWISE spindle=0",
|
|
"canon_event=START_SPEED_FEED_SYNCH spindle=0 feed_per_revolution=0.1 velocity_mode=0",
|
|
"canon_event=RIGID_TAP line=4 x=0 y=0 z=-1.2 scale=1",
|
|
"canon_event=STOP_SPEED_FEED_SYNCH",
|
|
"canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
|
|
const g6164Path = writeInterpRegressionFile("g6164", "test.ngc");
|
|
verifyExpectedOutput(
|
|
"interp_g6164_wasm",
|
|
interp.runFile(g6164Path),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=6",
|
|
"file_execute_count=6",
|
|
"canon_event=SET_MOTION_CONTROL_MODE mode=3 tolerance=0",
|
|
"canon_event=SET_NAIVECAM_TOLERANCE tolerance=0",
|
|
"canon_event=SET_MOTION_CONTROL_MODE mode=3 tolerance=1",
|
|
"canon_event=SET_NAIVECAM_TOLERANCE tolerance=1",
|
|
"canon_event=SET_NAIVECAM_TOLERANCE tolerance=2",
|
|
"canon_event=SET_MOTION_CONTROL_MODE mode=2 tolerance=0",
|
|
"canon_event=SET_MOTION_CONTROL_MODE mode=1 tolerance=0",
|
|
"canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
|
|
const rotationAbsPtsPath = writeInterpRegressionFile("rotation/abs-pts", "test.ngc");
|
|
const rotationAbsPtsOutput = interp.runFile(rotationAbsPtsPath);
|
|
verifyExpectedOutput(
|
|
"interp_rotation_abs_pts_wasm",
|
|
rotationAbsPtsOutput,
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=192",
|
|
"file_execute_count=192",
|
|
"file_saw_error=0",
|
|
"canon_event=MESSAGE: 0.000000 0.000000 0.000000",
|
|
"canon_event=MESSAGE: 1.000000 2.000000 3.000000",
|
|
"canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
assert.equal(
|
|
rotationAbsPtsOutput.match(/canon_event=MESSAGE: 0\.000000 0\.000000 0\.000000/g)?.length,
|
|
14,
|
|
"interp_rotation_abs_pts_wasm: zero absolute-position message count",
|
|
);
|
|
assert.equal(
|
|
rotationAbsPtsOutput.match(/canon_event=MESSAGE: 1\.000000 2\.000000 3\.000000/g)?.length,
|
|
14,
|
|
"interp_rotation_abs_pts_wasm: target absolute-position message count",
|
|
);
|
|
|
|
const rotationG28Path = writeInterpRegressionFile("rotation/g28", "g28.ngc");
|
|
const rotationG28Output = interp.runFile(rotationG28Path);
|
|
verifyExpectedOutput(
|
|
"interp_rotation_g28_wasm",
|
|
rotationG28Output,
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=13",
|
|
"file_execute_count=13",
|
|
"file_saw_error=0",
|
|
"canon_event=SET_XY_ROTATION rotation=45",
|
|
"canon_event=COMMENT: G55 G28",
|
|
"canon_event=STRAIGHT_TRAVERSE line=9 x=10 y=10 z=0",
|
|
"canon_event=COMMENT: G56 G28",
|
|
"canon_event=STRAIGHT_TRAVERSE line=14 x=0 y=14.1421 z=0 a=1",
|
|
"canon_event=FINISH",
|
|
].join("\n"),
|
|
);
|
|
assert.match(
|
|
rotationG28Output,
|
|
/canon_event=STRAIGHT_TRAVERSE line=14 x=(0|[0-9.e-]+) y=14\.1421 z=0 a=0/,
|
|
"interp_rotation_g28_wasm: G56 G28 final machine point",
|
|
);
|
|
|
|
const rotationG53Path = writeInterpRegressionFile("rotation/g53", "g53.ngc");
|
|
const rotationG53Output = interp.runFile(rotationG53Path);
|
|
verifyExpectedOutput(
|
|
"interp_rotation_g53_wasm",
|
|
rotationG53Output,
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=17",
|
|
"file_execute_count=17",
|
|
"file_saw_error=0",
|
|
"canon_event=SET_XY_ROTATION rotation=45",
|
|
"canon_event=COMMENT: g53 + g55 to 1,1",
|
|
"canon_event=COMMENT: g53 + g55 + g92 to 1,1",
|
|
"canon_event=STRAIGHT_TRAVERSE line=13 x=0 y=0 z=0",
|
|
"canon_event=COMMENT: g53 + g56 + g92 to 1,1",
|
|
"canon_event=STRAIGHT_TRAVERSE line=18 x=-0.414214 y=1 z=0 a=1",
|
|
"canon_event=FINISH",
|
|
].join("\n"),
|
|
);
|
|
assert.match(
|
|
rotationG53Output,
|
|
/canon_event=STRAIGHT_TRAVERSE line=8 x=1\.41421 y=([0-9.e-]+) z=0/,
|
|
"interp_rotation_g53_wasm: rotated G53 endpoint",
|
|
);
|
|
|
|
const iniparamDir = writeInterpRegressionFiles("iniparam", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"interp_iniparam_wasm",
|
|
interp.runFileWithIniContinueOnError(
|
|
`${iniparamDir}/test.ngc`,
|
|
`${iniparamDir}/test.ini`,
|
|
),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=9",
|
|
"file_execute_count=8",
|
|
"file_saw_error=1",
|
|
"file_error_text=Named parameter #<_ini[nosuchsection]nosuchname> not defined",
|
|
"setup.current_x=10",
|
|
"setup.current_y=20",
|
|
"setup.current_z=30",
|
|
"canon_event=STRAIGHT_TRAVERSE line=1 x=10 y=20 z=30",
|
|
"canon_event=MESSAGE: position now: 10.000000 20.000000 30.000000",
|
|
"canon_event=MESSAGE: not in INI: ######",
|
|
"canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
|
|
const iniparamFailassignDir = writeInterpRegressionFiles("iniparam-failassign", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"interp_iniparam_failassign_wasm",
|
|
interp.runFileWithIni(
|
|
`${iniparamFailassignDir}/test.ngc`,
|
|
`${iniparamFailassignDir}/test.ini`,
|
|
),
|
|
[
|
|
"file_open=0",
|
|
"file_execute_1=5",
|
|
"file_read_count=1",
|
|
"file_execute_count=1",
|
|
"file_saw_error=1",
|
|
"file_error_text=Cannot assign to read-only parameter #<_ini[vars]toolchange_x>",
|
|
"absent=canon_event=MESSAGE: notreached",
|
|
].join("\n"),
|
|
);
|
|
|
|
const subCallFromSubDir = writeInterpRegressionFiles("sub-call-from-sub", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
"subs/caller.ngc",
|
|
"subs/helper.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"interp_sub_call_from_sub_wasm",
|
|
interp.runFileWithIni(
|
|
`${subCallFromSubDir}/test.ngc`,
|
|
`${subCallFromSubDir}/test.ini`,
|
|
),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=10",
|
|
"file_execute_count=10",
|
|
"canon_event=COMMENT: Test: calling a sub from within another sub is valid",
|
|
"canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
|
|
const sequenceNumberDir = writeInterpRegressionFiles("sequence-number", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
"rm400.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"interp_sequence_number_wasm",
|
|
interp.runFileWithIni(
|
|
`${sequenceNumberDir}/test.ngc`,
|
|
`${sequenceNumberDir}/test.ini`,
|
|
),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=13",
|
|
"file_execute_count=13",
|
|
"canon_event=MESSAGE: main: line=7.000000 - expect 7",
|
|
"canon_event=MESSAGE: in rm400.ngc line=2.000000 - expect 2",
|
|
"canon_event=MESSAGE: main: line=9.000000 - expect 9",
|
|
"canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
|
|
const nestedSubErrorDir = writeInterpRegressionFiles("nested-sub-error", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
"subs/nested.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"interp_nested_sub_error_wasm",
|
|
interp.runFileWithIni(
|
|
`${nestedSubErrorDir}/test.ngc`,
|
|
`${nestedSubErrorDir}/test.ini`,
|
|
),
|
|
[
|
|
"file_open=0",
|
|
"file_read_4=5",
|
|
"file_error_text=Nested subroutine definition: 'O100 sub' found inside called subroutine 'Onested'",
|
|
"file_read_count=4",
|
|
"file_execute_count=3",
|
|
"canon_event=COMMENT: Test: nested sub definition inside named sub should error",
|
|
"absent=canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
|
|
const nestedSubInFileErrorDir = writeInterpRegressionFiles("nested-sub-in-file-error", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
"subs/sequential.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"interp_nested_sub_in_file_error_wasm",
|
|
interp.runFileWithIni(
|
|
`${nestedSubInFileErrorDir}/test.ngc`,
|
|
`${nestedSubInFileErrorDir}/test.ini`,
|
|
),
|
|
[
|
|
"file_open=0",
|
|
"file_execute_5=5",
|
|
"file_error_text=Subroutine 'O200' not found -- not in offset table and no file '",
|
|
"file_read_count=5",
|
|
"file_execute_count=5",
|
|
"canon_event=COMMENT: Test: numbered sub after named endsub in same file should error",
|
|
"canon_event=MESSAGE: sequential main: 7.000000 8.000000 9.000000",
|
|
"absent=canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
|
|
const owordUnwindDir = writeInterpRegressionFiles("oword-unwind", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
"fail.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"interp_oword_unwind_wasm",
|
|
interp.runFileWithIniContinueOnError(
|
|
`${owordUnwindDir}/test.ngc`,
|
|
`${owordUnwindDir}/test.ini`,
|
|
),
|
|
[
|
|
"file_open=0",
|
|
"file_read_5=5",
|
|
"file_read_10=5",
|
|
"file_read_count=11",
|
|
"file_execute_count=9",
|
|
"file_saw_error=1",
|
|
"canon_event=MESSAGE: pre divide-by-zero",
|
|
"canon_event=PROGRAM_END",
|
|
"absent=canon_event=MESSAGE: post divide-by-zero",
|
|
].join("\n"),
|
|
);
|
|
|
|
const abortHotCommentDir = writeInterpRegressionFiles("abort-hot-comment", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"interp_abort_hot_comment_wasm",
|
|
interp.runFileWithIniContinueOnError(
|
|
`${abortHotCommentDir}/test.ngc`,
|
|
`${abortHotCommentDir}/test.ini`,
|
|
),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=125",
|
|
"file_execute_count=125",
|
|
"file_saw_error=1",
|
|
"file_error_text= MixedCase param42=20.000000 named=4711.000000 INI=3.140000",
|
|
"absent=canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
|
|
const m19Dir = writeInterpRegressionFiles("m19", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"interp_m19_wasm",
|
|
interp.runFileWithIni(`${m19Dir}/test.ngc`, `${m19Dir}/test.ini`),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=8",
|
|
"file_execute_count=8",
|
|
"file_saw_error=0",
|
|
"canon_event=ORIENT_SPINDLE spindle=0 orientation=87 mode=0",
|
|
"canon_event=WAIT_SPINDLE_ORIENT_COMPLETE spindle=0 timeout=2",
|
|
"canon_event=ORIENT_SPINDLE spindle=0 orientation=42 mode=1",
|
|
"canon_event=ORIENT_SPINDLE spindle=0 orientation=132 mode=0",
|
|
"canon_event=ORIENT_SPINDLE spindle=0 orientation=132 mode=1",
|
|
"canon_event=WAIT_SPINDLE_ORIENT_COMPLETE spindle=0 timeout=1",
|
|
"canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
|
|
const magicCommentsParamFormatPath = writeInterpRegressionFile(
|
|
"magic_comments/param_format_printing",
|
|
"test.ngc",
|
|
);
|
|
verifyExpectedOutput(
|
|
"interp_magic_comments_param_format_wasm",
|
|
interp.runFile(magicCommentsParamFormatPath),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=13",
|
|
"file_execute_count=13",
|
|
"file_saw_error=0",
|
|
"canon_event=MESSAGE: native value = 1.123457",
|
|
"canon_event=MESSAGE: Test round to integer: 1",
|
|
"canon_event=MESSAGE: Test round to 4 decimals: 1.1235",
|
|
"canon_event=MESSAGE: Test format separate from param: The value is: 1.1235",
|
|
"canon_event=MESSAGE: Test round to 7 decimals: 1.1234568",
|
|
"canon_event=MESSAGE: native value2 = 2.345679",
|
|
"canon_event=MESSAGE: Test2 round all params in line to 4 decimals: The values are: 1.1235, 2.3457",
|
|
"canon_event=MESSAGE: Test2 only round last value to integer: The values are: 1.123457, 2",
|
|
"canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
|
|
const m98m99BasicsPath = writeInterpRegressionFile("m98m99/01-basics", "test.ngc");
|
|
verifyExpectedOutput(
|
|
"interp_m98m99_01_basics_wasm",
|
|
interp.runFile(m98m99BasicsPath),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=22",
|
|
"file_execute_count=22",
|
|
"file_saw_error=0",
|
|
"canon_event=COMMENT: A simple O sub example ",
|
|
"canon_event=STRAIGHT_TRAVERSE line=10 x=3 y=0 z=0.25",
|
|
"canon_event=STRAIGHT_FEED line=11 x=3 y=0 z=-1",
|
|
"canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
|
|
const m98m99VariablesPath = writeInterpRegressionFile("m98m99/02-variables", "test.ngc");
|
|
const m98m99VariablesRun = runWithCapturedPrints(() => interp.runFile(m98m99VariablesPath));
|
|
verifyExpectedOutput(
|
|
"interp_m98m99_02_variables_wasm",
|
|
m98m99VariablesRun.output,
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=54",
|
|
"file_execute_count=54",
|
|
"file_saw_error=0",
|
|
"canon_event=COMMENT: Fanuc params have global scope; rs274ngc params #1..#30 have local scope ",
|
|
"canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"interp_m98m99_02_variables_prints_wasm",
|
|
m98m99VariablesRun.prints,
|
|
[
|
|
"Q MAIN/FANUC: POST-M98: 1=13.010000; 30=13.300000; 31=13.310000",
|
|
"Q MAIN/RS274NGC: POST-O-CALL: 1=42.010000; 30=42.300000; 31=13.310000",
|
|
].join("\n"),
|
|
);
|
|
|
|
const m98m99NestedSubsPath = writeInterpRegressionFile("m98m99/07-nested-subs", "test.ngc");
|
|
const m98m99NestedSubsRun = runWithCapturedPrints(() => interp.runFile(m98m99NestedSubsPath));
|
|
verifyExpectedOutput(
|
|
"interp_m98m99_07_nested_subs_wasm",
|
|
m98m99NestedSubsRun.output,
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=163",
|
|
"file_execute_count=163",
|
|
"file_saw_error=0",
|
|
"canon_event=COMMENT: A nested Fanuc subroutine example ",
|
|
"canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"interp_m98m99_07_nested_subs_prints_wasm",
|
|
m98m99NestedSubsRun.prints,
|
|
[
|
|
"X >>>> LOOP [O2.O1]: 4.500000",
|
|
"X MAIN END: 1=5.000000",
|
|
].join("\n"),
|
|
);
|
|
|
|
const m98m99SubFollowsMainPath = writeInterpRegressionFile(
|
|
"m98m99/08-sub-follows-main",
|
|
"test.ngc",
|
|
);
|
|
const m98m99SubFollowsMainRun = runWithCapturedPrints(() =>
|
|
interp.runFile(m98m99SubFollowsMainPath),
|
|
);
|
|
verifyExpectedOutput(
|
|
"interp_m98m99_08_sub_follows_main_wasm",
|
|
m98m99SubFollowsMainRun.output,
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=9",
|
|
"file_execute_count=9",
|
|
"file_saw_error=0",
|
|
"canon_event=COMMENT: Fanuc-style subs may follow main program ",
|
|
"canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"interp_m98m99_08_sub_follows_main_prints_wasm",
|
|
m98m99SubFollowsMainRun.prints,
|
|
"X IN O1",
|
|
);
|
|
|
|
const m98m99M98P001Path = writeInterpRegressionFile("m98m99/10-M98-P001", "test.ngc");
|
|
const m98m99M98P001Run = runWithCapturedPrints(() => interp.runFile(m98m99M98P001Path));
|
|
verifyExpectedOutput(
|
|
"interp_m98m99_10_m98_p001_wasm",
|
|
m98m99M98P001Run.output,
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=8",
|
|
"file_execute_count=8",
|
|
"file_saw_error=0",
|
|
"canon_event=COMMENT: main program",
|
|
"canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"interp_m98m99_10_m98_p001_prints_wasm",
|
|
m98m99M98P001Run.prints,
|
|
[
|
|
"x got here",
|
|
"absent=ERROR: should not get here",
|
|
].join("\n"),
|
|
);
|
|
|
|
const m98m99NamedProgramNamedPath = writeInterpRegressionFile(
|
|
"m98m99/13-named-program",
|
|
"test-named.ngc",
|
|
);
|
|
verifyExpectedOutput(
|
|
"interp_m98m99_13_named_program_named_wasm",
|
|
interp.runFile(m98m99NamedProgramNamedPath),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=4",
|
|
"file_execute_count=4",
|
|
"file_saw_error=0",
|
|
"canon_event=COMMENT: test-named.ngc: Test named programs",
|
|
"canon_event=COMMENT: ...program body",
|
|
"canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
|
|
const m98m99NamedProgramNumberedPath = writeInterpRegressionFile(
|
|
"m98m99/13-named-program",
|
|
"test-numbered.ngc",
|
|
);
|
|
verifyExpectedOutput(
|
|
"interp_m98m99_13_named_program_numbered_wasm",
|
|
interp.runFile(m98m99NamedProgramNumberedPath),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=4",
|
|
"file_execute_count=4",
|
|
"file_saw_error=0",
|
|
"canon_event=COMMENT: test-numbered.ngc: Test numbered programs",
|
|
"canon_event=COMMENT: ...program body",
|
|
"canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
|
|
const m98m99OExpressionCallPath = writeInterpRegressionFile(
|
|
"m98m99/14-o-expression-call",
|
|
"test.ngc",
|
|
);
|
|
const m98m99OExpressionCallRun = runWithCapturedPrints(() =>
|
|
interp.runFile(m98m99OExpressionCallPath),
|
|
);
|
|
verifyExpectedOutput(
|
|
"interp_m98m99_14_o_expression_call_wasm",
|
|
m98m99OExpressionCallRun.output,
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=29",
|
|
"file_execute_count=29",
|
|
"file_saw_error=0",
|
|
"canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"interp_m98m99_14_o_expression_call_prints_wasm",
|
|
m98m99OExpressionCallRun.prints,
|
|
[
|
|
"In sub 100",
|
|
"In sub 200",
|
|
].join("\n"),
|
|
);
|
|
|
|
const userM110 = writeUserMCodeFixture("m110", "M110");
|
|
verifyExpectedOutput(
|
|
"interp_user_m110_wasm",
|
|
interp.runFileWithIni(userM110.programPath, userM110.iniPath),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=2",
|
|
"file_execute_count=2",
|
|
"canon_event=USER_M_COMMAND code=M110",
|
|
"canon_event=PROGRAM_END",
|
|
"absent=Unknown m code used: M110",
|
|
].join("\n"),
|
|
);
|
|
|
|
const userM111 = writeUserMCodeFixture("m111", "M111");
|
|
verifyExpectedOutput(
|
|
"interp_user_m111_wasm",
|
|
interp.runFileWithIni(userM111.programPath, userM111.iniPath),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=2",
|
|
"file_execute_count=2",
|
|
"canon_event=USER_M_COMMAND code=M111",
|
|
"canon_event=PROGRAM_END",
|
|
"absent=Unknown m code used: M111",
|
|
].join("\n"),
|
|
);
|
|
|
|
const parameterFilePath = "/work/rs274ngc.var";
|
|
interp.writeTextFile(
|
|
parameterFilePath,
|
|
[
|
|
"5161 10.5",
|
|
"5162 20.25",
|
|
"5220 1",
|
|
"5221 2.25",
|
|
"5399 44",
|
|
"<_named_param> 123",
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"restore_parameters",
|
|
interp.restoreParameters(parameterFilePath),
|
|
[
|
|
"restore_parameters=0",
|
|
"parameter_5161=10.5",
|
|
"parameter_5162=20.25",
|
|
"parameter_5220=1",
|
|
"parameter_5221=2.25",
|
|
"parameter_5399=44",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"restore_parameters_missing_file",
|
|
interp.restoreParameters("/work/missing.var"),
|
|
"restore_parameters=0",
|
|
);
|
|
|
|
const outOfOrderParameterFilePath = "/work/out-of-order.var";
|
|
interp.writeTextFile(outOfOrderParameterFilePath, "5220 1\n5161 2\n");
|
|
verifyExpectedOutput(
|
|
"restore_parameters_out_of_order",
|
|
interp.restoreParameters(outOfOrderParameterFilePath),
|
|
[
|
|
"restore_parameters=5",
|
|
"restore_error_text=Parameter file out of order",
|
|
].join("\n"),
|
|
);
|
|
|
|
const missingRequiredParameterFilePath = "/work/missing-required.var";
|
|
interp.writeTextFile(missingRequiredParameterFilePath, "5161 3.5\n5220 1\n");
|
|
verifyExpectedOutput(
|
|
"restore_parameters_missing_required",
|
|
interp.restoreParameters(missingRequiredParameterFilePath),
|
|
[
|
|
"restore_parameters=0",
|
|
"parameter_5161=3.5",
|
|
"parameter_5162=0",
|
|
].join("\n"),
|
|
);
|
|
|
|
verifyExpectedOutput(
|
|
"save_parameters",
|
|
interp.saveParameters(parameterFilePath, {
|
|
5161: 12.34,
|
|
5162: 56.78,
|
|
5220: 1.0,
|
|
5221: 9.87,
|
|
5399: 66.6,
|
|
}),
|
|
[
|
|
"save_parameters=0",
|
|
"parameter_5161=12.34",
|
|
"parameter_5162=56.78",
|
|
"parameter_5220=1",
|
|
"parameter_5221=9.87",
|
|
"parameter_5399=66.6",
|
|
].join("\n"),
|
|
);
|
|
const savedParameterFile = interp.readTextFile(parameterFilePath);
|
|
const backupParameterFile = interp.readTextFile(`${parameterFilePath}.bak`);
|
|
assert.equal(savedParameterFile.includes("5161\t12.340000"), true);
|
|
assert.equal(savedParameterFile.includes("5162\t56.780000"), true);
|
|
assert.equal(savedParameterFile.includes("5221\t9.870000"), true);
|
|
assert.equal(savedParameterFile.includes("5399\t66.600000"), true);
|
|
assert.equal(savedParameterFile.includes("_named_param"), false);
|
|
assert.equal(backupParameterFile.includes("5161 10.5"), true);
|
|
|
|
const toolTablePath = "/work/tool.tbl";
|
|
interp.writeTextFile(
|
|
toolTablePath,
|
|
[
|
|
"T2 P7 Z3.125 D1.5 I12 J34 Q4 ;finish tool",
|
|
"T5 P9 X1 Y2 Z3 ;rough tool",
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"load_tool_table",
|
|
interp.loadToolTable(toolTablePath),
|
|
[
|
|
"tooldata_load=0",
|
|
"tooldata_last_index=2",
|
|
"tool_0.toolno=-1",
|
|
"tool_1.toolno=2",
|
|
"tool_1.pocketno=7",
|
|
"tool_1.z=3.125",
|
|
"tool_1.diameter=1.5",
|
|
"tool_1.frontangle=12",
|
|
"tool_1.backangle=34",
|
|
"tool_1.orientation=4",
|
|
"tool_1.comment=finish tool",
|
|
"tool_2.toolno=5",
|
|
"tool_2.pocketno=9",
|
|
"tool_2.z=3",
|
|
"tool_2.comment=rough tool",
|
|
"tool_index_for_tool_2=1",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"save_tool_table",
|
|
interp.saveToolTable(toolTablePath),
|
|
[
|
|
"tooldata_save=0",
|
|
"tool_1.toolno=2",
|
|
"tool_2.toolno=5",
|
|
].join("\n"),
|
|
);
|
|
const savedToolTable = interp.readTextFile(toolTablePath);
|
|
assert.equal(savedToolTable.includes("T2"), true);
|
|
assert.equal(savedToolTable.includes("P7"), true);
|
|
assert.equal(savedToolTable.includes("D+1.500000"), true);
|
|
assert.equal(savedToolTable.includes("Z+3.125000"), true);
|
|
assert.equal(savedToolTable.includes("I+12.000000"), true);
|
|
assert.equal(savedToolTable.includes("J+34.000000"), true);
|
|
assert.equal(savedToolTable.includes("Q4"), true);
|
|
assert.equal(savedToolTable.includes(";finish tool"), true);
|
|
assert.equal(savedToolTable.includes("T5"), true);
|
|
assert.equal(savedToolTable.includes("P9"), true);
|
|
assert.equal(savedToolTable.includes(";rough tool"), true);
|
|
|
|
const randomToolTablePath = "/work/random-tool.tbl";
|
|
interp.writeTextFile(
|
|
randomToolTablePath,
|
|
[
|
|
"T2 P7 Z3.125 D1.5 I12 J34 Q4 ;random finish tool",
|
|
"T5 P9 X1 Y2 Z3 ;random rough tool",
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"load_tool_table_random",
|
|
interp.loadToolTable(randomToolTablePath, { randomToolChanger: true }),
|
|
[
|
|
"tooldata_random_toolchanger=1",
|
|
"tooldata_load=0",
|
|
"tooldata_last_index=9",
|
|
"tool_1.toolno=-1",
|
|
"tool_2.toolno=-1",
|
|
"tool_pocket_7.toolno=2",
|
|
"tool_pocket_7.pocketno=7",
|
|
"tool_pocket_7.z=3.125",
|
|
"tool_pocket_7.diameter=1.5",
|
|
"tool_pocket_7.frontangle=12",
|
|
"tool_pocket_7.backangle=34",
|
|
"tool_pocket_7.orientation=4",
|
|
"tool_pocket_7.comment=random finish tool",
|
|
"tool_pocket_9.toolno=5",
|
|
"tool_pocket_9.pocketno=9",
|
|
"tool_pocket_9.z=3",
|
|
"tool_pocket_9.comment=random rough tool",
|
|
"tool_index_for_tool_2=7",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"save_tool_table_random",
|
|
interp.saveToolTable(randomToolTablePath),
|
|
[
|
|
"tooldata_save=0",
|
|
"tool_pocket_7.toolno=2",
|
|
"tool_pocket_9.toolno=5",
|
|
].join("\n"),
|
|
);
|
|
const savedRandomToolTable = interp.readTextFile(randomToolTablePath);
|
|
assert.equal(savedRandomToolTable.includes("T2"), true);
|
|
assert.equal(savedRandomToolTable.includes("P7"), true);
|
|
assert.equal(savedRandomToolTable.includes(";random finish tool"), true);
|
|
assert.equal(savedRandomToolTable.includes("T5"), true);
|
|
assert.equal(savedRandomToolTable.includes("P9"), true);
|
|
assert.equal(savedRandomToolTable.includes(";random rough tool"), true);
|
|
console.log("interp_wasm_node_smoke=ok");
|