Table of Contents

Class SpindleSpeedSyntax

Namespace
Hi.NcParsers.LogicSyntaxs
Assembly
HiMech.dll

Consumes S (spindle speed) and spindle direction M-codes from Parsing. Both are modal — persist across blocks via backward node lookback. Writes resolved state to a ISpindleSpeedDef section. Direction is converted from M-codes to the conventional SpindleDirection enum at this layer.

Direction M-codes: the ISO defaults M03 (CW) / M04 (CCW) / M05 (STOP) always apply; a machine that starts/stops its spindle with custom M-codes (e.g., ultrasonic M203/M205) declares them on an ISpindleControlConfig dependency (ControllerParameterTableBase), which this syntax consults first — mapped flags are consumed like the ISO ones.

Fallback: an S > 0 with no direction ever issued is contradictory (physics would silently never run). The build assumes CW and emits a one-shot SpindleDirection--AssumedCw validation warning — once is structural, not stateful: the stamped CW propagates modally, so later blocks no longer lack a direction. An explicit M05 (STOP) is a real direction and never triggers the fallback.

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

Examples

New S + M03 (CW) — both consumed; SpindleSpeed section written with the converted direction enum string: #BeforeBuild:

{ "Parsing": { "Flags": ["M03"], "S": 2000 } }

#AfterBuild:

{ "SpindleSpeed": { "SpindleSpeed_rpm": 2000, "Direction": "CW" } }

M04 (CCW) only — RPM inherited from #Previous:; direction updated to the new CCW state: #Previous:

{ "SpindleSpeed": { "SpindleSpeed_rpm": 1500, "Direction": "CW" } }

#BeforeBuild:

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

#AfterBuild:

{ "SpindleSpeed": { "SpindleSpeed_rpm": 1500, "Direction": "CCW" } }

M05 (STOP) only — RPM still carried from #Previous: for bidirectional round-tripping; downstream consumers gate on Direction == STOP rather than RPM == 0: #Previous:

{ "SpindleSpeed": { "SpindleSpeed_rpm": 1500, "Direction": "CW" } }

#BeforeBuild:

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

#AfterBuild:

{ "SpindleSpeed": { "SpindleSpeed_rpm": 1500, "Direction": "STOP" } }

Custom direction M-code (test hardcodes an ISpindleControlConfig dependency mapping M203 → CW) — the mapped flag is consumed exactly like an ISO one: #BeforeBuild:

{ "Parsing": { "Flags": ["M203"], "S": 1670 } }

#AfterBuild:

{ "SpindleSpeed": { "SpindleSpeed_rpm": 1670, "Direction": "CW" } }

S with no direction ever issued — fallback assumes CW (and emits the one-shot SpindleDirection–AssumedCw validation warning): #BeforeBuild:

{ "Parsing": { "S": 1670 } }

#AfterBuild:

{ "SpindleSpeed": { "SpindleSpeed_rpm": 1670, "Direction": "CW" } }

Explicit M05 alongside S — a real direction, fallback must not fire: #BeforeBuild:

{ "Parsing": { "Flags": ["M05"], "S": 500 } }

#AfterBuild:

{ "SpindleSpeed": { "SpindleSpeed_rpm": 500, "Direction": "STOP" } }

Constructors

SpindleSpeedSyntax()

Initializes a new instance with default settings.

public SpindleSpeedSyntax()

SpindleSpeedSyntax(XElement)

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

public SpindleSpeedSyntax(XElement src)

Parameters

src XElement

Source XML element.

Properties

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