2808 lines
93 KiB
HTML
2808 lines
93 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>LinuxCNC Interpreter Browser Smoke</title>
|
|
</head>
|
|
<body>
|
|
<pre id="status">running</pre>
|
|
<script type="module">
|
|
import {
|
|
createLinuxCncIniSdk,
|
|
createLinuxCncInterpSdk,
|
|
} from "../../runtime/sdk/src/index.js";
|
|
import {
|
|
saveMachineParametersToOpfs,
|
|
} from "../../runtime/opfs/linuxcnc-parameter-bridge.js";
|
|
import {
|
|
loadTextFile,
|
|
saveTextFile,
|
|
} from "../../runtime/opfs/file-service.js";
|
|
import {
|
|
saveMachineToolTableToOpfs,
|
|
} from "../../runtime/opfs/linuxcnc-tool-table-bridge.js";
|
|
import {
|
|
loadMachineSessionFromOpfs,
|
|
} from "../../runtime/opfs/linuxcnc-machine-session-bridge.js";
|
|
import {
|
|
loadMachineTextFiles,
|
|
saveMachineTextFiles,
|
|
} from "../../runtime/opfs/machine-file-store.js";
|
|
import {
|
|
INTERP_BASELINE_INI_FIXTURE,
|
|
INTERP_BROWSER_FILE_FIXTURES,
|
|
INTERP_BROWSER_MDI_FIXTURES,
|
|
INTERP_COORDINATE_OFFSETS_FILE_FIXTURE,
|
|
INTERP_ERROR_FIXTURES,
|
|
INTERP_INI_FIXTURE,
|
|
INTERP_POSITION_PARAMS_FILE_FIXTURE,
|
|
INTERP_SPINDLE_ORIENT_OFFSET_FIXTURE,
|
|
} from "../fixtures/interp-fixture-matrix.mjs";
|
|
|
|
const status = document.getElementById("status");
|
|
|
|
async function fetchText(path) {
|
|
const response = await fetch(path);
|
|
if (!response.ok) {
|
|
throw new Error(`${path}: HTTP ${response.status}`);
|
|
}
|
|
return response.text();
|
|
}
|
|
|
|
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);
|
|
if (output.includes(forbidden)) {
|
|
throw new Error(`${fixtureName}: unexpected ${forbidden}`);
|
|
}
|
|
continue;
|
|
}
|
|
if (!output.includes(expectedLine)) {
|
|
throw new Error(`${fixtureName}: missing ${expectedLine}`);
|
|
}
|
|
}
|
|
}
|
|
|
|
function verifyExpectedFileError(fixtureName, output, expectedText) {
|
|
if (!output.includes("file_open=0")) {
|
|
throw new Error(`${fixtureName}: missing file_open=0`);
|
|
}
|
|
|
|
const expectedLines = expectedText.split("\n").filter(Boolean);
|
|
for (const expectedLine of expectedLines) {
|
|
if (expectedLine.startsWith("absent=")) {
|
|
const forbidden = expectedLine.slice("absent=".length);
|
|
if (output.includes(forbidden)) {
|
|
throw new Error(`${fixtureName}: unexpected ${forbidden}`);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
if (expectedLine.startsWith("error_text=")) {
|
|
const message = expectedLine.slice("error_text=".length);
|
|
if (!output.includes(`file_error_text=${message}`)) {
|
|
throw new Error(`${fixtureName}: missing file error ${message}`);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
if (expectedLine.startsWith("canon_event=") && !output.includes(expectedLine)) {
|
|
throw new Error(`${fixtureName}: missing ${expectedLine}`);
|
|
}
|
|
}
|
|
}
|
|
|
|
async function writeFetchedTextFile(interp, sourcePath, wasmPath, options = {}) {
|
|
interp.writeTextFile(wasmPath, await fetchText(sourcePath));
|
|
if (options.executable) {
|
|
interp.module.FS.chmod(wasmPath, 0o755);
|
|
}
|
|
}
|
|
|
|
async function loadSimMachineFiles(machineRel, files, executableFiles = []) {
|
|
const sourceDir = `../../vendor/linuxcnc/configs/sim/${machineRel}`;
|
|
const wasmDir = `/work/browser-sim/${machineRel}`;
|
|
const executableSet = new Set(executableFiles);
|
|
const machineFiles = [];
|
|
|
|
for (const filename of files) {
|
|
machineFiles.push({
|
|
path: `${wasmDir}/${filename}`,
|
|
text: await fetchText(`${sourceDir}/${filename}`),
|
|
executable: executableSet.has(filename),
|
|
});
|
|
}
|
|
|
|
return { wasmDir, files: machineFiles };
|
|
}
|
|
|
|
async function writeFiveAxisTrtMachineFiles(interp) {
|
|
const sourceDir =
|
|
"../../vendor/linuxcnc/configs/sim/axis/vismach/5axis/table-rotary-tilting";
|
|
const wasmDir = "/work/browser-fiveaxis/table-rotary-tilting";
|
|
const remapFiles = [
|
|
"428remap.ngc",
|
|
"429remap.ngc",
|
|
"430remap.ngc",
|
|
"centering.ngc",
|
|
"helix_ac.ngc",
|
|
"helix_bc.ngc",
|
|
"xyzac_switchkins_sub.ngc",
|
|
"xyzbc_switchkins_sub.ngc",
|
|
];
|
|
|
|
await writeFetchedTextFile(interp, `${sourceDir}/xyzac-trt.ini`, `${wasmDir}/xyzac-trt.ini`);
|
|
await writeFetchedTextFile(interp, `${sourceDir}/xyzbc-trt.ini`, `${wasmDir}/xyzbc-trt.ini`);
|
|
await writeFetchedTextFile(interp, `${sourceDir}/xyzac-trt.tbl`, `${wasmDir}/xyzac-trt.tbl`);
|
|
await writeFetchedTextFile(interp, `${sourceDir}/xyzbc-trt.tbl`, `${wasmDir}/xyzbc-trt.tbl`);
|
|
|
|
for (const filename of remapFiles) {
|
|
await writeFetchedTextFile(
|
|
interp,
|
|
`${sourceDir}/remap_subs/${filename}`,
|
|
`${wasmDir}/remap_subs/${filename}`,
|
|
);
|
|
}
|
|
|
|
await writeFetchedTextFile(
|
|
interp,
|
|
`${sourceDir}/demos/xyzac_switchkins.ngc`,
|
|
`${wasmDir}/demos/xyzac_switchkins.ngc`,
|
|
);
|
|
await writeFetchedTextFile(
|
|
interp,
|
|
`${sourceDir}/demos/xyzbc_switchkins.ngc`,
|
|
`${wasmDir}/demos/xyzbc_switchkins.ngc`,
|
|
);
|
|
await writeFetchedTextFile(
|
|
interp,
|
|
`${sourceDir}/demos/xyzac_switchkins_test_1.ngc`,
|
|
`${wasmDir}/demos/xyzac_switchkins_test_1.ngc`,
|
|
);
|
|
await writeFetchedTextFile(
|
|
interp,
|
|
`${sourceDir}/demos/xyzac_switchkins_test_2.ngc`,
|
|
`${wasmDir}/demos/xyzac_switchkins_test_2.ngc`,
|
|
);
|
|
await writeFetchedTextFile(
|
|
interp,
|
|
`${sourceDir}/demos/xyzac_switchkins_test_3.ngc`,
|
|
`${wasmDir}/demos/xyzac_switchkins_test_3.ngc`,
|
|
);
|
|
await writeFetchedTextFile(
|
|
interp,
|
|
`${sourceDir}/demos/boat-xyzac.ngc`,
|
|
`${wasmDir}/demos/boat-xyzac.ngc`,
|
|
);
|
|
await writeFetchedTextFile(
|
|
interp,
|
|
`${sourceDir}/demos/boat-xyzbc.ngc`,
|
|
`${wasmDir}/demos/boat-xyzbc.ngc`,
|
|
);
|
|
await writeFetchedTextFile(
|
|
interp,
|
|
`${sourceDir}/demos/impeller-7bl-xyzac.ngc`,
|
|
`${wasmDir}/demos/impeller-7bl-xyzac.ngc`,
|
|
);
|
|
|
|
return wasmDir;
|
|
}
|
|
|
|
async function writeFiveAxisTdrMachineFiles(interp) {
|
|
const sourceDir =
|
|
"../../vendor/linuxcnc/configs/sim/axis/vismach/5axis/table-dual-rotary";
|
|
const wasmDir = "/work/browser-fiveaxis/table-dual-rotary";
|
|
const remapFiles = ["428remap.ngc", "429remap.ngc"];
|
|
|
|
await writeFetchedTextFile(interp, `${sourceDir}/xyzab-tdr.ini`, `${wasmDir}/xyzab-tdr.ini`);
|
|
await writeFetchedTextFile(interp, `${sourceDir}/xyzab-tdr.tbl`, `${wasmDir}/xyzab-tdr.tbl`);
|
|
for (const filename of remapFiles) {
|
|
await writeFetchedTextFile(
|
|
interp,
|
|
`${sourceDir}/remap_subs/${filename}`,
|
|
`${wasmDir}/remap_subs/${filename}`,
|
|
);
|
|
}
|
|
await writeFetchedTextFile(
|
|
interp,
|
|
`${sourceDir}/demos/xyzab-tdr-demo.ngc`,
|
|
`${wasmDir}/demos/xyzab-tdr-demo.ngc`,
|
|
);
|
|
|
|
return wasmDir;
|
|
}
|
|
|
|
async function writeFiveAxisBridgeMillMachineFiles(interp) {
|
|
const sourceDir =
|
|
"../../vendor/linuxcnc/configs/sim/axis/vismach/5axis/bridgemill";
|
|
const wasmDir = "/work/browser-fiveaxis/bridgemill";
|
|
const remapFiles = ["428remap.ngc", "429remap.ngc", "430remap.ngc"];
|
|
|
|
await writeFetchedTextFile(interp, `${sourceDir}/5axis.ini`, `${wasmDir}/5axis.ini`);
|
|
await writeFetchedTextFile(interp, `${sourceDir}/5axis.tbl`, `${wasmDir}/5axis.tbl`);
|
|
for (const filename of remapFiles) {
|
|
await writeFetchedTextFile(
|
|
interp,
|
|
`${sourceDir}/remap_subs/${filename}`,
|
|
`${wasmDir}/remap_subs/${filename}`,
|
|
);
|
|
}
|
|
await writeFetchedTextFile(interp, `${sourceDir}/5axisgui.ngc`, `${wasmDir}/5axisgui.ngc`);
|
|
|
|
return wasmDir;
|
|
}
|
|
|
|
async function writeRemapRegressionFiles(interp, name, files) {
|
|
const sourceDir = `../../vendor/linuxcnc/tests/remap/${name}`;
|
|
const wasmDir = `/work/browser-remap/${name}`;
|
|
|
|
for (const filename of files) {
|
|
await writeFetchedTextFile(interp, `${sourceDir}/${filename}`, `${wasmDir}/${filename}`);
|
|
}
|
|
|
|
return wasmDir;
|
|
}
|
|
|
|
async function writeInterpRegressionFile(interp, name, filename) {
|
|
const sourceDir = `../../vendor/linuxcnc/tests/interp/${name}`;
|
|
const wasmDir = `/work/browser-interp/${name}`;
|
|
|
|
await writeFetchedTextFile(interp, `${sourceDir}/${filename}`, `${wasmDir}/${filename}`);
|
|
|
|
return `${wasmDir}/${filename}`;
|
|
}
|
|
|
|
async function writeInterpRegressionFiles(interp, name, files) {
|
|
const sourceDir = `../../vendor/linuxcnc/tests/interp/${name}`;
|
|
const wasmDir = `/work/browser-interp/${name}`;
|
|
|
|
for (const filename of files) {
|
|
await writeFetchedTextFile(interp, `${sourceDir}/${filename}`, `${wasmDir}/${filename}`);
|
|
}
|
|
|
|
return wasmDir;
|
|
}
|
|
|
|
async function runVendorNcFile(interp, filename) {
|
|
const wasmPath = `/work/browser-nc-files/${filename}`;
|
|
await writeFetchedTextFile(
|
|
interp,
|
|
`../../vendor/linuxcnc/nc_files/${filename}`,
|
|
wasmPath,
|
|
);
|
|
return interp.runFile(wasmPath);
|
|
}
|
|
|
|
async function verifyRejects(fixtureName, operation, expectedPattern) {
|
|
try {
|
|
await operation();
|
|
} catch (error) {
|
|
if (!expectedPattern.test(error.message)) {
|
|
throw new Error(`${fixtureName}: unexpected error ${error.message}`);
|
|
}
|
|
return;
|
|
}
|
|
throw new Error(`${fixtureName}: expected rejection`);
|
|
}
|
|
|
|
const interpPrints = [];
|
|
function runWithCapturedPrints(operation) {
|
|
interpPrints.length = 0;
|
|
const output = operation();
|
|
return { output, prints: interpPrints.join("\n") };
|
|
}
|
|
|
|
try {
|
|
const interp = await createLinuxCncInterpSdk({
|
|
locateFile(path) {
|
|
if (path === "linuxcnc_interp.wasm") {
|
|
return "../../build/wasm/core/linuxcnc_interp.wasm";
|
|
}
|
|
return path;
|
|
},
|
|
print(message) {
|
|
interpPrints.push(message);
|
|
},
|
|
printErr(message) {
|
|
console.error(message);
|
|
},
|
|
});
|
|
const ini = await createLinuxCncIniSdk({
|
|
locateFile(path) {
|
|
if (path === "linuxcnc_ini.wasm") {
|
|
return "../../runtime/ui/ini-panel/linuxcnc_ini.wasm";
|
|
}
|
|
return path;
|
|
},
|
|
print() {},
|
|
printErr(message) {
|
|
console.error(message);
|
|
},
|
|
});
|
|
|
|
const namedParamIniPath = "/work/namedparams.ini";
|
|
interp.writeTextFile(namedParamIniPath, await fetchText("../fixtures/ini/namedparams.ini"));
|
|
|
|
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_BROWSER_MDI_FIXTURES) {
|
|
const programText = await fetchText(`../fixtures/gcode/${fixtureName}.ngc`);
|
|
const expectedText = await fetchText(`../fixtures/canon/${fixtureName}.events`);
|
|
verifyExpectedOutput(fixtureName, interp.runProgram(programText), expectedText.trimEnd());
|
|
}
|
|
|
|
for (const errorFixtureName of INTERP_ERROR_FIXTURES) {
|
|
verifyExpectedOutput(
|
|
errorFixtureName,
|
|
interp.runProgram(await fetchText(`../fixtures/gcode_errors/${errorFixtureName}.ngc`)),
|
|
(await fetchText(`../fixtures/canon_errors/${errorFixtureName}.expected`)).trimEnd(),
|
|
);
|
|
}
|
|
|
|
for (const errorFixtureName of INTERP_ERROR_FIXTURES) {
|
|
const programPath = `/work/${errorFixtureName}-error.ngc`;
|
|
interp.writeTextFile(
|
|
programPath,
|
|
await fetchText(`../fixtures/gcode_errors/${errorFixtureName}.ngc`),
|
|
);
|
|
verifyExpectedFileError(
|
|
`${errorFixtureName}_file`,
|
|
interp.runFile(programPath),
|
|
(await fetchText(`../fixtures/canon_errors/${errorFixtureName}.expected`)).trimEnd(),
|
|
);
|
|
}
|
|
|
|
const namedParamProgramText = await fetchText(
|
|
`../fixtures/gcode/${INTERP_INI_FIXTURE}.ngc`,
|
|
);
|
|
const namedParamExpectedText = (
|
|
await fetchText(`../fixtures/canon/${INTERP_INI_FIXTURE}.events`)
|
|
).trimEnd();
|
|
verifyExpectedOutput(
|
|
INTERP_INI_FIXTURE,
|
|
interp.runProgramWithIni(namedParamProgramText, namedParamIniPath),
|
|
namedParamExpectedText,
|
|
);
|
|
|
|
const baselineIniProgramText = await fetchText(
|
|
`../fixtures/gcode/${INTERP_BASELINE_INI_FIXTURE}.ngc`,
|
|
);
|
|
const baselineIniExpectedText = (
|
|
await fetchText(`../fixtures/canon/${INTERP_BASELINE_INI_FIXTURE}.events`)
|
|
).trimEnd();
|
|
verifyExpectedOutput(
|
|
INTERP_BASELINE_INI_FIXTURE,
|
|
interp.runProgramWithIni(baselineIniProgramText, namedParamIniPath),
|
|
baselineIniExpectedText,
|
|
);
|
|
|
|
const spindleOrientOffsetProgramText = await fetchText(
|
|
`../fixtures/gcode/${INTERP_SPINDLE_ORIENT_OFFSET_FIXTURE}.ngc`,
|
|
);
|
|
const spindleOrientOffsetExpectedText = (
|
|
await fetchText(`../fixtures/canon/${INTERP_SPINDLE_ORIENT_OFFSET_FIXTURE}.events`)
|
|
).trimEnd();
|
|
const spindleOrientOffsetIniPath = "/work/browser-spindle-orient-offset.ini";
|
|
interp.writeTextFile(
|
|
spindleOrientOffsetIniPath,
|
|
await fetchText("../fixtures/ini/spindle_orient_offset.ini"),
|
|
);
|
|
const disableFanucStyleSubIniPath = "/work/browser-disable-fanuc-style-sub.ini";
|
|
interp.writeTextFile(
|
|
disableFanucStyleSubIniPath,
|
|
await fetchText("../fixtures/ini/disable_fanuc_style_sub.ini"),
|
|
);
|
|
verifyExpectedOutput(
|
|
INTERP_SPINDLE_ORIENT_OFFSET_FIXTURE,
|
|
interp.runProgramWithIni(spindleOrientOffsetProgramText, spindleOrientOffsetIniPath),
|
|
spindleOrientOffsetExpectedText,
|
|
);
|
|
|
|
const coordinateOffsetsText = await fetchText(
|
|
`../fixtures/gcode/${INTERP_COORDINATE_OFFSETS_FILE_FIXTURE}.ngc`,
|
|
);
|
|
const coordinateOffsetsPath = `/work/${INTERP_COORDINATE_OFFSETS_FILE_FIXTURE}.ngc`;
|
|
interp.writeTextFile(coordinateOffsetsPath, coordinateOffsetsText);
|
|
verifyExpectedOutput(
|
|
`${INTERP_COORDINATE_OFFSETS_FILE_FIXTURE}_file`,
|
|
interp.runFile(coordinateOffsetsPath),
|
|
(
|
|
await fetchText(
|
|
`../fixtures/canon_file/${INTERP_COORDINATE_OFFSETS_FILE_FIXTURE}.events`,
|
|
)
|
|
).trimEnd(),
|
|
);
|
|
|
|
const positionParamsText = await fetchText(
|
|
`../fixtures/gcode/${INTERP_POSITION_PARAMS_FILE_FIXTURE}.ngc`,
|
|
);
|
|
const positionParamsPath = `/work/${INTERP_POSITION_PARAMS_FILE_FIXTURE}.ngc`;
|
|
interp.writeTextFile(positionParamsPath, positionParamsText);
|
|
verifyExpectedOutput(
|
|
`${INTERP_POSITION_PARAMS_FILE_FIXTURE}_file`,
|
|
interp.runFile(positionParamsPath),
|
|
(
|
|
await fetchText(
|
|
`../fixtures/canon_file/${INTERP_POSITION_PARAMS_FILE_FIXTURE}.events`,
|
|
)
|
|
).trimEnd(),
|
|
);
|
|
|
|
for (const fileFixtureName of INTERP_BROWSER_FILE_FIXTURES) {
|
|
const programPath = `/work/${fileFixtureName}.ngc`;
|
|
interp.writeTextFile(programPath, await fetchText(`../fixtures/gcode/${fileFixtureName}.ngc`));
|
|
verifyExpectedOutput(
|
|
`${fileFixtureName}_file`,
|
|
interp.runFile(programPath),
|
|
(await fetchText(`../fixtures/canon/${fileFixtureName}.events`)).trimEnd(),
|
|
);
|
|
}
|
|
|
|
const namedParamPath = `/work/${INTERP_INI_FIXTURE}.ngc`;
|
|
interp.writeTextFile(namedParamPath, namedParamProgramText);
|
|
verifyExpectedOutput(
|
|
`${INTERP_INI_FIXTURE}_file`,
|
|
interp.runFileWithIni(namedParamPath, namedParamIniPath),
|
|
namedParamExpectedText,
|
|
);
|
|
|
|
const iniToolTableDir = "/work/browser-ini-tool-table";
|
|
const iniToolTableIniPath = `${iniToolTableDir}/ini_tool_table.ini`;
|
|
const iniToolTableProgramPath = `${iniToolTableDir}/ini_tool_table.ngc`;
|
|
interp.writeTextFile(iniToolTableIniPath, await fetchText("../fixtures/ini/ini_tool_table.ini"));
|
|
interp.writeTextFile(
|
|
`${iniToolTableDir}/ini_tool_table.tbl`,
|
|
await fetchText("../fixtures/ini/ini_tool_table.tbl"),
|
|
);
|
|
interp.writeTextFile(
|
|
iniToolTableProgramPath,
|
|
await fetchText("../fixtures/gcode/ini_tool_table.ngc"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_ini_tool_table_file",
|
|
interp.runFileWithIni(iniToolTableProgramPath, iniToolTableIniPath),
|
|
(await fetchText("../fixtures/canon/ini_tool_table.events")).trimEnd(),
|
|
);
|
|
|
|
const baselineIniPath = `/work/${INTERP_BASELINE_INI_FIXTURE}.ngc`;
|
|
interp.writeTextFile(baselineIniPath, baselineIniProgramText);
|
|
verifyExpectedOutput(
|
|
`${INTERP_BASELINE_INI_FIXTURE}_file`,
|
|
interp.runFileWithIni(baselineIniPath, namedParamIniPath),
|
|
baselineIniExpectedText,
|
|
);
|
|
|
|
const spindleOrientOffsetPath = `/work/${INTERP_SPINDLE_ORIENT_OFFSET_FIXTURE}.ngc`;
|
|
interp.writeTextFile(spindleOrientOffsetPath, spindleOrientOffsetProgramText);
|
|
verifyExpectedOutput(
|
|
`${INTERP_SPINDLE_ORIENT_OFFSET_FIXTURE}_file`,
|
|
interp.runFileWithIni(spindleOrientOffsetPath, spindleOrientOffsetIniPath),
|
|
spindleOrientOffsetExpectedText,
|
|
);
|
|
|
|
const disableFanucStyleSubPath = "/work/browser-disable_fanuc_style_sub_m98.ngc";
|
|
interp.writeTextFile(
|
|
disableFanucStyleSubPath,
|
|
await fetchText("../fixtures/gcode/disable_fanuc_style_sub_m98.ngc"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_disable_fanuc_style_sub_m98_file",
|
|
interp.runFileWithIni(disableFanucStyleSubPath, disableFanucStyleSubIniPath),
|
|
[
|
|
"file_open=0",
|
|
"file_saw_error=1",
|
|
"file_error_text=DISABLE_FANUC_STYLE_SUB set in INI file, but found m98",
|
|
].join("\n"),
|
|
);
|
|
|
|
verifyExpectedOutput(
|
|
"browser_nc_files_arcspiral",
|
|
await runVendorNcFile(interp, "arcspiral.ngc"),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=1008",
|
|
"file_execute_count=1008",
|
|
"file_saw_error=0",
|
|
"canon_event=STRAIGHT_TRAVERSE line=3 x=0 y=0 z=1",
|
|
"canon_event=STRAIGHT_FEED line=6 x=1.72464 y=-1.01273 z=-0.1",
|
|
"canon_event=PROGRAM_END",
|
|
"absent=file_error_text=",
|
|
].join("\n"),
|
|
);
|
|
|
|
verifyExpectedOutput(
|
|
"browser_nc_files_hole_circle",
|
|
await runVendorNcFile(interp, "hole-circle.ngc"),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=12",
|
|
"file_execute_count=12",
|
|
"file_saw_error=0",
|
|
"canon_event=STRAIGHT_TRAVERSE line=7 x=1.5 y=0 z=0",
|
|
"canon_event=STRAIGHT_FEED line=10 x=0.75 y=1.29904 z=-0.4",
|
|
"canon_event=PROGRAM_END",
|
|
"absent=file_error_text=",
|
|
].join("\n"),
|
|
);
|
|
|
|
verifyExpectedOutput(
|
|
"browser_nc_files_factorial",
|
|
await runVendorNcFile(interp, "factorial.ngc"),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=11",
|
|
"file_execute_count=11",
|
|
"file_saw_error=0",
|
|
"canon_event=PROGRAM_END",
|
|
"absent=file_error_text=",
|
|
].join("\n"),
|
|
);
|
|
|
|
verifyExpectedOutput(
|
|
"browser_nc_files_m6demo",
|
|
await runVendorNcFile(interp, "m6demo.ngc"),
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=88",
|
|
"file_execute_count=88",
|
|
"file_saw_error=0",
|
|
"canon_event=SET_G5X_OFFSET index=1",
|
|
"canon_event=STOP_SPINDLE_TURNING spindle=0",
|
|
"canon_event=PROGRAM_END",
|
|
"absent=file_error_text=",
|
|
].join("\n"),
|
|
);
|
|
|
|
const foam = await loadSimMachineFiles("axis/foam", [
|
|
"axis_foam.ini",
|
|
"foam.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"browser_sim_axis_foam_uv",
|
|
interp.runSimConfigProgram({
|
|
files: foam.files,
|
|
programPath: `${foam.wasmDir}/foam.ngc`,
|
|
iniPath: `${foam.wasmDir}/axis_foam.ini`,
|
|
}),
|
|
[
|
|
"file_open=0",
|
|
"file_saw_error=0",
|
|
"canon_event=PROGRAM_END",
|
|
"absent=Bad character 'u' used",
|
|
"absent=Bad character 'v' used",
|
|
].join("\n"),
|
|
);
|
|
|
|
const bridgeMillSim = await loadSimMachineFiles(
|
|
"axis/vismach/5axis/bridgemill",
|
|
[
|
|
"5axis.ini",
|
|
"5axis.tbl",
|
|
"5axisgui.ngc",
|
|
"remap_subs/428remap.ngc",
|
|
"remap_subs/429remap.ngc",
|
|
"remap_subs/430remap.ngc",
|
|
],
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_sim_axis_bridgemill_w",
|
|
interp.runSimConfigProgram({
|
|
files: bridgeMillSim.files,
|
|
programPath: `${bridgeMillSim.wasmDir}/5axisgui.ngc`,
|
|
iniPath: `${bridgeMillSim.wasmDir}/5axis.ini`,
|
|
executionMode: "fiveAxisRemap",
|
|
}),
|
|
[
|
|
"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_reached_exit=1",
|
|
"fiveaxis_hal_switchkins: rc=0 found=1 value=0",
|
|
"fiveaxis_linuxcnc_remap_file_execute=1",
|
|
"absent=Bad character 'w' used",
|
|
].join("\n"),
|
|
);
|
|
|
|
const geometry = await loadSimMachineFiles(
|
|
"axis/geometry",
|
|
[
|
|
"M110",
|
|
"xyzc.ini",
|
|
"xyzc.ngc",
|
|
],
|
|
["M110"],
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_sim_axis_geometry_xyzc_user_m110",
|
|
interp.runSimConfigProgram({
|
|
files: geometry.files,
|
|
programPath: `${geometry.wasmDir}/xyzc.ngc`,
|
|
iniPath: `${geometry.wasmDir}/xyzc.ini`,
|
|
}),
|
|
[
|
|
"file_open=0",
|
|
"file_saw_error=0",
|
|
"canon_event=USER_M_COMMAND code=M110",
|
|
"canon_event=PROGRAM_END",
|
|
"absent=Unknown m code used: M110",
|
|
"absent=Bad character 'c' used",
|
|
].join("\n"),
|
|
);
|
|
|
|
const externalOffsets = await loadSimMachineFiles(
|
|
"axis/external_offsets",
|
|
[
|
|
"M111",
|
|
"dyn_demo.ngc",
|
|
"dynamic_offsets.ini",
|
|
],
|
|
["M111"],
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_sim_axis_external_offsets_user_m111",
|
|
interp.runSimConfigProgram({
|
|
files: externalOffsets.files,
|
|
programPath: `${externalOffsets.wasmDir}/dyn_demo.ngc`,
|
|
iniPath: `${externalOffsets.wasmDir}/dynamic_offsets.ini`,
|
|
}),
|
|
[
|
|
"file_open=0",
|
|
"file_saw_error=0",
|
|
"canon_event=USER_M_COMMAND code=M111",
|
|
"canon_event=PROGRAM_END",
|
|
"absent=Unknown m code used: M111",
|
|
].join("\n"),
|
|
);
|
|
|
|
const fiveAxisTrtDir = await writeFiveAxisTrtMachineFiles(interp);
|
|
verifyExpectedOutput(
|
|
"browser_fiveaxis_xyzac_switchkins",
|
|
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_file_open=0",
|
|
"fiveaxis_file_read_count=620",
|
|
"fiveaxis_file_execute_count=620",
|
|
"fiveaxis_file_finish_count=21",
|
|
"fiveaxis_file_reached_exit=1",
|
|
"fiveaxis_hal_switchkins: rc=0 found=1 value=0",
|
|
"fiveaxis_linuxcnc_remap_file_execute=1",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_fiveaxis_xyzbc_switchkins",
|
|
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_file_open=0",
|
|
"fiveaxis_file_read_count=620",
|
|
"fiveaxis_file_execute_count=620",
|
|
"fiveaxis_file_finish_count=21",
|
|
"fiveaxis_file_reached_exit=1",
|
|
"fiveaxis_hal_switchkins: rc=0 found=1 value=0",
|
|
"fiveaxis_linuxcnc_remap_file_execute=1",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_fiveaxis_xyzac_switchkins_test_1",
|
|
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(
|
|
"browser_fiveaxis_xyzac_switchkins_test_2",
|
|
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(
|
|
"browser_fiveaxis_xyzac_switchkins_test_3",
|
|
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(
|
|
"browser_fiveaxis_boat_xyzac",
|
|
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(
|
|
"browser_fiveaxis_boat_xyzbc",
|
|
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(
|
|
"browser_fiveaxis_impeller_7bl_xyzac",
|
|
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 = await writeFiveAxisTdrMachineFiles(interp);
|
|
verifyExpectedOutput(
|
|
"browser_fiveaxis_xyzab_tdr_demo",
|
|
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 = await writeFiveAxisBridgeMillMachineFiles(interp);
|
|
verifyExpectedOutput(
|
|
"browser_fiveaxis_bridgemill_5axisgui",
|
|
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 = await writeRemapRegressionFiles(interp, "duplicate-o-word", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
"rm207.ngc",
|
|
"rm208.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"browser_duplicate_oword_remap",
|
|
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 = await writeRemapRegressionFiles(interp, "fail/args.0", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
"rm400.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"browser_fail_args_0_remap",
|
|
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 = await writeRemapRegressionFiles(interp, "fail/args.1", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
"rm400.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"browser_fail_args_1_remap",
|
|
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 = await writeRemapRegressionFiles(interp, "fail/args.2", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
"rm400.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"browser_fail_args_2_remap",
|
|
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 = await writeRemapRegressionFiles(interp, "fail/body-ngc", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
"rm400.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"browser_fail_body_ngc_remap",
|
|
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 = await writeRemapRegressionFiles(interp, "m30-interaction", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
"rm400.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"browser_m30_interaction_remap",
|
|
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 = await writeRemapRegressionFiles(
|
|
interp,
|
|
"nested-remaps-oword",
|
|
[
|
|
"test.ini",
|
|
"test.ngc",
|
|
"rm400.ngc",
|
|
"rm401.ngc",
|
|
"rm402.ngc",
|
|
"rm403.ngc",
|
|
],
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_nested_remaps_oword_remap",
|
|
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 = await writeRemapRegressionFiles(interp, "posargs.0", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
"rg881.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"browser_posargs_0_remap",
|
|
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 = await writeRemapRegressionFiles(interp, "sequencing", [
|
|
"test.ini",
|
|
"test.ngc",
|
|
"rg881.ngc",
|
|
"rm405.ngc",
|
|
"rm406.ngc",
|
|
"rm407.ngc",
|
|
"rm408.ngc",
|
|
"rm409.ngc",
|
|
"rm410.ngc",
|
|
]);
|
|
verifyExpectedOutput(
|
|
"browser_sequencing_remap",
|
|
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 = await writeRemapRegressionFiles(interp, "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(
|
|
"browser_remap_io_ngc_mdi",
|
|
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 = await writeInterpRegressionFile(
|
|
interp,
|
|
"do-while-break",
|
|
"test.ngc",
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_do_while_break",
|
|
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 = await writeInterpRegressionFile(
|
|
interp,
|
|
"oword-bug315",
|
|
"test.ngc",
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_oword_bug315",
|
|
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 = await writeInterpRegressionFile(
|
|
interp,
|
|
"oword-bug315-p2",
|
|
"test.ngc",
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_oword_bug315_p2",
|
|
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 = await writeInterpRegressionFile(interp, "exists", "test.ngc");
|
|
verifyExpectedOutput(
|
|
"browser_interp_exists",
|
|
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 = await writeInterpRegressionFile(
|
|
interp,
|
|
"return-value",
|
|
"test.ngc",
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_return_value",
|
|
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 = await writeInterpRegressionFile(
|
|
interp,
|
|
"subs-follow-main",
|
|
"test.ngc",
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_subs_follow_main",
|
|
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 = await writeInterpRegressionFile(
|
|
interp,
|
|
"fractional-linenumbers",
|
|
"test.ngc",
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_fractional_linenumbers",
|
|
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 = await writeInterpRegressionFile(
|
|
interp,
|
|
"namedparam-bug424",
|
|
"test.ngc",
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_namedparam_bug424",
|
|
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 g6164Path = await writeInterpRegressionFile(interp, "g6164", "test.ngc");
|
|
verifyExpectedOutput(
|
|
"browser_interp_g6164",
|
|
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 = await writeInterpRegressionFile(
|
|
interp,
|
|
"rotation/abs-pts",
|
|
"test.ngc",
|
|
);
|
|
const rotationAbsPtsOutput = interp.runFile(rotationAbsPtsPath);
|
|
verifyExpectedOutput(
|
|
"browser_interp_rotation_abs_pts",
|
|
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"),
|
|
);
|
|
if (
|
|
(rotationAbsPtsOutput.match(/canon_event=MESSAGE: 0\.000000 0\.000000 0\.000000/g) || [])
|
|
.length !== 14
|
|
) {
|
|
throw new Error("browser_interp_rotation_abs_pts: zero absolute-position message count");
|
|
}
|
|
if (
|
|
(rotationAbsPtsOutput.match(/canon_event=MESSAGE: 1\.000000 2\.000000 3\.000000/g) || [])
|
|
.length !== 14
|
|
) {
|
|
throw new Error("browser_interp_rotation_abs_pts: target absolute-position message count");
|
|
}
|
|
|
|
const rotationG28Path = await writeInterpRegressionFile(interp, "rotation/g28", "g28.ngc");
|
|
const rotationG28Output = interp.runFile(rotationG28Path);
|
|
verifyExpectedOutput(
|
|
"browser_interp_rotation_g28",
|
|
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"),
|
|
);
|
|
if (!/canon_event=STRAIGHT_TRAVERSE line=14 x=(0|[0-9.e-]+) y=14\.1421 z=0 a=0/.test(rotationG28Output)) {
|
|
throw new Error("browser_interp_rotation_g28: G56 G28 final machine point");
|
|
}
|
|
|
|
const rotationG53Path = await writeInterpRegressionFile(interp, "rotation/g53", "g53.ngc");
|
|
const rotationG53Output = interp.runFile(rotationG53Path);
|
|
verifyExpectedOutput(
|
|
"browser_interp_rotation_g53",
|
|
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"),
|
|
);
|
|
if (!/canon_event=STRAIGHT_TRAVERSE line=8 x=1\.41421 y=([0-9.e-]+) z=0/.test(rotationG53Output)) {
|
|
throw new Error("browser_interp_rotation_g53: rotated G53 endpoint");
|
|
}
|
|
|
|
const iniparamDir = await writeInterpRegressionFiles(
|
|
interp,
|
|
"iniparam",
|
|
[
|
|
"test.ini",
|
|
"test.ngc",
|
|
],
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_iniparam",
|
|
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 = await writeInterpRegressionFiles(
|
|
interp,
|
|
"iniparam-failassign",
|
|
[
|
|
"test.ini",
|
|
"test.ngc",
|
|
],
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_iniparam_failassign",
|
|
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 = await writeInterpRegressionFiles(
|
|
interp,
|
|
"sub-call-from-sub",
|
|
[
|
|
"test.ini",
|
|
"test.ngc",
|
|
"subs/caller.ngc",
|
|
"subs/helper.ngc",
|
|
],
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_sub_call_from_sub",
|
|
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 = await writeInterpRegressionFiles(
|
|
interp,
|
|
"sequence-number",
|
|
[
|
|
"test.ini",
|
|
"test.ngc",
|
|
"rm400.ngc",
|
|
],
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_sequence_number",
|
|
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 = await writeInterpRegressionFiles(
|
|
interp,
|
|
"nested-sub-error",
|
|
[
|
|
"test.ini",
|
|
"test.ngc",
|
|
"subs/nested.ngc",
|
|
],
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_nested_sub_error",
|
|
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 = await writeInterpRegressionFiles(
|
|
interp,
|
|
"nested-sub-in-file-error",
|
|
[
|
|
"test.ini",
|
|
"test.ngc",
|
|
"subs/sequential.ngc",
|
|
],
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_nested_sub_in_file_error",
|
|
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 = await writeInterpRegressionFiles(
|
|
interp,
|
|
"oword-unwind",
|
|
[
|
|
"test.ini",
|
|
"test.ngc",
|
|
"fail.ngc",
|
|
],
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_oword_unwind",
|
|
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 = await writeInterpRegressionFiles(
|
|
interp,
|
|
"abort-hot-comment",
|
|
[
|
|
"test.ini",
|
|
"test.ngc",
|
|
],
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_abort_hot_comment",
|
|
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 = await writeInterpRegressionFiles(
|
|
interp,
|
|
"m19",
|
|
[
|
|
"test.ini",
|
|
"test.ngc",
|
|
],
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_m19",
|
|
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 = await writeInterpRegressionFile(
|
|
interp,
|
|
"magic_comments/param_format_printing",
|
|
"test.ngc",
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_magic_comments_param_format",
|
|
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 = await writeInterpRegressionFile(
|
|
interp,
|
|
"m98m99/01-basics",
|
|
"test.ngc",
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_m98m99_01_basics",
|
|
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 = await writeInterpRegressionFile(
|
|
interp,
|
|
"m98m99/02-variables",
|
|
"test.ngc",
|
|
);
|
|
const m98m99VariablesRun = runWithCapturedPrints(() =>
|
|
interp.runFile(m98m99VariablesPath),
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_m98m99_02_variables",
|
|
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(
|
|
"browser_interp_m98m99_02_variables_prints",
|
|
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 = await writeInterpRegressionFile(
|
|
interp,
|
|
"m98m99/07-nested-subs",
|
|
"test.ngc",
|
|
);
|
|
const m98m99NestedSubsRun = runWithCapturedPrints(() =>
|
|
interp.runFile(m98m99NestedSubsPath),
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_m98m99_07_nested_subs",
|
|
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(
|
|
"browser_interp_m98m99_07_nested_subs_prints",
|
|
m98m99NestedSubsRun.prints,
|
|
[
|
|
"X >>>> LOOP [O2.O1]: 4.500000",
|
|
"X MAIN END: 1=5.000000",
|
|
].join("\n"),
|
|
);
|
|
|
|
const m98m99SubFollowsMainPath = await writeInterpRegressionFile(
|
|
interp,
|
|
"m98m99/08-sub-follows-main",
|
|
"test.ngc",
|
|
);
|
|
const m98m99SubFollowsMainRun = runWithCapturedPrints(() =>
|
|
interp.runFile(m98m99SubFollowsMainPath),
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_m98m99_08_sub_follows_main",
|
|
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(
|
|
"browser_interp_m98m99_08_sub_follows_main_prints",
|
|
m98m99SubFollowsMainRun.prints,
|
|
"X IN O1",
|
|
);
|
|
|
|
const m98m99M98P001Path = await writeInterpRegressionFile(
|
|
interp,
|
|
"m98m99/10-M98-P001",
|
|
"test.ngc",
|
|
);
|
|
const m98m99M98P001Run = runWithCapturedPrints(() =>
|
|
interp.runFile(m98m99M98P001Path),
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_m98m99_10_m98_p001",
|
|
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(
|
|
"browser_interp_m98m99_10_m98_p001_prints",
|
|
m98m99M98P001Run.prints,
|
|
[
|
|
"x got here",
|
|
"absent=ERROR: should not get here",
|
|
].join("\n"),
|
|
);
|
|
|
|
const m98m99NamedProgramNamedPath = await writeInterpRegressionFile(
|
|
interp,
|
|
"m98m99/13-named-program",
|
|
"test-named.ngc",
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_m98m99_13_named_program_named",
|
|
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 = await writeInterpRegressionFile(
|
|
interp,
|
|
"m98m99/13-named-program",
|
|
"test-numbered.ngc",
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_m98m99_13_named_program_numbered",
|
|
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 = await writeInterpRegressionFile(
|
|
interp,
|
|
"m98m99/14-o-expression-call",
|
|
"test.ngc",
|
|
);
|
|
const m98m99OExpressionCallRun = runWithCapturedPrints(() =>
|
|
interp.runFile(m98m99OExpressionCallPath),
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_m98m99_14_o_expression_call",
|
|
m98m99OExpressionCallRun.output,
|
|
[
|
|
"file_open=0",
|
|
"file_read_count=29",
|
|
"file_execute_count=29",
|
|
"file_saw_error=0",
|
|
"canon_event=PROGRAM_END",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"browser_interp_m98m99_14_o_expression_call_prints",
|
|
m98m99OExpressionCallRun.prints,
|
|
[
|
|
"In sub 100",
|
|
"In sub 200",
|
|
].join("\n"),
|
|
);
|
|
|
|
verifyExpectedOutput(
|
|
"restore_parameters_missing_file",
|
|
interp.restoreParameters("/work/browser-missing.var"),
|
|
"restore_parameters=0",
|
|
);
|
|
const outOfOrderParameterFilePath = "/work/browser-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/browser-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"),
|
|
);
|
|
|
|
const browserParameterFilePath = "/work/browser-direct.var";
|
|
interp.writeTextFile(
|
|
browserParameterFilePath,
|
|
[
|
|
"5161 10.5",
|
|
"5162 20.25",
|
|
"5220 1",
|
|
"5221 2.25",
|
|
"5399 44",
|
|
"<_named_param> 123",
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"restore_parameters_direct",
|
|
interp.restoreParameters(browserParameterFilePath),
|
|
[
|
|
"restore_parameters=0",
|
|
"parameter_5161=10.5",
|
|
"parameter_5162=20.25",
|
|
"parameter_5221=2.25",
|
|
"parameter_5399=44",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"save_parameters_direct",
|
|
interp.saveParameters(browserParameterFilePath, {
|
|
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_5221=9.87",
|
|
"parameter_5399=66.6",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"saved_parameters_direct_text",
|
|
interp.readTextFile(browserParameterFilePath),
|
|
[
|
|
"5161\t12.340000",
|
|
"5162\t56.780000",
|
|
"5221\t9.870000",
|
|
"5399\t66.600000",
|
|
"absent=<_named_param>",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"saved_parameters_direct_backup",
|
|
interp.readTextFile(`${browserParameterFilePath}.bak`),
|
|
[
|
|
"5161 10.5",
|
|
"5162 20.25",
|
|
"5221 2.25",
|
|
"5399 44",
|
|
"<_named_param> 123",
|
|
].join("\n"),
|
|
);
|
|
|
|
const browserToolTablePath = "/work/browser-direct-tool.tbl";
|
|
interp.writeTextFile(
|
|
browserToolTablePath,
|
|
[
|
|
"T2 P7 Z3.125 D1.5 I12 J34 Q4 ;browser direct finish tool",
|
|
"T5 P9 X1 Y2 Z3 ;browser direct rough tool",
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"load_tool_table_direct",
|
|
interp.loadToolTable(browserToolTablePath),
|
|
[
|
|
"tooldata_load=0",
|
|
"tooldata_last_index=2",
|
|
"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=browser direct finish tool",
|
|
"tool_2.toolno=5",
|
|
"tool_2.pocketno=9",
|
|
"tool_2.comment=browser direct rough tool",
|
|
"tool_index_for_tool_2=1",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"save_tool_table_direct",
|
|
interp.saveToolTable(browserToolTablePath),
|
|
[
|
|
"tooldata_save=0",
|
|
"tool_1.toolno=2",
|
|
"tool_2.toolno=5",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"saved_tool_table_direct_text",
|
|
interp.readTextFile(browserToolTablePath),
|
|
[
|
|
"T2",
|
|
"P7",
|
|
"Z+3.125000",
|
|
"D+1.500000",
|
|
"I+12.000000",
|
|
"J+34.000000",
|
|
"Q4",
|
|
";browser direct finish tool",
|
|
"T5",
|
|
"P9",
|
|
";browser direct rough tool",
|
|
].join("\n"),
|
|
);
|
|
|
|
const browserRandomToolTablePath = "/work/browser-direct-random-tool.tbl";
|
|
interp.writeTextFile(
|
|
browserRandomToolTablePath,
|
|
[
|
|
"T2 P7 Z3.125 D1.5 I12 J34 Q4 ;browser direct random finish tool",
|
|
"T5 P9 X1 Y2 Z3 ;browser direct random rough tool",
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"load_tool_table_direct_random",
|
|
interp.loadToolTable(browserRandomToolTablePath, { randomToolChanger: true }),
|
|
[
|
|
"tooldata_random_toolchanger=1",
|
|
"tooldata_load=0",
|
|
"tooldata_last_index=9",
|
|
"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=browser direct random finish tool",
|
|
"tool_pocket_9.toolno=5",
|
|
"tool_pocket_9.pocketno=9",
|
|
"tool_pocket_9.comment=browser direct random rough tool",
|
|
"tool_index_for_tool_2=7",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"save_tool_table_direct_random",
|
|
interp.saveToolTable(browserRandomToolTablePath),
|
|
[
|
|
"tooldata_save=0",
|
|
"tool_pocket_7.toolno=2",
|
|
"tool_pocket_9.toolno=5",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"saved_tool_table_direct_random_text",
|
|
interp.readTextFile(browserRandomToolTablePath),
|
|
[
|
|
"T2",
|
|
"P7",
|
|
";browser direct random finish tool",
|
|
"T5",
|
|
"P9",
|
|
";browser direct random rough tool",
|
|
].join("\n"),
|
|
);
|
|
|
|
await saveMachineTextFiles("browser-interp", {
|
|
ini: "[EMC]\nMACHINE = browser-interp\n",
|
|
toolTable: "T2 P7 Z3.125 D1.5 I12 J34 Q4 ;browser finish tool\n",
|
|
parameters: [
|
|
"5161 10.5",
|
|
"5162 20.25",
|
|
"5220 1",
|
|
"5221 2.25",
|
|
"5399 44",
|
|
"<_named_param> 123",
|
|
"",
|
|
].join("\n"),
|
|
});
|
|
const loadedSession = await loadMachineSessionFromOpfs(
|
|
interp,
|
|
"browser-interp",
|
|
{
|
|
iniWasmPath: "/work/browser-machine.ini",
|
|
parameterWasmPath: "/work/browser-linuxcnc.var",
|
|
toolTableWasmPath: "/work/browser-tool.tbl",
|
|
},
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_restore_parameters",
|
|
loadedSession.parameters.result,
|
|
[
|
|
"restore_parameters=0",
|
|
"parameter_5161=10.5",
|
|
"parameter_5162=20.25",
|
|
"parameter_5221=2.25",
|
|
"parameter_5399=44",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_load_tool_table",
|
|
loadedSession.toolTable.result,
|
|
[
|
|
"tooldata_load=0",
|
|
"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=browser finish tool",
|
|
"tool_index_for_tool_2=1",
|
|
].join("\n"),
|
|
);
|
|
const savedParameters = await saveMachineParametersToOpfs(
|
|
interp,
|
|
"browser-interp",
|
|
{
|
|
5161: 12.34,
|
|
5162: 56.78,
|
|
5220: 1.0,
|
|
5221: 9.87,
|
|
5399: 66.6,
|
|
},
|
|
{ wasmPath: "/work/browser-linuxcnc.var" },
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_save_parameters",
|
|
savedParameters.result,
|
|
[
|
|
"save_parameters=0",
|
|
"parameter_5161=12.34",
|
|
"parameter_5162=56.78",
|
|
"parameter_5221=9.87",
|
|
"parameter_5399=66.6",
|
|
].join("\n"),
|
|
);
|
|
const machineFiles = await loadMachineTextFiles("browser-interp");
|
|
verifyExpectedOutput(
|
|
"opfs_saved_parameter_text",
|
|
machineFiles.parameters,
|
|
[
|
|
"5161\t12.340000",
|
|
"5162\t56.780000",
|
|
"5221\t9.870000",
|
|
"5399\t66.600000",
|
|
"absent=<_named_param>",
|
|
].join("\n"),
|
|
);
|
|
if (
|
|
savedParameters.backupOpfsPath !==
|
|
"linuxcnc/machines/browser-interp/linuxcnc.var.bak"
|
|
) {
|
|
throw new Error(`unexpected parameter backup path: ${savedParameters.backupOpfsPath}`);
|
|
}
|
|
verifyExpectedOutput(
|
|
"opfs_saved_parameter_backup_text",
|
|
await loadTextFile(savedParameters.backupOpfsPath),
|
|
[
|
|
"5161 10.5",
|
|
"5162 20.25",
|
|
"5221 2.25",
|
|
"5399 44",
|
|
"<_named_param> 123",
|
|
].join("\n"),
|
|
);
|
|
const savedToolTable = await saveMachineToolTableToOpfs(
|
|
interp,
|
|
"browser-interp",
|
|
{ wasmPath: "/work/browser-tool.tbl" },
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_save_tool_table",
|
|
savedToolTable.result,
|
|
[
|
|
"tooldata_save=0",
|
|
"tool_1.toolno=2",
|
|
"tool_1.pocketno=7",
|
|
].join("\n"),
|
|
);
|
|
const savedMachineFiles = await loadMachineTextFiles("browser-interp");
|
|
verifyExpectedOutput(
|
|
"opfs_saved_tool_table_text",
|
|
savedMachineFiles.toolTable,
|
|
[
|
|
"T2",
|
|
"P7",
|
|
"Z+3.125000",
|
|
"D+1.500000",
|
|
"I+12.000000",
|
|
"J+34.000000",
|
|
"Q4",
|
|
";browser finish tool",
|
|
].join("\n"),
|
|
);
|
|
|
|
await saveMachineTextFiles("browser-random-toolchanger", {
|
|
ini: [
|
|
"[EMC]",
|
|
"MACHINE = browser-random-toolchanger",
|
|
"",
|
|
"[EMCIO]",
|
|
"RANDOM_TOOLCHANGER = yes",
|
|
"",
|
|
].join("\n"),
|
|
toolTable: [
|
|
"T2 P7 Z3.125 D1.5 I12 J34 Q4 ;browser random finish tool",
|
|
"T5 P9 X1 Y2 Z3 ;browser random rough tool",
|
|
"",
|
|
].join("\n"),
|
|
parameters: [
|
|
"5161 10.5",
|
|
"5162 20.25",
|
|
"5220 1",
|
|
"5221 2.25",
|
|
"5399 44",
|
|
"",
|
|
].join("\n"),
|
|
});
|
|
const loadedRandomSession = await loadMachineSessionFromOpfs(
|
|
interp,
|
|
"browser-random-toolchanger",
|
|
{
|
|
iniSdk: ini,
|
|
iniWasmPath: "/work/browser-random-machine.ini",
|
|
parameterWasmPath: "/work/browser-random-linuxcnc.var",
|
|
toolTableWasmPath: "/work/browser-random-tool.tbl",
|
|
},
|
|
);
|
|
if (
|
|
loadedRandomSession.parameters.opfsPath !==
|
|
"linuxcnc/machines/browser-random-toolchanger/linuxcnc.var"
|
|
) {
|
|
throw new Error(`unexpected default parameter path: ${loadedRandomSession.parameters.opfsPath}`);
|
|
}
|
|
if (
|
|
loadedRandomSession.toolTable.opfsPath !==
|
|
"linuxcnc/machines/browser-random-toolchanger/tool.tbl"
|
|
) {
|
|
throw new Error(`unexpected default tool path: ${loadedRandomSession.toolTable.opfsPath}`);
|
|
}
|
|
verifyExpectedOutput(
|
|
"opfs_load_random_tool_table",
|
|
loadedRandomSession.toolTable.result,
|
|
[
|
|
"tooldata_random_toolchanger=1",
|
|
"tooldata_load=0",
|
|
"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=browser random finish tool",
|
|
"tool_pocket_9.toolno=5",
|
|
"tool_pocket_9.pocketno=9",
|
|
"tool_index_for_tool_2=7",
|
|
].join("\n"),
|
|
);
|
|
const savedRandomToolTable = await saveMachineToolTableToOpfs(
|
|
interp,
|
|
"browser-random-toolchanger",
|
|
{ wasmPath: "/work/browser-random-tool.tbl" },
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_save_random_tool_table",
|
|
savedRandomToolTable.result,
|
|
[
|
|
"tooldata_save=0",
|
|
"tool_pocket_7.toolno=2",
|
|
"tool_pocket_9.toolno=5",
|
|
].join("\n"),
|
|
);
|
|
const savedRandomMachineFiles = await loadMachineTextFiles(
|
|
"browser-random-toolchanger",
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_saved_random_tool_table_text",
|
|
savedRandomMachineFiles.toolTable,
|
|
[
|
|
"T2",
|
|
"P7",
|
|
";browser random finish tool",
|
|
"T5",
|
|
"P9",
|
|
";browser random rough tool",
|
|
].join("\n"),
|
|
);
|
|
|
|
await saveMachineTextFiles("browser-ini-file-session", {
|
|
ini: [
|
|
"[EMC]",
|
|
"MACHINE = browser-ini-file-session",
|
|
"",
|
|
"[RS274NGC]",
|
|
"PARAMETER_FILE = browser-custom.var",
|
|
"",
|
|
"[EMCIO]",
|
|
"TOOL_TABLE = browser-custom-tool.tbl",
|
|
"",
|
|
].join("\n"),
|
|
});
|
|
await saveTextFile(
|
|
"linuxcnc/machines/browser-ini-file-session/browser-custom.var",
|
|
[
|
|
"5161 31.25",
|
|
"5162 62.5",
|
|
"5220 1",
|
|
"5221 4.5",
|
|
"5399 99",
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
await saveTextFile(
|
|
"linuxcnc/machines/browser-ini-file-session/browser-custom-tool.tbl",
|
|
"T8 P8 Z4.5 D0.5 ;browser custom tool\n",
|
|
);
|
|
const loadedIniFileSession = await loadMachineSessionFromOpfs(
|
|
interp,
|
|
"browser-ini-file-session",
|
|
{
|
|
iniSdk: ini,
|
|
iniWasmPath: "/work/browser-ini-file-session.ini",
|
|
parameterWasmPath: "/work/browser-custom.var",
|
|
toolTableWasmPath: "/work/browser-custom-tool.tbl",
|
|
},
|
|
);
|
|
if (
|
|
loadedIniFileSession.parameters.opfsPath !==
|
|
"linuxcnc/machines/browser-ini-file-session/browser-custom.var"
|
|
) {
|
|
throw new Error(`unexpected custom parameter path: ${loadedIniFileSession.parameters.opfsPath}`);
|
|
}
|
|
if (
|
|
loadedIniFileSession.toolTable.opfsPath !==
|
|
"linuxcnc/machines/browser-ini-file-session/browser-custom-tool.tbl"
|
|
) {
|
|
throw new Error(`unexpected custom tool path: ${loadedIniFileSession.toolTable.opfsPath}`);
|
|
}
|
|
verifyExpectedOutput(
|
|
"opfs_load_ini_named_parameter_file",
|
|
loadedIniFileSession.parameters.result,
|
|
[
|
|
"restore_parameters=0",
|
|
"parameter_5161=31.25",
|
|
"parameter_5162=62.5",
|
|
"parameter_5221=4.5",
|
|
"parameter_5399=99",
|
|
].join("\n"),
|
|
);
|
|
const savedIniNamedParameters = await saveMachineParametersToOpfs(
|
|
interp,
|
|
"browser-ini-file-session",
|
|
{
|
|
5161: 33.75,
|
|
5162: 67.5,
|
|
5220: 1.0,
|
|
5221: 5.25,
|
|
5399: 199,
|
|
},
|
|
{
|
|
opfsPath: loadedIniFileSession.parameters.opfsPath,
|
|
wasmPath: loadedIniFileSession.parameters.wasmPath,
|
|
},
|
|
);
|
|
if (
|
|
savedIniNamedParameters.opfsPath !==
|
|
"linuxcnc/machines/browser-ini-file-session/browser-custom.var"
|
|
) {
|
|
throw new Error(`unexpected custom saved parameter path: ${savedIniNamedParameters.opfsPath}`);
|
|
}
|
|
if (
|
|
savedIniNamedParameters.backupOpfsPath !==
|
|
"linuxcnc/machines/browser-ini-file-session/browser-custom.var.bak"
|
|
) {
|
|
throw new Error(`unexpected custom parameter backup path: ${savedIniNamedParameters.backupOpfsPath}`);
|
|
}
|
|
verifyExpectedOutput(
|
|
"opfs_save_ini_named_parameter_file",
|
|
savedIniNamedParameters.result,
|
|
[
|
|
"save_parameters=0",
|
|
"parameter_5161=33.75",
|
|
"parameter_5162=67.5",
|
|
"parameter_5221=5.25",
|
|
"parameter_5399=199",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_saved_ini_named_parameter_text",
|
|
await loadTextFile(loadedIniFileSession.parameters.opfsPath),
|
|
[
|
|
"5161\t33.750000",
|
|
"5162\t67.500000",
|
|
"5221\t5.250000",
|
|
"5399\t199.000000",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_saved_ini_named_parameter_backup_text",
|
|
await loadTextFile(savedIniNamedParameters.backupOpfsPath),
|
|
[
|
|
"5161 31.25",
|
|
"5162 62.5",
|
|
"5221 4.5",
|
|
"5399 99",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_load_ini_named_tool_table",
|
|
loadedIniFileSession.toolTable.result,
|
|
[
|
|
"tooldata_load=0",
|
|
"tool_1.toolno=8",
|
|
"tool_1.pocketno=8",
|
|
"tool_1.z=4.5",
|
|
"tool_1.diameter=0.5",
|
|
"tool_1.comment=browser custom tool",
|
|
].join("\n"),
|
|
);
|
|
const savedIniNamedToolTable = await saveMachineToolTableToOpfs(
|
|
interp,
|
|
"browser-ini-file-session",
|
|
{
|
|
opfsPath: loadedIniFileSession.toolTable.opfsPath,
|
|
wasmPath: loadedIniFileSession.toolTable.wasmPath,
|
|
},
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_save_ini_named_tool_table",
|
|
savedIniNamedToolTable.result,
|
|
[
|
|
"tooldata_save=0",
|
|
"tool_1.toolno=8",
|
|
"tool_1.pocketno=8",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_saved_ini_named_tool_table_text",
|
|
await loadTextFile(loadedIniFileSession.toolTable.opfsPath),
|
|
[
|
|
"T8",
|
|
"P8",
|
|
"Z+4.500000",
|
|
"D+0.500000",
|
|
";browser custom tool",
|
|
].join("\n"),
|
|
);
|
|
|
|
await saveMachineTextFiles("browser-ini-override-session", {
|
|
ini: [
|
|
"[EMC]",
|
|
"MACHINE = browser-ini-override-session",
|
|
"",
|
|
"[RS274NGC]",
|
|
"PARAMETER_FILE = browser-ignored.var",
|
|
"",
|
|
"[EMCIO]",
|
|
"TOOL_TABLE = browser-ignored-tool.tbl",
|
|
"",
|
|
].join("\n"),
|
|
});
|
|
await saveTextFile(
|
|
"linuxcnc/machines/browser-ini-override-session/browser-explicit.var",
|
|
[
|
|
"5161 41.25",
|
|
"5162 82.5",
|
|
"5220 1",
|
|
"5221 6.5",
|
|
"5399 101",
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
await saveTextFile(
|
|
"linuxcnc/machines/browser-ini-override-session/browser-explicit-tool.tbl",
|
|
"T9 P9 Z5.5 D0.625 ;browser explicit tool\n",
|
|
);
|
|
const loadedIniOverrideSession = await loadMachineSessionFromOpfs(
|
|
interp,
|
|
"browser-ini-override-session",
|
|
{
|
|
iniSdk: ini,
|
|
iniWasmPath: "/work/browser-ini-override-session.ini",
|
|
parameterFilename: "browser-explicit.var",
|
|
parameterWasmPath: "/work/browser-explicit.var",
|
|
toolTableFilename: "browser-explicit-tool.tbl",
|
|
toolTableWasmPath: "/work/browser-explicit-tool.tbl",
|
|
},
|
|
);
|
|
if (
|
|
loadedIniOverrideSession.parameters.opfsPath !==
|
|
"linuxcnc/machines/browser-ini-override-session/browser-explicit.var"
|
|
) {
|
|
throw new Error(`unexpected explicit parameter path: ${loadedIniOverrideSession.parameters.opfsPath}`);
|
|
}
|
|
if (
|
|
loadedIniOverrideSession.toolTable.opfsPath !==
|
|
"linuxcnc/machines/browser-ini-override-session/browser-explicit-tool.tbl"
|
|
) {
|
|
throw new Error(`unexpected explicit tool path: ${loadedIniOverrideSession.toolTable.opfsPath}`);
|
|
}
|
|
verifyExpectedOutput(
|
|
"opfs_load_explicit_parameter_file",
|
|
loadedIniOverrideSession.parameters.result,
|
|
[
|
|
"restore_parameters=0",
|
|
"parameter_5161=41.25",
|
|
"parameter_5162=82.5",
|
|
"parameter_5221=6.5",
|
|
"parameter_5399=101",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_load_explicit_tool_table",
|
|
loadedIniOverrideSession.toolTable.result,
|
|
[
|
|
"tooldata_load=0",
|
|
"tool_1.toolno=9",
|
|
"tool_1.pocketno=9",
|
|
"tool_1.z=5.5",
|
|
"tool_1.diameter=0.625",
|
|
"tool_1.comment=browser explicit tool",
|
|
].join("\n"),
|
|
);
|
|
const savedExplicitParameters = await saveMachineParametersToOpfs(
|
|
interp,
|
|
"browser-ini-override-session",
|
|
{
|
|
5161: 51.25,
|
|
5162: 102.5,
|
|
5220: 1.0,
|
|
5221: 7.5,
|
|
5399: 202,
|
|
},
|
|
{
|
|
opfsPath: loadedIniOverrideSession.parameters.opfsPath,
|
|
wasmPath: loadedIniOverrideSession.parameters.wasmPath,
|
|
},
|
|
);
|
|
if (
|
|
savedExplicitParameters.opfsPath !==
|
|
"linuxcnc/machines/browser-ini-override-session/browser-explicit.var"
|
|
) {
|
|
throw new Error(`unexpected explicit saved parameter path: ${savedExplicitParameters.opfsPath}`);
|
|
}
|
|
if (
|
|
savedExplicitParameters.backupOpfsPath !==
|
|
"linuxcnc/machines/browser-ini-override-session/browser-explicit.var.bak"
|
|
) {
|
|
throw new Error(`unexpected explicit backup path: ${savedExplicitParameters.backupOpfsPath}`);
|
|
}
|
|
verifyExpectedOutput(
|
|
"opfs_save_explicit_parameter_file",
|
|
savedExplicitParameters.result,
|
|
[
|
|
"save_parameters=0",
|
|
"parameter_5161=51.25",
|
|
"parameter_5162=102.5",
|
|
"parameter_5221=7.5",
|
|
"parameter_5399=202",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_saved_explicit_parameter_text",
|
|
await loadTextFile(loadedIniOverrideSession.parameters.opfsPath),
|
|
[
|
|
"5161\t51.250000",
|
|
"5162\t102.500000",
|
|
"5221\t7.500000",
|
|
"5399\t202.000000",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_saved_explicit_parameter_backup_text",
|
|
await loadTextFile(savedExplicitParameters.backupOpfsPath),
|
|
[
|
|
"5161 41.25",
|
|
"5162 82.5",
|
|
"5221 6.5",
|
|
"5399 101",
|
|
].join("\n"),
|
|
);
|
|
const savedExplicitToolTable = await saveMachineToolTableToOpfs(
|
|
interp,
|
|
"browser-ini-override-session",
|
|
{
|
|
opfsPath: loadedIniOverrideSession.toolTable.opfsPath,
|
|
wasmPath: loadedIniOverrideSession.toolTable.wasmPath,
|
|
},
|
|
);
|
|
if (
|
|
savedExplicitToolTable.opfsPath !==
|
|
"linuxcnc/machines/browser-ini-override-session/browser-explicit-tool.tbl"
|
|
) {
|
|
throw new Error(`unexpected explicit saved tool path: ${savedExplicitToolTable.opfsPath}`);
|
|
}
|
|
verifyExpectedOutput(
|
|
"opfs_save_explicit_tool_table",
|
|
savedExplicitToolTable.result,
|
|
[
|
|
"tooldata_save=0",
|
|
"tool_1.toolno=9",
|
|
"tool_1.pocketno=9",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_saved_explicit_tool_table_text",
|
|
await loadTextFile(loadedIniOverrideSession.toolTable.opfsPath),
|
|
[
|
|
"T9",
|
|
"P9",
|
|
"Z+5.500000",
|
|
"D+0.625000",
|
|
";browser explicit tool",
|
|
].join("\n"),
|
|
);
|
|
|
|
await saveMachineTextFiles("browser-invalid-param-file-session", {
|
|
ini: [
|
|
"[EMC]",
|
|
"MACHINE = browser-invalid-param-file-session",
|
|
"",
|
|
"[RS274NGC]",
|
|
"PARAMETER_FILE = ../escape.var",
|
|
"",
|
|
].join("\n"),
|
|
});
|
|
await verifyRejects(
|
|
"opfs_reject_invalid_ini_parameter_file",
|
|
() => loadMachineSessionFromOpfs(
|
|
interp,
|
|
"browser-invalid-param-file-session",
|
|
{
|
|
iniSdk: ini,
|
|
iniWasmPath: "/work/browser-invalid-param-file-session.ini",
|
|
},
|
|
),
|
|
/Invalid parameter filename/,
|
|
);
|
|
|
|
await saveMachineTextFiles("browser-invalid-tool-file-session", {
|
|
ini: [
|
|
"[EMC]",
|
|
"MACHINE = browser-invalid-tool-file-session",
|
|
"",
|
|
"[EMCIO]",
|
|
"TOOL_TABLE = nested/tool.tbl",
|
|
"",
|
|
].join("\n"),
|
|
});
|
|
await verifyRejects(
|
|
"opfs_reject_invalid_ini_tool_table",
|
|
() => loadMachineSessionFromOpfs(
|
|
interp,
|
|
"browser-invalid-tool-file-session",
|
|
{
|
|
iniSdk: ini,
|
|
iniWasmPath: "/work/browser-invalid-tool-file-session.ini",
|
|
},
|
|
),
|
|
/Invalid tool table filename/,
|
|
);
|
|
|
|
status.textContent = "browser_interp_smoke=ok";
|
|
} catch (error) {
|
|
status.textContent = `browser_interp_smoke=fail ${error.stack || error.message}`;
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|