diff --git a/docs/linuxcnc-porting.md b/docs/linuxcnc-porting.md index 1659c67..e9823de 100644 --- a/docs/linuxcnc-porting.md +++ b/docs/linuxcnc-porting.md @@ -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 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 | -| 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` | | 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` | diff --git a/test-all-native.sh b/test-all-native.sh index 0b9b4be..8b5a7e0 100755 --- a/test-all-native.sh +++ b/test-all-native.sh @@ -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 exit 1 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 \ test-native.sh \ diff --git a/test-linuxcnc-rs274-native.sh b/test-linuxcnc-rs274-native.sh index e529b10..15a84b9 100755 --- a/test-linuxcnc-rs274-native.sh +++ b/test-linuxcnc-rs274-native.sh @@ -141,6 +141,10 @@ if CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/li 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_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_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" @@ -377,6 +381,21 @@ if not any( if not any(event["type"] == "program-end" and event["line"] == 5 for event in threading_cycle): 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") if not any( 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_threading_sync.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_program_stops.json" echo "dumped $output_dir/cnc_sim_linuxcnc_coolant.json" diff --git a/test-linuxcnc-source-link.sh b/test-linuxcnc-source-link.sh index 63e567f..4895a2b 100755 --- a/test-linuxcnc-source-link.sh +++ b/test-linuxcnc-source-link.sh @@ -220,6 +220,12 @@ CNC_SIM_RS274_VAR="$var_file" \ CNC_SIM_RS274_VAR="$var_file" \ "$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_threading_cycle.ngc \ >"$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" \ "$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_tool_number.ngc \ >"$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): 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()) if not any( 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_threading_sync.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_program_stops.json" echo "dumped $output_dir/cnc_sim_linuxcnc_source_coolant.json" diff --git a/test-native.sh b/test-native.sh index 41b926b..1264eee 100755 --- a/test-native.sh +++ b/test-native.sh @@ -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 '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 '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' 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 diff --git a/tests/gcode/linuxcnc_lathe_diameter_mode.ngc b/tests/gcode/linuxcnc_lathe_diameter_mode.ngc new file mode 100644 index 0000000..09e9115 --- /dev/null +++ b/tests/gcode/linuxcnc_lathe_diameter_mode.ngc @@ -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