继续按 align-linuxcnc 约束:补只读命名参数源回归

结论:新增 LinuxCNC-backed readonly named parameter fixture,依据 interp_namedparams.cc::lookup_named_param 与 init_readonly_param,在 native librs274 与 source-link runner 中验证 #<_metric>/#<_imperial>/#<_absolute>/#<_incremental>/#<_feed>/#<_rpm>/#<_spindle_on>/#<_spindle_cw>;未扩展 smoke,test-native 与 test-linuxcnc-source-link 均通过。
This commit is contained in:
cnc
2026-06-02 15:40:23 +08:00
parent 23284e528f
commit df5c459b1d
6 changed files with 75 additions and 1 deletions

View File

@@ -205,7 +205,7 @@ This matrix tracks LinuxCNC feature coverage for the web/WASM simulator. A featu
| Digital/analog I/O `M62`-`M68` | covered with Canon digital output, analog output, and input wait callbacks preserved as temporary state events | `tests/gcode/linuxcnc_io_controls.ngc` |
| Override controls `M48`-`M53` | covered with Canon feed override, spindle speed override, adaptive feed, and feed hold callbacks preserved as temporary state events | `tests/gcode/linuxcnc_override_controls.ngc` |
| Modal state save/restore `M70`-`M73` | covered for main-program save/invalidate/restore plus O-word subroutine autorestore in smoke parser, with native/source regressions checking restored distance mode, units, and XY plane motion | `tests/gcode/linuxcnc_modal_state.ngc`, `tests/gcode/linuxcnc_modal_autorestore.ngc` |
| LinuxCNC read-only named parameters | partially covered in smoke parser for common modal state reads used by O-word macros; `#<_lathe_diameter_mode>` and `#<_lathe_radius_mode>` are now covered through LinuxCNC native/source backends | `tests/gcode/linuxcnc_lathe_diameter_mode.ngc`, smoke API regression |
| LinuxCNC read-only named parameters | common modal/unit/feed/spindle reads are covered through LinuxCNC native/source backends, with additional ccomp/spindle-mode readonly reads source-linked | `tests/gcode/linuxcnc_readonly_named_parameters.ngc`, `tests/gcode/linuxcnc_readonly_named_parameters_extra.ngc`, `tests/gcode/linuxcnc_lathe_diameter_mode.ngc` |
| Feed and motion control modes `G93/G94/G95`, `G61/G61.1/G64` | covered through LinuxCNC native/source backends | `tests/gcode/linuxcnc_feed_modes.ngc`, `tests/gcode/linuxcnc_motion_modes.ngc` |
| Canned cycle `G81/G80` | covered for drilling expand-to-canon path, including `G18/G19` plane-specific depth-axis mapping for representative drilling/boring cycles | `tests/gcode/linuxcnc_canned_cycle.ngc`, `tests/gcode/linuxcnc_canned_cycle_planes.ngc` |
| Coordinate offset Canon events `G10 L2`, `G10 L20`, `G10 P0 active-system targeting`, `G54`-`G59.3` selection, `G52`, `G92/G92.1/G92.2/G92.3` | covered through LinuxCNC native/source backends, including all nine G5X indices | `tests/gcode/linuxcnc_coordinate_offsets.ngc`, `tests/gcode/linuxcnc_coordinate_l20.ngc`, `tests/gcode/linuxcnc_coordinate_p0.ngc`, `tests/gcode/linuxcnc_coordinate_select_all.ngc`, `tests/gcode/linuxcnc_g92_restore.ngc`, `tests/gcode/linuxcnc_g52_offset.ngc` |

View File

@@ -559,6 +559,7 @@ fi
grep -F 'convert_lathe_diameter_mode() scales G7/G8 X words and G76 I/J/K words' test-native.sh >/dev/null
grep -F 'tests/gcode/linuxcnc_lathe_diameter_mode.ngc' test-native.sh >/dev/null
grep -F 'tests/gcode/linuxcnc_lathe_diameter_g76.ngc' test-native.sh >/dev/null
grep -F 'tests/gcode/linuxcnc_readonly_named_parameters.ngc' test-native.sh >/dev/null
for script in \
test-native.sh \

View File

@@ -171,6 +171,9 @@ CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs2
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_indexed_parameters.ngc >"$output_dir/cnc_sim_linuxcnc_indexed_parameters.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_named_parameter_normalization.ngc >"$output_dir/cnc_sim_linuxcnc_named_parameter_normalization.json"
INI_FILE_NAME="$ini_named_parameter_file" CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_ini_named_parameter.ngc >"$output_dir/cnc_sim_linuxcnc_ini_named_parameter.json"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_namedparams.cc lookup_named_param()
# and init_readonly_param() expose modal/unit/feed/spindle readonly parameters.
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_readonly_named_parameters.ngc >"$output_dir/cnc_sim_linuxcnc_readonly_named_parameters.json"
cp "$base_var_file" "$var_file"
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_coordinate_offsets.ngc >"$output_dir/cnc_sim_linuxcnc_coordinate_offsets.json"
cp "$base_var_file" "$var_file"
@@ -1101,6 +1104,23 @@ expected_ini_named_moves = [(3, 3.25, 0), (5, 3.25, 1)]
if ini_named_moves != expected_ini_named_moves:
raise SystemExit(f"unexpected LinuxCNC INI named parameter motions: {ini_named_moves!r}")
readonly_named = load("cnc_sim_linuxcnc_readonly_named_parameters.json")
readonly_moves = [
(event["line"], event["end"]["x"], event["end"]["y"], event["end"]["z"])
for event in readonly_named
if event["type"] == "linear-feed"
]
expected_readonly_moves = [
(4, 1, 0, 0),
(8, 0.0393701, 1, 0),
(12, 1, 25.4, 1),
(16, 2, 25.4, 1),
(22, 2, 3, 1),
(25, 2, 3, 2),
]
if readonly_moves != expected_readonly_moves:
raise SystemExit(f"unexpected LinuxCNC readonly named parameter motions: {readonly_moves!r}")
coords = load("cnc_sim_linuxcnc_coordinate_offsets.json")
g5x = [event for event in coords if event["type"] == "set-g5x-offset"]
g92 = [event for event in coords if event["type"] == "set-g92-offset"]
@@ -1251,6 +1271,7 @@ echo "dumped $output_dir/cnc_sim_linuxcnc_named_parameter_exists.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_indexed_parameters.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_named_parameter_normalization.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_ini_named_parameter.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_readonly_named_parameters.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_coordinate_offsets.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_coordinate_l20.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_coordinate_p0.json"

View File

@@ -545,6 +545,11 @@ CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
INI_FILE_NAME="$ini_named_parameter_file" CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_ini_named_parameter.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_ini_named_parameter.json"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_namedparams.cc lookup_named_param()
# and init_readonly_param() expose modal/unit/feed/spindle readonly parameters.
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_readonly_named_parameters.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_readonly_named_parameters.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_readonly_named_parameters_extra.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_readonly_named_parameters_extra.json"
@@ -1826,6 +1831,23 @@ expected_ini_named_moves = [(3, 3.25, 0), (5, 3.25, 1)]
if ini_named_moves != expected_ini_named_moves:
raise SystemExit(f"unexpected source-linked INI named parameter motions: {ini_named_moves!r}")
readonly_common = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_readonly_named_parameters.json").read_text())
readonly_common_moves = [
(event["line"], event["end"]["x"], event["end"]["y"], event["end"]["z"])
for event in readonly_common
if event["type"] == "linear-feed"
]
expected_readonly_common_moves = [
(4, 1, 0, 0),
(8, 0.0393701, 1, 0),
(12, 1, 25.4, 1),
(16, 2, 25.4, 1),
(22, 2, 3, 1),
(25, 2, 3, 2),
]
if readonly_common_moves != expected_readonly_common_moves:
raise SystemExit(f"unexpected source-linked readonly named parameter motions: {readonly_common_moves!r}")
readonly_named = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_readonly_named_parameters_extra.json").read_text())
if not any(
event["type"] == "linear-feed" and
@@ -2539,6 +2561,7 @@ echo "dumped $output_dir/cnc_sim_linuxcnc_source_named_parameter_exists.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_indexed_parameters.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_named_parameter_normalization.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_ini_named_parameter.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_readonly_named_parameters.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_readonly_named_parameters_extra.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_value_returned.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_call_level.json"

View File

@@ -145,6 +145,8 @@ grep -F 'convert_lathe_diameter_mode() scales G7/G8 X words and G76 I/J/K words'
grep -F 'tests/gcode/linuxcnc_lathe_diameter_mode.ngc' docs/linuxcnc-porting.md >/dev/null
grep -F 'tests/gcode/linuxcnc_lathe_diameter_g76.ngc' docs/linuxcnc-porting.md >/dev/null
grep -F 'missing source-linked G7 diameter-mode G76 final threading pass' test-linuxcnc-source-link.sh >/dev/null
grep -F 'lookup_named_param()' test-linuxcnc-rs274-native.sh >/dev/null
grep -F 'tests/gcode/linuxcnc_readonly_named_parameters.ngc' docs/linuxcnc-porting.md >/dev/null
grep -F 'rs274ngc_pre.cc ini_load() consumes INI_FILE_NAME' test-web-wasm-node-smoke.cjs >/dev/null
grep -F 'rs274ngc_pre.cc ini_load() consumes INI_FILE_NAME' web/test-browser-wasm-smoke-linuxcnc-sections.js >/dev/null
grep -F 'metadata:src/emc/nml_intf/emcops.cc:source basis for native source-link EMC status constructor support object' linuxcnc-rs274-source-files.txt >/dev/null

View File

@@ -0,0 +1,27 @@
G21 G90 G17
F100
O10 if [#<_metric> EQ 1]
G1 X1
O10 endif
G20
O20 if [#<_imperial> EQ 1]
G1 Y1
O20 endif
G21
O30 if [#<_absolute> EQ 1]
G1 Z1
O30 endif
G91
O40 if [#<_incremental> EQ 1]
G1 X1
O40 endif
G90
F123
S456 M3
O50 if [[#<_feed> EQ 123] AND [#<_rpm> EQ 456]]
G1 Y3
O50 endif
O60 if [[#<_spindle_on> EQ 1] AND [#<_spindle_cw> EQ 1]]
G1 Z2
O60 endif
M30