diff --git a/docs/linuxcnc-porting.md b/docs/linuxcnc-porting.md index 154b3bc..091dff0 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 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 | +| Lathe diameter/radius mode `G7/G8` | covered through LinuxCNC native/source backends for same-block X scaling, `G76` I/J/K threading geometry interaction, and `#<_lathe_diameter_mode>`/`#<_lathe_radius_mode>` readonly named-parameter state | `tests/gcode/linuxcnc_lathe_diameter_mode.ngc`, `tests/gcode/linuxcnc_lathe_diameter_g76.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` | | 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 8b5a7e0..e1a6788 100755 --- a/test-all-native.sh +++ b/test-all-native.sh @@ -556,8 +556,9 @@ 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 '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 for script in \ test-native.sh \ diff --git a/test-linuxcnc-rs274-native.sh b/test-linuxcnc-rs274-native.sh index 15a84b9..20315b6 100755 --- a/test-linuxcnc-rs274-native.sh +++ b/test-linuxcnc-rs274-native.sh @@ -142,9 +142,11 @@ 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>. +# convert_lathe_diameter_mode() scales G7/G8 X words and G76 I/J/K 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_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_lathe_diameter_g76.ngc >"$output_dir/cnc_sim_linuxcnc_lathe_diameter_g76.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" @@ -396,6 +398,24 @@ expected_lathe_feeds = [ if lathe_feeds != expected_lathe_feeds: raise SystemExit(f"unexpected G7/G8 lathe diameter-mode feeds: {lathe_feeds!r}") +lathe_g76 = load("cnc_sim_linuxcnc_lathe_diameter_g76.json") +if not any( + event["type"] == "linear-feed" and + event["line"] == 4 and + abs(event["end"]["x"] - 0.98125) < 1e-9 and + event["end"]["z"] == -1 + for event in lathe_g76 +): + raise SystemExit("missing G7 diameter-mode G76 final threading pass") +if not any( + event["type"] == "comment" and + event["line"] == 4 and + event["reserved"] == 3301 and + abs(event["feed"] - 0.0515388) < 1e-7 + for event in lathe_g76 +): + raise SystemExit("missing G7 diameter-mode G76 taper sync pitch") + tool_number = load("cnc_sim_linuxcnc_tool_number.json") if not any( event["type"] == "tool-change" and @@ -1206,6 +1226,7 @@ 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_lathe_diameter_g76.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 4895a2b..fdb7db0 100755 --- a/test-linuxcnc-source-link.sh +++ b/test-linuxcnc-source-link.sh @@ -221,11 +221,15 @@ 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>. +# convert_lathe_diameter_mode() scales G7/G8 X words and G76 I/J/K 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_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \ + "$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_lathe_diameter_g76.ngc \ + >"$output_dir/cnc_sim_linuxcnc_source_lathe_diameter_g76.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" @@ -1094,6 +1098,24 @@ expected_lathe_feeds = [ if lathe_feeds != expected_lathe_feeds: raise SystemExit(f"unexpected source-linked G7/G8 lathe diameter-mode feeds: {lathe_feeds!r}") +lathe_g76 = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_lathe_diameter_g76.json").read_text()) +if not any( + event["type"] == "linear-feed" and + event["line"] == 4 and + abs(event["end"]["x"] - 0.98125) < 1e-9 and + event["end"]["z"] == -1 + for event in lathe_g76 +): + raise SystemExit("missing source-linked G7 diameter-mode G76 final threading pass") +if not any( + event["type"] == "comment" and + event["line"] == 4 and + event["reserved"] == 3301 and + abs(event["feed"] - 0.0515388) < 1e-7 + for event in lathe_g76 +): + raise SystemExit("missing source-linked G7 diameter-mode G76 taper sync pitch") + tool_number = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_tool_number.json").read_text()) if not any( event["type"] == "tool-change" and @@ -2491,6 +2513,7 @@ 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_lathe_diameter_g76.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 1264eee..d473510 100755 --- a/test-native.sh +++ b/test-native.sh @@ -140,9 +140,11 @@ 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 'convert_lathe_diameter_mode() scales G7/G8 X words and G76 I/J/K words' test-linuxcnc-rs274-native.sh >/dev/null +grep -F 'convert_lathe_diameter_mode() scales G7/G8 X words and G76 I/J/K 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 '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 '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_g76.ngc b/tests/gcode/linuxcnc_lathe_diameter_g76.ngc new file mode 100644 index 0000000..3e5422a --- /dev/null +++ b/tests/gcode/linuxcnc_lathe_diameter_g76.ngc @@ -0,0 +1,5 @@ +G20 G90 G18 +S500 M3 +G0 X1 Z0.1 +G7 G76 P0.05 Z-1 I-.075 J0.008 K0.045 Q29.5 L2 E0.045 +M30