This commit is contained in:
2025-12-30 15:43:10 +08:00
parent 955dab6e65
commit 7083653661
44 changed files with 1165 additions and 513 deletions
@@ -208,7 +208,11 @@ public unsafe RenderingCanvas(params IDisplayee[] displayees)
</code></pre><h3 id="input-handling">Input Handling</h3>
<h4 id="windows-message-handling-for-touch">Windows Message Handling for Touch</h4>
<p>WinForm implementation intercepts Windows touch messages and forwards them to DispEngine:</p>
<pre><code class="lang-csharp" name="RenderingCanvas">protected override void WndProc(ref Message m)
<pre><code class="lang-csharp" name="RenderingCanvas">/// &lt;summary&gt;
/// Processes Windows messages, handling touch input and forwarding other messages to the base class.
/// &lt;/summary&gt;
/// &lt;param name=&quot;m&quot;&gt;The Windows message to process.&lt;/param&gt;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_TOUCH)
{
@@ -296,16 +296,12 @@ namespace HiNcRcl.Areas.Player
{
using var _ = await DisposeSemaphore.EmbraceAsync();
if (disposedValue) return;
var machiningProject = MachiningProject;
if (machiningProject != null)
{
LocalProjectService.PacePlayer.IsLockedChangedEvent
+= EnumerablePlayer_IsLockedEventHandler;
LocalProjectService.PacePlayer.IsRunningChangedEvent
+= EnumerablePlayer_IsLockedEventHandler;
LocalProjectService.PacePlayer.IsFinishedChangedEvent
+= EnumerablePlayer_IsLockedEventHandler;
}
LocalProjectService.PacePlayer.IsLockedChangedEvent
+= EnumerablePlayer_IsLockedEventHandler;
LocalProjectService.PacePlayer.IsRunningChangedEvent
+= EnumerablePlayer_IsLockedEventHandler;
LocalProjectService.PacePlayer.IsFinishedChangedEvent
+= EnumerablePlayer_IsLockedEventHandler;
}
}
@@ -313,16 +309,12 @@ namespace HiNcRcl.Areas.Player
public async ValueTask DisposeAsync()
{
using var _ = await DisposeSemaphore.EmbraceAsync();
var machiningProject = MachiningProject;
if (machiningProject != null)
{
LocalProjectService.PacePlayer.IsLockedChangedEvent
-= EnumerablePlayer_IsLockedEventHandler;
LocalProjectService.PacePlayer.IsRunningChangedEvent
-= EnumerablePlayer_IsLockedEventHandler;
LocalProjectService.PacePlayer.IsFinishedChangedEvent
-= EnumerablePlayer_IsLockedEventHandler;
}
LocalProjectService.PacePlayer.IsLockedChangedEvent
-= EnumerablePlayer_IsLockedEventHandler;
LocalProjectService.PacePlayer.IsRunningChangedEvent
-= EnumerablePlayer_IsLockedEventHandler;
LocalProjectService.PacePlayer.IsFinishedChangedEvent
-= EnumerablePlayer_IsLockedEventHandler;
disposedValue = true;
await ValueTask.CompletedTask;
}
@@ -352,21 +344,21 @@ namespace HiNcRcl.Areas.Player
await Task.Run(() =&gt;
{
LocalProjectService.PacePlayer.Pause();
}).ShowIfCatched(this);
}).ShowIfCatched(this);
}
public async Task RunToLineEnd()
{
await Task.Run(() =&gt;
{
LocalProjectService.NcRunner.RunToLineEnd();
}).ShowIfCatched(this);
}).ShowIfCatched(this);
}
public async Task RunToNextPace()
{
await Task.Run(() =&gt;
{
LocalProjectService.PacePlayer.RunToNextPace();
}).ShowIfCatched(this);
}).ShowIfCatched(this);
}
public async Task Break()
{
@@ -87,6 +87,19 @@
<article data-uid="">
<h1 id="release-note">Release Note</h1>
<h2 id="hinc-packages-version-31106">HiNc Packages Version 3.1.106</h2>
<ul>
<li>Rename mapping API for clearer naming:
<ul>
<li><code>ReadCsvByTimeInterpolation</code><a class="xref" href="../../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_MapSingleByCsvFile_">MapSingleByCsvFile</a> (one-to-one mapping)</li>
<li><code>MapByActualTime</code><a class="xref" href="../../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_MapSeriesByCsvFile_">MapSeriesByCsvFile</a> (one-to-many mapping)</li>
</ul>
</li>
<li>Unify CSV column tags to <a class="xref" href="../../../api/Hi.Mapping.MappingUtil.html">MappingUtil</a> for consistent data mapping</li>
<li>Fix <a class="xref" href="../../../api/Hi.CutterLocations.ClStrips.ClStrip.html#Hi_CutterLocations_ClStrips_ClStrip_ChartRange">ChartRange</a> manipulation to be time-based instead of step-based for more accurate time chart display</li>
<li>Tune thread priority for machining parallel processing to improve UI responsiveness during simulation</li>
<li>Various code cleanup and improvements</li>
</ul>
<h2 id="hinc-packages-version-31102">HiNc Packages Version 3.1.102</h2>
<ul>
<li>Separate resource files (Resource, wwwroot, Doc) to HiNc-Resource nuget package for smaller package size</li>
@@ -134,7 +134,7 @@
<h2 id="功率扭矩與能耗">功率、扭矩與能耗</h2>
<ul>
<li>SpindleInputPower_W(輸入功率):進入主軸的能量。</li>
<li>SpindleOutputPower_W(輸出功率):經過主軸能量損耗後,作用於切削端的能量,亦即造成工件與切屑形變、溫度改變的能量。</li>
<li>SpindleOutputPower_W(輸出功率):經過主軸能量損耗後,作用於切削端的能量,亦即造成工件與切屑形變、溫度改變的能量。通常輸出功率與輸入功率成比例,比例為主軸設置中的能量效率 <a class="xref" href="../../../../api/Hi.Milling.SpindleCapability.html#Hi_Milling_SpindleCapability_EnergyEfficiency">EnergyEfficiency</a><small>(API)</small></li>
<li>MaxSpindlePowerRatio(最大主軸功率比率):輸入功率 / 基於主軸性能的瞬間最大功率。</li>
<li>InfInsistentSpindlePowerRatio(持續主軸功率比率):輸入功率 / 基於主軸性能的不限時最大功率。</li>
<li>AccumulatedSpindleEnergyConsumption_kWh:主軸累積能耗。</li>
@@ -98,16 +98,16 @@
<p>一對一的資料映射方式:</p>
<ul>
<li><a class="xref" href="../PlayCsvFile/play-csv-file.html">執行CSV檔</a>:適用控制器資料,每個步階對應一個CSV資料行</li>
<li><a class="xref" href="../../../../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_ReadCsvByTimeInterpolation_">ReadCsvByTimeInterpolation</a><small>(API)</small>:使用時間插值將CSV資料映射到加工步階</li>
<li><a class="xref" href="../../../../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_MapSingleByCsvFile_">MapSingleByCsvFile</a><small>(API)</small>:使用時間插值將CSV資料映射到加工步階</li>
</ul>
<h3 id="playcsvfile">PlayCsvFile</h3>
<p><a class="xref" href="../PlayCsvFile/play-csv-file.html">執行CSV檔</a> 可以與一對多的資料映射協同使用,詳見 <a class="xref" href="../PlayCsvFile/play-csv-file.html">執行CSV檔</a></p>
<h3 id="readcsvbytimeinterpolation">ReadCsvByTimeInterpolation</h3>
<p><a class="xref" href="../../../../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_ReadCsvByTimeInterpolation_">ReadCsvByTimeInterpolation</a><small>(API)</small> 讀取CSV檔案並使用時間插值將資料映射到加工步階。每個仿真步對應一個外部資料點(透過時間插值計算)。</p>
<h3 id="mapsinglebycsvfile">MapSingleByCsvFile</h3>
<p><a class="xref" href="../../../../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_MapSingleByCsvFile_">MapSingleByCsvFile</a><small>(API)</small> 讀取CSV檔案並使用時間插值將資料映射到加工步階。每個仿真步對應一個外部資料點(透過時間插值計算)。</p>
<div class="NOTE">
<h5>Note</h5>
<p><strong>指令格式</strong></p>
<pre><code class="lang-csharp">ReadCsvByTimeInterpolation(&lt;CSV檔案路徑&gt;);
<pre><code class="lang-csharp">MapSingleByCsvFile(&lt;CSV檔案路徑&gt;);
</code></pre>
</div>
<div class="TIP">
@@ -115,7 +115,7 @@
<p><strong>指令範例</strong></p>
<pre><code class="lang-csharp">// 讀取CSV檔案並映射到步階
PlayNcFile(&quot;NC/file1.nc&quot;);
ReadCsvByTimeInterpolation(&quot;Data/sensor.csv&quot;);
MapSingleByCsvFile(&quot;Data/sensor.csv&quot;);
</code></pre>
</div>
<div class="NOTE">
@@ -127,12 +127,12 @@ ReadCsvByTimeInterpolation(&quot;Data/sensor.csv&quot;);
<p>一對多的形式適用智慧刀把、加速規、測力計等高採樣率資料。</p>
<p>一對多的資料映射可以直接<a href="#%E5%B0%8D%E6%87%89%E7%9C%9F%E5%AF%A6%E5%8A%A0%E5%B7%A5%E6%99%82%E9%96%93%E5%85%A8%E5%B1%80%E6%98%A0%E5%B0%84">對應真實加工時間全局映射</a>,也可以對<a href="#%E6%8C%87%E5%AE%9A%E6%95%B8%E6%8E%A7%E8%B7%AF%E5%BE%91%E5%8F%8A%E6%99%82%E9%96%93%E5%B1%80%E9%83%A8%E6%98%A0%E5%B0%84">指定數控路徑及時間局部映射</a></p>
<h3 id="對應真實加工時間全局映射">對應真實加工時間全局映射</h3>
<p>需使用<a class="xref" href="../PlayCsvFile/play-csv-file.html">執行CSV檔</a>作為前置,以獲取真實加工時間,csv檔案中須包含<code>ActualTime</code>欄位(<a class="xref" href="../../../../../api/Hi.MachiningSteps.MachiningStep.html#Hi_MachiningSteps_MachiningStep_ActualTime">ActualTime</a><small>(API)</small>)。然後使用<a class="xref" href="../../../../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_MapByActualTime_">MapByActualTime</a><small>(API)</small>映射外部資料。</p>
<p>需使用<a class="xref" href="../PlayCsvFile/play-csv-file.html">執行CSV檔</a>作為前置,以獲取真實加工時間,csv檔案中須包含<code>ActualTime</code>欄位(<a class="xref" href="../../../../../api/Hi.MachiningSteps.MachiningStep.html#Hi_MachiningSteps_MachiningStep_ActualTime">ActualTime</a><small>(API)</small>)。然後使用<a class="xref" href="../../../../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_MapSeriesByCsvFile_">MapSeriesByCsvFile</a><small>(API)</small>映射外部資料。</p>
<p>此方法為一對多映射,每個仿真步會對應多個外部資料點。</p>
<div class="NOTE">
<h5>Note</h5>
<p><strong>指令格式</strong></p>
<pre><code>MapByActualTime(&lt;檔案名&gt;);
<pre><code>MapSeriesByCsvFile(&lt;檔案名&gt;);
</code></pre>
</div>
<h3 id="指定數控路徑及時間局部映射">指定數控路徑及時間局部映射</h3>
@@ -237,7 +237,36 @@ X25. F10 (;@LineSelection(&quot;lineB&quot;, FirstTouch, null, LastTouch, null);
...
</code></pre>
</div>
<h2 id="外部資料檔案格式">外部資料檔案格式</h2>
<h3 id="選區結束映射設定">選區結束映射設定</h3>
<p><a class="xref" href="../../../../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_EnableMapOnSelectionEnd">EnableMapOnSelectionEnd</a><small>(API)</small> 設定是否在選擇結束時連帶執行映射。</p>
<div class="NOTE">
<h5>Note</h5>
<p><strong>指令格式</strong></p>
<pre><code class="lang-csharp">EnableMapOnSelectionEnd = true; // 或 false
</code></pre>
</div>
<div class="TIP">
<h5>Tip</h5>
<p><strong>指令範例</strong></p>
<pre><code class="lang-csharp">// 啟用選區結束映射
EnableMapOnSelectionEnd = true;
BeginSelection(&quot;region1&quot;);
// ... NC 代碼 ...
EndSelection(&quot;region1&quot;); // 連帶執行映射
// 停用選區結束映射
EnableMapOnSelectionEnd = false;
BeginSelection(&quot;region2&quot;);
// ... NC 代碼 ...
EndSelection(&quot;region2&quot;); // 不連帶執行映射
Map(&quot;region2&quot;); // 手動執行映射
</code></pre>
</div>
<div class="NOTE">
<h5>Note</h5>
<p>預設值為 <code>true</code>。當設為 <code>true</code> 時,<code>EndSelection</code> 會連帶執行對應的 <code>Map</code> 操作。</p>
</div>
<h2 id="感測器資料檔案格式">感測器資料檔案格式</h2>
<p>輸入檔案格式為csv,須包含時間資訊,其餘資訊可選擇包含或不包含。</p>
<p>csv檔案需有標題列,欄位標題需用特定指示詞標示。
部分欄位指示詞為方便性是多擇一。</p>
@@ -277,19 +306,19 @@ X25. F10 (;@LineSelection(&quot;lineB&quot;, FirstTouch, null, LastTouch, null);
<li>X方向力矩:
<ul>
<li><code>Mx</code></li>
<li><code>Spindle.Mx</code></li>
<li><code>Holder.Mx</code></li>
</ul>
</li>
<li>Y方向力矩:
<ul>
<li><code>My</code></li>
<li><code>Spindle.My</code></li>
<li><code>Holder.My</code></li>
</ul>
</li>
<li>Z方向力矩:
<ul>
<li><code>Mz</code></li>
<li><code>Spindle.Mz</code></li>
<li><code>Holder.Mz</code></li>
</ul>
</li>
</ul>
@@ -312,36 +341,48 @@ X25. F10 (;@LineSelection(&quot;lineB&quot;, FirstTouch, null, LastTouch, null);
...
</code></pre>
</div>
<h2 id="其他設置">其他設置</h2>
<h3 id="自動映射設定">自動映射設定</h3>
<p><a class="xref" href="../../../../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_EnableAutoMapOnSelectionEnd">EnableAutoMapOnSelectionEnd</a><small>(API)</small> 設定是否在選擇結束時自動執行映射。</p>
<h2 id="串接控制器資料及感測器資料至數控路徑">串接控制器資料及感測器資料至數控路徑</h2>
<p>因為機台加減速,模擬加工時間與實際加工時間會累積誤差,時間拉長了對不上。所以在資料映射時透過錨點做線性投影。</p>
<ul>
<li>模擬步資料及控制器資料皆含檔案號行號,故可依此設定兩者相應錨點</li>
<li>控制器資料及感測器資料皆含實際時間,故可依此設定兩者相應錨點</li>
</ul>
<p>串接後可使模擬步索引感測器資料。</p>
<div class="NOTE">
<h5>Note</h5>
<p><strong>指令格式</strong></p>
<pre><code class="lang-csharp">EnableAutoMapOnSelectionEnd = true; // 或 false
</code></pre>
<p><strong>為何使用兩層映射?</strong></p>
<p>雖然可以直接使用 <a class="xref" href="../PlayCsvFile/play-csv-file.html">執行CSV檔</a> 執行模擬,但控制器的採樣頻率有限,直接播放會導致模擬路徑失真。</p>
<p>透過系統解譯器解譯數控路徑(<a class="xref" href="../PlayNcFile/index.html">執行NC檔</a>),再將控制器資料與感測器資料映射至模擬步,可獲得較精確的模擬路徑。</p>
</div>
<h3 id="操作流程">操作流程</h3>
<p>依序使用兩指令串聯控制器資料及感測器資料至虛擬環境:</p>
<ol>
<li><p><strong>先使用 <a class="xref" href="../../../../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_MapSingleByCsvFile_">MapSingleByCsvFile</a><small>(API)</small> 將控制器資料映射至模擬數控路徑</strong></p>
<ul>
<li>控制器資料至少包含 <code>FileNo</code><code>LineNo</code><code>ActualTime</code></li>
<li>該指令會依 <code>FileNo</code><code>LineNo</code><code>ActualTime</code> 及其他控制器資料插補至模擬步中</li>
</ul>
</li>
<li><p><strong>而後使用 <a class="xref" href="../../../../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_MapSeriesByCsvFile_">MapSeriesByCsvFile</a><small>(API)</small> 將感測器資料映射至模擬數控路徑</strong></p>
<ul>
<li>感測器資料至少包含 <code>ActualTime</code></li>
<li>該指令會依 <code>ActualTime</code> 將其他感測器資料插補至模擬步中</li>
</ul>
</li>
</ol>
<div class="TIP">
<h5>Tip</h5>
<p><strong>指令範例</strong></p>
<pre><code class="lang-csharp">// 啟用自動映射
EnableAutoMapOnSelectionEnd = true;
BeginSelection(&quot;region1&quot;);
// ... NC 代碼 ...
EndSelection(&quot;region1&quot;); // 自動執行映射
<pre><code class="lang-csharp">// 1. 使用系統解譯器解譯數控路徑(獲得精確的模擬路徑)
PlayNcFile(&quot;NC/machining.nc&quot;);
// 停用自動映射
EnableAutoMapOnSelectionEnd = false;
BeginSelection(&quot;region2&quot;);
// ... NC 代碼 ...
EndSelection(&quot;region2&quot;); // 不自動執行映射
Map(&quot;region2&quot;); // 手動執行映射
// 2. 映射控制器資料(含FileNo, LineNo, ActualTime
MapSingleByCsvFile(&quot;Data/controller.csv&quot;);
// 3. 映射感測器資料(含ActualTime及感測器數據)
MapSeriesByCsvFile(&quot;Data/sensor.csv&quot;);
</code></pre>
</div>
<div class="NOTE">
<h5>Note</h5>
<p>預設值為 <code>true</code>。當設為 <code>true</code> 時,<code>EndSelection</code> 會自動執行對應的 <code>Map</code> 操作。</p>
</div>
</article>