Namespace Hi.NcParsers.Dependencys.Fanuc
Classes
- FanucGotoIterationDependency
Watchdog for Fanuc Custom Macro B GOTO loops. Holds a MaxIterationsPerTarget limit (XML-persisted user config — the soft cap above which the upcoming
FanucGotoSyntaxstops firing and emits a warning) plus a runtime per-target hit counter (CountByTarget — not serialised, cleared at session start by the ISessionResettable sweep in RunControlLines(string, IEnumerable<string>, MachiningSession, SessionProgress, CancellationToken)).The dependency is syntax-managed:
FanucGotoSyntaxreads the limit, increments the counter, and decides whether to fire. There is no hostFuncprovider — the dep is placed in Hi.NcParsers.Dependencys.Fanuc rather than Hi.NcParsers.Dependencys.SystemWired because nothing outside the syntax pipeline writes it; OnSessionReset() is the session-init hook the runner invokes through ISessionResettable, not a host-wired Func.The counter key is
(FileName, TargetN)whereFileNameis the source-level file path of the block containing the GOTO (the relative path form carried on FilePath — same form used byIndexedFileLinelabels). Source-level keying means multiple inline invocations of the same subprogram pool their counts (they ARE the same source-code GOTO), while two different files with their own N100 stay isolated (they ARE different jumps).Default MaxIterationsPerTarget is 1000 — a runaway-loop guard, not a precise iteration budget. Legitimate macro loops (multi-hole drill matrices, calibration sweeps) sit well below this; truly infinite loops hit the limit fast. Projects with batch-style macros that legitimately need higher counts can raise the value in the project XML.
- FanucParameterTable
Fanuc controller parameter table. Stores system parameters (single value) and axis parameters (per-axis value) following real Fanuc parameter numbering.
- FanucPositionVariableLookup
Fanuc-style position system variables read from the previous block's runtime-state JSON sections:
#5001-#5003Block-end position X/Y/Z (workpiece) → previous block's ProgramXyz.#5021-#5023Current machine position X/Y/Z → previous block's MachineCoordinateState.#5041-#5043Current absolute position X/Y/Z → previous block's ProgramXyz.
Stateless. Configured on RuntimeVariableLookups rather than
NcDependencyListbecause the read needs the block node for Previous access — there is no long-lived dependency object that owns this data.
- FanucToolOffsetVariableLookup
Fanuc-side adapter that exposes a wrapped ToolOffsetTable (resolved at call time from the dependency list) as an IRuntimeVariableLookup following Fanuc Memory C tool offset addressing:
#2001+N → effective height of offset N(geometry − wear).The underlying ToolOffsetTable stays brand-neutral — Heidenhain / Siemens can use the same storage with different addressing by registering their own adapter alongside the table. Stateless: holds no reference of its own and resolves the table from the per-call
dependencieslist, so XML round-trip is trivial (an empty element).Registered on a brand preset's RuntimeVariableLookups, not on NcDependencyList — the wrapper owns no long-lived data, only the Fanuc-style id addressing scheme. The underlying ToolOffsetTable still lives in
NcDependencyListas the data dependency.
- FanucWhileDoIterationDependency
Watchdog for Fanuc Custom Macro B WHILE/END m bounded loops. Sibling to FanucGotoIterationDependency with the same “soft-cap + runtime counter + session-init ISessionResettable” shape, but kept as a separate dep (rather than sharing the GOTO bucket) so loop and jump iteration limits can be tuned independently and so diagnostic codes do not cross.
The counter key is
(FileName, LoopId)whereFileNameis the source-level file path of the WHILE/END pair (the relative path form carried on FilePath). Source-level keying means multiple inline invocations of the same subprogram pool their counts (same source-code loop), while two different files each with their ownWHILE DO 1stay isolated.The consuming syntax (FanucWhileDoSyntax) increments the counter at the END m reverse-jump step — not on the WHILE entry — so a loop that exits on first WHILE evaluation (condition false from the outset) consumes zero iterations. Above MaxIterationsPerLoopId, the END m block emits a warning and suppresses the redirect; subsequent flow falls through past END.
Default MaxIterationsPerLoopId is 10000 — higher than the GOTO equivalent (1000) because WHILE/END is the legitimate iteration primitive that NcOpt-generated programs (drill grids, adaptive sweeps) depend on, and 1000 is too tight for those.
- RetainedCommonVariableTable
Fanuc-style ISO controller common variable table for the retained range
#500-#999. These variables survive a power cycle (in real hardware they live in NV-RAM) and are serialised into the project file.Excluded by design:
- Local
#1-#33Call-frame scoped (Fanuc local variables); lives in theSyntaxPieceJSON dataflow, not here. - Non-retained common
#100-#499Cleared by program-end / power reset; lives in theSyntaxPieceJSON dataflow as well, not in this table. - System
#1000+Read-only or computed from runtime state; resolved by dedicated reading syntaxes against other dependencies (e.g. FanucParameterTable, tool offset / WCS tables).
Vacant (Fanuc
<vacant>) is represented bynull: either the dictionary has no entry for the key, or the entry maps tonull. Both are treated identically by GetVariable(int).Naming rationale: Fanuc official documentation calls
#500-#999"retained common variables" (and#100-#499"non-retained common variables"). The umbrella term "macro variable" was avoided because it conflicts with Custom Macro B's call-frame concept (G65/G66 push a frame containing the local#1-#33); usingRetainedCommonVariableTablereserves "macro" for the call-frame topic.- Local
Enums
- CutterCompensationType
Fanuc #5003: Cutter compensation startup/cancellation type.