Table of Contents

Class ModalCarrySyntax

Namespace
Hi.NcParsers.PostLogicSyntaxs
Assembly
HiMech.dll

Per-block modal-section carry. For each key in TrackedKeys, if the current block has no section for that key, deep-clone the same section from the immediately previous block (which is itself guaranteed to carry it because every block is processed by this syntax) and set AddedByKey = AddedByValue inside the cloned section. Lets every block stand alone with its full modal context, so downstream readers (cache-file dumps, semantics, UI jumping to a single block) do not need EnumerateBack() to resolve modal state.

A JSON section is a candidate for TrackedKeys when ALL four criteria hold:

  1. Writers concentrated — one or two syntaxes own the section (e.g. LinearMotionSyntax / CircularMotionSyntax own MotionState; the call/return pair own SubProgramCall-derived state).
  2. Readers distributed — multiple downstream consumers each need the value, and none of them should walk back to find it. Single-reader sections do not benefit from blanket carry.
  3. Every block must see the section — cache-dump readers landing randomly, single-block UI views, and look-ahead syntaxes all require the section to be present on every block.
  4. Carry is unconditional — no frame-gating or other per-block veto. Sections that need conditional carry (e.g. FanucLocalVariableReadingSyntax's frame-aware Vars.Local dict-merge — carry only when MacroFrame matches) belong in the owning syntax's own carry logic, not here.
A section failing any criterion should be carried through its owning syntax's own logic (single-step node.Previous read, or no carry at all if absence is meaningful — e.g. MacroFrame absent = main frame).

This replaces the earlier CacheSyntax design (which sampled every Pace blocks). The legacy CacheSyntax XName is still recognised on load for backward compatibility with previously-saved project files.

public class ModalCarrySyntax : ISituNcSyntax, INcSyntax, IMakeXmlSource
Inheritance
ModalCarrySyntax
Implements
Inherited Members
Extension Methods

Constructors

ModalCarrySyntax()

Creates an empty ModalCarrySyntax; populate TrackedKeys before use.

public ModalCarrySyntax()

ModalCarrySyntax(XElement)

Reconstructs a ModalCarrySyntax from a project XML element previously produced by MakeXmlSource(string, string, bool).

public ModalCarrySyntax(XElement src)

Parameters

src XElement

XML element carrying a TrackedKeys child with one Key per entry; null is treated as defaults.

Fields

AddedByValue

Value written under AddedByKey on each section this syntax deep-clones from the previous block. Mirrors AddedByValue's role for its own synthesis — both let cache-file readers distinguish post-Logic / Inspection stage injections from LogicSyntaxs-stage authored values (the latter have no AddedByKey).

public const string AddedByValue = "ModalCarry"

Field Value

string

Properties

Default

Full-set carrier (LogicPostLogic) — retained for the legacy backstop in SoftNcRunner that appends a single ModalCarry to pre-3.1.168 project syntax lists. New brand syntax kits should split into Logic + PostLogic instead.

public static ModalCarrySyntax Default { get; }

Property Value

ModalCarrySyntax

Logic

Logic-stage carrier — modal sections that are written in the Logic bundle and never mutated by PostLogic. Carrying these at the end of each block's Logic bundle keeps single-step node.Previous modal lookups from Logic syntaxes correct, even when a PostLogic syntax (e.g. RadiusCompensationSyntax) does node.Next look-forward and drags subsequent blocks' Logic builds forward before the intermediate block's PostLogic ModalCarry has run.

public static ModalCarrySyntax Logic { get; }

Property Value

ModalCarrySyntax

Name

Syntax kind name (typically the concrete type name).

public string Name { get; }

Property Value

string

PostLogic

PostLogic-stage carrier — modal sections that may still be mutated by PostLogic syntaxes after Logic completes. Today only MachineCoordinateState qualifies (overwritten by RadiusCompensationSyntax with the radius-compensated position). Carrying these at the end of PostLogic ensures the modal value reflects the final, post-compensation state.

public static ModalCarrySyntax PostLogic { get; }

Property Value

ModalCarrySyntax

TrackedKeys

Section keys to carry. Order-insensitive; duplicates ignored.

public List<string> TrackedKeys { get; set; }

Property Value

List<string>

XName

XML element name for Generators registration.

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> node, List<INcDependency> ncDependencyList, NcDiagnosticProgress ncDiagnosticProgress)

Parameters

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

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