Table of Contents

Class ProgramEndSyntax

Namespace
Hi.NcParsers.LogicSyntaxs
Assembly
HiMech.dll

Consumes M02/M30 (program end) from Flags and writes IProgramEndDef section.

Downstream syntaxes that need to reset modal state on program end (e.g. IsoLocalCoordinateOffsetSyntax for G52 reset) should read the ProgramEnd section rather than scanning for M30 in Flags directly.

The program-end edge. On a real controller M02/M30 ends the program and enters the reset state: the modal G codes return to their power-on defaults — tool length compensation is cancelled (G49, which also ends tool-center-point control: Fanuc TCP is cancelled by G49 or reset), the tilted work plane and coordinate rotation are cancelled (G69), cutter radius compensation is cancelled (G40), the canned cycle is cancelled (G80). A simulator that plays a file with several programs chained by M02 must keep playing, so the reset is modelled as an edge between the program-end block and its successor: the program-end block itself keeps the modal state it executed under (its own motion — G0 Z100. M30 — still sees the compensation), and the successor starts from the reset defaults. Each modal owner tests the edge with IsResetEdge(LazyLinkedListNode<SyntaxPiece>) in its single-step node.Previous lookback and writes its cancel state on the successor instead of carrying: ToolHeightOffsetSyntax (G43/G44 → G49), G43p4RtcpSyntax (G43.4 → G49), SiemensTraoriSyntax (TRAORI → TRAFOOF, the D compensation itself stays — Siemens retains the active tool on reset), HeidenhainRtcpSyntax (M128 / TCPM → off, TOOL CALL compensation stays), TiltTransformUtil (every tilt / rotation / frame term → G69), RadiusCompensationSyntax (G41/G42 → G40, the modal D is kept) and CannedCycleResolveSyntax (→ G80). Deliberately not reset: G00/G01, G90/G91, G17–G19, G94/G95, the work offset (G54–G59) and the path-smoothing mode — their reset defaults are controller-parameter dependent and they do not enter the program→machine transform chain; G20/G21 is retained by the controller itself. G52 keeps its existing behaviour of clearing on the program-end block (HardNc parity). A block right after the edge that has no words at all (a comment line) is still the edge — every owner handles it before any "no Parsing" early return, or the modal carry would clone the active section across it.

Must be placed before syntaxes that depend on the ProgramEnd section.
public class ProgramEndSyntax : ISituNcSyntax, INcSyntax, IMakeXmlSource
Inheritance
ProgramEndSyntax
Implements
Inherited Members
Extension Methods

Examples

#BeforeBuild:

{ "Parsing": { "Flags": ["M30"] } }

#AfterBuild:

{ "ProgramEnd": { "Term": "M30" } }

#BeforeBuild:

{ "Parsing": { "Flags": ["M02"] } }

#AfterBuild:

{ "ProgramEnd": { "Term": "M02" } }

#BeforeBuild:

{ "Parsing": { "Flags": ["M03"] } }

#AfterBuild:

{ "Parsing": { "Flags": ["M03"] } }

Constructors

ProgramEndSyntax()

Initializes a new instance with default settings.

public ProgramEndSyntax()

ProgramEndSyntax(XElement)

Initializes a new instance by deserializing from the given XML element.

public ProgramEndSyntax(XElement src)

Parameters

src XElement

Source XML element.

Properties

Name

Syntax kind name (typically the concrete type name).

public string Name { get; }

Property Value

string

XName

XML element name used to register this syntax with XFactory.

public static string XName { get; }

Property Value

string

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

syntaxPieceNode LazyLinkedListNode<SyntaxPiece>
ncDependencyList List<INcDependency>
ncDiagnosticProgress NcDiagnosticProgress

IsResetEdge(LazyLinkedListNode<SyntaxPiece>)

True when node is the first block after a program end — its predecessor carries the ProgramEnd section (M02 / M30, or a brand equivalent such as klartext END PGM). Modal owners call this in their node.Previous lookback and, when true, write their reset (cancel) state on node instead of carrying the predecessor's modal forward — see the class summary for the set. The section is one-shot (never carried), so the edge is exactly one block wide.

public static bool IsResetEdge(LazyLinkedListNode<SyntaxPiece> node)

Parameters

node LazyLinkedListNode<SyntaxPiece>

Returns

bool

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

baseDirectory string

The base directory for resolving relative paths

relFile string

The relative file path for the XML source

exhibitionOnly bool

if 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

factory XFactory