Skip to content

Commit 7ad5e45

Browse files
FANUC Kernel Semantics
1 parent a12cd0b commit 7ad5e45

36 files changed

Lines changed: 2279 additions & 1446 deletions

‎CHANGELOG.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Changelog
22

3+
## 1.6.1 - 2026-09-22
4+
5+
- Fixed milling `G84` tapping so withdrawal from depth is emitted as synchronized feed motion instead of rapid motion.
6+
- Added turning `G53` non-modal machine-coordinate motion while preserving the active WCS for subsequent blocks.
7+
- Added machine-specific modal-group validation for the supported code set. Conflicting codes now produce `MODAL_GROUP_CONFLICT` and the complete block is skipped instead of silently applying the last code.
8+
- Corrected the shared AST so milling `G90/G94` are not classified as turning cycles, and preserved `Y/J/V` plus coordinate-only modal motion blocks with Python/Cython parser parity.
9+
- Added kernel/API support for `G54.1 P1-P99` through `extended_wcs_offsets`, and `G10 L2 P1-P6` / `G10 L20 P1-P99` runtime work-offset programming without requiring UI configuration.
10+
- Modeled milling `G82` dwell, `G84` spindle synchronization/reversal and `G86` spindle-stop signals. The high-speed `G73` retract distance is now configurable through `milling_g73_retract_distance` instead of being hardcoded in cycle expansion.
11+
- Fixed Lathe Mode zoom so perspective zoom no longer stalls at the intentionally near-orthographic `0.01` FOV limit. Turning zoom now changes camera distance while preserving the existing projection, orientation and visual appearance; milling 3D keeps its previous FOV-based zoom behavior.
12+
- Made the WCS dialog vertically compact and resizable instead of enforcing the previous oversized minimum height.
13+
- Fixed missing `QDoubleSpinBox` up/down arrows in the Windows 10 dark-theme fallback. Spin-box buttons now keep native Windows geometry while the dark compatibility style explicitly renders visible arrows; the Windows 11 native dark-style path is unchanged.
14+
- Added regression coverage for Lathe Mode zoom behavior, preserved turning camera FOV/orientation, compact WCS sizing and Windows 10 dark-theme spin-box arrow rendering.
15+
316
## 1.6.0 - 2026-09-21
417

518
- Added FANUC `G65` custom-macro calls for turning and milling: `P` target selection, `L` repetition, Type I/II address-to-`#1..#33` argument binding, four macro-local nesting levels, local-variable restoration on `M99`, and shared execution/export events. `G65` argument words are isolated from normal motion, feed, spindle, M-code and tool-selection side effects; Python/Cython parsing and tool discovery follow the same rule. `G66/G67` remain intentionally out of scope for this release.

‎FAQ.md‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,12 @@ G43/G49 and H values are tracked for execution/export context, but H-offset geom
215215

216216
Axis-specific scaling of a circular arc would require non-circular/spiral interpolation and is currently reported as unsupported instead of being approximated. A `G51` block without `P` or `I/J/K` also produces a diagnostic because no controller parameter supplies a default factor.
217217

218+
### How do extended work offsets and G10 work?
219+
220+
The kernel supports `G54.1 P1` through `G54.1 P99` for both milling and turning. API callers supply these offsets through the `extended_wcs_offsets` mapping, keyed by the P number. The WCS dialog continues to configure only `G54-G59`; extended offsets intentionally have no UI dependency.
221+
222+
`G10 L2 P1-P6` programs `G54-G59`, and `G10 L20 P1-P99` programs extended `G54.1` offsets for the current execution. X/Y/Z values follow the active G20/G21 units. A G10 block never creates motion, and changing the active offset preserves the physical tool position. Runtime G10 changes are returned in `ExecutionResult.wcs_offsets` and `ExecutionResult.extended_wcs_offsets` but are not written to application settings.
223+
218224
## Units and arc programming
219225

220226
### What does the default unit option do?
@@ -247,7 +253,9 @@ Yes. When exporting an R-format full circle, Expanded Execution emits two exact
247253
- `G17/G18/G19` planes where applicable.
248254
- `G20/G21` units.
249255
- `G28` configured reference return.
250-
- `G54-G59` work coordinate systems.
256+
- `G53` non-modal machine-coordinate motion.
257+
- `G54-G59` and `G54.1 P1-P99` work coordinate systems.
258+
- `G10 L2/L20` runtime work-offset programming.
251259
- `G90/G91` absolute/incremental programming where applicable.
252260
- Macro B expressions and assignments.
253261
- `IF/GOTO` and `WHILE/END`.
@@ -257,8 +265,8 @@ Yes. When exporting an R-format full circle, Expanded Execution emits two exact
257265
### FANUC milling
258266

259267
- XYZ motion and helical interpolation.
260-
- G53 machine-coordinate motion.
261268
- G80/G81/G82/G83/G84/G85/G86 canned cycles.
269+
- G82 dwell, G84 feed-return/spindle synchronization and G86 spindle-stop semantics.
262270
- G98/G99 canned-cycle return modes.
263271
- G94/G95 feed modes.
264272
- Configured milling tools and cutter-radius compensation.

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Easy G-Code Plot is a desktop editor, analyzer, simulator and trace exporter for
2626

2727
- FANUC turning and milling with Macro B expressions, conditions, loops, `G65` custom-macro calls and `M98/M99` subprograms.
2828
- Turning G70–G76 cycles, G32/G33/G92 threading, tool-nose compensation and direct A/C/corner-R programming.
29-
- Milling canned cycles, helical arcs, cutter-radius compensation and G50/G51/G52/G68/G69 coordinate transforms.
29+
- Milling canned cycles, helical arcs, cutter-radius compensation and G10/G50/G51/G52/G54.1/G68/G69 coordinate operations.
3030
- G-code editor with highlighting, line numbers, search, replace and cleanup tools.
3131
- Interactive OpenGL toolpath, logical-motion playback and source-line synchronization.
3232
- Cutter-aware turning Stock Removal, including thread profiles.

‎app/gcode/export/common.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from ..kernel import ExecutionResult, TraceMotion
99
from ..kernel.events import PROGRAM_END, PROGRAM_START
10+
from ..kernel.geometry.coordinates import extended_wcs_id
1011
from .options import ExportOptions
1112

1213

@@ -40,6 +41,7 @@ def _motion_in_active_wcs(
4041
turning: bool = False,
4142
) -> TraceMotion:
4243
offsets = dict(result.wcs_offsets)
44+
offsets.update({extended_wcs_id(p_number): value for p_number, value in result.extended_wcs_offsets})
4345
offset = offsets.get(step.active_wcs, (0.0, 0.0, 0.0))
4446
if not any(abs(value) > 1e-12 for value in offset):
4547
return motion

‎app/gcode/kernel/api/engine.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
from ..frontend.program import parse_program, try_wcs_from_gcode, x_delta_to_diameter, x_value_to_diameter
1212
from ..geometry import resolve_arc
1313
from ..geometry.coordinates import WcsOffset, WcsOffsets # noqa: F401 - compatibility re-export
14+
from ..geometry.coordinates import milling_extended_wcs_offsets as _mill_extended_wcs_offsets
1415
from ..geometry.coordinates import milling_wcs_offsets as _mill_wcs_offsets
16+
from ..geometry.coordinates import published_extended_wcs_offsets as _result_extended_wcs_offsets
1517
from ..geometry.coordinates import published_wcs_offsets as _result_wcs_offsets
18+
from ..geometry.coordinates import turning_extended_wcs_offsets as _turn_extended_wcs_offsets
1619
from ..geometry.coordinates import turning_wcs_offsets as _turn_wcs_offsets
1720
from ..milling import execute_milling
1821
from ..runtime.diagnostics import SUPPORTED_TURNING_G_CODES as SUPPORTED_G_CODES # noqa: F401
@@ -174,6 +177,8 @@ def _execute_impl(
174177
home_y: float = 0.0,
175178
home_z: float = 0.0,
176179
wcs_offsets: WcsOffsets | None = None,
180+
extended_wcs_offsets: WcsOffsets | None = None,
181+
milling_g73_retract_distance: float = 1.0,
177182
emulate_g28_home: bool = False,
178183
include_instructions: bool = True,
179184
) -> ExecutionResult:
@@ -200,24 +205,29 @@ def _execute_impl(
200205

201206
if language == "fanuc_mill":
202207
mill_offsets = _mill_wcs_offsets(wcs_offsets)
208+
mill_offsets.update(_mill_extended_wcs_offsets(extended_wcs_offsets))
203209
return replace(
204210
execute_milling(
205211
source,
206212
skip_optional_blocks=skip_optional_blocks,
207213
default_unit_scale=default_unit_scale,
208214
home=(home_x, home_y, home_z),
209215
wcs_offsets=mill_offsets,
216+
g73_retract_distance=milling_g73_retract_distance,
210217
include_instructions=include_instructions,
211218
),
212219
wcs_offsets=_result_wcs_offsets(mill_offsets),
220+
extended_wcs_offsets=_result_extended_wcs_offsets(mill_offsets),
213221
)
214222

215223
program: Program | None = None
216224
unsupported: tuple[Diagnostic, ...] = ()
217225
turn_offsets = _turn_wcs_offsets(wcs_offsets)
226+
turn_offsets.update(_turn_extended_wcs_offsets(extended_wcs_offsets))
218227
try:
219228
program = parse_program(source)
220229
unsupported = _unsupported_g_diagnostics(program)
230+
execution_diagnostics: list[Diagnostic] = []
221231
rough, finish = [], []
222232
native_motions, trace_steps = _build_source_motion_trace_with_steps(
223233
program,
@@ -238,7 +248,9 @@ def _execute_impl(
238248
motion_ctor=Motion,
239249
point_ctor=Point2,
240250
tools=tools,
251+
diagnostics=execution_diagnostics,
241252
)
253+
unsupported += tuple(execution_diagnostics)
242254
unsupported += _fractional_code_diagnostics(program, trace_steps)
243255
except Exception as exc:
244256
return ExecutionResult(
@@ -267,6 +279,7 @@ def _execute_impl(
267279
execution_steps=tuple(trace_steps),
268280
events=events,
269281
wcs_offsets=_result_wcs_offsets(turn_offsets),
282+
extended_wcs_offsets=_result_extended_wcs_offsets(turn_offsets),
270283
)
271284

272285

‎app/gcode/kernel/api/types.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,4 @@ class ExecutionResult:
144144
language: str = "fanuc_turn"
145145
events: tuple[ExecutionEvent, ...] = ()
146146
wcs_offsets: tuple[tuple[int, tuple[float, float, float]], ...] = ()
147+
extended_wcs_offsets: tuple[tuple[int, tuple[float, float, float]], ...] = ()

‎app/gcode/kernel/frontend/_native_parser.pyx‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,13 @@ cdef tuple _native_block(Py_ssize_t index, str raw, bytes clean):
127127
cdef object cycle_expr = None
128128
cdef object cycle_code = None
129129
cdef object x_expr = None
130+
cdef object y_expr = None
130131
cdef object z_expr = None
131132
cdef object u_expr = None
133+
cdef object v_expr = None
132134
cdef object w_expr = None
133135
cdef object i_expr = None
136+
cdef object j_expr = None
134137
cdef object k_expr = None
135138
cdef object r_expr = None
136139
cdef object f_expr = None
@@ -204,7 +207,7 @@ cdef tuple _native_block(Py_ssize_t index, str raw, bytes clean):
204207
if int_code in (0, 1, 2, 3, 32, 33):
205208
motion_expr = expr
206209
motion_code = int_code
207-
if int_code in (70, 71, 72, 73, 74, 75, 76, 80, 83, 84, 90, 92, 94):
210+
if int_code in (70, 71, 72, 73, 74, 75, 76, 80, 83, 84):
208211
cycle_expr = expr
209212
cycle_code = int_code
210213
elif letter == "M" and int_code is not None:
@@ -215,14 +218,20 @@ cdef tuple _native_block(Py_ssize_t index, str raw, bytes clean):
215218
olabel = int_code
216219
elif letter == "X":
217220
x_expr = expr
221+
elif letter == "Y":
222+
y_expr = expr
218223
elif letter == "Z":
219224
z_expr = expr
220225
elif letter == "U":
221226
u_expr = expr
227+
elif letter == "V":
228+
v_expr = expr
222229
elif letter == "W":
223230
w_expr = expr
224231
elif letter == "I":
225232
i_expr = expr
233+
elif letter == "J":
234+
j_expr = expr
226235
elif letter == "K":
227236
k_expr = expr
228237
elif letter == "R":
@@ -235,19 +244,22 @@ cdef tuple _native_block(Py_ssize_t index, str raw, bytes clean):
235244
c_expr = expr
236245

237246
if g65_call:
238-
modal = ModalSnapshot(None, None, None, None, None, None)
247+
modal = ModalSnapshot(None, None, None, None, None, None, None, None)
239248
else:
240249
modal = ModalSnapshot(
241250
motion_expr if motion_expr is not None else last_g_expr,
242251
x_expr, z_expr, u_expr, w_expr, f_expr,
252+
y_expr, v_expr,
243253
)
244254
if not g65_call and (
245-
motion_expr is not None or x_expr is not None or z_expr is not None or u_expr is not None or w_expr is not None
255+
motion_expr is not None or x_expr is not None or y_expr is not None or z_expr is not None
256+
or u_expr is not None or v_expr is not None or w_expr is not None
246257
):
247258
motion = MotionNode(
248259
motion_expr,
249260
x_expr, z_expr, u_expr, w_expr,
250261
i_expr, k_expr, r_expr, f_expr, a_expr, c_expr,
262+
y_expr, v_expr, j_expr,
251263
)
252264
token_tuple = tuple(tokens)
253265
ast_tuple = tuple(ast_words)
@@ -263,6 +275,7 @@ cdef tuple _native_block(Py_ssize_t index, str raw, bytes clean):
263275
motion_code,
264276
x_expr, z_expr, u_expr, w_expr,
265277
i_expr, k_expr, r_expr, f_expr, a_expr, c_expr,
278+
y_expr, v_expr, j_expr,
266279
)
267280
elif g_codes or m_codes:
268281
node = ControlAstNode(

‎app/gcode/kernel/frontend/ast.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ class MotionAstNode(AstNode):
3535
f_expr: str | None = None
3636
a_expr: str | None = None
3737
c_expr: str | None = None
38+
y_expr: str | None = None
39+
v_expr: str | None = None
40+
j_expr: str | None = None
3841

3942

4043
@dataclass(frozen=True, slots=True)
@@ -152,6 +155,9 @@ def build_ast_node(block: object) -> AstNode:
152155
f_expr=getattr(motion, "f_expr", None),
153156
a_expr=getattr(motion, "a_expr", None),
154157
c_expr=getattr(motion, "c_expr", None),
158+
y_expr=getattr(motion, "y_expr", None),
159+
v_expr=getattr(motion, "v_expr", None),
160+
j_expr=getattr(motion, "j_expr", None),
155161
)
156162

157163
g_codes: list[int] = []

‎app/gcode/kernel/frontend/model.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ class ModalSnapshot:
7171
u_expr: str | None
7272
w_expr: str | None
7373
f_expr: str | None
74+
y_expr: str | None = None
75+
v_expr: str | None = None
7476

7577

7678
@dataclass(frozen=True, slots=True)
@@ -86,6 +88,9 @@ class MotionNode:
8688
f_expr: str | None
8789
a_expr: str | None
8890
c_expr: str | None
91+
y_expr: str | None = None
92+
v_expr: str | None = None
93+
j_expr: str | None = None
8994

9095

9196
@dataclass(frozen=True, slots=True)

‎app/gcode/kernel/frontend/program.py‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ def literal_codes(tokens: tuple[WordToken, ...], letter: str) -> tuple[int, ...]
9292

9393
def _parse_blocks(lines: Iterable[str], *, start_index: int = 0):
9494
motion_codes = {0, 1, 2, 3, 32, 33}
95-
cycle_codes = {70, 71, 72, 73, 74, 75, 76, 80, 83, 84, 90, 92, 94}
95+
# G90/G92/G94 are turning cycles but have different milling meanings.
96+
# Keep the shared parser dialect-neutral; the selected executor resolves
97+
# those codes after parsing.
98+
cycle_codes = {70, 71, 72, 73, 74, 75, 76, 80, 83, 84}
9699
for offset, raw in checkpointed(lines):
97100
i = start_index + offset
98101
clean = strip_comments(raw).upper()
@@ -124,10 +127,12 @@ def _parse_blocks(lines: Iterable[str], *, start_index: int = 0):
124127
u_expr=None if g65_call else word_map.get("U"),
125128
w_expr=None if g65_call else word_map.get("W"),
126129
f_expr=None if g65_call else word_map.get("F"),
130+
y_expr=None if g65_call else word_map.get("Y"),
131+
v_expr=None if g65_call else word_map.get("V"),
127132
)
128133

129134
motion_node: MotionNode | None = None
130-
if not g65_call and (any(k in word_map for k in ("X", "Z", "U", "W")) or motion_g_word is not None):
135+
if not g65_call and (any(k in word_map for k in ("X", "Y", "Z", "U", "V", "W")) or motion_g_word is not None):
131136
motion_node = MotionNode(
132137
g_expr=motion_g_word.expr if motion_g_word is not None else None,
133138
x_expr=word_map.get("X"),
@@ -140,6 +145,9 @@ def _parse_blocks(lines: Iterable[str], *, start_index: int = 0):
140145
f_expr=word_map.get("F"),
141146
a_expr=word_map.get("A"),
142147
c_expr=word_map.get("C"),
148+
y_expr=word_map.get("Y"),
149+
v_expr=word_map.get("V"),
150+
j_expr=word_map.get("J"),
143151
)
144152

145153
cycle_node: CycleNode | None = None

0 commit comments

Comments
 (0)