fix SoftNcRunner GM code normalization.

This commit is contained in:
2026-05-16 18:08:13 +08:00
parent e026da61b3
commit 8b285cc863
765 changed files with 18689 additions and 9785 deletions
@@ -88,8 +88,8 @@
<h1 id="glossary-script-commands">Glossary: Script Commands</h1>
<h2 id="what-is-a-script-command">What Is a Script Command?</h2>
<p>A <strong>script command</strong> is a C# statement executed by the HiNC scripting engine. Scripts directly reference members and methods of <a class="xref" href="../../api/Hi.MachiningProcs.RuntimeApi.html">RuntimeApi</a>, which serves as the global scope — no explicit object reference is needed.</p>
<pre><code class="lang-csharp">// These are all RuntimeApi members used directly as globals
<p>A <strong>script command</strong> is a C# statement executed by the HiNC scripting engine. Scripts directly reference members and methods of <a class="xref" href="../../api/Hi.MachiningProcs.SessionShell.html">SessionShell</a>, which serves as the global scope — no explicit object reference is needed.</p>
<pre><code class="lang-csharp">// These are all SessionShell members used directly as globals
EnablePhysics = true;
MachiningResolution_mm = 0.125;
PlayNcFile(&quot;NC/file1.nc&quot;);
@@ -145,19 +145,19 @@ Message(&quot;Done&quot;);
<h3 id="session-lifecycle">Session Lifecycle</h3>
<ol>
<li>Scripts execute in order on the <strong>Task</strong> page</li>
<li>A <a class="xref" href="../../api/Hi.Common.PacePlayer.html">PacePlayer</a><small>(API)</small> controls playback — script commands like <a class="xref" href="../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_PlayNcFile_">PlayNcFile</a><small>(API)</small> block until the NC program completes</li>
<li>Player control commands (<a class="xref" href="../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_Pace">Pace()</a><small>(API)</small>, <a class="xref" href="../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_Pause">Pause()</a><small>(API)</small>, <a class="xref" href="../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_Reset">Reset()</a><small>(API)</small>) interact with the <a class="xref" href="../../api/Hi.Common.PacePlayer.html">PacePlayer</a><small>(API)</small></li>
<li><a class="xref" href="../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_ResetRuntime_">ResetRuntime</a><small>(API)</small> clears event handlers, buffers, and runtime state</li>
<li>A <a class="xref" href="../../api/Hi.Common.PacePlayer.html">PacePlayer</a><small>(API)</small> controls playback — script commands like <a class="xref" href="../../api/Hi.MachiningProcs.SessionShell.html#Hi_MachiningProcs_SessionShell_PlayNcFile_">PlayNcFile</a><small>(API)</small> block until the NC program completes</li>
<li>Player control commands (<a class="xref" href="../../api/Hi.MachiningProcs.SessionShell.html#Hi_MachiningProcs_SessionShell_Pace">Pace()</a><small>(API)</small>, <a class="xref" href="../../api/Hi.MachiningProcs.SessionShell.html#Hi_MachiningProcs_SessionShell_Pause">Pause()</a><small>(API)</small>, <a class="xref" href="../../api/Hi.MachiningProcs.SessionShell.html#Hi_MachiningProcs_SessionShell_Reset">Reset()</a><small>(API)</small>) interact with the <a class="xref" href="../../api/Hi.Common.PacePlayer.html">PacePlayer</a><small>(API)</small></li>
<li><a class="xref" href="../../api/Hi.MachiningProcs.SessionShell.html#Hi_MachiningProcs_SessionShell_ResetRuntime_">ResetRuntime</a><small>(API)</small> clears event handlers, buffers, and runtime state</li>
</ol>
<h3 id="event-driven-execution">Event-Driven Execution</h3>
<p>Events like <a class="xref" href="../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_SessionStepBuilt">SessionStepBuilt</a><small>(API)</small> fire during simulation and allow per-step logic:</p>
<p>Events like <a class="xref" href="../../api/Hi.MachiningProcs.SessionShell.html#Hi_MachiningProcs_SessionShell_SessionStepBuilt">SessionStepBuilt</a><small>(API)</small> fire during simulation and allow per-step logic:</p>
<pre><code class="lang-csharp">SessionStepBuilt += (preStep, curStep) =&gt; {
if (curStep != null)
Message($&quot;Step: ToolId={curStep.ToolId}&quot;);
};
PlayNcFile(&quot;NC/file1.nc&quot;);
</code></pre>
<p>Events are cleared by <a class="xref" href="../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_ResetRuntime_">ResetRuntime</a>.</p>
<p>Events are cleared by <a class="xref" href="../../api/Hi.MachiningProcs.SessionShell.html#Hi_MachiningProcs_SessionShell_ResetRuntime_">ResetRuntime</a>.</p>
<hr>
<h2 id="script-commands-in-nc-code">Script Commands in NC Code</h2>
<p>Script commands can be embedded inside NC code comments. Lines starting with <code>;@</code> execute before that NC line runs:</p>
@@ -184,11 +184,11 @@ WriteShotFiles(&quot;Output/[NcName].shot.csv&quot;, 1);
<li><strong>Do not save the project during simulation.</strong> System-internal configuration (e.g., training-specific resolution overrides) may overwrite your settings.</li>
<li><strong>Do not reset the player during milling coefficient training.</strong> Close the project instead of pressing the reset button to avoid unexpected errors.</li>
<li><strong>Do not modify resolution, tool, or controller settings during training.</strong> Changing these mid-training invalidates the results.</li>
<li><strong>Do not combine <code>UpdateNcOptOption</code> in <a class="xref" href="../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_SessionStepBuilt">SessionStepBuilt</a><small>(API)</small> with NC-embedded optimization commands.</strong> Parallel computation may cause undefined behavior.</li>
<li><strong>Do not combine <code>UpdateNcOptOption</code> in <a class="xref" href="../../api/Hi.MachiningProcs.SessionShell.html#Hi_MachiningProcs_SessionShell_SessionStepBuilt">SessionStepBuilt</a><small>(API)</small> with NC-embedded optimization commands.</strong> Parallel computation may cause undefined behavior.</li>
</ul>
<hr>
<h2 id="global-variables">Global Variables</h2>
<p><a class="xref" href="../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_Global">Global</a> provides a key-value dictionary for sharing data across scripts:</p>
<p><a class="xref" href="../../api/Hi.MachiningProcs.SessionShell.html#Hi_MachiningProcs_SessionShell_Global">Global</a> provides a key-value dictionary for sharing data across scripts:</p>
<pre><code class="lang-csharp">Global[&quot;material&quot;] = &quot;Steel&quot;;
var material = Global[&quot;material&quot;];
</code></pre>
@@ -196,12 +196,12 @@ var material = Global[&quot;material&quot;];
<h2 id="full-api-reference">Full API Reference</h2>
<p>For the complete list of available commands, properties, and events, see:</p>
<ul>
<li><a class="xref" href="../../api/Hi.MachiningProcs.RuntimeApi.html">RuntimeApi</a> — full API documentation</li>
<li><a class="xref" href="runtime-api.html">Glossary: RuntimeApi Quick-Reference</a> — categorized quick-reference table</li>
<li><a class="xref" href="../../api/Hi.MachiningProcs.SessionShell.html">SessionShell</a> — full API documentation</li>
<li><a class="xref" href="session-shell.html">Glossary: SessionShell Quick-Reference</a> — categorized quick-reference table</li>
</ul>
<h2 id="see-also">See Also</h2>
<ul>
<li><a class="xref" href="runtime-api.html">Glossary: RuntimeApi Quick-Reference</a>RuntimeApi quick-reference</li>
<li><a class="xref" href="session-shell.html">Glossary: SessionShell Quick-Reference</a>SessionShell quick-reference</li>
<li><a class="xref" href="machining-step.html">Glossary: Machining Step</a> — machining step data model</li>
<li><a class="xref" href="../../workflows/basic-simulation.html">Workflow: Basic Machining Simulation</a> — using scripts in a simulation workflow</li>
</ul>