Table of Contents

Class G43p4RtcpSyntax

Namespace
Hi.NcParsers.LogicSyntaxs
Assembly
HiMech.dll

Handles G43.4 RTCP (Rotary Tool Center Point) activation. Writes the IToolHeightCompensationDef section and the ToolHeightCompensationSource entry in ProgramToMcTransform — a tool-normal · offset_mm translation at the block endpoint ABC. The chain entry is tagged KindDynamic when RTCP is active and ABC changes across the block, and KindStatic otherwise.

The RTCP kinematic rotary part (Pn→MC rigid transform) is orthogonal to this syntax and is written by PivotTransformationSyntax on every block, because rotary state remains in effect beyond the RTCP modal (e.g. a non-RTCP G01 after G49 still inherits the last ABC from the program).

The "rotary dynamic" distinction lives on the chain entry's KindKey alone and is read via HasDynamicEntry(JsonObject) by LinearMotionSyntax to pick ClLinear vs McLinear.

G43.4 is used by Fanuc, Mazak, Syntec, and Okuma. Siemens (TRAORI) and Heidenhain (M128) are handled by separate syntaxes. Must be placed after ToolHeightOffsetSyntax (to override the ToolHeightCompensation entry when RTCP is active) and before PivotTransformationSyntax (which runs last in the chain).

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

Examples

Real-kinematics cases below wire TestDeps.CodeKinematics with the default chain code [O][Z][A][w];[O][Y][X][B][S][t] — a table-A / head-B 5-axis machine. A pivots around -X through origin (table side); B pivots around +Y through origin (head side). Both pivot axes pass through (0,0,0) because CodeXyzabcChain uses zero-offset component attachments — the head-B origin pivot is a pedagogical simplification (a real table-head machine has the spindle pivot offset from origin). Realistic MachineCoordinateState therefore carries A and B only; there is no C axis in this chain (5-axis machines have at most two rotary axes).

Verification cue: with B=30° on the head side and the cutter extending +Z in tool frame at ABC=0, the tool normal after the head rotation lies at (sin 30°, 0, cos 30°); multiplying by the 10 mm tool length gives Trans ≈ (5, 0, 8.66).

Explicit G43.4 H1 activation with no IMachineKinematics and no IToolOffsetConfig in the dependency list — exercises the activate path on its identity-matrix corner. The section is written with Offset_mm = 0 (no offset table → rawHeight = 0); the height-mat falls back to the no-kinematics branch new Mat4d { Trans = UnitZ * 0 } which collapses to identity; abcChanged is false (no current MC, no previous block) so the entry is tagged KindStatic.

#BeforeBuild:
{ "Parsing": { "G43.4": { "H": "1" } } }
#AfterBuild:
{
  "ToolHeightCompensation": { "Offset_mm": 0, "Term": "G43.4", "OffsetId": 1 },
  "ProgramToMcTransform": [
    {
      "Source": "ToolHeightCompensation",
      "Kind": "Static",
      "Mat4d": [1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1]
    }
  ]
}
G43.4 H1 with ToolOffset(1 → 10 mm), the real 5-axis solver above, and current block carrying both rotary axes MachineCoordinateState.A = 0, B = 30 (as a prior McAbcSyntax would have written on this machine). The height-mat goes through MakeToolHeightMat(IMachineKinematics, Vec3d, double) which probes kinematics.McToPn(Zero, abc).Normal at abc = (0, π/6, 0) to get the tool orientation, then scales by 10 mm. With no previous block, abcChanged is false → entry stays Static: #BeforeBuild:
{
  "Parsing": { "G43.4": { "H": "1" } },
  "MachineCoordinateState": { "A": 0, "B": 30 }
}
#AfterBuild:
{
  "MachineCoordinateState": { "A": 0, "B": 30 },
  "ToolHeightCompensation": { "Offset_mm": 10, "Term": "G43.4", "OffsetId": 1 },
  "ProgramToMcTransform": [
    {
      "Source": "ToolHeightCompensation",
      "Kind": "Static",
      "Mat4d": [
        1, 0, 0, 0,
        0, 1, 0, 0,
        0, 0, 1, 0,
        4.999999999999999, 0, 8.660254037844387, 1
      ]
    }
  ]
}
Same setup plus a #Previous: block with MachineCoordinateState.B = 0 + XYZ origin — DidAbcChange(LazyLinkedListNode<SyntaxPiece>, IMachineAxisConfig) compares the rotary deltas and finds B changed across the block, so the entry is tagged KindDynamic (signalling that the tool orientation varies along the contour): #Previous:
{
  "MachineCoordinateState": { "X": 0, "Y": 0, "Z": 0, "A": 0, "B": 0 }
}
#BeforeBuild:
{
  "Parsing": { "G43.4": { "H": "1" } },
  "MachineCoordinateState": { "A": 0, "B": 30 }
}
#AfterBuild:
{
  "MachineCoordinateState": { "A": 0, "B": 30 },
  "ToolHeightCompensation": { "Offset_mm": 10, "Term": "G43.4", "OffsetId": 1 },
  "ProgramToMcTransform": [
    {
      "Source": "ToolHeightCompensation",
      "Kind": "Dynamic",
      "Mat4d": [
        1, 0, 0, 0,
        0, 1, 0, 0,
        0, 0, 1, 0,
        4.999999999999999, 0, 8.660254037844387, 1
      ]
    }
  ]
}
Explicit activation whose H did not survive variable evaluation (vacant #100 stays a string) — no offset id resolves, RTCP still activates with a zero-length compensation (identity height mat) and the syntax emits the Comp-ToolHeight--001 validation warning (asserted by the integration test; the dump below pins the JSON shape only): #BeforeBuild:
{ "Parsing": { "G43.4": { "H": "#100" } } }
#AfterBuild:
{
  "ToolHeightCompensation": { "Offset_mm": 0, "Term": "G43.4", "OffsetId": 0 },
  "ProgramToMcTransform": [
    {
      "Source": "ToolHeightCompensation",
      "Kind": "Static",
      "Mat4d": [1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1]
    }
  ]
}
G43.4 with no H word on a block whose ToolChange section says tool 1 is in the spindle — the offset id is the equipped tool number (HardNc parity), the same ToolOffset(1 → 10 mm) and real kinematics as above, no rotary state so the tool normal is +Z and the height-mat carries Trans = (0, 0, 10). A bare G43.4 arrives as a flag (no parameter object to hang an H on): #BeforeBuild:
{
  "Parsing": { "Flags": ["G43.4"] },
  "ToolChange": { "ToolId": 1, "IsChange": true, "Term": "M06" }
}
#AfterBuild:
{
  "ToolChange": { "ToolId": 1, "IsChange": true, "Term": "M06" },
  "ToolHeightCompensation": { "Offset_mm": 10, "Term": "G43.4", "OffsetId": 1 },
  "ProgramToMcTransform": [
    {
      "Source": "ToolHeightCompensation",
      "Kind": "Static",
      "Mat4d": [1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,10,1]
    }
  ]
}
The first block after a program end — #Previous: carries the ProgramEnd section next to the still-active G43.4, and the block itself swings a rotary axis (as a post-M02 G0 A90. does when a CAM file chains several programs). This is the reset edge (ProgramEndSyntax): the controller's reset cancels tool-center-point control, so the modal is not carried, no Dynamic entry is written (the swing stays a plain McLinear rotary move instead of pinning the tool tip), and the block gets the G49 sentinel with the identity Mat4d — ToolHeightOffsetSyntax skipped this block because the previous term was not ISO: #Previous:
{
  "ProgramEnd": { "Term": "M02" },
  "MachineCoordinateState": { "X": 0, "Y": 0, "Z": 0, "A": 0, "B": 0 },
  "ToolHeightCompensation": { "Offset_mm": 10, "Term": "G43.4", "OffsetId": 1 }
}
#BeforeBuild:
{ "MachineCoordinateState": { "A": 90, "B": 0 } }
#AfterBuild:
{
  "MachineCoordinateState": { "A": 90, "B": 0 },
  "ToolHeightCompensation": { "Offset_mm": 0, "Term": "G49", "OffsetId": 0 },
  "ProgramToMcTransform": [
    {
      "Source": "ToolHeightCompensation",
      "Kind": "Static",
      "Mat4d": [1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1]
    }
  ]
}

Constructors

G43p4RtcpSyntax()

Initializes a new instance with default settings.

public G43p4RtcpSyntax()

G43p4RtcpSyntax(XElement)

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

public G43p4RtcpSyntax(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