Table of Contents

Class FileIndexCounterDependency

Namespace
Hi.NcParsers.Dependencys.SystemWired
Assembly
HiMech.dll

Per-session monotonically-increasing file index allocator. Holds the counter as a private field; Allocate() returns the next unused value and increments. OnSessionReset() rewinds to 0 — the owning RunControlLines(string, IEnumerable<string>, MachiningSession, SessionProgress, CancellationToken) invokes it via the ISessionResettable sweep on the same edge that initializes a fresh NcRunnerSessionState, so a controller power-reset clears both the syntax-piece pipeline and this counter in lock-step.

Two consumers share one allocator:

Holding the counter on this dependency rather than on NcRunnerSessionState avoids a duplicate source-of-truth: the dep is the single seam through which syntaxes reach the counter, and there is no third reader that would benefit from session-state visibility.
public class FileIndexCounterDependency : INcDependency, IMakeXmlSource, ISessionResettable
Inheritance
FileIndexCounterDependency
Implements
Inherited Members
Extension Methods

Constructors

FileIndexCounterDependency()

Initializes a new instance with the counter at 0.

public FileIndexCounterDependency()

Properties

XName

XML element name used to register this dependency with XFactory.

public static string XName { get; }

Property Value

string

Methods

Allocate()

Returns the next unused file index and post-increments the counter. First call after construction or OnSessionReset() returns 0.

public int Allocate()

Returns

int

MakeXmlSource(string, string, bool)

Runtime-only dependency — the live counter value is per-session and not meaningful to persist; serialization writes only the empty element so the dependency survives an XML round-trip with the counter implicitly reset to 0.

public XElement MakeXmlSource(string baseDirectory, string relFile, bool exhibitionOnly)

Parameters

baseDirectory string
relFile string
exhibitionOnly bool

Returns

XElement

OnSessionReset()

Rewinds the counter to 0. Called by RunControlLines(string, IEnumerable<string>, MachiningSession, SessionProgress, CancellationToken) via the ISessionResettable sweep on the same edge that initializes a fresh session pipeline so a single brand-preset runner can be reused across sessions without leaking file indices from the previous session.

public void OnSessionReset()

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