继续按 align-linuxcnc 约束:补 G7G8 源链接回归

结论:新增 LinuxCNC-backed lathe diameter/radius fixture,依据 interp_convert.cc::convert_lathe_diameter_mode 与 interp_namedparams.cc readonly 参数,在 native librs274 与 source-link runner 中验证 G7/G8 同块 X 缩放和 #<_lathe_diameter_mode>/#<_lathe_radius_mode> 分支;未扩展 smoke,test-native 与 test-linuxcnc-source-link 均通过。
This commit is contained in:
cnc
2026-06-02 15:27:31 +08:00
parent 6266887fec
commit 6e0a5627f0
6 changed files with 59 additions and 1 deletions

View File

@@ -201,7 +201,7 @@ This matrix tracks LinuxCNC feature coverage for the web/WASM simulator. A featu
| Spindle speed mode `G96/G97` | covered with Canon `SET_SPINDLE_MODE` preserved as mode state events, including `G96 D...` max-RPM value | `tests/gcode/linuxcnc_spindle_modes.ngc` | | Spindle speed mode `G96/G97` | covered with Canon `SET_SPINDLE_MODE` preserved as mode state events, including `G96 D...` max-RPM value | `tests/gcode/linuxcnc_spindle_modes.ngc` |
| Spindle orientation `M19 R... P... Q...` | covered with Canon `ORIENT_SPINDLE` and `WAIT_SPINDLE_ORIENT_COMPLETE` preserved as temporary mode state events | `tests/gcode/linuxcnc_spindle_orient.ngc` | | Spindle orientation `M19 R... P... Q...` | covered with Canon `ORIENT_SPINDLE` and `WAIT_SPINDLE_ORIENT_COMPLETE` preserved as temporary mode state events | `tests/gcode/linuxcnc_spindle_orient.ngc` |
| Spindle-synchronized feed and threading `G33/G33.1/G76` | covered through smoke, LinuxCNC native, and source-linked paths with Canon `START_SPEED_FEED_SYNCH`/`STOP_SPEED_FEED_SYNCH` preserved, rigid-tap line numbers normalized, and G76 multi-pass threading smoke-covered | `tests/gcode/linuxcnc_threading_sync.ngc`, `tests/gcode/linuxcnc_threading_cycle.ngc`, smoke API regression | | Spindle-synchronized feed and threading `G33/G33.1/G76` | covered through smoke, LinuxCNC native, and source-linked paths with Canon `START_SPEED_FEED_SYNCH`/`STOP_SPEED_FEED_SYNCH` preserved, rigid-tap line numbers normalized, and G76 multi-pass threading smoke-covered | `tests/gcode/linuxcnc_threading_sync.ngc`, `tests/gcode/linuxcnc_threading_cycle.ngc`, smoke API regression |
| Lathe diameter/radius mode `G7/G8` | covered in smoke parser for X-axis diameter/radius scaling, including interaction with G76 threading geometry; native/source backends use LinuxCNC interpreter state directly | smoke API regression | | Lathe diameter/radius mode `G7/G8` | covered through LinuxCNC native/source backends for same-block X scaling and `#<_lathe_diameter_mode>`/`#<_lathe_radius_mode>` readonly named-parameter state; G76 threading geometry interaction remains smoke-covered | `tests/gcode/linuxcnc_lathe_diameter_mode.ngc`, smoke API regression |
| 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` | | 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` | | 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` | | 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` |

View File

@@ -556,6 +556,8 @@ if grep -F 'read -r -a python_includes <<<"$(' list-linuxcnc-source-common-cxxfl
echo "source common cxxflags still hides python-config failures behind read" >&2 echo "source common cxxflags still hides python-config failures behind read" >&2
exit 1 exit 1
fi fi
grep -F 'convert_lathe_diameter_mode() scales G7/G8 X words' test-native.sh >/dev/null
grep -F 'tests/gcode/linuxcnc_lathe_diameter_mode.ngc' test-native.sh >/dev/null
for script in \ for script in \
test-native.sh \ test-native.sh \

View File

@@ -141,6 +141,10 @@ if CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/li
fi fi
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_threading_sync.ngc >"$output_dir/cnc_sim_linuxcnc_threading_sync.json" CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_threading_sync.ngc >"$output_dir/cnc_sim_linuxcnc_threading_sync.json"
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_threading_cycle.ngc >"$output_dir/cnc_sim_linuxcnc_threading_cycle.json" CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_threading_cycle.ngc >"$output_dir/cnc_sim_linuxcnc_threading_cycle.json"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_convert.cc
# convert_lathe_diameter_mode() scales G7/G8 X words; interp_namedparams.cc
# exposes #<_lathe_diameter_mode> and #<_lathe_radius_mode>.
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_lathe_diameter_mode.ngc >"$output_dir/cnc_sim_linuxcnc_lathe_diameter_mode.json"
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_tool_number.ngc >"$output_dir/cnc_sim_linuxcnc_tool_number.json" CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_tool_number.ngc >"$output_dir/cnc_sim_linuxcnc_tool_number.json"
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_program_stops.ngc >"$output_dir/cnc_sim_linuxcnc_program_stops.json" CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_program_stops.ngc >"$output_dir/cnc_sim_linuxcnc_program_stops.json"
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_coolant.ngc >"$output_dir/cnc_sim_linuxcnc_coolant.json" CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_coolant.ngc >"$output_dir/cnc_sim_linuxcnc_coolant.json"
@@ -377,6 +381,21 @@ if not any(
if not any(event["type"] == "program-end" and event["line"] == 5 for event in threading_cycle): if not any(event["type"] == "program-end" and event["line"] == 5 for event in threading_cycle):
raise SystemExit("missing G76 program end line number") raise SystemExit("missing G76 program end line number")
lathe_diameter_mode = load("cnc_sim_linuxcnc_lathe_diameter_mode.json")
lathe_feeds = [
(event["line"], event["end"]["x"], event["end"]["y"])
for event in lathe_diameter_mode
if event["type"] == "linear-feed"
]
expected_lathe_feeds = [
(3, 5, 0),
(5, 5, 1),
(7, 6, 1),
(9, 6, 2),
]
if lathe_feeds != expected_lathe_feeds:
raise SystemExit(f"unexpected G7/G8 lathe diameter-mode feeds: {lathe_feeds!r}")
tool_number = load("cnc_sim_linuxcnc_tool_number.json") tool_number = load("cnc_sim_linuxcnc_tool_number.json")
if not any( if not any(
event["type"] == "tool-change" and event["type"] == "tool-change" and
@@ -1186,6 +1205,7 @@ echo "dumped $output_dir/cnc_sim_linuxcnc_modal_state.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_modal_autorestore.json" echo "dumped $output_dir/cnc_sim_linuxcnc_modal_autorestore.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_threading_sync.json" echo "dumped $output_dir/cnc_sim_linuxcnc_threading_sync.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_threading_cycle.json" echo "dumped $output_dir/cnc_sim_linuxcnc_threading_cycle.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_lathe_diameter_mode.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_tool_number.json" echo "dumped $output_dir/cnc_sim_linuxcnc_tool_number.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_program_stops.json" echo "dumped $output_dir/cnc_sim_linuxcnc_program_stops.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_coolant.json" echo "dumped $output_dir/cnc_sim_linuxcnc_coolant.json"

View File

@@ -220,6 +220,12 @@ CNC_SIM_RS274_VAR="$var_file" \
CNC_SIM_RS274_VAR="$var_file" \ CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_threading_cycle.ngc \ "$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_threading_cycle.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_threading_cycle.json" >"$output_dir/cnc_sim_linuxcnc_source_threading_cycle.json"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_convert.cc
# convert_lathe_diameter_mode() scales G7/G8 X words; interp_namedparams.cc
# exposes #<_lathe_diameter_mode> and #<_lathe_radius_mode>.
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_lathe_diameter_mode.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_lathe_diameter_mode.json"
CNC_SIM_RS274_VAR="$var_file" \ CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_tool_number.ngc \ "$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_tool_number.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_tool_number.json" >"$output_dir/cnc_sim_linuxcnc_source_tool_number.json"
@@ -1073,6 +1079,21 @@ if not any(
if not any(event["type"] == "program-end" and event["line"] == 5 for event in threading_cycle): if not any(event["type"] == "program-end" and event["line"] == 5 for event in threading_cycle):
raise SystemExit("missing source-linked G76 program end line number") raise SystemExit("missing source-linked G76 program end line number")
lathe_diameter_mode = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_lathe_diameter_mode.json").read_text())
lathe_feeds = [
(event["line"], event["end"]["x"], event["end"]["y"])
for event in lathe_diameter_mode
if event["type"] == "linear-feed"
]
expected_lathe_feeds = [
(3, 5, 0),
(5, 5, 1),
(7, 6, 1),
(9, 6, 2),
]
if lathe_feeds != expected_lathe_feeds:
raise SystemExit(f"unexpected source-linked G7/G8 lathe diameter-mode feeds: {lathe_feeds!r}")
tool_number = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_tool_number.json").read_text()) tool_number = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_tool_number.json").read_text())
if not any( if not any(
event["type"] == "tool-change" and event["type"] == "tool-change" and
@@ -2469,6 +2490,7 @@ echo "dumped $output_dir/cnc_sim_linuxcnc_source_modal_state.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_modal_autorestore.json" echo "dumped $output_dir/cnc_sim_linuxcnc_source_modal_autorestore.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_threading_sync.json" echo "dumped $output_dir/cnc_sim_linuxcnc_source_threading_sync.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_threading_cycle.json" echo "dumped $output_dir/cnc_sim_linuxcnc_source_threading_cycle.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_lathe_diameter_mode.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_tool_number.json" echo "dumped $output_dir/cnc_sim_linuxcnc_source_tool_number.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_program_stops.json" echo "dumped $output_dir/cnc_sim_linuxcnc_source_program_stops.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_coolant.json" echo "dumped $output_dir/cnc_sim_linuxcnc_source_coolant.json"

View File

@@ -140,6 +140,9 @@ grep -F 'expected LinuxCNC INI PARAMETER_FILE to restore numbered parameters' co
grep -F 'expected LinuxCNC config INI_FILE_NAME to back #<_ini[]> named parameters' core/tests/cnc_sim_api_linuxcnc_rs274_smoke.cpp >/dev/null grep -F 'expected LinuxCNC config INI_FILE_NAME to back #<_ini[]> named parameters' core/tests/cnc_sim_api_linuxcnc_rs274_smoke.cpp >/dev/null
grep -F 'interp->ini_load(options.ini_file_name.c_str())' core/src/linuxcnc_rs274_backend.cpp >/dev/null grep -F 'interp->ini_load(options.ini_file_name.c_str())' core/src/linuxcnc_rs274_backend.cpp >/dev/null
grep -F 'ScopedEnvironmentVariable ini_file_env("INI_FILE_NAME", options.ini_file_name)' core/src/linuxcnc_rs274_backend.cpp >/dev/null grep -F 'ScopedEnvironmentVariable ini_file_env("INI_FILE_NAME", options.ini_file_name)' core/src/linuxcnc_rs274_backend.cpp >/dev/null
grep -F 'convert_lathe_diameter_mode() scales G7/G8 X words' test-linuxcnc-rs274-native.sh >/dev/null
grep -F 'convert_lathe_diameter_mode() scales G7/G8 X words' test-linuxcnc-source-link.sh >/dev/null
grep -F 'tests/gcode/linuxcnc_lathe_diameter_mode.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' 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 '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 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,11 @@
G21 G90
F100
G7 G1 X10
O10 if [#<_lathe_diameter_mode> EQ 1]
G1 Y1
O10 endif
G8 G1 X6
O20 if [#<_lathe_radius_mode> EQ 1]
G1 Y2
O20 endif
M30