Class FanucMacroCallSyntax
- Namespace
- Hi.NcParsers.EvaluationSyntaxs.Fanuc
- Assembly
- HiMech.dll
Inlines a Fanuc Custom Macro B one-shot call (G65 P_ L_ [letter
value …]) into the source layer and binds the call-line argument
letters to Vars.Local #1-#26 per the Type-I map (see
FanucMacroArgumentMap). Every inlined block carries the
binding dict, a clone of the FanucMacroCall diagnostic
record, and a MacroFrame id stamp — so
LocalVariableLookup resolves arg references in a
single-block lookup, a cache dump landing on any block immediately
shows which call it belongs to, and downstream
FanucLocalVariableReadingSyntax carries body-internal
#1-#33 writes forward only within the same frame. The host
block itself records FanucMacroCall but stays in the
caller's frame (no MacroFrame stamp) and emits no
motion act; after the macro body's last inlined block the pipeline
continues naturally into the caller's next block (the inlined pieces
sit ahead of the host block's successor in layers[0]).
Frame isolation works on two layers. Statically, caller blocks
have no MacroFrame stamp (frame id 0 by
Get(JsonObject)), so the inlined frame ids (allocated
fresh per L-repetition) never collide with main. Dynamically,
LocalVariableLookup and
FanucLocalVariableReadingSyntax compare frame ids
before carrying any Vars.Local entry across a block boundary
— a macro body's body-internal writes therefore stay inside the
macro and never leak back into the caller's frame.
Filename lookup mirrors SubProgramCallSyntax:
O{P:D4}.NC, O{P}.NC, O{P:D4}, O{P},
{P:D4}.NC, {P}.NC — first match wins. The lookup root
is InternalFolder (G65 has no
"external storage" variant; M198's external root is M98/M198-only).
L > 1 inlines the same macro L times in series. Each
repetition is a fresh segmentation pass (so each block gets its own
SyntaxPiece JSON object — the downstream pipeline
mutates JSON in place and would clobber sibling repetitions if
instances were shared) and gets a fresh FileIndex (so
(FileIndex, LineIndex) pairs stay unique across the
L-copies of the same source lines).
Recursion rail: a call whose host block already carries
MaxCallDepth CallStack frames is not
inlined. The call word is consumed, the host's
FanucMacroCall record is written with
Skipped (no arguments bound), and
FanucMacroCall--DepthLimitExceeded is reported; the call-line
arguments the evaluator could not resolve are reported before it,
whatever becomes of the call.
Pipeline placement: inside the Fanuc Evaluation
BundleSyntax, right behind
VariableEvaluatorSyntax — whose tag pass turns a call
word written as a variable or bracket expression
(G65 P9010 H[#113] A#101, G65 P#500) into a number, in
the caller's frame, before this syntax binds it and consumes the
sub-object — and ahead of SubProgramCallSyntax
so a hypothetical G65 P_ + M98 P_ on the same block
expands the G65 macro first (would be an unusual but legal
composition). Detection is on the Parsing.G65 sub-object
written by G65Syntax
(a ParameterizedFlagSyntax) — the
keyword "G65" never reaches Parsing.Flags because the
parameterized match has already consumed the text by the time
NumberedFlagSyntax runs.
public class FanucMacroCallSyntax : ISituNcSyntax, INcSyntax, IMakeXmlSource
- Inheritance
-
FanucMacroCallSyntax
- Implements
- Inherited Members
- Extension Methods
Constructors
FanucMacroCallSyntax()
Parameterless instance with the default settings.
public FanucMacroCallSyntax()
FanucMacroCallSyntax(XElement)
Loads MaxCallDepth from XML produced by MakeXmlSource(string, string, bool). An absent, empty or non-numeric element leaves DefaultMaxCallDepth: a controller saved before the element existed loads with the rail at its default.
public FanucMacroCallSyntax(XElement src)
Parameters
Fields
DefaultMaxCallDepth
Default for MaxCallDepth: the Fanuc control's total call nesting, the value DefaultMaxCallDepth documents with its sources. For G65 the same manuals add: “Macro calls can be nested to a depth of up to five levels including simple calls (G65) and modal calls (G66). Subprogram calls can be nested to a depth of up to 15 levels including macro calls” (B-64304EN/02 §14.7.1 Simple Call (G65), Call nesting, p.211; B-64484EN/03 §16.9.1, Limitation, Call nesting, p.461, which reads "(G66/G66.1)"). The rail counts CallStack frames of every kind, so it is the total, not the control's five for macro calls alone: a 6-deep nest of G65 calls is inlined here up to 15 levels, while the control's alarm list names PS0122 TOO MANY MACRO NESTING, “Too many macro calls were nested in a custom macro” (B-64304EN/02 Appendix H, p.976; B-64484EN/03 Appendix H, p.2191).
public const int DefaultMaxCallDepth = 15
Field Value
Properties
MaxCallDepth
Recursion rail, the MaxCallDepth
of G65: a macro that calls itself re-captures its own call inside
every inlined body and would splice without end. A call whose host
block already carries this many CallStack frames is
consumed as a structured safe-skip: the host's
FanucMacroCall record carries
Skipped,
FanucMacroCall–DepthLimitExceeded is reported, nothing is
inlined or bound and nothing moves. The two Fanuc rails read one stack
(M98 / M198, G65 and G66 expansions push onto the same frames), so a
recursion that alternates M98 and G65 is caught by whichever call
stands at the limit. Any integer is taken: 0 or less refuses every
call, the main program's included. The value is written into every
saved controller, so a later change of DefaultMaxCallDepth
reaches a controller saved from this version on only through a legacy
patch. The depth is read, and under-counted after a jump, as
MaxCallDepth describes.
public int MaxCallDepth { get; set; }
Property Value
Name
Syntax kind name (typically the concrete type name).
public string Name { get; }
Property Value
XName
XML element name used to register this syntax with XFactory.
public static string XName { get; }
Property Value
Methods
Build(LazyLinkedListNode<SyntaxPiece>, List<INcDependency>, NcDiagnosticProgress)
Build syntax arrangement into the
syntaxPieceNode in-place.
public void Build(LazyLinkedListNode<SyntaxPiece> syntaxPieceNode, List<INcDependency> ncDependencyList, NcDiagnosticProgress ncDiagnosticProgress)
Parameters
syntaxPieceNodeLazyLinkedListNode<SyntaxPiece>ncDependencyListList<INcDependency>ncDiagnosticProgressNcDiagnosticProgress
MakeXmlSource(string, string, bool)
Creates an XML representation of the object. This method may also generate additional resources such as related files.
public XElement MakeXmlSource(string baseDirectory, string relFile, bool exhibitionOnly)
Parameters
baseDirectorystringThe base directory for resolving relative paths
relFilestringThe relative file path for the XML source
exhibitionOnlyboolif true, the extended file creation is suppressed.
Returns
- XElement
An XML element representing the object's state
Remarks
For the demand of easy moving source folder (especially project folder) without configuration file path corruption, the relative file path is applied.
The baseDirectory is typically the folder at the nearest configuration file folder.
Since the folder can be moving with the configuration file.
Reg(XFactory)
Registers this type's deserializer with the given XFactory
(or Default when factory is
null). Idempotent.
public static void Reg(XFactory factory = null)
Parameters
factoryXFactory