Class ProgramEndCleanSyntax
- Namespace
- Hi.NcParsers.LogicSyntaxs
- Assembly
- HiMech.dll
Clears the per-block Vars.Volatile dictionary on blocks that
triggered program end (M02 / M30, identified by the
ProgramEnd section written by ProgramEndSyntax).
Real Fanuc clears non-retained common variables (#100-#499) on program end + reset; this syntax models that behaviour at the simulator level. The clear happens on the same block that carried M02/M30 — the next block's VolatileVariableReadingSyntax carry then sees an empty dictionary on the predecessor and starts fresh.
Pipeline placement: must run after both ProgramEndSyntax (which writes the ProgramEnd section this syntax checks) and VolatileVariableReadingSyntax (so the carry has already happened on this block; this syntax overwrites the result).
Retained common variables (#500-#999, owned by
RetainedCommonVariableTable) are
untouched — they survive program end on real hardware (NV-RAM).
Local variables (#1-#33, scope: macro call frame) are also
untouched here; their lifecycle belongs to G65/G66/M99 push/pop, not
program end.
Also clears any active FanucModalMacro on the same
edge: a G66 modal that was still active when M02/M30 hit is
implicitly cancelled, matching real Fanuc reset behaviour. The
section is overwritten with a G67-shaped cancel marker so
the carry mechanism in
FanucModalMacroSyntax sees the boundary
and does not propagate the modal past the program-end edge.
public class ProgramEndCleanSyntax : ISituNcSyntax, INcSyntax, IMakeXmlSource
- Inheritance
-
ProgramEndCleanSyntax
- Implements
- Inherited Members
- Extension Methods
Examples
M30 with a populated Vars.Volatile — the dictionary is wiped
to an empty JsonObject in place (assignment, not removal, so
downstream snapshots can distinguish “cleared on program end” from
“block never had volatile data”):
#BeforeBuild:
{
"ProgramEnd": { "Term": "M30" },
"Vars": { "Volatile": { "#100": 1.5, "#101": 2.5 } }
}
#AfterBuild:
{
"ProgramEnd": { "Term": "M30" },
"Vars": { "Volatile": {} }
}
M02 with an active G66 FanucModalMacro and no
pre-existing Vars — the modal is overwritten with a
G67-shaped cancel marker (P/L dropped), and a fresh
Vars.Volatile dictionary is created:
#BeforeBuild:
{
"ProgramEnd": { "Term": "M02" },
"FanucModalMacro": { "Term": "G66", "P": 1234, "L": 1 }
}
#AfterBuild:
{
"ProgramEnd": { "Term": "M02" },
"FanucModalMacro": { "Term": "G67" },
"Vars": { "Volatile": {} }
}
No ProgramEnd on the block (regular machining line) — the
guard rejects the block; Vars.Volatile is left intact for
downstream blocks to inherit via carry:
#BeforeBuild:
{ "Vars": { "Volatile": { "#100": 1.5 } } }
#AfterBuild:
{ "Vars": { "Volatile": { "#100": 1.5 } } }
Constructors
ProgramEndCleanSyntax()
Default constructor.
public ProgramEndCleanSyntax()
ProgramEndCleanSyntax(XElement)
Loads from XML produced by MakeXmlSource(string, string, bool); no state.
public ProgramEndCleanSyntax(XElement src)
Parameters
srcXElement
Properties
Name
Syntax kind name (typically the concrete type name).
public string Name { get; }
Property Value
XName
XML element name for Generators registration.
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