Class ToolChangeMotionSyntax
- Namespace
- Hi.NcParsers.LogicSyntaxs
- Assembly
- HiMech.dll
Synthesizes the machine motion of a tool change: on a block whose
SectionName section carries
IsChangeKey = true AND whose tool number
actually differs from the previously equipped tool, overlays
IToolingMcConfig's per-axis tooling position onto the
current machine pose (NaN / missing axis = stays) and emits a one-item
rapid ICompoundMotionDef to that target — the axis travel
a real machine's M06 macro performs before the changer cycle runs.
Root ProgramXyz (and the moved rotary axes
in root MachineCoordinateState)
are overwritten for subsequent-block modal lookback, mirroring
HardNcLine's M06 handling (McXyz/McAbc_rad overlay +
RebuildProgramXyzByMc).
A same-number tool call (M06 without an actual change) emits no motion —
the parity twin of HardNc's preT != T overlay gate. A block with
its own motion words folds them into the single rapid: the overlay
applies on top of the block's commanded position and the stamped
CompoundMotion makes LinearMotionSyntax skip
the block, so one contour covers both — the HardNc M06 branch shape.
Placement: the ReferenceReturnSyntax (G28) slot — after
the offset/frame syntaxes (the ProgramXyz back-derivation needs the
composed transform), before McXyzSyntax /
McAbcCyclicPathSyntax (root MC XYZ backfill; rotary
targets wrapped shortest-path by the cyclic tail-pass).
Programs that retract on their own (G75/G28/SUPA before M06 — every
healthy post) reach the tooling position before the M06 block, so the
synthesized move is zero-length and
CompoundMotionSemantic emits nothing. Only a
program that leaves the tool elsewhere (typically hand-edited) gets an
actual synthesized travel — and the machining steps along it surface
any material contact, plus the runtime's ToolChange--UnsafePose
diagnostic.
public class ToolChangeMotionSyntax : ISituNcSyntax, INcSyntax, IMakeXmlSource
- Inheritance
-
ToolChangeMotionSyntax
- Implements
- Inherited Members
- Extension Methods
Examples
All cases run with a ToolingMcConfig
shaped like Default3Axis
(X/Y stay, Z moves to 0) unless stated otherwise, and leave the
ProgramToMcTransform chain at identity so ProgramXyz
equals MachineCoordinateState.
M06 with an actual tool change (previously equipped tool 1, new tool
2) while the machine sits at (50,60,-20): Z retracts to 0, X/Y keep
the previous position, and the target lands in a one-item rapid
CompoundMotion plus root ProgramXyz for modal lookback:
{
"MachineCoordinateState": { "X": 50, "Y": 60, "Z": -20 },
"ToolChange": { "ToolId": 1, "IsChange": true }
}
#BeforeBuild:
{ "ToolChange": { "ToolId": 2, "IsChange": true, "Term": "M06" } }
#AfterBuild:
{
"ToolChange": { "ToolId": 2, "IsChange": true, "Term": "M06" },
"CompoundMotion": {
"Term": "M06",
"Items": [
{
"MotionEvent": { "Form": "McLinear", "IsRapid": true },
"MachineCoordinateState": { "X": 50, "Y": 60, "Z": 0 }
}
]
},
"ProgramXyz": { "X": 50, "Y": 60, "Z": 0 }
}
Same tool re-called (previous change equipped tool 5, M06 calls 5
again) — no motion is synthesized, the block passes through
untouched:
#Previous:
{
"MachineCoordinateState": { "X": 50, "Y": 60, "Z": -20 },
"ToolChange": { "ToolId": 5, "IsChange": true }
}
#BeforeBuild:
{ "ToolChange": { "ToolId": 5, "IsChange": true, "Term": "M06" } }
#AfterBuild:
{ "ToolChange": { "ToolId": 5, "IsChange": true, "Term": "M06" } }
No IToolingMcConfig dependency — the syntax
early-returns (no motion source to read):
#Previous:
{
"MachineCoordinateState": { "X": 50, "Y": 60, "Z": -20 },
"ToolChange": { "ToolId": 1, "IsChange": true }
}
#BeforeBuild:
{ "ToolChange": { "ToolId": 2, "IsChange": true, "Term": "M06" } }
#AfterBuild:
{ "ToolChange": { "ToolId": 2, "IsChange": true, "Term": "M06" } }
Rotary tooling position: the config additionally sends B to 0 and the
machine declares B rotary; the previous modal B is 30°. The rotary
target rides in the same item and lands in root MC for modal carry
(wrapped shortest-path later by McAbcCyclicPathSyntax):
#Previous:
{
"MachineCoordinateState": { "X": 50, "Y": 60, "Z": -20, "B": 30 },
"ToolChange": { "ToolId": 1, "IsChange": true }
}
#BeforeBuild:
{ "ToolChange": { "ToolId": 2, "IsChange": true, "Term": "M06" } }
#AfterBuild:
{
"ToolChange": { "ToolId": 2, "IsChange": true, "Term": "M06" },
"MachineCoordinateState": { "B": 0 },
"CompoundMotion": {
"Term": "M06",
"Items": [
{
"MotionEvent": { "Form": "McLinear", "IsRapid": true },
"MachineCoordinateState": { "X": 50, "Y": 60, "Z": 0, "B": 0 }
}
]
},
"ProgramXyz": { "X": 50, "Y": 60, "Z": 0 }
}
Machine already at the tooling position (Z at 0) — the overlay target
equals the current pose, so no motion is synthesized:
#Previous:
{
"MachineCoordinateState": { "X": 50, "Y": 60, "Z": 0 },
"ToolChange": { "ToolId": 1, "IsChange": true }
}
#BeforeBuild:
{ "ToolChange": { "ToolId": 2, "IsChange": true, "Term": "M06" } }
#AfterBuild:
{ "ToolChange": { "ToolId": 2, "IsChange": true, "Term": "M06" } }
Properties
Name
Syntax kind name (typically the concrete type name).
public string Name { get; }
Property Value
XName
XML element name used to register this syntax with XFactory.
public static string XName { get; }
Property Value
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
syntaxPieceNodeLazyLinkedListNode<SyntaxPiece>ncDependencyListList<INcDependency>ncDiagnosticProgressNcDiagnosticProgress
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
baseDirectorystringThe base directory for resolving relative paths
relFilestringThe relative file path for the XML source
exhibitionOnlyboolif 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
factoryXFactory