nc-gcode-interpreter 0.4.0__tar.gz → 0.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/CHANGELOG.md +26 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/Cargo.lock +1 -1
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/Cargo.toml +1 -1
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/PKG-INFO +1 -1
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/README.md +1 -1
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/nc_gcode_interpreter/__init__.py +21 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/nc_gcode_interpreter/_internal.pyi +1 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_bspline_pl.py +54 -4
- nc_gcode_interpreter-0.4.1/python/tests/test_frame_columns.py +115 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/src/flatten.rs +32 -9
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/src/interpret_rules.rs +4 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/src/lib.rs +5 -1
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/src/line_driver.rs +3 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/src/output.rs +29 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/src/state.rs +21 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/src/subprogram.rs +4 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/src/vm.rs +4 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/.github/workflows/benchmark.yml +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/.github/workflows/build-and-release.yml +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/.gitignore +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/CONTRIBUTING.md +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/Development.md +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/LICENSE +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/TODO.md +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/benches/extensions.rs +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/benches/fixtures.rs +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/benches/workloads.rs +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/build.rs +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/build_backend/nc_build_backend.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/docs/resumable-interpretation-design.md +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/docs/sinumerik-execution-model.md +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/actual_position.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/actual_position.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/arc.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/arc.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/arrays.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/arrays.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/axis_index_assignment.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/axis_index_assignment.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/basic_math.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/basic_math.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/case.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/case.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/case_insensitive_variables.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/case_insensitive_variables.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/custom_vars.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/custom_vars.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/def_string.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/def_string.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/defaults.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/defaults.def +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/defaults.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/defaults_start.json +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/edge_cases.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/edge_cases.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/flattening/flatten_demo.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/flattening/flatten_demo_flattened.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/flattening/flatten_demo_raw.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/for_loop.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/for_loop.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/function_calls.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/function_calls.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/goto.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/goto.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/if_statement.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/if_statement.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/increment.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/increment.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/logic_operators.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/logic_operators.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/loop.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/loop.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/multiple_m_codes.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/multiple_m_codes.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/precedence.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/precedence.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/r_param.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/r_param.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/repeat.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/repeat.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/rot.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/rot.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/simple.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/simple.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/spline.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/spline.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/tool.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/tool.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/trans.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/trans.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/trans2.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/trans2.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/trans_ic.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/trans_ic.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/trans_reset.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/trans_reset.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/trig.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/trig.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/variables.csv +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/variables.mpf +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/ggroups/generate_g_commands.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/pyproject.toml +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/example/minimal.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/example/streaming.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/nc_gcode_interpreter/cli.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/nc_gcode_interpreter/ggroups.json +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/nc_gcode_interpreter/py.typed +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/nc_gcode_interpreter/viz.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/nc_source.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_arithmetic_functions.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_batch_variables.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_batches.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_build_backend.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_compare_benchmarks.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_diagnostics.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_expected_output.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_feed_check.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_feed_group.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_field_defects.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_flags.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_flatten.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_frames.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_g_group_enum.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_g_groups.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_g_vocabulary.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_jumps.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_preset.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_real_comparisons.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_stage1.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_start_inputs.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_streaming.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_string_operations.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_structured_errors.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_subprograms.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_unsupported.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/rustfmt.toml +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/scripts/benchmark.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/scripts/compare_benchmarks.py +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/src/errors.rs +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/src/frame.rs +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/src/grammar.pest +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/src/interpreter.rs +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/src/line_driver/experiments.rs +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/src/main.rs +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/src/modal_groups.rs +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/src/start.rs +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/src/structure_scan.rs +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/src/types.rs +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/tests/cli.rs +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/tests/performance_contract.rs +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/tests/syntax_compatibility.rs +0 -0
- {nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/uv.lock +0 -0
|
@@ -4,6 +4,32 @@ Notable changes to **nc-gcode-interpreter**. The format loosely follows
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/); versions are git tags,
|
|
5
5
|
released to PyPI.
|
|
6
6
|
|
|
7
|
+
## [v0.4.1] - 2026-11-24
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `include_frame` on `nc_to_dataframe` and `nc_to_batches` (#130). When set,
|
|
12
|
+
every row carries the programmable frame that is active on it: the rotation
|
|
13
|
+
`R` as `frame_r11` to `frame_r33` (row by row) and the translation `t` as
|
|
14
|
+
`frame_tx`, `frame_ty`, `frame_tz`, in machine XYZ = R * local XYZ + t. The
|
|
15
|
+
values are written on the first row and on the first row after a change and
|
|
16
|
+
forward-filled like the axis columns. The interpreter does not rotate
|
|
17
|
+
programmed A/B/C values, so a consumer that needs the orientation in the
|
|
18
|
+
basic system can apply `R` itself. The columns are absent by default.
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- `BSPLINE` flattening accepts `PL=0` as a knot distance of zero, a repeated
|
|
23
|
+
knot (#129). Before, any `PL=0` on a control-point block made the whole
|
|
24
|
+
spline fall back to uniform knots with a warning, unless that block happened
|
|
25
|
+
to repeat the previous position and was dropped, so the same `PL` values gave
|
|
26
|
+
different knots depending on where the spline started. A `PL=0` on a block
|
|
27
|
+
whose `PL` is not used (the first and last block of a cubic) no longer has an
|
|
28
|
+
effect. Two cases still warn and use uniform knots, because they would split
|
|
29
|
+
the curve and are not measured on a control: `PL=0` as often in succession as
|
|
30
|
+
the spline degree, and `PL=0` on the first or last knot span. A negative `PL`
|
|
31
|
+
warns as before.
|
|
32
|
+
|
|
7
33
|
## [v0.4.0] - 2026-11-23
|
|
8
34
|
|
|
9
35
|
### Changed
|
|
@@ -26,7 +26,7 @@ The **NC-GCode-Interpreter** offers a streamlined and efficient solution for int
|
|
|
26
26
|
|
|
27
27
|
- **Streaming interpretation**: `nc_to_rows(program)` yields `(line_no, row)` tuples lazily while the interpreter runs on a background thread — bounded output buffering, early exit by dropping the iterator (breaking out of a `for` loop over an anonymous iterator does this; a stored iterator keeps the run alive until it is deleted or garbage-collected), and source-line numbers for mapping trace rows back to the program. With `include_variables=True` it yields `(line_no, row, variables)` instead, exposing every variable assignment (`R1=R1+1`, `DEF`, FOR counters) as it happens — including blocks that only assign variables, which are invisible in the batch DataFrame.
|
|
28
28
|
|
|
29
|
-
- **Curve flattening**: pass `flatten_tolerance` (Python) or `--flatten-tolerance` (CLI) to convert curved motions — `G2`/`G3` arcs (`I`/`J`/`K` centre offsets or `CR=` radius form, `G17`/`G18`/`G19` planes, helical third axis with `TURN=` multi-turn support, full circles) and `ASPLINE`/`BSPLINE`/`CSPLINE` splines (including `PW` weights and `SD` degree) — into runs of plain `G1` rows in the same table format. `CIP`/`CT`/`POLY`/thread/involute blocks pass through unchanged with a warning; spline start/end conditions (`BAUTO`/`BNAT`/... ) are approximated by natural (CSPLINE) / Akima (ASPLINE) boundaries — see the `flatten` module docs for the full list of checked approximations. A `BSPLINE` whose control-point blocks all carry a `PL` is built on those knot distances (cubic and quadratic, mapping measured on a SINUMERIK ONE). Without `PL` it is built on uniform knots, which is an approximation: the control's knots in that case are not uniform and the rule is not identified. A `PL` on only some of the blocks is ignored with a warning. The single tolerance is the maximum deviation between the emitted polyline and the true curve, in path units: arcs use the exact sagitta bound, splines adaptive subdivision. The interpolation addresses (`I`/`J`/`K`/`CR`/`PW`/`SD`/`PL`) are consumed and do not appear in the output; sampled rows keep the source block's line number, and its other cells (`F`, `M`, comments, ...) ride on the first sample so modal behavior is preserved. Generated samples carry a `flattened = 1` marker column (never forward-filled); programmed positions stay null there, so filtering on null recovers the original toolpath points.
|
|
29
|
+
- **Curve flattening**: pass `flatten_tolerance` (Python) or `--flatten-tolerance` (CLI) to convert curved motions — `G2`/`G3` arcs (`I`/`J`/`K` centre offsets or `CR=` radius form, `G17`/`G18`/`G19` planes, helical third axis with `TURN=` multi-turn support, full circles) and `ASPLINE`/`BSPLINE`/`CSPLINE` splines (including `PW` weights and `SD` degree) — into runs of plain `G1` rows in the same table format. `CIP`/`CT`/`POLY`/thread/involute blocks pass through unchanged with a warning; spline start/end conditions (`BAUTO`/`BNAT`/... ) are approximated by natural (CSPLINE) / Akima (ASPLINE) boundaries — see the `flatten` module docs for the full list of checked approximations. A `BSPLINE` whose control-point blocks all carry a `PL` is built on those knot distances (cubic and quadratic, mapping measured on a SINUMERIK ONE). Without `PL` it is built on uniform knots, which is an approximation: the control's knots in that case are not uniform and the rule is not identified. A `PL` on only some of the blocks is ignored with a warning. `PL=0` repeats a knot; as often in succession as the spline degree, or on the first or last knot span, it is ignored with a warning. The single tolerance is the maximum deviation between the emitted polyline and the true curve, in path units: arcs use the exact sagitta bound, splines adaptive subdivision. The interpolation addresses (`I`/`J`/`K`/`CR`/`PW`/`SD`/`PL`) are consumed and do not appear in the output; sampled rows keep the source block's line number, and its other cells (`F`, `M`, comments, ...) ride on the first sample so modal behavior is preserved. Generated samples carry a `flattened = 1` marker column (never forward-filled); programmed positions stay null there, so filtering on null recovers the original toolpath points.
|
|
30
30
|
- **Toolpath visualization** (optional): with the `viz` extra (`pip install 'nc-gcode-interpreter[viz]'`), `nc_gcode_interpreter.viz.view_toolpath(df)` renders an interpreted toolpath in [threejs-viewer](https://pypi.org/project/threejs-viewer/) as an extruded bead tube with a draw-range animation replaying the program at feed-rate-proportional speed. Combined with `flatten_tolerance`, programmed points render orange and flattener-generated samples blue. The extra also installs the `nc-view` command: `nc-view part.mpf` interprets, flattens (default tolerance 0.1, `--no-flatten` to skip) and opens the animated toolpath in the browser; `--speed` sets the time-lapse factor (default 60 = one machine-minute per second).
|
|
31
31
|
- **Custom Axes**: Allows users to define additional axes beyond the standard `X`, `Y`, `Z`.
|
|
32
32
|
- **Definitions, variables and start state**: `definitions` takes the definition files a control loads (GUD/MGUD/UGUD `.DEF`: DEF and REDEF statements, assignments, comments; M17/M30/M2 ends a file), `variables` takes variable values checked against their declared type, and `start` takes the machine state at program start in the shape of the returned `state` dict (axes, frame, variables, modal G groups, feed, tool, transformation, FGROUP and FGREF radii). The G groups, feed, tool, transformation, FGROUP and FGREF fill the first output row; seeded G groups have the same `pl.Enum` dtype as the rest of the column. They are applied in that order, before the main program. In a definition file `CHANDATA(1)` is ignored, another channel is an error, `TRAFOOF` sets the start transformation to off (a later `start["transformation"]` wins), M0 and M1 are ignored, a subprogram call is an error, and assigning to an undeclared name is an error unless it is an R parameter or `allow_undefined_variables` is set.
|
{nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/nc_gcode_interpreter/__init__.py
RENAMED
|
@@ -107,6 +107,11 @@ def _definition_texts(
|
|
|
107
107
|
return texts
|
|
108
108
|
|
|
109
109
|
|
|
110
|
+
_FRAME_COLUMNS = frozenset(
|
|
111
|
+
[f"frame_r{row}{column}" for row in (1, 2, 3) for column in (1, 2, 3)] + ["frame_tx", "frame_ty", "frame_tz"]
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
|
|
110
115
|
def _subprogram_texts(subprograms: "Mapping[str, str] | None") -> dict[str, str] | None:
|
|
111
116
|
return None if subprograms is None else dict(subprograms)
|
|
112
117
|
|
|
@@ -129,6 +134,7 @@ def nc_to_dataframe(
|
|
|
129
134
|
m_function_subprograms: "Mapping[int, str] | None" = None,
|
|
130
135
|
required_subprograms: "Iterable[str] | None" = None,
|
|
131
136
|
stop_on_setal: bool = False,
|
|
137
|
+
include_frame: bool = False,
|
|
132
138
|
) -> tuple[pl.DataFrame, dict]:
|
|
133
139
|
"""
|
|
134
140
|
Parses Sinumerik-flavored NC G-code and converts it into a Polars DataFrame along with the final state.
|
|
@@ -200,6 +206,16 @@ def nc_to_dataframe(
|
|
|
200
206
|
across a jump, matching the streaming `nc_to_rows`. Never
|
|
201
207
|
forward-filled; `dataframe_to_nc` ignores it. Default False (column
|
|
202
208
|
absent, output schema unchanged).
|
|
209
|
+
include_frame: bool, optional
|
|
210
|
+
If True, add the programmable frame (TRANS/ATRANS, ROT/AROT) that is
|
|
211
|
+
active on each row as twelve Float64 columns: `frame_r11` to
|
|
212
|
+
`frame_r33`, the rotation R row by row, and `frame_tx`, `frame_ty`,
|
|
213
|
+
`frame_tz`, the translation t, in machine XYZ = R * local XYZ + t.
|
|
214
|
+
The values are written on the first row and on the first row after
|
|
215
|
+
each change, and forward-filled like the axis columns; with
|
|
216
|
+
`disable_forward_fill` the other rows are null. Programmed A/B/C
|
|
217
|
+
values are not rotated by the interpreter, so a consumer can apply R
|
|
218
|
+
to them. Default False (columns absent).
|
|
203
219
|
|
|
204
220
|
Returns:
|
|
205
221
|
--------
|
|
@@ -258,6 +274,7 @@ def nc_to_dataframe(
|
|
|
258
274
|
stop_on_setal,
|
|
259
275
|
# No row is read before the run ends, so a provider call need not wait for one.
|
|
260
276
|
defer_rows=True,
|
|
277
|
+
include_frame=include_frame,
|
|
261
278
|
)
|
|
262
279
|
# pl.DataFrame wraps each Arrow record batch via __arrow_c_array__ (polars
|
|
263
280
|
# >= 1.3), no pyarrow needed. Exhaust the iterator before reading .state.
|
|
@@ -391,6 +408,8 @@ def sanitize_dataframe(
|
|
|
391
408
|
# dataframe_to_nc.
|
|
392
409
|
if "line_no" in df.columns:
|
|
393
410
|
df = df.drop("line_no")
|
|
411
|
+
# The `frame_*` columns (include_frame=True) report the frame; they are not NC words.
|
|
412
|
+
df = df.drop([name for name in df.columns if name in _FRAME_COLUMNS])
|
|
394
413
|
|
|
395
414
|
modal = [g["short_name"] for g in GGroups.g_groups if g["effectiveness"] == "modal"]
|
|
396
415
|
non_modal = [g["short_name"] for g in GGroups.g_groups if g["effectiveness"] != "modal"]
|
|
@@ -688,6 +707,7 @@ def nc_to_batches(
|
|
|
688
707
|
m_function_subprograms: "Mapping[int, str] | None" = None,
|
|
689
708
|
required_subprograms: "Iterable[str] | None" = None,
|
|
690
709
|
stop_on_setal: bool = False,
|
|
710
|
+
include_frame: bool = False,
|
|
691
711
|
) -> _BatchIterator:
|
|
692
712
|
"""Interpret an NC program into a stream of columnar polars DataFrames.
|
|
693
713
|
|
|
@@ -755,5 +775,6 @@ def nc_to_batches(
|
|
|
755
775
|
None if m_function_subprograms is None else dict(m_function_subprograms),
|
|
756
776
|
None if required_subprograms is None else list(required_subprograms),
|
|
757
777
|
stop_on_setal,
|
|
778
|
+
include_frame=include_frame,
|
|
758
779
|
)
|
|
759
780
|
return _BatchIterator(inner)
|
|
@@ -72,7 +72,8 @@ def de_boor(ctrl, knots, degree, t):
|
|
|
72
72
|
for r in range(1, degree + 1):
|
|
73
73
|
for j in range(degree, r - 1, -1):
|
|
74
74
|
i = j + k - degree
|
|
75
|
-
|
|
75
|
+
width = knots[i + degree + 1 - r] - knots[i]
|
|
76
|
+
alpha = 0.0 if width == 0 else (t - knots[i]) / width
|
|
76
77
|
d[j] = [(1 - alpha) * a + alpha * b for a, b in zip(d[j - 1], d[j], strict=True)]
|
|
77
78
|
x, y, w = d[degree]
|
|
78
79
|
return x / w, y / w
|
|
@@ -206,10 +207,50 @@ def test_pl_with_other_degree_warns_and_uses_uniform_knots(capfd, degree):
|
|
|
206
207
|
assert_frame_equal(with_pl, without)
|
|
207
208
|
|
|
208
209
|
|
|
209
|
-
def
|
|
210
|
+
def test_negative_pl_warns_and_uses_uniform_knots(capfd):
|
|
210
211
|
without = flatten(program(pl_of=lambda i, value: None))
|
|
211
|
-
|
|
212
|
-
assert "not a
|
|
212
|
+
with_negative = flatten(program(pl_of=lambda i, value: -1 if i == 4 else value))
|
|
213
|
+
assert "negative or not a number" in capfd.readouterr().err
|
|
214
|
+
assert_frame_equal(with_negative, without)
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
@pytest.mark.parametrize(("degree", "zero_blocks"), [(3, (4,)), (3, (4, 5)), (2, (4,))])
|
|
218
|
+
def test_zero_pl_repeats_a_knot(capfd, degree, zero_blocks):
|
|
219
|
+
"""PL=0 is a node distance of zero (#129)."""
|
|
220
|
+
text = program(degree=degree, pl_of=lambda i, value: 0 if i in zero_blocks else value)
|
|
221
|
+
points = curve_points(flatten(text))
|
|
222
|
+
assert capfd.readouterr().err == ""
|
|
223
|
+
used = BLOCKS[1:8] if degree == 3 else BLOCKS[0:8]
|
|
224
|
+
first = 2 if degree == 3 else 1
|
|
225
|
+
spans = [0 if i in zero_blocks else value for i, (_, _, value) in enumerate(used, start=first)]
|
|
226
|
+
assert Reference(CONTROL, spans, degree).max_distance(points) < 1e-6
|
|
227
|
+
assert points[-1] == CONTROL[-1]
|
|
228
|
+
# No sample is emitted twice for the empty span.
|
|
229
|
+
assert all(a != b for a, b in itertools.pairwise(points))
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def test_zero_pl_on_an_unused_cubic_block_is_accepted(capfd):
|
|
233
|
+
"""The same PL values give the same knots wherever the spline starts (#129)."""
|
|
234
|
+
zero_first = program(pl_of=lambda i, value: 0 if i in (1, 9) else value)
|
|
235
|
+
assert_frame_equal(flatten(zero_first), flatten(program()))
|
|
236
|
+
assert capfd.readouterr().err == ""
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
@pytest.mark.parametrize(
|
|
240
|
+
("degree", "zero_blocks", "reason"),
|
|
241
|
+
[
|
|
242
|
+
(3, (4, 5, 6), "as often in succession as the spline degree"),
|
|
243
|
+
(2, (4, 5), "as often in succession as the spline degree"),
|
|
244
|
+
(3, (2,), "first or last knot span"),
|
|
245
|
+
(3, (8,), "first or last knot span"),
|
|
246
|
+
(2, (1,), "first or last knot span"),
|
|
247
|
+
],
|
|
248
|
+
)
|
|
249
|
+
def test_zero_pl_that_would_split_the_curve_warns(capfd, degree, zero_blocks, reason):
|
|
250
|
+
without = flatten(program(degree=degree, pl_of=lambda i, value: None))
|
|
251
|
+
text = program(degree=degree, pl_of=lambda i, value: 0 if i in zero_blocks else value)
|
|
252
|
+
with_zero = flatten(text)
|
|
253
|
+
assert reason in capfd.readouterr().err
|
|
213
254
|
assert_frame_equal(with_zero, without)
|
|
214
255
|
|
|
215
256
|
|
|
@@ -291,3 +332,12 @@ def test_huge_pl_values_do_not_overflow():
|
|
|
291
332
|
small = flatten(program(degree=2))
|
|
292
333
|
huge = flatten(program(degree=2, pl_of=lambda i, value: f"{value}{'0' * 306}"))
|
|
293
334
|
assert flat(curve_points(huge)) == pytest.approx(flat(curve_points(small)), abs=1e-9)
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
def test_zero_pl_on_the_only_span_left_after_a_repeat_warns(capfd):
|
|
338
|
+
"""Dropping a repeated point must not skip the end-span check (review of #131)."""
|
|
339
|
+
body = "X10 Y10{}\nX10 Y10{}\nX20 Y0{}\nG1 X30\n"
|
|
340
|
+
head = "G1 X0 Y0 F100\nBSPLINE SD=2\n"
|
|
341
|
+
with_zero = flatten(head + body.format(" PL=0", " PL=1", " PL=2"), tolerance=0.1)
|
|
342
|
+
assert "first or last knot span" in capfd.readouterr().err
|
|
343
|
+
assert_frame_equal(with_zero, flatten(head + body.format("", "", ""), tolerance=0.1))
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"""The programmable frame per row, `include_frame` (#130)."""
|
|
2
|
+
|
|
3
|
+
import math
|
|
4
|
+
|
|
5
|
+
import polars as pl
|
|
6
|
+
import pytest
|
|
7
|
+
from nc_gcode_interpreter import dataframe_to_nc, nc_to_batches, nc_to_dataframe
|
|
8
|
+
|
|
9
|
+
ROTATION = [f"frame_r{row}{column}" for row in (1, 2, 3) for column in (1, 2, 3)]
|
|
10
|
+
TRANSLATION = ["frame_tx", "frame_ty", "frame_tz"]
|
|
11
|
+
IDENTITY = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@pytest.fixture(params=["0", "1"])
|
|
15
|
+
def stage1(request, monkeypatch):
|
|
16
|
+
monkeypatch.setenv("NC_STAGE1", request.param)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def frames(text, **options):
|
|
20
|
+
df, state = nc_to_dataframe(text, include_frame=True, **options)
|
|
21
|
+
return df, state
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def rotation(df, row):
|
|
25
|
+
return [df[name][row] for name in ROTATION]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def translation(df, row):
|
|
29
|
+
return [df[name][row] for name in TRANSLATION]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_columns_are_absent_by_default(stage1):
|
|
33
|
+
df, _ = nc_to_dataframe("AROT Z30\nG1 X1 Y0 Z0 F1000\n")
|
|
34
|
+
assert not [name for name in df.columns if name.startswith("frame_")]
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_issue_example_reports_the_evaluated_rotation(stage1):
|
|
38
|
+
text = "G18\nR1=10\nAROT RPL=R1*3\nG1 X1 Y0 Z0 F1000\n"
|
|
39
|
+
df, state = frames(text)
|
|
40
|
+
row = df.height - 1
|
|
41
|
+
assert rotation(df, row) == pytest.approx([v for line in state["rotation"] for v in line])
|
|
42
|
+
# Machine XYZ of the row is R * local XYZ.
|
|
43
|
+
r = rotation(df, row)
|
|
44
|
+
assert [df["X"][row], df["Y"][row], df["Z"][row]] == pytest.approx([r[0], r[3], r[6]])
|
|
45
|
+
assert r[0] == pytest.approx(math.cos(math.radians(30)))
|
|
46
|
+
assert r[4] == pytest.approx(1.0)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_every_row_carries_the_frame_active_on_it(stage1):
|
|
50
|
+
text = "G1 X1 Y0 Z0 F1000\nX2\nTRANS X10 Y20 Z30\nAROT Z90\nX1\nX2\nATRANS X1\nX3\nROT\nX4\nTRANS\nX5\n"
|
|
51
|
+
df, _ = frames(text)
|
|
52
|
+
quarter = [0.0, -1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0]
|
|
53
|
+
# ATRANS X1 is added in the rotated frame; ROT deletes the whole frame.
|
|
54
|
+
expected = [
|
|
55
|
+
(IDENTITY, [0, 0, 0]),
|
|
56
|
+
(IDENTITY, [0, 0, 0]),
|
|
57
|
+
(quarter, [10, 20, 30]),
|
|
58
|
+
(quarter, [10, 20, 30]),
|
|
59
|
+
(quarter, [10, 21, 30]),
|
|
60
|
+
(IDENTITY, [0, 0, 0]),
|
|
61
|
+
(IDENTITY, [0, 0, 0]),
|
|
62
|
+
]
|
|
63
|
+
assert df.height == len(expected)
|
|
64
|
+
for row, (r, t) in enumerate(expected):
|
|
65
|
+
assert rotation(df, row) == pytest.approx(r, abs=1e-12), row
|
|
66
|
+
assert translation(df, row) == pytest.approx(t, abs=1e-12), row
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def test_frame_from_a_loop_and_a_branch(stage1):
|
|
70
|
+
text = "G1 X1 Y0 Z0 F1000\nR1=0\nWHILE R1<3\nAROT Z10\nX1\nR1=R1+1\nENDWHILE\nIF R1==3\nROT Z90\nENDIF\nX1\n"
|
|
71
|
+
df, state = frames(text)
|
|
72
|
+
angles = [math.degrees(math.atan2(df["frame_r21"][row], df["frame_r11"][row])) for row in range(df.height)]
|
|
73
|
+
assert angles == pytest.approx([0, 10, 20, 30, 90])
|
|
74
|
+
assert rotation(df, df.height - 1) == pytest.approx([v for line in state["rotation"] for v in line])
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def test_only_changes_are_written_without_forward_fill(stage1):
|
|
78
|
+
df, _ = frames("G1 X1 Y0 Z0 F1000\nX2\nAROT Z90\nX3\nX4\n", disable_forward_fill=True)
|
|
79
|
+
assert df["frame_r11"].is_not_null().to_list() == [True, False, True, False]
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def test_flattened_arc_rows_carry_the_frame(stage1):
|
|
83
|
+
pytest.importorskip("numpy")
|
|
84
|
+
text = "G1 X0 Y0 Z0 F1000\nAROT Z90\nG2 X10 Y0 I5 J0\nG1 X20\n"
|
|
85
|
+
df, _ = frames(text, flatten_tolerance=0.01)
|
|
86
|
+
assert df.height > 4
|
|
87
|
+
assert df["frame_r21"].to_list() == pytest.approx([0.0] + [1.0] * (df.height - 1))
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def test_batches_fill_the_frame_across_batch_borders(stage1):
|
|
91
|
+
text = "G1 X0 Y0 Z0 F1000\nTRANS X5\n" + "".join(f"X{i}\n" for i in range(1, 10))
|
|
92
|
+
whole, _ = frames(text)
|
|
93
|
+
batches = pl.concat(list(nc_to_batches(text, batch_size=3, include_frame=True)))
|
|
94
|
+
assert batches.select(ROTATION + TRANSLATION).equals(whole.select(ROTATION + TRANSLATION))
|
|
95
|
+
assert batches["frame_tx"].to_list() == [0.0] + [5.0] * 9
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def test_a_frame_block_that_gives_a_row_carries_its_own_frame(stage1):
|
|
99
|
+
df, _ = frames("G0 X0\nTRANS X10 ; offset\nN30 ATRANS X5\nG0 X0\n")
|
|
100
|
+
assert df["frame_tx"].to_list() == [0.0, 10.0, 15.0, 15.0]
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def test_comment_only_program_has_the_columns(stage1):
|
|
104
|
+
df, _ = frames("; only a comment\n")
|
|
105
|
+
assert df.select(ROTATION + TRANSLATION).row(0) == (*IDENTITY, 0.0, 0.0, 0.0)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def test_export_ignores_the_frame_columns(stage1, tmp_path):
|
|
109
|
+
text = "G0 X0\nTRANS X10\nG0 X1\n"
|
|
110
|
+
plain, _ = nc_to_dataframe(text)
|
|
111
|
+
with_frame, _ = frames(text)
|
|
112
|
+
dataframe_to_nc(plain, tmp_path / "plain.mpf")
|
|
113
|
+
dataframe_to_nc(with_frame, tmp_path / "frame.mpf")
|
|
114
|
+
assert (tmp_path / "frame.mpf").read_text() == (tmp_path / "plain.mpf").read_text()
|
|
115
|
+
assert "frame_" not in (tmp_path / "frame.mpf").read_text()
|
|
@@ -787,9 +787,8 @@ fn bspline_knot_plan(
|
|
|
787
787
|
return fallback("not every control-point block carries a PL");
|
|
788
788
|
}
|
|
789
789
|
let pls: Vec<f64> = pls.into_iter().flatten().collect();
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
return fallback("a PL is not a positive number");
|
|
790
|
+
if pls.iter().any(|&pl| !(pl >= 0.0 && pl.is_finite())) {
|
|
791
|
+
return fallback("a PL is negative or not a number");
|
|
793
792
|
}
|
|
794
793
|
// Judged on the programmed degree: dropping repeats can lower the effective one.
|
|
795
794
|
if degree != 2 && degree != 3 {
|
|
@@ -798,15 +797,35 @@ fn bspline_knot_plan(
|
|
|
798
797
|
let n = kept.len();
|
|
799
798
|
let p = degree.min(n - 1).max(1);
|
|
800
799
|
let spans = n - p;
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
800
|
+
// A single knot span has no interior knots: PL cannot change the curve.
|
|
801
|
+
let single = KnotPlan {
|
|
802
|
+
kept: kept.clone(),
|
|
803
|
+
intervals: vec![1.0],
|
|
804
|
+
};
|
|
805
|
+
if p < 2 {
|
|
806
|
+
return Some(single);
|
|
807
807
|
}
|
|
808
808
|
// `pls[i]` is the PL of control point i + 1.
|
|
809
809
|
let intervals = pls[p - 2..p - 2 + spans].to_vec();
|
|
810
|
+
// PL=0 repeats a knot; fewer than `p` in succession keep the curve in one piece.
|
|
811
|
+
let mut zeros = 0;
|
|
812
|
+
for (index, &interval) in intervals.iter().enumerate() {
|
|
813
|
+
if interval > 0.0 {
|
|
814
|
+
zeros = 0;
|
|
815
|
+
continue;
|
|
816
|
+
}
|
|
817
|
+
zeros += 1;
|
|
818
|
+
if index == 0 || index == spans - 1 {
|
|
819
|
+
return fallback("PL=0 on the first or last knot span is not supported");
|
|
820
|
+
}
|
|
821
|
+
if zeros >= p {
|
|
822
|
+
// The control allows exactly `p` (alarm 10891 above that), which splits the curve.
|
|
823
|
+
return fallback("PL=0 as often in succession as the spline degree is not supported");
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
if spans == 1 {
|
|
827
|
+
return Some(single);
|
|
828
|
+
}
|
|
810
829
|
Some(KnotPlan { kept, intervals })
|
|
811
830
|
}
|
|
812
831
|
|
|
@@ -1234,6 +1253,10 @@ impl BSpline {
|
|
|
1234
1253
|
let mut prev_p = self.eval(0.0);
|
|
1235
1254
|
for j in 0..self.spans {
|
|
1236
1255
|
let t1 = self.knots[self.p + j + 1];
|
|
1256
|
+
if t1 <= prev_t {
|
|
1257
|
+
// A repeated knot (PL=0) gives an empty span.
|
|
1258
|
+
continue;
|
|
1259
|
+
}
|
|
1237
1260
|
let p1 = self.eval(t1);
|
|
1238
1261
|
adaptive_flatten(&eval, prev_t, &prev_p, t1, &p1, tol, metric, 0, &mut |t, p| {
|
|
1239
1262
|
out.push((t, p.to_vec()))
|
|
@@ -4138,6 +4138,10 @@ pub(crate) fn interpret_block(
|
|
|
4138
4138
|
}
|
|
4139
4139
|
// Only a statement row can carry arc words; a control block's
|
|
4140
4140
|
// rows belong to its body blocks, which ran this hook themselves.
|
|
4141
|
+
// A frame block is no statement, and its comment or block number can still give a row.
|
|
4142
|
+
if let Some(frame) = state.take_frame_change() {
|
|
4143
|
+
output.seed_frame(frame);
|
|
4144
|
+
}
|
|
4141
4145
|
if had_statements {
|
|
4142
4146
|
output.seed_assumed_starts(&mut state.assumed_starts);
|
|
4143
4147
|
let last = output.last_mut().expect("Output vector should not be empty");
|
|
@@ -492,6 +492,7 @@ mod python_bindings {
|
|
|
492
492
|
required_subprograms: Vec<String>,
|
|
493
493
|
stop_on_setal: bool,
|
|
494
494
|
defer_rows: bool,
|
|
495
|
+
include_frame: bool,
|
|
495
496
|
) -> PyResult<(
|
|
496
497
|
mpsc::Receiver<WorkerMessage>,
|
|
497
498
|
mpsc::Receiver<Result<FinalState, ErrInfo>>,
|
|
@@ -515,6 +516,7 @@ mod python_bindings {
|
|
|
515
516
|
required_subprograms,
|
|
516
517
|
stop_on_setal,
|
|
517
518
|
defer_rows,
|
|
519
|
+
include_frame,
|
|
518
520
|
};
|
|
519
521
|
if let Some(name) = extensions.duplicate_subprogram() {
|
|
520
522
|
return Err(PyErr::new::<PyValueError, _>(format!(
|
|
@@ -1130,7 +1132,7 @@ mod python_bindings {
|
|
|
1130
1132
|
/// thread. Wrapping each with `pl.DataFrame` and concatenating reconstructs
|
|
1131
1133
|
/// `nc_to_dataframe`.
|
|
1132
1134
|
#[pyfunction]
|
|
1133
|
-
#[pyo3(signature = (input, batch_size = 500_000, definitions = None, variables = None, start = None, axis_identifiers = None, extra_axes = None, iteration_limit = 10000, disable_forward_fill = false, axis_index_map = None, allow_undefined_variables = false, input_is_path = false, flatten_tolerance = None, include_line_numbers = false, include_variables = false, subprograms = None, external_variables = None, m_function_subprograms = None, required_subprograms = None, stop_on_setal = false, defer_rows = false))]
|
|
1135
|
+
#[pyo3(signature = (input, batch_size = 500_000, definitions = None, variables = None, start = None, axis_identifiers = None, extra_axes = None, iteration_limit = 10000, disable_forward_fill = false, axis_index_map = None, allow_undefined_variables = false, input_is_path = false, flatten_tolerance = None, include_line_numbers = false, include_variables = false, subprograms = None, external_variables = None, m_function_subprograms = None, required_subprograms = None, stop_on_setal = false, defer_rows = false, include_frame = false))]
|
|
1134
1136
|
#[allow(clippy::too_many_arguments)]
|
|
1135
1137
|
fn nc_to_batches(
|
|
1136
1138
|
input: PyBackedStr,
|
|
@@ -1154,6 +1156,7 @@ mod python_bindings {
|
|
|
1154
1156
|
required_subprograms: Option<Vec<String>>,
|
|
1155
1157
|
stop_on_setal: bool,
|
|
1156
1158
|
defer_rows: bool,
|
|
1159
|
+
include_frame: bool,
|
|
1157
1160
|
py: Python<'_>,
|
|
1158
1161
|
) -> PyResult<NcBatchIterator> {
|
|
1159
1162
|
// The provider declares the variable names it serves.
|
|
@@ -1186,6 +1189,7 @@ mod python_bindings {
|
|
|
1186
1189
|
required_subprograms.unwrap_or_default(),
|
|
1187
1190
|
stop_on_setal,
|
|
1188
1191
|
defer_rows,
|
|
1192
|
+
include_frame,
|
|
1189
1193
|
)?;
|
|
1190
1194
|
|
|
1191
1195
|
Ok(NcBatchIterator {
|
|
@@ -807,6 +807,9 @@ fn execute_decoded(
|
|
|
807
807
|
// Same end-of-block frame hook as interpret_block (arc words under a rotation).
|
|
808
808
|
state.finish_block_frame(last, line.line_no)?;
|
|
809
809
|
output.seed_assumed_starts(&mut state.assumed_starts);
|
|
810
|
+
if let Some(frame) = state.take_frame_change() {
|
|
811
|
+
output.seed_frame(frame);
|
|
812
|
+
}
|
|
810
813
|
let last = output.last_mut().expect("row was just pushed");
|
|
811
814
|
if let Some(n) = line.n {
|
|
812
815
|
last.insert("N", Value::Str(n.to_string()));
|
|
@@ -764,6 +764,18 @@ impl OutputRows {
|
|
|
764
764
|
|
|
765
765
|
/// Hand the axis starts the interpreter assumed in this block to the
|
|
766
766
|
/// flattener, before the block's row reaches it.
|
|
767
|
+
/// Put a changed programmable frame on the next row that has a cell: a
|
|
768
|
+
/// frame block emits no row of its own.
|
|
769
|
+
pub fn seed_frame(&mut self, frame: [f64; 12]) {
|
|
770
|
+
self.seed.retain(|(key, _)| !FRAME_COLUMNS.contains(key));
|
|
771
|
+
self.seed.extend(
|
|
772
|
+
FRAME_COLUMNS
|
|
773
|
+
.iter()
|
|
774
|
+
.zip(frame)
|
|
775
|
+
.map(|(&key, value)| (key, Value::Float(value))),
|
|
776
|
+
);
|
|
777
|
+
}
|
|
778
|
+
|
|
767
779
|
pub fn seed_assumed_starts(&mut self, starts: &mut Vec<(String, f64)>) {
|
|
768
780
|
for (axis, machine_value) in starts.drain(..) {
|
|
769
781
|
if let Some(flattener) = self.flattener.as_mut() {
|
|
@@ -1424,6 +1436,23 @@ pub(crate) fn is_preset_call(text: &str) -> bool {
|
|
|
1424
1436
|
/// block addresses: never forward-filled.
|
|
1425
1437
|
pub const FLATTENED_COLUMN: &str = "flattened";
|
|
1426
1438
|
|
|
1439
|
+
/// The programmable frame per row (`include_frame`): the rotation `R`
|
|
1440
|
+
/// row-major and the translation `t` in machine XYZ = R * local XYZ + t.
|
|
1441
|
+
pub const FRAME_COLUMNS: [&str; 12] = [
|
|
1442
|
+
"frame_r11",
|
|
1443
|
+
"frame_r12",
|
|
1444
|
+
"frame_r13",
|
|
1445
|
+
"frame_r21",
|
|
1446
|
+
"frame_r22",
|
|
1447
|
+
"frame_r23",
|
|
1448
|
+
"frame_r31",
|
|
1449
|
+
"frame_r32",
|
|
1450
|
+
"frame_r33",
|
|
1451
|
+
"frame_tx",
|
|
1452
|
+
"frame_ty",
|
|
1453
|
+
"frame_tz",
|
|
1454
|
+
];
|
|
1455
|
+
|
|
1427
1456
|
/// Leading column carrying each output row's 1-based source line number (the
|
|
1428
1457
|
/// `Row::line_no` the streaming path yields). One value per row, never
|
|
1429
1458
|
/// forward-filled and never null; loops and jumps produce repeated /
|
|
@@ -141,6 +141,8 @@ pub struct State {
|
|
|
141
141
|
warned_addresses: HashSet<String>,
|
|
142
142
|
/// Axis starts assumed by IC() before any position (axis, machine value), handed to the flattener at block end.
|
|
143
143
|
pub assumed_starts: Vec<(String, f64)>,
|
|
144
|
+
/// The frame the `frame_*` columns last reported.
|
|
145
|
+
emitted_frame: Option<[f64; 12]>,
|
|
144
146
|
/// Interned output keys of the geometry axes X, Y, Z (`None` when the axis
|
|
145
147
|
/// is not configured) and of the arc centre offsets I, J, K.
|
|
146
148
|
geometry_keys: [Option<&'static str>; 3],
|
|
@@ -274,6 +276,7 @@ impl State {
|
|
|
274
276
|
seen_jump_targets: HashSet::new(),
|
|
275
277
|
warned_addresses: HashSet::new(),
|
|
276
278
|
assumed_starts: Vec::new(),
|
|
279
|
+
emitted_frame: None,
|
|
277
280
|
geometry_keys,
|
|
278
281
|
arc_offset_keys,
|
|
279
282
|
warned_unpositioned: [false; 3],
|
|
@@ -407,6 +410,24 @@ impl State {
|
|
|
407
410
|
}
|
|
408
411
|
|
|
409
412
|
/// Gets the translation value for an axis
|
|
413
|
+
/// The programmable frame as `[R row-major, t]` when the `frame_*` columns
|
|
414
|
+
/// are requested and it differs from what the last row carried.
|
|
415
|
+
pub fn take_frame_change(&mut self) -> Option<[f64; 12]> {
|
|
416
|
+
if !self.ext.include_frame {
|
|
417
|
+
return None;
|
|
418
|
+
}
|
|
419
|
+
let mut frame = [0.0; 12];
|
|
420
|
+
for row in 0..3 {
|
|
421
|
+
frame[row * 3..row * 3 + 3].copy_from_slice(&self.rotation[row]);
|
|
422
|
+
frame[9 + row] = self.geometry_keys[row].map_or(0.0, |key| self.get_translation(key));
|
|
423
|
+
}
|
|
424
|
+
if self.emitted_frame == Some(frame) {
|
|
425
|
+
return None;
|
|
426
|
+
}
|
|
427
|
+
self.emitted_frame = Some(frame);
|
|
428
|
+
Some(frame)
|
|
429
|
+
}
|
|
430
|
+
|
|
410
431
|
pub fn get_translation(&self, axis: &str) -> f64 {
|
|
411
432
|
*self.translation.get(axis).unwrap_or(&0.0)
|
|
412
433
|
}
|
|
@@ -91,6 +91,8 @@ pub struct Extensions {
|
|
|
91
91
|
/// Keep finished rows batched across provider calls instead of sending
|
|
92
92
|
/// them first; for a consumer that reads no row before the run ends.
|
|
93
93
|
pub defer_rows: bool,
|
|
94
|
+
/// Put the programmable frame on the rows (`frame_*` columns).
|
|
95
|
+
pub include_frame: bool,
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
/// A subprogram text with its line-start table, shared across calls.
|
|
@@ -169,6 +171,7 @@ pub(crate) struct ExtState {
|
|
|
169
171
|
pub m_functions: Arc<HashMap<u32, String>>,
|
|
170
172
|
pub required: Arc<HashSet<String>>,
|
|
171
173
|
pub stop_on_setal: bool,
|
|
174
|
+
pub include_frame: bool,
|
|
172
175
|
external_names: Arc<HashSet<String>>,
|
|
173
176
|
provider: Option<SharedProvider>,
|
|
174
177
|
/// The batch sink to flush before a provider call, when rows are streamed.
|
|
@@ -237,6 +240,7 @@ impl ExtState {
|
|
|
237
240
|
.collect(),
|
|
238
241
|
),
|
|
239
242
|
stop_on_setal: extensions.stop_on_setal,
|
|
243
|
+
include_frame: extensions.include_frame,
|
|
240
244
|
m_functions: Arc::new(m_functions),
|
|
241
245
|
subprograms: Arc::new(subprograms),
|
|
242
246
|
external_names: Arc::new(names),
|
|
@@ -353,6 +353,10 @@ fn exec_block<'i>(block: Pair<'i, Rule>, output: &mut Output, state: &mut State)
|
|
|
353
353
|
state.finish_block_frame(last, line_no)?;
|
|
354
354
|
output.seed_assumed_starts(&mut state.assumed_starts);
|
|
355
355
|
}
|
|
356
|
+
// A frame block is no statement, and its comment or block number can still give a row.
|
|
357
|
+
if let Some(frame) = state.take_frame_change() {
|
|
358
|
+
output.seed_frame(frame);
|
|
359
|
+
}
|
|
356
360
|
Ok(match flow {
|
|
357
361
|
BlockFlow::Continue => Step::Continue,
|
|
358
362
|
BlockFlow::EndProgram => Step::EndProgram,
|
|
File without changes
|
{nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/.github/workflows/build-and-release.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/docs/resumable-interpretation-design.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/axis_index_assignment.csv
RENAMED
|
File without changes
|
{nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/axis_index_assignment.mpf
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/case_insensitive_variables.csv
RENAMED
|
File without changes
|
{nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/case_insensitive_variables.mpf
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/flattening/flatten_demo.mpf
RENAMED
|
File without changes
|
|
File without changes
|
{nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/examples/flattening/flatten_demo_raw.csv
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/nc_gcode_interpreter/cli.py
RENAMED
|
File without changes
|
{nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/nc_gcode_interpreter/ggroups.json
RENAMED
|
File without changes
|
{nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/nc_gcode_interpreter/py.typed
RENAMED
|
File without changes
|
{nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/nc_gcode_interpreter/viz.py
RENAMED
|
File without changes
|
|
File without changes
|
{nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_arithmetic_functions.py
RENAMED
|
File without changes
|
{nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_batch_variables.py
RENAMED
|
File without changes
|
|
File without changes
|
{nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_build_backend.py
RENAMED
|
File without changes
|
{nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_compare_benchmarks.py
RENAMED
|
File without changes
|
|
File without changes
|
{nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_expected_output.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_field_defects.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_real_comparisons.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_string_operations.py
RENAMED
|
File without changes
|
{nc_gcode_interpreter-0.4.0 → nc_gcode_interpreter-0.4.1}/python/tests/test_structured_errors.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|