From 0b70bb0aa86d38a4dac063ddfe85cc4a9d01ddee Mon Sep 17 00:00:00 2001 From: wangdequan Date: Mon, 8 Jun 2026 00:07:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=89=E5=BB=BA=E8=AE=AE=EF=BC=8C=E7=BB=A7?= =?UTF-8?q?=E7=BB=AD=E5=AE=8C=E6=88=90=E5=90=8E=E7=BB=AD=E5=B7=A5=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 结论:将 GET_EXTERNAL_FEED_RATE 接入 canonical feed 状态,并用 G20/G21 长度单位 fixture 验证回读。 --- wasm-port/docs/compatibility-validation.md | 5 +++-- wasm-port/docs/drift-report.md | 1 + wasm-port/docs/source-reuse-map.md | 2 +- .../core/linuxcnc_wrap/linuxcnc_interp_minimal_runtime.cpp | 4 +++- wasm-port/tests/fixtures/canon/length_units.events | 3 ++- wasm-port/tests/fixtures/gcode/length_units.ngc | 1 + 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/wasm-port/docs/compatibility-validation.md b/wasm-port/docs/compatibility-validation.md index a2690ec..06e68a2 100644 --- a/wasm-port/docs/compatibility-validation.md +++ b/wasm-port/docs/compatibility-validation.md @@ -54,7 +54,7 @@ The validation fails if: | `linuxcnc_interp_state_probe` | Validates interpreter state constants and structs compile under the standalone boundary. | | `linuxcnc_emc_status_probe` | Validates the standalone `emcStatus` machine-units status boundary used by vendored interpreter conversion and initialization code. | | `linuxcnc_namedparam_harness` | Validates LinuxCNC named parameter behavior, `_ini[...]`, and `_hal[...]` adapter resolution. | -| `linuxcnc_interp_minimal_harness` | Runs G-code fixtures through vendored LinuxCNC parser/execution/conversion code and captures canonical events. | +| `linuxcnc_interp_minimal_harness` | Runs G-code fixtures through vendored LinuxCNC parser/execution/conversion code, captures canonical events, and validates feed-rate state readback across length-unit changes. | | `linuxcnc_parameter_file_harness` | Validates LinuxCNC parameter file restore/save behavior and required/read-only parameter handling. | | `linuxcnc_interp_init_harness` | Validates vendored LinuxCNC `Interp::init()` emits canonical initialization boundaries, reads metric/inch machine units, and synchronizes current/selected tool slots through standalone status adapters. | | `linuxcnc_indexer_harness` | Validates vendored LinuxCNC single-axis rotary indexer dispatch emits lock/unlock and motion boundaries through the standalone event sink. | @@ -123,7 +123,8 @@ machine-session validation remain future work. The current fixture expectations validate standalone behavior against both the vendored LinuxCNC source path and an upstream `rs274` side-by-side baseline for -parser/conversion, arc geometry, offsets, feed-control, comment/logging, +parser/conversion, arc geometry, offsets, feed-control and feed-state +readback, comment/logging, numbered-parameter, probing, spindle-orient, file-open reset, file-finish, tool-reload, tool select/change/length-offset, canned-cycle, state-tag motion, tool-table setup, and O-word subroutine fixtures, plus threading/rigid tap, diff --git a/wasm-port/docs/drift-report.md b/wasm-port/docs/drift-report.md index 5a52076..0fe17d7 100644 --- a/wasm-port/docs/drift-report.md +++ b/wasm-port/docs/drift-report.md @@ -26,6 +26,7 @@ semantic rewrites: | HAL lookup | Standalone HAL adapter for `_hal[...]` named parameter reads. | | INI lookup | Standalone INI adapter around vendored LinuxCNC INI parser behavior. | | Canonical output | Canonical calls are captured as test events instead of driving hardware. | +| Feed-rate state | `SET_FEED_RATE` updates standalone canonical runtime state so vendored `convert_length_units()` can read it back through `GET_EXTERNAL_FEED_RATE()` during G20/G21 changes. | | Tool-data reload | LinuxCNC `RELOAD_TOOLDATA` is captured as a canonical test event; browser/native tool-table reload plumbing remains a future host/runtime adapter. | | Tool slot status | Standalone tool adapter state supplies `GET_EXTERNAL_TOOL_SLOT()` and `GET_EXTERNAL_SELECTED_TOOL_SLOT()` for vendored `Interp::synch()`; `linuxcnc_interp_init_harness` guards current/selected slot synchronization. | | Interpreter state tags | LinuxCNC `UPDATE_TAG` callbacks are captured from the state tags packed by vendored interpreter code; standalone code does not derive modal state. | diff --git a/wasm-port/docs/source-reuse-map.md b/wasm-port/docs/source-reuse-map.md index 39c08f5..6b81f01 100644 --- a/wasm-port/docs/source-reuse-map.md +++ b/wasm-port/docs/source-reuse-map.md @@ -43,7 +43,7 @@ Current validation is intentionally mechanical: | Ruckig C planner support | Selected `src/emc/tp/cruckig/*.c` and `*.h` files in the manifest | Copy unchanged | Used as LinuxCNC planner support code through vendored TP sources | Vendor byte sync, per-file source probes | | Posemath | `src/libnml/posemath/posemath.cc`, `_posemath.c`, `gomath.c`, `sincos.c`, and matching headers | Copy unchanged | `gomath.c` is compiled as C; `rtapi.h` shim is C/C++ compatible for this boundary | Vendor byte sync, per-file source probes, TP probe | | RS274 interpreter state and parser | `src/emc/rs274ngc/modal_state.*`, `interp_internal.*`, `interp_read.cc`, `interp_check.cc`, `interp_execute.cc`, `interp_find.cc`, `interp_array.cc`, `interp_queue.*`, `rs274ngc*`, `units.h` | Copy unchanged | Python/remap/runtime edges are isolated in standalone wrappers and shims; parser and execution logic remain LinuxCNC source | Vendor byte sync, per-file source probes, interpreter harness fixtures | -| RS274 conversion semantics | `src/emc/rs274ngc/interp_convert.cc`, `interp_arc.cc`, `interp_inverse.cc`, `interp_cycles.cc`, `interp_g7x.cc`, `interp_o_word.cc`, `interp_write.cc` | Copy unchanged | Canonical calls are captured by standalone event sink functions; conversion behavior stays in vendored LinuxCNC files | Vendor byte sync, per-file source probes, canonical fixture suite, no standalone `Interp::convert_g()` guard | +| RS274 conversion semantics | `src/emc/rs274ngc/interp_convert.cc`, `interp_arc.cc`, `interp_inverse.cc`, `interp_cycles.cc`, `interp_g7x.cc`, `interp_o_word.cc`, `interp_write.cc` | Copy unchanged | Canonical calls are captured by standalone event sink functions; conversion behavior stays in vendored LinuxCNC files; feed-rate state is read back through the canonical runtime boundary during length-unit conversion | Vendor byte sync, per-file source probes, canonical fixture suite, no standalone `Interp::convert_g()` guard | | Named parameters and tool slot status | `src/emc/rs274ngc/interp_namedparams.cc`, related interpreter headers | Copy unchanged | `_ini[...]` and `_hal[...]` resolve through standalone INI/HAL adapters while lookup order stays LinuxCNC-derived; current/selected tool slot reads for vendored `Interp::synch()` come from the standalone tool adapter | Vendor byte sync, source probe, `linuxcnc_namedparam_harness`, `linuxcnc_interp_init_harness` | | Dynamic interpreter base | `src/emc/rs274ngc/interp_base.*` | Copy unchanged | `interp_base.cc` source probe uses standalone `EMC2_HOME` compile-time path boundary for LinuxCNC dynamic interpreter lookup | Vendor byte sync, `linuxcnc_interp_base_source_probe` | diff --git a/wasm-port/runtime/core/linuxcnc_wrap/linuxcnc_interp_minimal_runtime.cpp b/wasm-port/runtime/core/linuxcnc_wrap/linuxcnc_interp_minimal_runtime.cpp index fd44400..8a7cdfc 100644 --- a/wasm-port/runtime/core/linuxcnc_wrap/linuxcnc_interp_minimal_runtime.cpp +++ b/wasm-port/runtime/core/linuxcnc_wrap/linuxcnc_interp_minimal_runtime.cpp @@ -18,6 +18,7 @@ namespace standalone { static std::vector g_canon_events; +static double g_external_feed_rate = 0.0; void reset_canon_events() { @@ -447,7 +448,7 @@ void CANON_ERROR(const char *fmt, ...) va_end(ap); } -double GET_EXTERNAL_FEED_RATE() { return 0.0; } +double GET_EXTERNAL_FEED_RATE() { return standalone::g_external_feed_rate; } int GET_EXTERNAL_FLOOD() { return 0; } CANON_UNITS GET_EXTERNAL_LENGTH_UNIT_TYPE() { @@ -639,6 +640,7 @@ void ARC_FEED(int lineno, void SET_FEED_RATE(double rate) { + standalone::g_external_feed_rate = rate; std::ostringstream oss; oss << "SET_FEED_RATE rate=" << rate; standalone::push_canon_event(oss.str()); diff --git a/wasm-port/tests/fixtures/canon/length_units.events b/wasm-port/tests/fixtures/canon/length_units.events index 2a1eed1..c8a7529 100644 --- a/wasm-port/tests/fixtures/canon/length_units.events +++ b/wasm-port/tests/fixtures/canon/length_units.events @@ -4,5 +4,6 @@ canon_event=USE_LENGTH_UNITS units=1 canon_event=SET_FEED_RATE rate=60 canon_event=STRAIGHT_FEED line=3 x=1.5 y=0 z=0 a=0 b=0 c=0 u=0 v=0 w=0 canon_event=USE_LENGTH_UNITS units=2 +canon_event=MESSAGE: feed after_g21=60.0000 canon_event=SET_FEED_RATE rate=120 -canon_event=STRAIGHT_FEED line=5 x=50.8 y=0 z=0 a=0 b=0 c=0 u=0 v=0 w=0 +canon_event=STRAIGHT_FEED line=6 x=50.8 y=0 z=0 a=0 b=0 c=0 u=0 v=0 w=0 diff --git a/wasm-port/tests/fixtures/gcode/length_units.ngc b/wasm-port/tests/fixtures/gcode/length_units.ngc index 17a873e..64f742d 100644 --- a/wasm-port/tests/fixtures/gcode/length_units.ngc +++ b/wasm-port/tests/fixtures/gcode/length_units.ngc @@ -2,4 +2,5 @@ G90 G17 G0 X25.4 Y0 Z0 G20 G1 X1.5 F60 G21 +(DEBUG, feed after_g21=%f#<_feed>) G1 X50.8 F120