结论:未扩展 smoke 功能行为,仅让 architecture、source-policy 与 workstreams source-map 形成双向索引,并由 check-linuxcnc-workstreams-source-map.sh 守卫。 LinuxCNC 来源依据:configs/sim/axis/vismach/5axis/bridgemill/5axis.ini、remap_subs/428remap.ngc、src/emc/kinematics/Submakefile、kinematics.h、src/emc/rs274ngc/interp_internal.hh、rs274ngc_pre.cc、rs274ngc/Submakefile、tooldata/Submakefile、ini/Submakefile、pythonplugin/Submakefile 的六分组边界。 检查通过:./check-linuxcnc-workstreams-source-map.sh;./check-linuxcnc-build-source-map.sh;./test-native.sh;./test-linuxcnc-source-link.sh;CNC_SIM_ALL_NATIVE_GUARDRAILS_ONLY=1 ./test-all-native.sh。
4.1 KiB
WASM CNC simulator architecture
Native code boundary
The wasm core should expose a small C ABI and hide all LinuxCNC internals. The browser should never call LinuxCNC classes directly. This keeps the UI independent from whether the backend is LinuxCNC RS274, Fanuc preprocessing, Siemens preprocessing, or a future independent interpreter.
Current ABI entry points:
cnc_sim_createcnc_sim_destroycnc_sim_resetcnc_sim_set_dialectcnc_sim_load_config_jsoncnc_sim_parse_programcnc_sim_last_error
The event callback emits normalized CncSimEvent records. JavaScript can transform those records into JSON, binary buffers, or renderable typed arrays.
LinuxCNC integration plan
Functional behavior must come from LinuxCNC source code, not independently
designed project code. See docs/linuxcnc-source-policy.md.
- Build a native
CanonEventSinkthat implements all functions declared incanon.hh. - Link the sink with
src/emc/rs274ngcandsrc/emc/nml_intfinstead of the task controller. - Stub or remove Python remap support for the first browser target.
- Compile with Emscripten after replacing
dlopen, Python, HAL and filesystem-only features. - Compare event output with native LinuxCNC using the same G-code corpus.
Current Workstreams
The current porting work is being split into six small contexts and should be advanced in this order:
switchkins/remapgenerator and tableslinuxcnc-kinematicssource manifest- WASM filesystem and OPFS persistence
- browser app integration
- Node and browser smoke coverage
- source-link, build, and documentation constraints
Each step should stay source-backed and close one small gap at a time. A single
pass should advance one workstream context only; crossing into another context
requires naming the dependency and keeping the edit set minimal.
The synchronized source-map guard for these contexts is
docs/linuxcnc-workstreams-source-map.md.
Dialect expansion
LinuxCNC support should be the baseline. Fanuc and Siemens support should be implemented as dialect adapters, not by forking the simulator core.
Fanuc high-priority items:
- Macro B variables and expression semantics
G65,G66,G67macro calls- common fixed cycles
- cutter compensation and work offsets
- lathe cycles where required
Siemens high-priority items:
- named variables and arithmetic expressions
CYCLE*canned cyclesTRANS,ROT,SCALE,MIRRORTRAORIandCYCLE800- frame and workpiece coordinate transforms
Commercial simulator parity
Feature parity needs more than G-code parsing:
- exact toolpath display with modal state inspection
- configurable machine kinematics and limits
- holder, fixture and stock collision detection
- material removal simulation
- time estimation with acceleration and lookahead
- diagnostics for unsupported controller-specific words
- reproducible comparison tests for each controller dialect
Five-axis and RTCP
RTCP pivot events are emitted only for known LinuxCNC switchkins modes. These paths must use formulas copied from LinuxCNC source code, not independently derived geometry. The current source mapping is:
M428/XYZBC_TRT:linuxcnc/src/emc/kinematics/trtfuncs.c,xyzbcKinematicsForward()andxyzbcKinematicsInverse()M430/USERK_IDENTITY:linuxcnc/src/emc/kinematics/userkfuncs.c, delegating toidentityKinematicsForward()andidentityKinematicsInverse()inkins_util.c- The retained
5axiskinshelpers map tolinuxcnc/src/emc/kinematics/5axiskins.c,fiveaxis_KinematicsForward()andfiveaxis_KinematicsInverse()
RTCP is opt-in through config JSON. When enabled, the original motion events
remain programmed tool-tip motion and an additional rtcp-pivot event is emitted
for each rapid/feed/arc event. This keeps the ABI useful for both toolpath
display and machine-axis/pivot visualization.
Current files:
core/src/rtcp_kinematics.hcore/src/rtcp_kinematics.cppcore/tests/rtcp_kinematics_smoke.cpp
The next integration step is to add more LinuxCNC source-backed kinematics for additional switchkins or machine topologies.