Table of Contents

Class SoftNcRunner

Namespace
Hi.NcParsers
Assembly
HiMech.dll

Configurable NC Runner.

public class SoftNcRunner : IControlRunner, IMakeXmlSource
Inheritance
SoftNcRunner
Implements
Inherited Members
Extension Methods

Constructors

SoftNcRunner()

Creates an empty runner; populate the pipeline lists before use.

public SoftNcRunner()

SoftNcRunner(XElement, string, string, IProgress<IMessage>, object[])

Reconstructs a SoftNcRunner from a project XML element. Each pipeline list (PipelineNcDependencyList, Segmenter, NcInitializationList, NcSyntaxList, NcSemanticList) is rehydrated via XFactory.

public SoftNcRunner(XElement src, string baseDirectory, string relFile, IProgress<IMessage> progress, object[] res = null)

Parameters

src XElement

XML element previously produced by MakeXmlSource(string, string, bool).

baseDirectory string

Project base directory for resolving relative paths.

relFile string

Project file path relative to baseDirectory.

progress IProgress<IMessage>

Diagnostic sink propagated to nested factories.

res object[]

Optional ambient resources (e.g. ProjectApiVersion for legacy patches).

Properties

FanucNcRunner

Brand preset for Fanuc — composes a SoftNcRunner whose NcSyntaxList comes from DefaultSyntaxList.

public static SoftNcRunner FanucNcRunner { get; }

Property Value

SoftNcRunner

HeidenhainNcRunner

Brand preset for Heidenhain — composes a SoftNcRunner whose NcSyntaxList comes from DefaultSyntaxList.

public static SoftNcRunner HeidenhainNcRunner { get; }

Property Value

SoftNcRunner

MazakNcRunner

Brand preset for Mazak — composes a SoftNcRunner whose NcSyntaxList comes from DefaultSyntaxList.

public static SoftNcRunner MazakNcRunner { get; }

Property Value

SoftNcRunner

NcInitializationList

Seeds the initial SyntaxPiece JSON state (e.g. home position, defaults).

public List<INcInitializer> NcInitializationList { get; set; }

Property Value

List<INcInitializer>

NcSemanticList

Final-stage semantics that turn the last syntax layer into SourcedActEntry records consumed by the runtime.

public List<INcSemantic> NcSemanticList { get; set; }

Property Value

List<INcSemantic>

NcSyntaxList

Ordered syntax pipeline. Each entry consumes the previous layer's SyntaxPiece stream and emits the next layer.

public List<INcSyntax> NcSyntaxList { get; set; }

Property Value

List<INcSyntax>

PipelineNcDependencyList

External configuration providers consumed by syntaxes/semantics (machine axes, tool offsets, coordinate tables, block-skip flags, etc.). May contain INcDependencyProxy placeholders — see GetEffectiveNcDependencyList().

public List<INcDependency> PipelineNcDependencyList { get; set; }

Property Value

List<INcDependency>

Segmenter

Splits raw NC text into Sentence blocks.

public ISegmenter Segmenter { get; set; }

Property Value

ISegmenter

SiemensNcRunner

Brand preset for Siemens — composes a SoftNcRunner whose NcSyntaxList comes from DefaultSyntaxList.

public static SoftNcRunner SiemensNcRunner { get; }

Property Value

SoftNcRunner

SyntecNcRunner

Brand preset for Syntec — composes a SoftNcRunner whose NcSyntaxList comes from DefaultSyntaxList.

public static SoftNcRunner SyntecNcRunner { get; }

Property Value

SoftNcRunner

XName

XML element name for Generators registration.

public static string XName { get; }

Property Value

string

Methods

ConfigureByMachiningChain(IMachiningChain)

Configures this SoftNcRunner to match the kinematic chain of a machine tool. Registers every axis present on the chain into the IMachineAxisConfig in PipelineNcDependencyList (linear or rotary, derived from whether the chain's transformer implements IDynamicRotation). When the chain carries any rotary axis, a NcKinematicsDependency is appended so that downstream syntaxes / semantics (e.g. G53.1, G68.2, McLinearMotionSemantic) can resolve orientation; its KinematicsProvider is intentionally left null — the owning project service wires it up after the solver instance is available (see LocalProjectService.BuildCoordinateConverter).

The axis / home machine config is read from GetEffectiveNcDependencyList(), so a proxied parameter table resolves to the host's materialized instance — call this only after the proxies' host is wired. The NcKinematicsDependency, by contrast, is a runner-level pipeline dependency and is appended to the runner's own PipelineNcDependencyList below.

public void ConfigureByMachiningChain(IMachiningChain chain)

Parameters

chain IMachiningChain

The machining chain whose axes and kinematics the runner should match. No-op when null.

EnumerateSnapshotSyntaxs()

Enumerates every SnapshotSyntax reachable from NcSyntaxList, including those nested inside any top-level BundleSyntax's inner list. Yields in pipeline-execution order: each top-level slot in turn, and within a bundle slot the bundle's SyntaxList order.

public IEnumerable<SnapshotSyntax> EnumerateSnapshotSyntaxs()

Returns

IEnumerable<SnapshotSyntax>

FromLegacyNcEnvXml(XElement)

Creates a SoftNcRunner brand preset from legacy HardNcEnv XML, picked by the CncBrand element. The returned runner carries proxy placeholders for both per-case data and the (Fanuc-family) parameter table, so machine config and per-case values are not populated here — the owning project wires the proxies to its host, then calls PopulateLegacyMachineConfig(XElement, List<INcDependency>), ConfigureByMachiningChain(IMachiningChain), and PopulateLegacyPerCaseData(XElement, List<INcDependency>) against the resolved host tables. Remove this region when HardNcEnv is fully replaced.

public static SoftNcRunner FromLegacyNcEnvXml(XElement ncEnvXml)

Parameters

ncEnvXml XElement

The inner XML element of the legacy HardNcEnv.

Returns

SoftNcRunner

An unconfigured brand-preset SoftNcRunner.

GetEffectiveNcDependencyList()

Resolves every INcDependencyProxy in PipelineNcDependencyList to the concrete dependency it stands in for (via GetNcDependency()), leaving every non-proxy entry in place. Order is preserved, so downstream OfType<T>().FirstOrDefault() lookups behave exactly as for a proxy-free runner; entries a proxy resolves to null are dropped.

Proxies must have their host wired (InitNcDependencyHost(INcDependencyListHost)) before this is called. RunControlLines(string, IEnumerable<string>, MachiningSession, StepDiagnosticProgress, NcDiagnosticProgress, CancellationToken) resolves the list once per session and caches it on NcRunnerSessionState, so each proxy maps to a single stable instance for the whole session and every pipeline stage sees the same dependencies.

public List<INcDependency> GetEffectiveNcDependencyList()

Returns

List<INcDependency>

GetSourcedActEntrysFromNode(LazyLinkedListNode<SyntaxPiece>, NcDiagnosticProgress, List<INcDependency>, CancellationToken)

Drives the NcSemanticList over the post-syntax SyntaxPiece stream starting at startNode, yielding a SourcedActEntry for each emitted IAct (or a single null-act entry when a semantic produces no acts but still updates the source SyntaxPiece).

public IEnumerable<SourcedActEntry> GetSourcedActEntrysFromNode(LazyLinkedListNode<SyntaxPiece> startNode, NcDiagnosticProgress ncDiagnosticProgress, List<INcDependency> ncDependencyList, CancellationToken cancellationToken)

Parameters

startNode LazyLinkedListNode<SyntaxPiece>

First node to evaluate; iteration walks Next.

ncDiagnosticProgress NcDiagnosticProgress

Sink for semantic exceptions.

ncDependencyList List<INcDependency>

Proxy-resolved dependency list (see GetEffectiveNcDependencyList()) handed to each semantic's Resolve.

cancellationToken CancellationToken

Cancellation token (checked between blocks).

Returns

IEnumerable<SourcedActEntry>

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.

PopulateLegacyMachineConfig(XElement, List<INcDependency>)

Populates legacy machine config — home position, tooling pose/time, rapid rates, and stroke limits — from a legacy HardNcEnv XML element onto targetDeps. Split out of FromLegacyNcEnvXml(XElement) so it runs against the proxy-resolved host list (GetEffectiveNcDependencyList()) after the parameter-table proxy has materialized its host table — the Fanuc-family parameter table (which implements IHomeMcConfig / IRapidFeedrateConfig / IStrokeLimitConfig) is no longer a concrete entry on the runner. No-op for configs with no matching provider.

public static void PopulateLegacyMachineConfig(XElement ncEnvXml, List<INcDependency> targetDeps)

Parameters

ncEnvXml XElement

The inner XML element of the legacy HardNcEnv.

targetDeps List<INcDependency>

The proxy-resolved dependency list holding the machine-config providers.

PopulateLegacyPerCaseData(XElement, List<INcDependency>)

Populates the legacy per-case tables — tool offsets, work coordinate offsets, and (Heidenhain) datum preset/shift tables — from a legacy HardNcEnv XML element into targetDeps. Split out of FromLegacyNcEnvXml(XElement) so the per-case values land on the owning project's PerCaseNcDependencyList (where its proxies have materialized the real tables), not on the shared runner. No-op when targetDeps has no matching table.

public static void PopulateLegacyPerCaseData(XElement ncEnvXml, List<INcDependency> targetDeps)

Parameters

ncEnvXml XElement

The inner XML element of the legacy HardNcEnv.

targetDeps List<INcDependency>

The host dependency list holding the materialized per-case tables.

Reg(XFactory)

Registers SoftNcRunner and chains Reg() on every pipeline component the runner may deserialize from XML — dependencies, initializers, segmenters, parsing/logic/evaluation/post-logic/inspection syntaxes, and semantics. Idempotent; safe to call from any number of boot paths.

public static void Reg(XFactory factory = null)

Parameters

factory XFactory

RunControlLines(string, IEnumerable<string>, MachiningSession, StepDiagnosticProgress, NcDiagnosticProgress, CancellationToken)

Runs raw Control lines and yields source sentence and Act pairs.

public IEnumerable<SourcedActEntry> RunControlLines(string relFilePath, IEnumerable<string> lines, MachiningSession machiningSession, StepDiagnosticProgress stepDiagnosticProgress, NcDiagnosticProgress ncDiagnosticProgress, CancellationToken cancellationToken)

Parameters

relFilePath string

The relative path of the control file

lines IEnumerable<string>

The enumerable collection of command (control code) lines

machiningSession MachiningSession

Session-scoped state shared across multiple RunControlLines(string, IEnumerable<string>, MachiningSession, StepDiagnosticProgress, NcDiagnosticProgress, CancellationToken) calls (e.g. lazy-initialized pipeline state, file-index counter).

stepDiagnosticProgress StepDiagnosticProgress

Step-anchored IMessage-channel sink.

ncDiagnosticProgress NcDiagnosticProgress

NC-pipeline diagnostic sink, threaded in as an input so the runner stays host-agnostic (the caller injects it; the production caller passes the service-scoped instance, standalone tests pass their own).

cancellationToken CancellationToken

Cancellation token to cancel the operation

Returns

IEnumerable<SourcedActEntry>

Enumerable of source sentence and Act pairs

SetAllSnapshotSyntaxEnabled(bool)

Sets IsEnabled on every SnapshotSyntax reachable from NcSyntaxList (including those nested inside top-level BundleSyntax) to isEnabled. Callers that need finer control (per-section toggling, instance inspection) should iterate EnumerateSnapshotSyntaxs() directly.

public void SetAllSnapshotSyntaxEnabled(bool isEnabled)

Parameters

isEnabled bool