Table of Contents

Interface INcPieceConverter

Namespace
Hi.NcParsers.NcWriteback
Assembly
HiMech.dll

Stage one of the two-stage NC writeback pattern: converts a finished source SyntaxPiece stream (the last layer of a SoftNc pipeline run) into a new destination SyntaxPiece stream whose BlockText holds the produced NC text, together with the src↔dst NcPieceMap. Stage two — serializing the destination stream to text lines — is the shared ToLines(IEnumerable<SyntaxPiece>) (a reversed segmenter), so every converter (cross-dialect synthesis, same-dialect patch, and the future optimization output) reuses one text stage and one mapping mechanism.

Two converter modes share this contract:

  • Patch mode (same dialect as the source) — uses BlockText as the verbatim draft and performs anchored token edits only (feedrate/coordinate rewrites). Zero information loss for untouched text; src↔dst map is 1:1. See NcPatchWriter.
  • Synthesis mode (cross dialect, e.g. NX CLSF → Fanuc) — composes whole lines from the brand-neutral JSON sections (MotionEvent/Feedrate/ProgramXyz/ ProgramToMcTransform/…). The source text does not participate; one src piece maps to n dst pieces. See NcSynthesisConverter, which delegates the per-sentence data→text step to an INcSentenceComposer.

Mode dispatch rule: a piece is patch-eligible when its source dialect (the pipeline's CncBrandDependency) equals TargetBrand; otherwise only synthesis applies.

public interface INcPieceConverter
Extension Methods

Properties

TargetBrand

Target dialect token; one of the CncBrandDependency brand constants.

string TargetBrand { get; }

Property Value

string

Methods

Convert(IEnumerable<SyntaxPiece>, NcDstPieceFactory, NcDiagnosticProgress)

Converts the executed source piece stream into the destination piece stream plus the src↔dst map. Pieces must come from a single source file, in execution order. Problems are reported through conversionProgress with the source piece as the sentence anchor.

NcConversion Convert(IEnumerable<SyntaxPiece> syntaxPieces, NcDstPieceFactory dstPieceFactory, NcDiagnosticProgress conversionProgress)

Parameters

syntaxPieces IEnumerable<SyntaxPiece>

Finished source pieces (final pipeline layer), execution order.

dstPieceFactory NcDstPieceFactory

Factory stamping identity (file path / file index / fresh SentenceIndex) onto the destination pieces.

conversionProgress NcDiagnosticProgress

Diagnostic sink for the manipulation scenario (conversion/optimization) — keep it separate from the NC play diagnostic home; may be null.

Returns

NcConversion

The destination stream and mapping; never null.