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, and what that state keeps is the
controller's: Fanuc with CLR=0 keeps the modal G codes and drops the
cutter compensation vectors (B-64304EN/02 Appendix F p.959), with CLR=1
returns them to their defaults; Siemens returns every G group to
MD20150 (LIS1 p.256-257). HiNC's edge takes one shape for every
controller — 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) — and names its differences from each controller
below. 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 — a choice of this edge: Siemens' factory
reset setting, MD20110 bit 6 = 0, does not retain the active tool,
LIS1 p.258), HeidenhainRtcpSyntax (M128 / TCPM
→ off, TOOL CALL compensation stays — a choice of this edge too: the TNC
cancels M128 only by M129, FUNCTION RESET TCPM or the selection of a
program, Klartext 892903-2C p.497, TNC7 Programming 1358773-23 p.576,
so an internal stop keeps it), TiltTransformUtil
(every tilt / rotation / frame term → G69),
RadiusCompensationSyntax (G41/G42 →
G40; the modal D is kept, HiNC's choice — Fanuc wants D again after a
reset, B-64304EN-2/01 p.154, Siemens returns the edge number to
MD20130, LIS1 p.258), CannedCycleResolveSyntax
(→ G80), PolarInterpolationSyntax and
PolarGCodeCheckSyntax (G12.1 → G13.1) and
HeidenhainCannedCycleSyntax (the armed
CYCL DEF, its M89 modality and the CYCL CALL POS reference are
dropped). Deliberately not reset: G00/G01, G90/G91, G17–G19, G94/G95
and the work offset (G54–G59) — their reset defaults are
controller-parameter dependent (Fanuc CLR, Siemens MD20150) and they do
not enter the program→machine transform chain — and the path-smoothing
mode, which the controllers do cancel (Fanuc G05.1 on reset,
B-64304EN/02 p.245; Siemens group 10 back to G60, LIS1 p.271): a known
difference. 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.
The reset after a stop. A run that follows a stop in the same session (RunNcLines(INcRunner, string, IEnumerable<string>, CancellationToken)) starts on the same edge: its first block follows a piece that carries this section, with ResetTerm as its term, so the owners above cancel there as they do after M02/M30, and the clears a program-end block makes on itself (ProgramEndCleanSyntax, IsoLocalCoordinateOffsetSyntax) hold there as well. What this edge cancels beyond a controller's reset or internal stop is a known difference of the run after a stop, recorded with that change: Heidenhain keeps M128, PLANE and the rotation across an internal stop when the program is started again from its head without a reset, and drops them -- the datum shift and the mirror with them, which HiNC keeps -- on Reset program or a program selection (TNC7 Setup 1358774-23 p.417, p.419; TNC 640 Setup 1261174-22 p.294); Fanuc with CLR=0 keeps the canned cycle and the two-dimensional G68 (B-64304EN/02 Appendix F p.959; B-64304EN-2/01 p.77), keeps G68.2 and the three-dimensional G68 only while D3R=1 (B-64484EN/03 p.291, p.1924) and the G43.4 vector only while LVK=1 (B-64310EN/02 p.200), and cancels them all when TCP and a tilted plane are combined (B-64484EN/03 p.720). A change to any owner here changes the M02/M30 boundary of every session as well.
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
srcXElementSource XML element.
Fields
ResetTerm
The Term of the resume seed a run after a stop starts from (not a code of any program): IsResetEdge(LazyLinkedListNode<SyntaxPiece>) reads the section's presence alone, so its successor is the reset edge.
public const string ResetTerm = "Reset"
Field Value
Properties
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
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
Returns
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