nc-gcode-interpreter 0.1.8__tar.gz → 0.1.10__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.
Files changed (70) hide show
  1. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/.github/workflows/build-and-release.yml +79 -63
  2. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/Cargo.lock +4 -4
  3. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/Cargo.toml +1 -1
  4. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/PKG-INFO +48 -33
  5. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/README.md +40 -25
  6. nc_gcode_interpreter-0.1.10/examples/function_calls.csv +3 -0
  7. nc_gcode_interpreter-0.1.10/examples/if_statement.mpf +13 -0
  8. nc_gcode_interpreter-0.1.10/examples/loop.csv +321 -0
  9. nc_gcode_interpreter-0.1.10/examples/multiple_m_codes.csv +10 -0
  10. nc_gcode_interpreter-0.1.10/examples/simple.csv +6 -0
  11. nc_gcode_interpreter-0.1.10/examples/tool.csv +2 -0
  12. nc_gcode_interpreter-0.1.10/ggroups/generate_modal_ggroups.py +29 -0
  13. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/pyproject.toml +3 -3
  14. nc_gcode_interpreter-0.1.10/python/nc_gcode_interpreter/__init__.py +259 -0
  15. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/python/nc_gcode_interpreter/_internal.pyi +22 -1
  16. nc_gcode_interpreter-0.1.10/python/tests/test_expected_output.py +68 -0
  17. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/src/interpret_rules.rs +2 -1
  18. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/src/interpreter.rs +104 -51
  19. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/src/lib.rs +16 -0
  20. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/src/main.rs +1 -1
  21. {nc_gcode_interpreter-0.1.8/ggroups → nc_gcode_interpreter-0.1.10/src}/modal_groups.rs +9 -1
  22. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/uv.lock +106 -30
  23. nc_gcode_interpreter-0.1.8/examples/function_calls.csv +0 -3
  24. nc_gcode_interpreter-0.1.8/examples/if_statement.mpf +0 -13
  25. nc_gcode_interpreter-0.1.8/examples/loop.csv +0 -321
  26. nc_gcode_interpreter-0.1.8/examples/multiple_m_codes.csv +0 -10
  27. nc_gcode_interpreter-0.1.8/examples/simple.csv +0 -6
  28. nc_gcode_interpreter-0.1.8/examples/tool.csv +0 -2
  29. nc_gcode_interpreter-0.1.8/ggroups/generate_modal_ggroups.py +0 -21
  30. nc_gcode_interpreter-0.1.8/python/nc_gcode_interpreter/__init__.py +0 -127
  31. nc_gcode_interpreter-0.1.8/python/tests/test_expected_output.py +0 -40
  32. nc_gcode_interpreter-0.1.8/src/modal_groups.rs +0 -57
  33. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/.gitignore +0 -0
  34. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/CONTRIBUTING.md +0 -0
  35. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/Development.md +0 -0
  36. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/LICENSE +0 -0
  37. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/TODO.md +0 -0
  38. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/examples/arrays.csv +0 -0
  39. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/examples/arrays.mpf +0 -0
  40. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/examples/basic_math.csv +0 -0
  41. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/examples/basic_math.mpf +0 -0
  42. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/examples/custom_vars.csv +0 -0
  43. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/examples/custom_vars.mpf +0 -0
  44. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/examples/defaults.csv +0 -0
  45. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/examples/defaults.mpf +0 -0
  46. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/examples/for_loop.csv +0 -0
  47. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/examples/for_loop.mpf +0 -0
  48. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/examples/function_calls.mpf +0 -0
  49. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/examples/if_statement.csv +0 -0
  50. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/examples/increment.csv +0 -0
  51. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/examples/increment.mpf +0 -0
  52. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/examples/loop.mpf +0 -0
  53. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/examples/multiple_m_codes.mpf +0 -0
  54. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/examples/simple.mpf +0 -0
  55. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/examples/tool.mpf +0 -0
  56. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/examples/trans.csv +0 -0
  57. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/examples/trans.mpf +0 -0
  58. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/examples/variables.csv +0 -0
  59. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/examples/variables.mpf +0 -0
  60. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/ggroups/generate_pest.py +0 -0
  61. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/ggroups/ggroups.pest +0 -0
  62. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/python/example/minimal.py +0 -0
  63. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/python/nc_gcode_interpreter/ggroups.json +0 -0
  64. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/python/nc_gcode_interpreter/py.typed +0 -0
  65. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/python/tests/test_g_groups.py +0 -0
  66. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/rustfmt.toml +0 -0
  67. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/src/errors.rs +0 -0
  68. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/src/grammar.pest +0 -0
  69. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/src/state.rs +0 -0
  70. {nc_gcode_interpreter-0.1.8 → nc_gcode_interpreter-0.1.10}/src/types.rs +0 -0
@@ -7,7 +7,7 @@
7
7
  # - build using binary bindings
8
8
  # - extract the binaries from the wheel
9
9
  # - upload both the wheel and the binary to the release
10
- # - disable some platforms
10
+ # - disable some platforms
11
11
 
12
12
  name: Build and Release
13
13
 
@@ -33,7 +33,7 @@ jobs:
33
33
  - uses: actions/checkout@v4
34
34
  - uses: actions/setup-python@v5
35
35
  with:
36
- python-version: 3.12
36
+ python-version: 3.13
37
37
  - name: Install Python linter
38
38
  run: pip install ruff
39
39
  - name: Lint Python code with ruff
@@ -47,11 +47,12 @@ jobs:
47
47
  platform:
48
48
  - runner: ubuntu-latest
49
49
  target: x86_64
50
+ python-version: ["3.12", "3.13"]
50
51
  steps:
51
52
  - uses: actions/checkout@v4
52
53
  - uses: actions/setup-python@v5
53
54
  with:
54
- python-version: 3.12
55
+ python-version: ${{ matrix.python-version }}
55
56
  - name: Update Cargo.toml Version
56
57
  if: startsWith(github.ref, 'refs/tags/')
57
58
  run: |
@@ -68,25 +69,40 @@ jobs:
68
69
  - name: Upload wheels
69
70
  uses: actions/upload-artifact@v4
70
71
  with:
71
- name: wheels-linux-${{ matrix.platform.target }}
72
+ name: wheels-linux-${{ matrix.platform.target }}-py${{ matrix.python-version }}
72
73
  path: dist
73
74
 
74
75
  test:
75
76
  needs: [linux-x64]
76
77
  runs-on: ubuntu-latest
78
+ strategy:
79
+ matrix:
80
+ python-version: ["3.12", "3.13"]
77
81
  steps:
78
82
  - uses: actions/checkout@v4
79
83
  - uses: actions/download-artifact@v4
80
84
  with:
81
- name: wheels-linux-x86_64
85
+ name: wheels-linux-x86_64-py${{ matrix.python-version }}
82
86
  path: dist
83
87
  - uses: actions/setup-python@v5
84
88
  with:
85
- python-version: 3.12
89
+ python-version: ${{ matrix.python-version }}
86
90
  - name: Install py_opw_kinematics
91
+ shell: bash
87
92
  run: |
88
- WHL_FILE=$(ls dist/*cp312*.whl)
89
- pip install "${WHL_FILE}[test]"
93
+ set -e # Exit on error
94
+ PY_VERSION="${{ matrix.python-version }}"
95
+ PY_VERSION_NO_DOT="${PY_VERSION//./}"
96
+ WHL_FILES=(dist/*cp${PY_VERSION_NO_DOT}*.whl)
97
+ if [ ${#WHL_FILES[@]} -eq 0 ]; then
98
+ echo "No matching wheel files found!"
99
+ exit 1
100
+ fi
101
+ if [ ${#WHL_FILES[@]} -gt 1 ]; then
102
+ echo "Multiple wheel files found: ${WHL_FILES[*]}"
103
+ exit 1
104
+ fi
105
+ pip install "${WHL_FILES[0]}[test]"
90
106
  - name: Run tests with pytest
91
107
  run: pytest
92
108
  - name: Type checking with mypy
@@ -102,23 +118,23 @@ jobs:
102
118
  # target: x86
103
119
  - runner: ubuntu-latest
104
120
  target: aarch64
105
- # - runner: ubuntu-latest
106
- # target: armv7
107
- # - runner: ubuntu-latest
108
- # target: s390x
109
- # - runner: ubuntu-latest
110
- # target: ppc64le
121
+ python-version: ["3.12", "3.13"]
111
122
  steps:
112
123
  - uses: actions/checkout@v4
113
124
  - uses: actions/setup-python@v5
114
125
  with:
115
- python-version: 3.12
126
+ python-version: ${{ matrix.python-version }}
116
127
  - name: Update Cargo.toml Version
117
128
  if: startsWith(github.ref, 'refs/tags/')
129
+ shell: bash
118
130
  run: |
131
+ set -e # Exit on error
119
132
  VERSION=${GITHUB_REF#refs/tags/v}
120
133
  echo "Setting version to $VERSION"
121
- sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml
134
+ if ! sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml; then
135
+ echo "Failed to update version in Cargo.toml"
136
+ exit 1
137
+ fi
122
138
  - name: Build wheels
123
139
  uses: PyO3/maturin-action@v1
124
140
  with:
@@ -129,42 +145,9 @@ jobs:
129
145
  - name: Upload wheels
130
146
  uses: actions/upload-artifact@v4
131
147
  with:
132
- name: wheels-linux-${{ matrix.platform.target }}
148
+ name: wheels-linux-${{ matrix.platform.target }}-py${{ matrix.python-version }}
133
149
  path: dist
134
150
 
135
-
136
- # musllinux:
137
- # needs: [lint, test]
138
- # runs-on: ${{ matrix.platform.runner }}
139
- # strategy:
140
- # matrix:
141
- # platform:
142
- # - runner: ubuntu-latest
143
- # target: x86_64
144
- # # - runner: ubuntu-latest
145
- # # target: x86
146
- # # - runner: ubuntu-latest
147
- # # target: aarch64
148
- # # - runner: ubuntu-latest
149
- # # target: armv7
150
- # steps:
151
- # - uses: actions/checkout@v4
152
- # - uses: actions/setup-python@v5
153
- # with:
154
- # python-version: '>=3.12'
155
- # - name: Build wheels
156
- # uses: PyO3/maturin-action@v1
157
- # with:
158
- # target: ${{ matrix.platform.target }}
159
- # args: --release --out dist --find-interpreter
160
- # sccache: 'true'
161
- # manylinux: musllinux_1_2
162
- # - name: Upload wheels
163
- # uses: actions/upload-artifact@v4
164
- # with:
165
- # name: wheels-musllinux-${{ matrix.platform.target }}
166
- # path: dist
167
-
168
151
  windows:
169
152
  if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
170
153
  needs: [lint, test]
@@ -174,21 +157,42 @@ jobs:
174
157
  platform:
175
158
  - runner: windows-latest
176
159
  target: x64
177
- # - runner: windows-latest
178
- # target: x86
160
+ python-version: ["3.12", "3.13"]
179
161
  steps:
180
162
  - uses: actions/checkout@v4
181
163
  - uses: actions/setup-python@v5
182
164
  with:
183
- python-version: 3.12
165
+ python-version: ${{ matrix.python-version }}
184
166
  architecture: ${{ matrix.platform.target }}
185
167
  - name: Update Cargo.toml Version
186
168
  if: startsWith(github.ref, 'refs/tags/')
187
169
  shell: pwsh
188
170
  run: |
189
- $VERSION = $env:GITHUB_REF -replace 'refs/tags/v',''
190
- Write-Host "Setting version to $VERSION"
191
- (Get-Content Cargo.toml) -replace '^version = ".*"', ('version = "' + $VERSION + '"') | Set-Content Cargo.toml
171
+ $ErrorActionPreference = "Stop"
172
+ try {
173
+ $VERSION = $env:GITHUB_REF -replace 'refs/tags/v',''
174
+ Write-Host "Setting version to $VERSION"
175
+
176
+ # Read Cargo.toml as UTF-8
177
+ $path = Resolve-Path Cargo.toml
178
+ $content = [System.IO.File]::ReadAllText($path, [System.Text.Encoding]::UTF8)
179
+
180
+ # Update version using multiline regex to match "version ="
181
+ $newContent = $content -replace '(?m)^\s*version\s*=\s*".*"', "version = `"$VERSION`""
182
+
183
+ if ($newContent -eq $content) {
184
+ throw "Version pattern not found in Cargo.toml"
185
+ }
186
+
187
+ # Write back with UTF-8 encoding
188
+ [System.IO.File]::WriteAllText($path, $newContent, [System.Text.Encoding]::UTF8)
189
+ Write-Host "Cargo.toml version updated successfully."
190
+ }
191
+ catch {
192
+ Write-Error "Failed to update version in Cargo.toml: $_"
193
+ exit 1
194
+ }
195
+
192
196
  - name: Build wheels
193
197
  uses: PyO3/maturin-action@v1
194
198
  with:
@@ -198,7 +202,7 @@ jobs:
198
202
  - name: Upload wheels
199
203
  uses: actions/upload-artifact@v4
200
204
  with:
201
- name: wheels-windows-${{ matrix.platform.target }}
205
+ name: wheels-windows-${{ matrix.platform.target }}-py${{ matrix.python-version }}
202
206
  path: dist
203
207
 
204
208
  macos:
@@ -208,20 +212,27 @@ jobs:
208
212
  strategy:
209
213
  matrix:
210
214
  platform:
211
- - runner: macos-12
215
+ - runner: macos-latest
212
216
  target: x86_64
213
- - runner: macos-14
217
+ - runner: macos-latest
214
218
  target: aarch64
219
+ python-version: ["3.12", "3.13"]
215
220
  steps:
216
221
  - uses: actions/checkout@v4
217
222
  - uses: actions/setup-python@v5
218
223
  with:
219
- python-version: 3.12
224
+ python-version: ${{ matrix.python-version }}
220
225
  - name: Update Cargo.toml Version
226
+ if: startsWith(github.ref, 'refs/tags/')
227
+ shell: bash
221
228
  run: |
229
+ set -e # Exit on error
222
230
  VERSION=${GITHUB_REF#refs/tags/v}
223
231
  echo "Setting version to $VERSION"
224
- sed -i '' "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml
232
+ if ! sed -i '' "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml; then
233
+ echo "Failed to update version in Cargo.toml"
234
+ exit 1
235
+ fi
225
236
  - name: Build wheels
226
237
  uses: PyO3/maturin-action@v1
227
238
  with:
@@ -231,7 +242,7 @@ jobs:
231
242
  - name: Upload wheels
232
243
  uses: actions/upload-artifact@v4
233
244
  with:
234
- name: wheels-macos-${{ matrix.platform.target }}
245
+ name: wheels-macos-${{ matrix.platform.target }}-py${{ matrix.python-version }}
235
246
  path: dist
236
247
 
237
248
  sdist:
@@ -245,10 +256,15 @@ jobs:
245
256
  python-version: 3.12
246
257
  - name: Update Cargo.toml Version
247
258
  if: startsWith(github.ref, 'refs/tags/')
259
+ shell: bash
248
260
  run: |
261
+ set -e # Exit on error
249
262
  VERSION=${GITHUB_REF#refs/tags/v}
250
263
  echo "Setting version to $VERSION"
251
- sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml
264
+ if ! sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml; then
265
+ echo "Failed to update version in Cargo.toml"
266
+ exit 1
267
+ fi
252
268
  - name: Build sdist
253
269
  uses: PyO3/maturin-action@v1
254
270
  with:
@@ -1,6 +1,6 @@
1
1
  # This file is automatically @generated by Cargo.
2
2
  # It is not intended for manual editing.
3
- version = 3
3
+ version = 4
4
4
 
5
5
  [[package]]
6
6
  name = "ahash"
@@ -724,7 +724,7 @@ dependencies = [
724
724
 
725
725
  [[package]]
726
726
  name = "nc-gcode-interpreter"
727
- version = "0.1.8"
727
+ version = "0.1.10"
728
728
  dependencies = [
729
729
  "clap",
730
730
  "csv",
@@ -819,9 +819,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
819
819
 
820
820
  [[package]]
821
821
  name = "pest"
822
- version = "2.7.13"
822
+ version = "2.7.14"
823
823
  source = "registry+https://github.com/rust-lang/crates.io-index"
824
- checksum = "fdbef9d1d47087a895abd220ed25eb4ad973a5e26f6a4367b038c25e28dfc2d9"
824
+ checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442"
825
825
  dependencies = [
826
826
  "memchr",
827
827
  "thiserror",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "nc-gcode-interpreter"
3
- version = "0.1.8"
3
+ version = "0.1.10"
4
4
  edition = "2021"
5
5
 
6
6
  [lib]
@@ -1,24 +1,24 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: nc-gcode-interpreter
3
- Version: 0.1.8
3
+ Version: 0.1.10
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
- Classifier: Programming Language :: Python :: 3.11
7
6
  Classifier: Programming Language :: Python :: 3.12
7
+ Classifier: Programming Language :: Python :: 3.13
8
8
  Classifier: License :: OSI Approved :: MIT License
9
9
  Classifier: Operating System :: OS Independent
10
10
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
11
- Requires-Dist: maturin >=1.7.4
12
- Requires-Dist: polars >=1.9.0
13
- Requires-Dist: jupyter >=1.1.1 ; extra == 'dev'
14
- Requires-Dist: pytest >=8.3.3 ; extra == 'test'
11
+ Requires-Dist: maturin>=1.7.4
12
+ Requires-Dist: polars[pyarrow]>=1.9.0
13
+ Requires-Dist: jupyter>=1.1.1 ; extra == 'dev'
14
+ Requires-Dist: pytest>=8.3.3 ; extra == 'test'
15
15
  Requires-Dist: mypy ; extra == 'test'
16
16
  Provides-Extra: dev
17
17
  Provides-Extra: test
18
18
  License-File: LICENSE
19
19
  Summary: A interpreter for NC (Numerical Control) GCode
20
20
  Author-email: CEAD Group <software@ceadgroup.com>
21
- Requires-Python: >=3.11
21
+ Requires-Python: >=3.12
22
22
  Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
23
23
  Project-URL: Homepage, https://github.com/CEAD-group/nc-gcode-interpreter
24
24
  Project-URL: Repository, https://github.com/CEAD-group/nc-gcode-interpreter.git
@@ -26,44 +26,42 @@ Project-URL: Documentation, https://github.com/CEAD-group/nc-gcode-interpreter/b
26
26
 
27
27
  # NC-GCode-Interpreter
28
28
 
29
- A robust interpreter tailored for processing Sinumerik-flavored NC G-code, designed to convert MPF files into CSV outputs or Polars dataframes when used with Python bindings.
29
+ A robust interpreter designed for processing Sinumerik-flavored NC G-code, capable of converting MPF files into CSV outputs or Polars DataFrames via Python bindings.
30
30
 
31
31
  ## Overview
32
32
 
33
- The NC-GCode-Interpreter provides a streamlined and efficient solution for interpreting G-code specifically designed with Sinumerik specifications in mind. This tool caters to both CLI users and those preferring a Python environment, ensuring versatility and ease of use in processing NC programming commands into structured formats like CSV files or Polars dataframes.
33
+ The **NC-GCode-Interpreter** offers a streamlined and efficient solution for interpreting G-code specifically tailored to Sinumerik specifications. This tool caters to both command-line interface (CLI) users and those preferring a Python environment, ensuring versatility and ease of use in processing NC programming commands into structured formats like CSV files or Polars DataFrames.
34
34
 
35
35
  ## Features
36
36
 
37
37
  ### Supported G-code Features
38
38
 
39
- - **G Group Commands**: Recognizes G-code groups and modal gcode commands.
40
- - **Global Translations**: Supports commands like TRANS and ATRANS for adjusting coordinates globally.
41
- - **Looping Constructs**: Handles loops using WHILE and FOR statements.
39
+ - **G Group Commands**: Recognizes G-code groups and modal G-code commands.
40
+ - **Global Transformations**: Supports commands like `TRANS` and `ATRANS` for adjusting coordinates globally.
41
+ - **Looping Constructs**: Handles loops using `WHILE` and `FOR` statements.
42
42
  - **Variable Handling**: Supports definition and manipulation of local variables.
43
- - **Conditional Logic**: Implements conditional execution with IF, ELSE, and ENDIF.
44
- - **Arithmetic Operations**: Basic operations such as addition, subtraction, multiplication, and division are supported.
43
+ - **Conditional Logic**: Implements conditional execution with `IF`, `ELSE`, and `ENDIF`.
44
+ - **Arithmetic Operations**: Supports basic operations such as addition, subtraction, multiplication, and division.
45
45
  - **Array Operations**: Manages arrays and allows operations on them.
46
- - **Incremental Changes**: Facilitates incremental changes in axes positions like X=IC(2).
46
+ - **Incremental Changes**: Facilitates incremental changes in axes positions like `X=IC(2)`.
47
47
 
48
48
  ### Additional Functionality
49
49
 
50
- - **Custom Axes**: Allows users to define additional axes beyond the standard X, Y, Z.
50
+ - **Custom Axes**: Allows users to define additional axes beyond the standard `X`, `Y`, `Z`.
51
51
  - **Initial State Configuration**: Enables the use of an initial state MPF file to set default values for multiple runs.
52
- - **CLI Options**: Numerous command-line options to customize the processing like axis overriding, loop limits, and more.
53
-
54
-
52
+ - **CLI Options**: Numerous command-line options to customize the processing, such as axis overriding, loop limits, and more.
55
53
 
56
54
  ## Example Usage
57
55
 
58
-
59
56
  Consider this example program to generate a square in two layers:
57
+
60
58
  ```scheme
61
- ;Example.MPF
62
- DEF INT n_layers = 2, layer=1
63
- DEF REAL size = 100 ;size of the square
64
- DEF REAL layer_height = 4 ;size of the square
65
- TRANS Z = 0.5 ; move up all z coordinates by 0.5
66
- G1 F=1000; Set feed rate in millimeters per minute
59
+ ; Example.MPF
60
+ DEF INT n_layers = 2, layer = 1
61
+ DEF REAL size = 100 ; size of the square
62
+ DEF REAL layer_height = 4 ; height of each layer
63
+ TRANS Z = 0.5 ; move up all Z coordinates by 0.5
64
+ G1 F=1000 ; Set feed rate in millimeters per minute
67
65
  G1 X0 Y500 Z0 ; move to the starting point
68
66
  WHILE (layer <= n_layers)
69
67
  X=IC(size)
@@ -72,13 +70,12 @@ WHILE (layer <= n_layers)
72
70
  Y=IC(-size) Z=IC(layer_height)
73
71
  layer = layer + 1
74
72
  ENDWHILE
75
- M31; end of program
76
- ```
73
+ M31 ; end of program
77
74
 
78
75
 
79
76
  ### CLI Usage
80
77
  ```bash
81
- > cargo run -- --help
78
+ $ cargo run -- --help
82
79
  A G-code interpreter
83
80
 
84
81
  Usage: nc-gcode-interpreter [OPTIONS] <input>
@@ -89,13 +86,13 @@ Arguments:
89
86
  Options:
90
87
  -a, --axes <AXIS> Override default axis identifiers (comma-separated, e.g., "X,Y,Z")
91
88
  -e, --extra-axes <EXTRA_AXIS> Add extra axis identifiers (comma-separated, e.g., "RA1,RA2")
92
- -i, --initial_state <INITIAL_STATE> Optional initial_state file to initialize state
89
+ -i, --initial_state <INITIAL_STATE> Optional initial state file to e.g. define global variables or set axis positions
93
90
  -l, --iteration_limit <LIMIT> Maximum number of iterations for loops [default: 10000]
94
91
  -f, --disable-forward-fill Disable forward-filling of null values in axes columns
95
92
  -h, --help Print help
96
93
  -V, --version Print version
97
94
 
98
- > cargo run -- Example.MPF
95
+ $ cargo run -- Example.MPF
99
96
  ```
100
97
 
101
98
  ```csv
@@ -119,6 +116,13 @@ X ,Y ,Z ,F ,M ,gg01_motion ,comment
119
116
 
120
117
  ### python example
121
118
 
119
+ To install the Python bindings, run:
120
+ ```bash
121
+ pip install nc-gcode-interpreter
122
+ ```
123
+
124
+ Then, you can use the Python bindings to convert an MPF file to a DataFrame:
125
+
122
126
  ```bash
123
127
  python -c "\
124
128
  from nc_gcode_interpreter import nc_to_dataframe; \
@@ -145,6 +149,17 @@ shape: (14, 7)
145
149
  └───────┴───────┴──────┴────────┴───────────┴─────────────┴─────────────────────────────────┘
146
150
  ```
147
151
 
152
+ The Python bindings also return the state of the program after execution, which can be used for inspection.
153
+
154
+ Additionally, conversion from a Polars DataFrame back to an MPF (NC) program is also supported:
155
+
156
+ ```bash
157
+ python -c "\
158
+ from nc_gcode_interpreter import nc_to_dataframe, dataframe_to_nc; \
159
+ from pathlib import Path; \
160
+ df, state = nc_to_dataframe(Path('Example.MPF').open(), extra_axes=['ELX']); \
161
+ dataframe_to_nc(df, Path('Example_out.MPF').open('w'))"
162
+ ```
148
163
 
149
164
  ```bash
150
165
  target/release/nc-gcode-interpreter --help
@@ -167,7 +182,7 @@ Options:
167
182
 
168
183
  ## Why?
169
184
 
170
- The Sinumerik NC programming guide is extensive, and some of it's functionality can be very convenient for making on the fly improvements to cde. However to better uderstand, visualize and simulate the code, it is often necessary to convert it to a more structured format like CSV or a dataframe. This tool aims to provide a simple and efficient way to convert Sinumerik-flavored G-code to a structured format, making it easier to analyze and visualize the code.
185
+ The Sinumerik NC programming guide is extensive, and some of its functionality can be very convenient for making on-the-fly improvements to code. However, to better understand, visualize, and simulate the code, it is often necessary to convert it to a more structured format like CSV or a DataFrame. This tool aims to provide a simple and efficient way to convert Sinumerik-flavored G-code to a structured format, making it easier to analyze and visualize.
171
186
 
172
187
  Only a limited subset is supported, but the tool is designed to be easily extensible to support more features in the future.
173
188
 
@@ -1,43 +1,41 @@
1
1
  # NC-GCode-Interpreter
2
2
 
3
- A robust interpreter tailored for processing Sinumerik-flavored NC G-code, designed to convert MPF files into CSV outputs or Polars dataframes when used with Python bindings.
3
+ A robust interpreter designed for processing Sinumerik-flavored NC G-code, capable of converting MPF files into CSV outputs or Polars DataFrames via Python bindings.
4
4
 
5
5
  ## Overview
6
6
 
7
- The NC-GCode-Interpreter provides a streamlined and efficient solution for interpreting G-code specifically designed with Sinumerik specifications in mind. This tool caters to both CLI users and those preferring a Python environment, ensuring versatility and ease of use in processing NC programming commands into structured formats like CSV files or Polars dataframes.
7
+ The **NC-GCode-Interpreter** offers a streamlined and efficient solution for interpreting G-code specifically tailored to Sinumerik specifications. This tool caters to both command-line interface (CLI) users and those preferring a Python environment, ensuring versatility and ease of use in processing NC programming commands into structured formats like CSV files or Polars DataFrames.
8
8
 
9
9
  ## Features
10
10
 
11
11
  ### Supported G-code Features
12
12
 
13
- - **G Group Commands**: Recognizes G-code groups and modal gcode commands.
14
- - **Global Translations**: Supports commands like TRANS and ATRANS for adjusting coordinates globally.
15
- - **Looping Constructs**: Handles loops using WHILE and FOR statements.
13
+ - **G Group Commands**: Recognizes G-code groups and modal G-code commands.
14
+ - **Global Transformations**: Supports commands like `TRANS` and `ATRANS` for adjusting coordinates globally.
15
+ - **Looping Constructs**: Handles loops using `WHILE` and `FOR` statements.
16
16
  - **Variable Handling**: Supports definition and manipulation of local variables.
17
- - **Conditional Logic**: Implements conditional execution with IF, ELSE, and ENDIF.
18
- - **Arithmetic Operations**: Basic operations such as addition, subtraction, multiplication, and division are supported.
17
+ - **Conditional Logic**: Implements conditional execution with `IF`, `ELSE`, and `ENDIF`.
18
+ - **Arithmetic Operations**: Supports basic operations such as addition, subtraction, multiplication, and division.
19
19
  - **Array Operations**: Manages arrays and allows operations on them.
20
- - **Incremental Changes**: Facilitates incremental changes in axes positions like X=IC(2).
20
+ - **Incremental Changes**: Facilitates incremental changes in axes positions like `X=IC(2)`.
21
21
 
22
22
  ### Additional Functionality
23
23
 
24
- - **Custom Axes**: Allows users to define additional axes beyond the standard X, Y, Z.
24
+ - **Custom Axes**: Allows users to define additional axes beyond the standard `X`, `Y`, `Z`.
25
25
  - **Initial State Configuration**: Enables the use of an initial state MPF file to set default values for multiple runs.
26
- - **CLI Options**: Numerous command-line options to customize the processing like axis overriding, loop limits, and more.
27
-
28
-
26
+ - **CLI Options**: Numerous command-line options to customize the processing, such as axis overriding, loop limits, and more.
29
27
 
30
28
  ## Example Usage
31
29
 
32
-
33
30
  Consider this example program to generate a square in two layers:
31
+
34
32
  ```scheme
35
- ;Example.MPF
36
- DEF INT n_layers = 2, layer=1
37
- DEF REAL size = 100 ;size of the square
38
- DEF REAL layer_height = 4 ;size of the square
39
- TRANS Z = 0.5 ; move up all z coordinates by 0.5
40
- G1 F=1000; Set feed rate in millimeters per minute
33
+ ; Example.MPF
34
+ DEF INT n_layers = 2, layer = 1
35
+ DEF REAL size = 100 ; size of the square
36
+ DEF REAL layer_height = 4 ; height of each layer
37
+ TRANS Z = 0.5 ; move up all Z coordinates by 0.5
38
+ G1 F=1000 ; Set feed rate in millimeters per minute
41
39
  G1 X0 Y500 Z0 ; move to the starting point
42
40
  WHILE (layer <= n_layers)
43
41
  X=IC(size)
@@ -46,13 +44,12 @@ WHILE (layer <= n_layers)
46
44
  Y=IC(-size) Z=IC(layer_height)
47
45
  layer = layer + 1
48
46
  ENDWHILE
49
- M31; end of program
50
- ```
47
+ M31 ; end of program
51
48
 
52
49
 
53
50
  ### CLI Usage
54
51
  ```bash
55
- > cargo run -- --help
52
+ $ cargo run -- --help
56
53
  A G-code interpreter
57
54
 
58
55
  Usage: nc-gcode-interpreter [OPTIONS] <input>
@@ -63,13 +60,13 @@ Arguments:
63
60
  Options:
64
61
  -a, --axes <AXIS> Override default axis identifiers (comma-separated, e.g., "X,Y,Z")
65
62
  -e, --extra-axes <EXTRA_AXIS> Add extra axis identifiers (comma-separated, e.g., "RA1,RA2")
66
- -i, --initial_state <INITIAL_STATE> Optional initial_state file to initialize state
63
+ -i, --initial_state <INITIAL_STATE> Optional initial state file to e.g. define global variables or set axis positions
67
64
  -l, --iteration_limit <LIMIT> Maximum number of iterations for loops [default: 10000]
68
65
  -f, --disable-forward-fill Disable forward-filling of null values in axes columns
69
66
  -h, --help Print help
70
67
  -V, --version Print version
71
68
 
72
- > cargo run -- Example.MPF
69
+ $ cargo run -- Example.MPF
73
70
  ```
74
71
 
75
72
  ```csv
@@ -93,6 +90,13 @@ X ,Y ,Z ,F ,M ,gg01_motion ,comment
93
90
 
94
91
  ### python example
95
92
 
93
+ To install the Python bindings, run:
94
+ ```bash
95
+ pip install nc-gcode-interpreter
96
+ ```
97
+
98
+ Then, you can use the Python bindings to convert an MPF file to a DataFrame:
99
+
96
100
  ```bash
97
101
  python -c "\
98
102
  from nc_gcode_interpreter import nc_to_dataframe; \
@@ -119,6 +123,17 @@ shape: (14, 7)
119
123
  └───────┴───────┴──────┴────────┴───────────┴─────────────┴─────────────────────────────────┘
120
124
  ```
121
125
 
126
+ The Python bindings also return the state of the program after execution, which can be used for inspection.
127
+
128
+ Additionally, conversion from a Polars DataFrame back to an MPF (NC) program is also supported:
129
+
130
+ ```bash
131
+ python -c "\
132
+ from nc_gcode_interpreter import nc_to_dataframe, dataframe_to_nc; \
133
+ from pathlib import Path; \
134
+ df, state = nc_to_dataframe(Path('Example.MPF').open(), extra_axes=['ELX']); \
135
+ dataframe_to_nc(df, Path('Example_out.MPF').open('w'))"
136
+ ```
122
137
 
123
138
  ```bash
124
139
  target/release/nc-gcode-interpreter --help
@@ -141,7 +156,7 @@ Options:
141
156
 
142
157
  ## Why?
143
158
 
144
- The Sinumerik NC programming guide is extensive, and some of it's functionality can be very convenient for making on the fly improvements to cde. However to better uderstand, visualize and simulate the code, it is often necessary to convert it to a more structured format like CSV or a dataframe. This tool aims to provide a simple and efficient way to convert Sinumerik-flavored G-code to a structured format, making it easier to analyze and visualize the code.
159
+ The Sinumerik NC programming guide is extensive, and some of its functionality can be very convenient for making on-the-fly improvements to code. However, to better understand, visualize, and simulate the code, it is often necessary to convert it to a more structured format like CSV or a DataFrame. This tool aims to provide a simple and efficient way to convert Sinumerik-flavored G-code to a structured format, making it easier to analyze and visualize.
145
160
 
146
161
  Only a limited subset is supported, but the tool is designed to be easily extensible to support more features in the future.
147
162
 
@@ -0,0 +1,3 @@
1
+ gg01_motion,X,function_call
2
+ ,,SETAL(12345)
3
+ G1,1.000,
@@ -0,0 +1,13 @@
1
+ DEF INT aa=1
2
+ IF TRUE
3
+ X1
4
+ ELSE
5
+ IF aa
6
+ X5
7
+ ELSE
8
+ X3
9
+ Y32
10
+ ENDIF
11
+ ENDIF
12
+
13
+