This commit is contained in:
2026-09-09 17:35:23 +08:00
parent 2a98ae7556
commit 161af68fe3
1271 changed files with 58251 additions and 98639 deletions
@@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="title" content="Class ToolChangeSyntax | HiAPI-C# 2025 ">
<meta name="description" content="Consumes T (tool number) and M06 (tool change) from . T is modal — persists across blocks. M06 triggers the change. Writes resolved state to a ToolChange section: { &amp;ldquo;ToolId&amp;rdquo;: 1, &amp;ldquo;IsChange&amp;rdquo;: true, &amp;ldquo;Term&amp;rdquo;: &amp;ldquo;M06&amp;rdquo; }. records the trigger command and is only written when is true (i.e. the block actually carried the tool-change M code); modal-only blocks omit it. ToolId is an int for numeric calls (T5) and a string for Siemens string tool calls (T=&quot;D8R1&quot;, captured by ); both shapes carry modally. String names are resolved to tool numbers at the semantic layer () — this syntax records the call verbatim. The trigger is machine-configurable. A custom tool-change M-code (Siemens MD22560 $MC_TOOL_CHANGE_M_CODE) is declared on the controller parameter table () and reaches this syntax already expanded to M06 by . Turret/lathe machines where the T word itself performs the change (Siemens MD22550 $MC_TOOL_CHANGE_MODE = 0) set ; the block then triggers with recorded as . Without that config a bare T block stays pre-selection only — magazine rotation is the PLC&#39;s business and moves no feed axis.">
<meta name="description" content="Consumes T (tool number) and M06 (tool change) from . T is modal — persists across blocks. M06 triggers the change. Writes resolved state to a ToolChange section: { &amp;ldquo;ToolId&amp;rdquo;: 1, &amp;ldquo;IsChange&amp;rdquo;: true, &amp;ldquo;Term&amp;rdquo;: &amp;ldquo;M06&amp;rdquo; }. records the trigger command and is only written when is true (i.e. the block actually carried the tool-change M code); modal-only blocks omit it. Two more keys mirror HardNc&#39;s T / PreparationT split. holds the second T of a dual tool word (T10 T2 M06: 10 is loaded, 2 is pre-selected) and is carried until the next change loads it. is written on non-change blocks and names the tool in the spindle — the ToolId of the last change — because ToolId on such a block may already be a pre-selection (T2 alone). Consumers read it through . ToolId is an int for numeric calls (T5) and a string for Siemens string tool calls (T=&quot;D8R1&quot;, captured by ); both shapes carry modally. String names are resolved to tool numbers at the semantic layer () — this syntax records the call verbatim. The trigger is machine-configurable. A custom tool-change M-code (Siemens MD22560 $MC_TOOL_CHANGE_M_CODE) is declared on the controller parameter table () and reaches this syntax already expanded to M06 by . Turret/lathe machines where the T word itself performs the change (Siemens MD22550 $MC_TOOL_CHANGE_MODE = 0) set ; the block then triggers with recorded as . Without that config a bare T block stays pre-selection only — magazine rotation is the PLC&#39;s business and moves no feed axis.">
<link rel="icon" href="../img/HiAPI.favicon.ico">
<link rel="stylesheet" href="../public/docfx.min.css">
<link rel="stylesheet" href="../public/main.css">
@@ -106,6 +106,16 @@ Writes resolved state to a <code>ToolChange</code> section:
when <a class="xref" href="Hi.NcParsers.LogicSyntaxs.ToolChangeSyntax.html#Hi_NcParsers_LogicSyntaxs_ToolChangeSyntax_IsChangeKey">IsChangeKey</a> is true (i.e. the block actually carried
the tool-change M code); modal-only blocks omit it.</p>
<p>
Two more keys mirror HardNc's <code>T</code> / <code>PreparationT</code> split.
<a class="xref" href="Hi.NcParsers.LogicSyntaxs.ToolChangeSyntax.html#Hi_NcParsers_LogicSyntaxs_ToolChangeSyntax_PreparedToolIdKey">PreparedToolIdKey</a> holds the second T of a dual tool word
(<code>T10 T2 M06</code>: 10 is loaded, 2 is pre-selected) and is carried
until the next change loads it. <a class="xref" href="Hi.NcParsers.LogicSyntaxs.ToolChangeSyntax.html#Hi_NcParsers_LogicSyntaxs_ToolChangeSyntax_EquippedToolIdKey">EquippedToolIdKey</a> is
written on non-change blocks and names the tool in the spindle — the
ToolId of the last change — because <code>ToolId</code> on such a block may
already be a pre-selection (<code>T2</code> alone). Consumers read it through
<a class="xref" href="Hi.NcParsers.LogicSyntaxs.ToolChangeSyntax.html#Hi_NcParsers_LogicSyntaxs_ToolChangeSyntax_ReadEquippedToolId_System_Text_Json_Nodes_JsonObject_">ReadEquippedToolId(JsonObject)</a>.
</p>
<p>
<code>ToolId</code> is an int for numeric calls (<code>T5</code>) and a string for
Siemens string tool calls (<code>T="D8R1"</code>, captured by
<a class="xref" href="Hi.NcParsers.ParsingSyntaxs.Siemens.SiemensToolCallSyntax.html">SiemensToolCallSyntax</a>); both
@@ -247,6 +257,36 @@ change and <code>Term</code> records <code>&ldquo;T&rdquo;</code>:
<pre><code class="lang-csharp">{ "Parsing": { "T": 9 } }</code></pre>
<p>#AfterBuild:</p>
<pre><code class="lang-csharp">{ "ToolChange": { "ToolId": 9, "IsChange": true, "Term": "T" } }</code></pre>
<p>Dual tool word <code>T10 T2 M06</code> (Mazak; some Fanuc posts) — the
parser keeps the first T in <code>Parsing.T</code> and lists the second under
<code>RepeatedWords</code>: M06 loads 10, 2 is pre-selected as
<code>PreparedToolId</code> (HardNc: <code>T</code> = first grab on the M06 branch,
the leftover T becomes <code>PreparationT</code>):
#BeforeBuild:</p>
<pre><code class="lang-csharp">{ "Parsing": { "Flags": ["M06"], "T": 10, "RepeatedWords": { "T": [2] } } }</code></pre>
<p>#AfterBuild:</p>
<pre><code class="lang-csharp">{ "ToolChange": { "ToolId": 10, "PreparedToolId": 2, "IsChange": true, "Term": "M06" } }</code></pre>
<p>Bare M06 after a dual tool word — the change loads the prepared tool
and consumes the slot (nothing stays armed):
#Previous:</p>
<pre><code class="lang-csharp">{ "ToolChange": { "ToolId": 10, "PreparedToolId": 2, "IsChange": true, "Term": "M06" } }</code></pre>
<p>#BeforeBuild:</p>
<pre><code class="lang-csharp">{ "Parsing": { "Flags": ["M06"] } }</code></pre>
<p>#AfterBuild:</p>
<pre><code class="lang-csharp">{ "ToolChange": { "ToolId": 2, "IsChange": true, "Term": "M06" } }</code></pre>
<p>A block that performs no change carries the armed tool, the prepared
tool and — for consumers that need the tool in the spindle rather than
the armed one (<a class="xref" href="Hi.NcParsers.LogicSyntaxs.ToolHeightOffsetSyntax.html">ToolHeightOffsetSyntax</a>'s omitted-H
fallback) — <code>EquippedToolId</code>, the ToolId of the last change:
#Previous:</p>
<pre><code class="lang-csharp">{ "ToolChange": { "ToolId": 10, "PreparedToolId": 2, "IsChange": true, "Term": "M06" } }</code></pre>
<p>#BeforeBuild:</p>
<pre><code class="lang-csharp">{ "Parsing": { "Flags": ["M03"] } }</code></pre>
<p>#AfterBuild:</p>
<pre><code class="lang-csharp">{
"Parsing": { "Flags": ["M03"] },
"ToolChange": { "ToolId": 10, "PreparedToolId": 2, "IsChange": false, "EquippedToolId": 10 }
}</code></pre>
@@ -256,6 +296,40 @@ change and <code>Term</code> records <code>&ldquo;T&rdquo;</code>:
<h3 id="Hi_NcParsers_LogicSyntaxs_ToolChangeSyntax_EquippedToolIdKey" data-uid="Hi.NcParsers.LogicSyntaxs.ToolChangeSyntax.EquippedToolIdKey">
EquippedToolIdKey
</h3>
<div class="markdown level1 summary"><p>Section key holding the tool currently in the spindle on blocks
that do not perform a change themselves (on a change block the
equipped tool is <a class="xref" href="Hi.NcParsers.LogicSyntaxs.ToolChangeSyntax.html#Hi_NcParsers_LogicSyntaxs_ToolChangeSyntax_ToolIdKey">ToolIdKey</a>). Read through
<a class="xref" href="Hi.NcParsers.LogicSyntaxs.ToolChangeSyntax.html#Hi_NcParsers_LogicSyntaxs_ToolChangeSyntax_ReadEquippedToolId_System_Text_Json_Nodes_JsonObject_">ReadEquippedToolId(JsonObject)</a>.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public const string EquippedToolIdKey = &quot;EquippedToolId&quot;</code></pre>
</div>
<h4 class="section">Field Value</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
<dd></dd>
</dl>
<h3 id="Hi_NcParsers_LogicSyntaxs_ToolChangeSyntax_IsChangeKey" data-uid="Hi.NcParsers.LogicSyntaxs.ToolChangeSyntax.IsChangeKey">
IsChangeKey
@@ -287,6 +361,39 @@ change and <code>Term</code> records <code>&ldquo;T&rdquo;</code>:
<h3 id="Hi_NcParsers_LogicSyntaxs_ToolChangeSyntax_PreparedToolIdKey" data-uid="Hi.NcParsers.LogicSyntaxs.ToolChangeSyntax.PreparedToolIdKey">
PreparedToolIdKey
</h3>
<div class="markdown level1 summary"><p>Section key holding the tool pre-selected by the SECOND T word of a
dual-word change block (<code>T10 T2 M06</code>: 10 is loaded, 2 is
prepared). Carried modally until the next change consumes it.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public const string PreparedToolIdKey = &quot;PreparedToolId&quot;</code></pre>
</div>
<h4 class="section">Field Value</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
<dd></dd>
</dl>
<h3 id="Hi_NcParsers_LogicSyntaxs_ToolChangeSyntax_SectionName" data-uid="Hi.NcParsers.LogicSyntaxs.ToolChangeSyntax.SectionName">
SectionName
@@ -570,6 +677,48 @@ Since the folder can be moving with the configuration file.</p>
<a id="Hi_NcParsers_LogicSyntaxs_ToolChangeSyntax_ReadEquippedToolId_" data-uid="Hi.NcParsers.LogicSyntaxs.ToolChangeSyntax.ReadEquippedToolId*"></a>
<h3 id="Hi_NcParsers_LogicSyntaxs_ToolChangeSyntax_ReadEquippedToolId_System_Text_Json_Nodes_JsonObject_" data-uid="Hi.NcParsers.LogicSyntaxs.ToolChangeSyntax.ReadEquippedToolId(System.Text.Json.Nodes.JsonObject)">
ReadEquippedToolId(JsonObject)
</h3>
<div class="markdown level1 summary"><p>The numeric tool in the spindle at this block: the block's own
<a class="xref" href="Hi.NcParsers.LogicSyntaxs.ToolChangeSyntax.html#Hi_NcParsers_LogicSyntaxs_ToolChangeSyntax_ToolIdKey">ToolIdKey</a> when it performs the change, otherwise the
carried <a class="xref" href="Hi.NcParsers.LogicSyntaxs.ToolChangeSyntax.html#Hi_NcParsers_LogicSyntaxs_ToolChangeSyntax_EquippedToolIdKey">EquippedToolIdKey</a>. Null before the first
change of the program, and for a string (Siemens name) tool call.
One-step read — no backward walk.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static int? ReadEquippedToolId(JsonObject json)</code></pre>
</div>
<h4 class="section">Parameters</h4>
<dl class="parameters">
<dt><code>json</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.text.json.nodes.jsonobject">JsonObject</a></dt>
<dd><p>The block's JSON object.</p>
</dd>
</dl>
<h4 class="section">Returns</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a>?</dt>
<dd></dd>
</dl>
<a id="Hi_NcParsers_LogicSyntaxs_ToolChangeSyntax_Reg_" data-uid="Hi.NcParsers.LogicSyntaxs.ToolChangeSyntax.Reg*"></a>
<h3 id="Hi_NcParsers_LogicSyntaxs_ToolChangeSyntax_Reg_Hi_Common_XmlUtils_XFactory_" data-uid="Hi.NcParsers.LogicSyntaxs.ToolChangeSyntax.Reg(Hi.Common.XmlUtils.XFactory)">