Namespace Hi.NcParsers.LogicSyntaxs
Classes
- BackBoringSyntax
G87 back boring cycle. Supports modal repetition. Cuts upward from Z to R — used to bore the back side of a workpiece.
Cycle sequence:
- Oriented spindle stop (OSS) at current position
- Rapid (shifted) to init position, then down to bottom Z — tool enters pre-drilled hole without contacting bore wall
- Shift back to hole center at bottom
- Spindle start (CW)
- Feed upward from Z to R-point (back boring cut)
- Oriented spindle stop at R
- Tool shift, rapid retract (shifted) to final Z
- Shift back to center, spindle restart
Q specifies the lateral shift distance (mm). Shift direction defaults to +X (OSS angle 0°).
Reads absolute coordinates from the cycle section, which is resolved by CannedCycleResolveSyntax before this syntax runs.
- BoringCycleSyntax
G85/G86/G89 boring cycles.
Cycle sequence:
- Rapid to init position (target XY, previous Z)
- Rapid from init to R-point
- Feed from R-point to bottom Z
- [G86 only] Spindle stop at bottom
- [G89 only] Dwell P seconds at bottom
- Retract: G85/G89 → feed retract, G86 → rapid retract
- [G86 only] Spindle restart (CW) after retract
G85: feed to Z, feed retract — smooth bore finish. G86: feed to Z, spindle stop (implicit), rapid retract. G89: feed to Z, dwell P, feed retract — like G85 with bottom dwell.
Reads absolute coordinates from the cycle section, which is resolved by CannedCycleResolveSyntax (modal repetition, G91 conversion, missing-axis fallback) before this syntax runs. Must be placed after CannedCycleResolveSyntax and before IncrementalResolveSyntax in the syntax chain.
- CannedCycleResolveSyntax
Resolves canned cycle parameters for the current block: modal repetition detection, G91 incremental-to-absolute conversion, and missing-axis fallback from last known position.
After this syntax, the cycle sub-section in
Parsing(e.g.,Parsing.G83) contains fully resolved absolute coordinates — downstream cycle syntaxes (DrillingCycleSyntax, PeckDrillingCycleSyntax) can read them directly without incremental or modal logic.For modal repetition (no cycle G-code in the current block), merges stored parameters from the previous block's CompoundMotion.Hi.NcParsers.LogicSyntaxs.CannedCycleSyntaxUtil.ResolvedParamsKey with current-block overrides from
Parsingroot, removes consumed keys fromParsingroot, and writes the merged section toParsingunder the cycle code key.Must be placed after PositioningModeSyntax and before the individual cycle syntaxes in the chain.
- CircularMotionSyntax
Writes McArc motion for circular commands (ISO G02/G03). Detects motion mode from Flags, reads I/J/K center offsets or R radius from Parsing, computes arc center in program coordinates, and writes IMotionDef + IArcMotionDef data.
G02/G03 mode is modal (Group 01) — persists via backward lookback. Arc parameters (I/J/K/R) are per-block and must be present in every arc block.
Must be placed before LinearMotionSyntax in the syntax chain. Both share the Group 01 Hi.Motion slot; whichever writes first claims it.
- CoordinateOffsetUtil
Shared utilities for all coordinate offset syntaxes (ISO, Siemens, Heidenhain). Handles section IO, backward lookback, and ProgramToMcTransform composition.
- DrillingCycleSyntax
G81/G82 drilling cycle (rapid retract). Supports modal repetition. G82 covers G81 — the only difference is an optional dwell (P) at the bottom.
Cycle sequence:
- Rapid to init position (target XY, previous Z)
- Rapid from init to R-point
- Feed from R-point to bottom Z
- [G82 only] Dwell P seconds at bottom
- Rapid from bottom to final (G98 → init Z, G99 → R)
Reads absolute coordinates from the cycle section, which is resolved by CannedCycleResolveSyntax (modal repetition, G91 conversion, missing-axis fallback) before this syntax runs. Must be placed after CannedCycleResolveSyntax and before IncrementalResolveSyntax in the syntax chain.
- FeedrateSyntax
Consumes F (feedrate) from Parsing and G94/G95 mode from Flags. Both are modal — persist across blocks via backward node lookback. Writes resolved state to a IFeedrateDef section.
- FineBoringSyntax
G76 fine boring cycle. Supports modal repetition.
Cycle sequence:
- Rapid to init position (target XY, previous Z)
- Rapid from init to R-point
- Feed from R-point to bottom Z
- Oriented spindle stop (OSS)
- Tool shift by Q in +X direction (clear bore wall)
- Rapid retract (shifted) to final Z
- Tool shift back to center
- Spindle restart (CW)
Q specifies the lateral shift distance (mm) to avoid dragging the tool across the finished bore surface during retract. Shift direction defaults to +X (OSS angle 0°).
Reads absolute coordinates from the cycle section, which is resolved by CannedCycleResolveSyntax before this syntax runs.
- G53p1RotaryPositionSyntax
G53.1 — non-modal, one-shot rotary axis positioning. Positions the rotary axes (A/B/C) to align the physical tool axis with the active tilted work plane defined by G68.2. XYZ position is unchanged; only rotary axes move via rapid traverse.
Requires IsoG68p2TiltSyntax (or equivalent) to have written the tilt transform. Uses IMachineKinematics to solve for the target A/B/C via inverse kinematics.
Must be placed after IsoG68p2TiltSyntax (needs tilt data) and before ProgramXyzSyntax in the syntax chain. Writes A/B/C into MachineCoordinate. Motion is handled by LinearMotionSyntax via modal G00/G01.
- HighSpeedPeckCycleSyntax
G73 high-speed peck drilling cycle (chip breaking). Supports modal repetition. Drills in increments of depth Q, partially retracting by PeckRetractionDistance_mm between strokes (instead of fully back to R like PeckDrillingCycleSyntax).
Cycle sequence:
- Rapid to init position (target XY, previous Z)
- Rapid from init to R-point
- For each stroke: feed Q deeper, rapid retract by d
- If remainder exists: feed to bottom Z, rapid retract by d
- Rapid to final (G98 → init Z, G99 → R)
Reads absolute coordinates from the cycle section, which is resolved by CannedCycleResolveSyntax (modal repetition, G91 conversion, missing-axis fallback) before this syntax runs. Must be placed after CannedCycleResolveSyntax and before IncrementalResolveSyntax in the syntax chain.
- IncrementalResolveSyntax
Resolves G91 incremental axis values to absolute in-place within Parsing and its sub-sections. Reads PositioningMode written by PositioningModeSyntax.
WorkingPathList specifies which JSON paths contain axis values that need incremental-to-absolute conversion. Default:
[["Parsing"], ["Parsing", "G28"]]. All matching paths are converted.Canned cycle paths (Parsing.G81, G82, G83, …) are intentionally excluded — their Z/R incremental semantics differ from normal axes (R is relative to init level, Z is relative to R-point). Resolution is handled by ResolveCycleCoordinates(JsonObject, Vec3d, double?, double?, double, double) inside each cycle syntax class, which runs before this syntax.
Uses AxisNames to determine which tags are motion axes. Traces backward nodes for last known ProgramXyz to resolve incremental values. After this syntax, all axis values in the working paths are absolute — ProgramXyzSyntax can consume them without incremental logic.
- IsoCoordinateOffsetSyntax
ISO/Fanuc/Mazak/Okuma/Syntec: resolves G54–G59.9 work coordinate offset. Reads G54/G55/.../G59.9 from Flags, looks up offset Vec3d from IsoCoordinateTable dependency, composes into ProgramToMcTransform. Modal — active coordinate persists via backward lookback. Default coordinate ID is set by StaticInitializer.
- IsoG68RotationSyntax
ISO/Fanuc: resolves G68 (2D coordinate rotation) and G69 (cancel). Computes a rotation Mat4d around the active plane normal and composes it into ProgramToMcTransform.
No IMachineKinematics dependency needed — G68 is pure geometric rotation.
Managed commands: G68, G69 (idempotent with IsoG68p2TiltSyntax).
- IsoG68p2TiltSyntax
ISO/Fanuc: resolves G68.2 (tilted work plane) and G69 (cancel). Computes a tilt Mat4d from I/J/K euler angles (Fanuc ZXZ convention) and composes it into ProgramToMcTransform.
Managed commands: G68.2, G69 (idempotent with IsoG68RotationSyntax). Siemens equivalent: CYCLE800 (separate syntax). Heidenhain equivalent: PLANE SPATIAL (separate syntax).
- IsoLocalCoordinateOffsetSyntax
ISO G52: Local coordinate system offset (additive to G54-series).
ReadsG52 X10 Y20 Z5→ sets local offset.G52 X0 Y0 Z0→ cancels (resets to zero). M30 (program end) → also cancels.Parsing.G52(from G52Syntax), writes LocalCoordinateOffset section, and adds a"LocalCoordinateOffset"entry to the transformation chain. Modal — persists via backward lookback until changed or cancelled.
- LinearMotionSyntax
Writes McLinear motion for linear commands (ISO G00/G01, Heidenhain L/LN). Detects motion mode from Flags, writes IMotionDef section when MachineCoordinate exists.
McLinearMotionSemantic discriminates between XYZ-only and XYZABC motion by checking whether rotary axis values are present in MachineCoordinate.
Modal — persists across blocks via backward node lookback. Must be placed after McAbcSyntax in the syntax chain.
- MachineCoordSelectSyntax
Handles G53 (machine coordinate selection) — non-modal, one-shot. The axis values (X/Y/Z) in the block are interpreted as machine coordinates, bypassing all work offsets, local coordinates, tool height compensation, and coordinate rotations. If G91 (incremental) is active, G53 is ignored per ISO standard.
Must be placed before ProgramXyzSyntax in the syntax chain. When G53 is active, this syntax consumes X/Y/Z from Parsing and writes MachineCoordinate directly, preventing ProgramXyzSyntax from processing them as program coordinates.
- McAbcCyclicPathSyntax
Resolve modular rotary axes to the shortest cyclic path relative to the previous node. Uses IsModularRotary(string) to determine which axes within MachineCoordinate need cyclic resolution. Falls back to hardcoded A/B/C if no IMachineAxisConfig is available. Must be placed after ProgramXyzSyntax in NcSyntaxList.
- McAbcSyntax
Writes rotary axis values (A/B/C) into MachineCoordinate from Parsing.
Only active when IMachineAxisConfig declares rotary axes. Works for both 3+2-axis (no IMachineKinematics) and simultaneous 5-axis configurations.
When MachineCoordinate does not exist (e.g., rotary-only blocks like
G00 A30.with no X/Y/Z), the section is created with XYZ filled from lookback.Missing rotary axes are filled from previous MachineCoordinate lookback, unless the current section already has the value (e.g., from HomeMcInitializer). Values are stored in degrees (matching McAbcCyclicPathSyntax).
Must be placed after McXyzSyntax and before McAbcCyclicPathSyntax and LinearMotionSyntax in the syntax chain.
- McXyzSyntax
Derives MachineCoordinate from ProgramXyz by applying the composed ProgramToMcTransform.
Processes two stages:
- Root
ProgramXyz→ rootMachineCoordinate - CompoundMotion.ItemsKey[*]
— derives
MachineCoordinatefromProgramXyzfor items that haveProgramXyzbut noMachineCoordinate
ProgramXyz(e.g., ReferenceReturnSyntax) and before syntaxes that readMachineCoordinate(e.g., LinearMotionSyntax).- Root
- PeckDrillingCycleSyntax
G83 peck drilling cycle. Supports modal repetition. Drills in increments of depth Q, fully retracting to R between strokes.
Cycle sequence (per stroke):
- Rapid to init position (target XY, previous Z)
- Rapid from init to R-point
- For each stroke: rapid to clearance above previous depth, feed Q deeper, rapid back to R
- If remainder exists: feed to bottom Z, rapid to R
- Rapid from R/bottom to final (G98 → init Z, G99 → R)
Retraction distance is read from ICannedCycleConfig (Fanuc #4002 / Syntec Pr4002, or Generic.FallbackConfig fallback).
Reads absolute coordinates from the cycle section, which is resolved by CannedCycleResolveSyntax (modal repetition, G91 conversion, missing-axis fallback) before this syntax runs. Must be placed after CannedCycleResolveSyntax and before IncrementalResolveSyntax in the syntax chain.
- PositioningModeSyntax
Detects G90/G91 positioning mode from Flags (or by modal lookback) and writes PositioningMode to the block JSON.
Fanuc/ISO: reads G90/G91 from Flags (global modal). Heidenhain: would need a separate implementation reading I-prefix per axis. Siemens: would extend with AC()/IC() per-axis override.
Does NOT convert incremental values — that is handled by IncrementalResolveSyntax which can be placed later in the syntax chain, after canned cycle syntaxes have consumed their parameters with cycle-specific G91 semantics.
- ProgramXyzSyntax
Resolves ProgramXyz (leaf coordinate) from syntax XYZ tags. Writes ProgramXyz sub-object to SyntaxPiece.JsonObject. Must be placed after BundleSyntax since it uses cross-node lookback for last position.
McXyzSyntax (placed after this in the chain) reads ProgramXyz and writes MachineCoordinate.
- ProgramXyzUtil
Shared utilities for ProgramXyz and MachineCoordinate lookback and resolution. Used by ProgramXyzSyntax, ReferenceReturnSyntax, and semantic resolvers that need position lookback.
- ReferenceReturnSyntax
Writes ICompoundMotionDef section for G28 reference point return. Reads intermediate XYZ from
Parsing.G28(written by G28Syntax) and converts to machine coordinates via ResolveProgramXyz(JsonNode, LazyLinkedListNode<SyntaxPiece>, Mat4d).Must be placed after LinearMotionSyntax in the syntax chain. Removes the IMotionDef section written by LinearMotionSyntax (G28 handles its own motion). Overwrites root MachineCoordinate and ProgramXyz with reference position for subsequent block lookback.
- RotaryAxisUtil
Shared utilities for rotary axis (A/B/C) resolution. Used by G53p1RotaryPositionSyntax, McAbcSyntax, IsoG68p2TiltSyntax, and other syntaxes that read or write rotary axis values.
- SpindleSpeedSyntax
Consumes S (spindle speed) and M03/M04/M05 (spindle direction) from Parsing. Both are modal — persist across blocks via backward node lookback. Writes resolved state to a ISpindleSpeedDef section. Direction is converted from ISO M-codes to the conventional SpindleDirection enum at this layer.
- TappingCycleSyntax
G84 (right-hand) / G74 (left-hand) tapping cycles. Supports modal repetition.
Cycle sequence:
- Rapid to init position (target XY, previous Z)
- Rapid from init to R-point
- Feed from R-point to bottom Z
- Spindle reverse at bottom
- Feed retract to final Z (G98 → init Z, G99 → R)
- Spindle restore to forward direction
G84: forward = CW (M03), reverse = CCW (M04). G74: forward = CCW (M04), reverse = CW (M03).
Reads absolute coordinates from the cycle section, which is resolved by CannedCycleResolveSyntax (modal repetition, G91 conversion, missing-axis fallback) before this syntax runs. Must be placed after CannedCycleResolveSyntax and before IncrementalResolveSyntax in the syntax chain.
- TiltTransformUtil
Shared utilities for all tilt transform syntaxes (ISO, Siemens, Heidenhain). Handles section IO, backward lookback, and ProgramToMcTransform composition.
- ToolHeightOffsetSyntax
Resolves tool height offset ID to the effective offset value (mm) and composes the offset as a translation into the accumulated ProgramToMcTransform matrix.
Reads parsed G43/G43.4/G44/G49 flags and H numbers from upstream parsing syntaxes, looks up the offset value from IToolOffsetConfig dependency, writes the resolved state to a IToolHeightCompensationDef section for debuggability, and composes
ProgramToMcTransform.Trans += toolOrientation * height_mm.The tool orientation direction is read from a "ToolOrientation" key in JSON (written by a prior syntax, e.g., ToolOrientationSyntax). If absent, falls back to the current ProgramToMcTransform's AxialNormal (rotated Z). If no transformation exists yet, defaults to UnitZ.