Table of Contents

Class UnitModeSyntax

Namespace
Hi.NcParsers.LogicSyntaxs
Assembly
HiMech.dll

Detects the unit-system code (ISO Group 06: G20 inch / G21 metric) from Flags and writes a Unit section (Term, System). Modal — absence of an explicit flag inherits the previous block's unit, defaulting to Metric at program start.

The code vocabulary is configurable per brand: InchCodes / MetricCodes default to ISO G20 / G21; the Siemens preset uses G70+G700 / G710+G71 instead (G70/G71 switch geometry-word interpretation only, G700/G710 also switch feedrate interpretation — a distinction preserved via the verbatim Term but irrelevant to this record-only syntax; both inch variants warn identically). The first MetricCodes entry doubles as the program-start default Term. Note Siemens G70/G71 must never be added to ISO/Fanuc presets — on Fanuc lathes the same codes are finishing/roughing cycles (same collision family as the documented Siemens G74 exclusion).

The HiNC pipeline works exclusively in millimetres. When an inch code is detected this syntax emits an Unit--InchNotSupported Unsupported Error so upstream callers are forced to pre-convert the NC program to metric — while still recording what the program said. Metric codes are accepted as no-op confirmations of the default.

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

Examples

#BeforeBuild:

{ "Parsing": { "Flags": ["G21"] } }

#AfterBuild:

{ "Unit": { "Term": "G21", "System": "Metric" } }

#BeforeBuild:

{ "Parsing": { "Flags": ["G20"] } }

#AfterBuild:

{ "Unit": { "Term": "G20", "System": "Inch" } }

#Previous:

{ "Unit": { "Term": "G21", "System": "Metric" } }

#BeforeBuild:

{ "Parsing": { "Flags": ["M03"] } }

#AfterBuild:

{
  "Parsing": { "Flags": ["M03"] },
  "Unit": { "Term": "G21", "System": "Metric" }
}

Siemens metric confirmation (SUT configured with InchCodes = [“G70”, “G700”], MetricCodes = [“G710”, “G71”]) — corpus header shape N1 G40 G17 G710 G94 G90 G64 reduced to the unit flag; the verbatim code is recorded as Term, unrelated flags stay: #BeforeBuild:

{ "Parsing": { "Flags": ["G40", "G710", "G90"] } }

#AfterBuild:

{
  "Parsing": { "Flags": ["G40", "G90"] },
  "Unit": { "Term": "G710", "System": "Metric" }
}

Siemens inch code — recorded faithfully as Inch despite the Unit–InchNotSupported diagnostic (record what the program said, warn, don't silently coerce): #BeforeBuild:

{ "Parsing": { "Flags": ["G700"] } }

#AfterBuild:

{ "Unit": { "Term": "G700", "System": "Inch" } }

Siemens no-flag block — modal inherit from the previous block's section; program-start default would be the first MetricCodes entry: #Previous:

{ "Unit": { "Term": "G710", "System": "Metric" } }

#BeforeBuild:

{ "Parsing": { "X": 10 } }

#AfterBuild:

{
  "Parsing": { "X": 10 },
  "Unit": { "Term": "G710", "System": "Metric" }
}

Constructors

UnitModeSyntax()

Initializes a new instance with default settings.

public UnitModeSyntax()

UnitModeSyntax(XElement)

Initializes a new instance by deserializing from the given XML element.

public UnitModeSyntax(XElement src)

Parameters

src XElement

Source XML element.

Properties

Default

Default instance with standard settings.

public static UnitModeSyntax Default { get; }

Property Value

UnitModeSyntax

InchCodes

Codes that select the inch input system; each detection emits Unit–InchNotSupported. Defaults to ISO G20; the Siemens preset uses G70 + G700.

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

Property Value

List<string>

MetricCodes

Codes that select the metric input system. Defaults to ISO G21; the Siemens preset uses G710 + G71. The first entry doubles as the program-start default Term.

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

Property Value

List<string>

Name

Syntax kind name (typically the concrete type name).

public string Name { get; }

Property Value

string

XName

XML element name used to register this syntax with XFactory.

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

Parameters

syntaxPieceNode 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