543 lines
32 KiB
HTML
543 lines
32 KiB
HTML
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<title>HardNc 到 SoftNc 改寫進度報告 | HiAPI-C# 2025 </title>
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<meta name="title" content="HardNc 到 SoftNc 改寫進度報告 | HiAPI-C# 2025 ">
|
||
|
||
|
||
<link rel="icon" href="../img/HiAPI.favicon.ico">
|
||
<link rel="stylesheet" href="../public/docfx.min.css">
|
||
<link rel="stylesheet" href="../public/main.css">
|
||
<meta name="docfx:navrel" content="../toc.html">
|
||
<meta name="docfx:tocrel" content="toc.html">
|
||
|
||
<meta name="docfx:rel" content="../">
|
||
|
||
|
||
|
||
<meta name="loc:inThisArticle" content="In this article">
|
||
<meta name="loc:searchResultsCount" content="{count} results for "{query}"">
|
||
<meta name="loc:searchNoResults" content="No results for "{query}"">
|
||
<meta name="loc:tocFilter" content="Filter by title">
|
||
<meta name="loc:nextArticle" content="Next">
|
||
<meta name="loc:prevArticle" content="Previous">
|
||
<meta name="loc:themeLight" content="Light">
|
||
<meta name="loc:themeDark" content="Dark">
|
||
<meta name="loc:themeAuto" content="Auto">
|
||
<meta name="loc:changeTheme" content="Change theme">
|
||
<meta name="loc:copy" content="Copy">
|
||
<meta name="loc:downloadPdf" content="Download PDF">
|
||
|
||
<script type="module" src="./../public/docfx.min.js"></script>
|
||
|
||
<script>
|
||
const theme = localStorage.getItem('theme') || 'auto'
|
||
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
|
||
</script>
|
||
|
||
</head>
|
||
|
||
<body class="tex2jax_ignore" data-layout="" data-yaml-mime="">
|
||
<header class="bg-body border-bottom">
|
||
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
|
||
<div class="container-xxl flex-nowrap">
|
||
<a class="navbar-brand" href="../index.html">
|
||
<img id="logo" class="svg" src="../img/HiAPI.logo.png" alt="">
|
||
|
||
</a>
|
||
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
|
||
<i class="bi bi-three-dots"></i>
|
||
</button>
|
||
<div class="collapse navbar-collapse" id="navpanel">
|
||
<div id="navbar">
|
||
<form class="search" role="search" id="search">
|
||
<i class="bi bi-search"></i>
|
||
<input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</nav>
|
||
</header>
|
||
|
||
<main class="container-xxl">
|
||
<div class="toc-offcanvas">
|
||
<div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
|
||
<div class="offcanvas-header">
|
||
<h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
|
||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
|
||
</div>
|
||
<div class="offcanvas-body">
|
||
<nav class="toc" id="toc"></nav>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="content">
|
||
<div class="actionbar">
|
||
<button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
|
||
<i class="bi bi-list"></i>
|
||
</button>
|
||
|
||
<nav id="breadcrumb"></nav>
|
||
</div>
|
||
|
||
<article data-uid="SoftNc-Rewrite-Report">
|
||
<h1 id="hardnc--softnc-改寫進度報告">HardNc → SoftNc 改寫進度報告</h1>
|
||
|
||
<blockquote>
|
||
<p><strong>說明:</strong> 此頁為從最新 release note 連入的暫時性進度頁面。
|
||
內容描述進行中的改寫,未來可能重整、改置或移除,因此並未列入主導覽選單。</p>
|
||
</blockquote>
|
||
<p>HiAPIs 的 NC 解譯器正從早期單體式 <code>HardNcXxx</code> 全面改寫為可重組(reconfigurable)的
|
||
<code>SoftNcXxx</code> pipeline。本頁說明改寫動機、架構轉變、目前完成度,以及剩餘工作。</p>
|
||
<p><strong>Last Updated:</strong> 2026-04-26</p>
|
||
<hr>
|
||
<h2 id="1-executive-summary">1. Executive Summary</h2>
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>指標</th>
|
||
<th>內容</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>客戶需求</td>
|
||
<td>NC 解譯器需「Reconfigurable(可重組)」 — 不同廠牌、不同機械架構、不同 G/M code 集合,必須可由設定檔切換而不需重編譯。</td>
|
||
</tr>
|
||
<tr>
|
||
<td>改寫策略</td>
|
||
<td>將 3,000+ 行的 <a class="xref" href="../api/Hi.Numerical.HardNcLine.html">HardNcLine</a> 單體類別解構為 <a class="xref" href="../api/Hi.NcParsers.Segmenters.ISegmenter.html">ISegmenter</a> + <a class="xref" href="../api/Hi.NcParsers.Initializers.INcInitializer.html">INcInitializer</a> + 多層 <a class="xref" href="../api/Hi.NcParsers.Syntaxs.INcSyntax.html">INcSyntax</a> + <a class="xref" href="../api/Hi.NcParsers.Semantics.INcSemantic.html">INcSemantic</a> + <a class="xref" href="../api/Hi.NcParsers.Dependencys.INcDependency.html">INcDependency</a> 五段 pipeline,全部以介面為主、可由 XML 序列化。</td>
|
||
</tr>
|
||
<tr>
|
||
<td>完成度估算</td>
|
||
<td><strong>ISO 共通部分接近完成</strong> — 主流 G/M code、modal 行為、ISO 座標系、刀具補償、CL/MC 兩段路徑、Cycle、G43.4 RTCP、G68/G68.2 傾斜、單位/暫停/冷卻、診斷系統皆已上線。其他廠牌(Siemens / Syntec / Mazak / Heidenhain)特定語法尚未深入盤點,不敢稱為接近完成。</td>
|
||
</tr>
|
||
<tr>
|
||
<td>仍未動工</td>
|
||
<td>(1) 程式呼叫 / 巨集 / 子程式(<code>CALL</code>, <code>M98</code>, <code>LBL CALL</code>) (2) 數學/邏輯函式(<code>#var = expr</code>, <code>IF/GOTO/WHILE</code>, Q-parameter 算式) (3) <a class="xref" href="../api/Hi.NcOpt.NcOptProc.html">NcOptProc</a> 模組(仍綁定舊 <a class="xref" href="../api/Hi.Numerical.HardNcLine.html">HardNcLine</a> / <a class="xref" href="../api/Hi.Numerical.HardNcEnv.html">HardNcEnv</a>,尚未深入規劃)。</td>
|
||
</tr>
|
||
<tr>
|
||
<td>風險評估</td>
|
||
<td>程式呼叫 / 數學邏輯:低 — 可在現有 <a class="xref" href="../api/Hi.NcParsers.Syntaxs.IExpandingNcSyntax.html">IExpandingNcSyntax</a> / <a class="xref" href="../api/Hi.NcParsers.Syntaxs.INcSyntax.html">INcSyntax</a> / <a class="xref" href="../api/Hi.NcParsers.Dependencys.INcDependency.html">INcDependency</a> 介面下,以「新增實作」而非「改架構」的方式落地。NcOpt:不算低風險,仍有未知的設計工作待釐清。</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<blockquote>
|
||
<p><strong>Hard → Soft 不是改寫一個類別,而是把「規則寫在程式裡」搬成「規則寫在資料裡」。</strong></p>
|
||
</blockquote>
|
||
<hr>
|
||
<h2 id="2-設計哲學三大支柱">2. 設計哲學:三大支柱</h2>
|
||
<p><a class="xref" href="../api/Hi.NcParsers.SoftNcRunner.html">SoftNcRunner</a> 的彈性奠基於三個彼此正交的設計原則。任何一條缺失,整個 pipeline 都會退化回 <a class="xref" href="../api/Hi.Numerical.HardNcLine.html">HardNcLine</a> 那種「想改任何東西都要動到中央類別」的狀態。</p>
|
||
<h3 id="21-xml-configurable--結構即資料">2.1 XML-configurable — 結構即資料</h3>
|
||
<p><code>SoftNcRunner</code> 本身只是一個容器,內部 5 個 List 全部由 XML 載入:</p>
|
||
<pre><code class="lang-xml"><SoftNcRunner>
|
||
<NcDependencyList>...</NcDependencyList> <!-- 1. 依賴設定 -->
|
||
<Segmenter>...</Segmenter> <!-- 2. 段落切分器 -->
|
||
<NcInitializationList>...</NcInitializationList> <!-- 3. 初始化 -->
|
||
<NcSyntaxList>...</NcSyntaxList> <!-- 4. 語法層 -->
|
||
<NcSemanticList>...</NcSemanticList> <!-- 5. 語義層 -->
|
||
</SoftNcRunner>
|
||
</code></pre>
|
||
<p>每個 <a class="xref" href="../api/Hi.NcParsers.Syntaxs.INcSyntax.html">INcSyntax</a> / <a class="xref" href="../api/Hi.NcParsers.Semantics.INcSemantic.html">INcSemantic</a> / <a class="xref" href="../api/Hi.NcParsers.Dependencys.INcDependency.html">INcDependency</a> 都實作 <a class="xref" href="../api/Hi.Common.XmlUtils.IMakeXmlSource.html">IMakeXmlSource</a>,透過 <a class="xref" href="../api/Hi.Common.XmlUtils.XFactory.html">XFactory</a>.<code>Regs.Add(XName, ...)</code> 自動註冊。<strong>新增一個 G code 不需改 SoftNcRunner,只需新增一個 syntax class 並在 XML 加一行。</strong></p>
|
||
<h3 id="22-dataflow-transparent--json-為共通通貨">2.2 DataFlow-transparent — JSON 為共通通貨</h3>
|
||
<p>每個 <a class="xref" href="../api/Hi.NcParsers.Sentence.html">Sentence</a> 通過 pipeline 時帶著一個 <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.text.json.nodes.jsonobject">JsonObject</a>,每一層 syntax 都是「讀某些鍵 → 寫某些鍵 → 移除已消費的鍵」。整段 dataflow 對外可序列化為 JSON,方便:</p>
|
||
<ul>
|
||
<li><strong>除錯</strong> — 可在任何一層之間印出 JSON snapshot 看狀態。</li>
|
||
<li><strong>測試</strong> — unit test 可直接斷言 JSON 結構,不需 mock 整個 NcEnv。</li>
|
||
<li><strong>跨語言整合</strong> — 未來若要做 Web API / Python binding,JSON 即現成傳輸格式。</li>
|
||
</ul>
|
||
<p>JSON 鍵名採「Section + Term」雙層結構:section key 用語義名稱(<code>Unit</code>、<code>Feedrate</code>、<code>Motion</code> ...)跨廠牌一致;NC 代碼實際關鍵字(<code>G21</code> / <code>G94</code> / <code>G01</code>、Heidenhain <code>BLK FORM</code> / <code>LBL</code> / <code>PGM</code> 等)放在子物件的 <code>Term</code> 欄位以保留與原始 NC 的對應。</p>
|
||
<h4 id="範例--一行-nc-block-的-json-結構">範例 — 一行 NC block 的 JSON 結構</h4>
|
||
<p>原始 NC(Fanuc 風格):</p>
|
||
<pre><code class="lang-text">N162 X-14.696 Y-6.42 Z45.638
|
||
</code></pre>
|
||
<p>該 block 通過 pipeline 後的 <a class="xref" href="../api/Hi.NcParsers.Syntaxs.SyntaxPiece.html">SyntaxPiece</a>.<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.text.json.nodes.jsonobject">JsonObject</a> 內容(截自實機輸出,矩陣數值省略):</p>
|
||
<pre><code class="lang-json">{
|
||
"IndexNote": {"Symbol":"N","Number":162},
|
||
"Positioning": {"Term":"G90","Mode":"Absolute"},
|
||
"Unit": {"Term":"G21","System":"Metric"},
|
||
"PlaneSelect": {"Term":"G17","Plane":"XY"},
|
||
"Feedrate": {"FeedrateValue":400,"Term":"G94","Unit":"mm/min"},
|
||
"SpindleSpeed": {"SpindleSpeed_rpm":20000,"Direction":"CW"},
|
||
"Coolant": {"IsOn":true,"Mode":"Flood"},
|
||
"ToolChange": {"ToolId":4,"IsChange":false},
|
||
"TiltTransform": {"Term":"G68.2"},
|
||
"EndPointProgramToMcTransform": [
|
||
{"Source":"TiltTransform", "Mat4d":[ /* 16 doubles */ ]},
|
||
{"Source":"ToolHeightCompensation", "Mat4d":[ /* 16 doubles */ ]},
|
||
{"Source":"CoordinateOffset", "Mat4d":[ /* 16 doubles */ ]},
|
||
{"Source":"PivotTransform", "Mat4d":[ /* 16 doubles */ ]}
|
||
],
|
||
"ToolHeightCompensation": {"Offset_mm":16,"Term":"G43","OffsetId":4},
|
||
"CoordinateOffset": {"CoordinateId":"G54","Offset_X":72.4,"Offset_Y":-72.4,"Offset_Z":-116.44},
|
||
"ProgramXyz": {"X":-14.696,"Y":-6.42,"Z":45.638},
|
||
"MachineCoordinate": {"X":140.5947...,"Y":-78.8200...,"Z":-124.4559...},
|
||
"MotionState": {"Term":"G01"},
|
||
"MotionEvent": {"Form":"McLinear","IsRapid":false},
|
||
"RadiusCompensation": {"Term":"G40","OffsetId":0,"Radius_mm":0}
|
||
}
|
||
</code></pre>
|
||
<p>幾點觀察:</p>
|
||
<ul>
|
||
<li>每一個區塊(<code>Positioning</code>, <code>Feedrate</code>, <code>Coolant</code>, <code>ToolChange</code>, ...)都是某一個 syntax 的輸出 — 例如 <code>Feedrate</code> 來自 <a class="xref" href="../api/Hi.NcParsers.LogicSyntaxs.FeedrateSyntax.html">FeedrateSyntax</a>,<code>MachineCoordinate</code> 來自 <a class="xref" href="../api/Hi.NcParsers.LogicSyntaxs.McXyzSyntax.html">McXyzSyntax</a>。</li>
|
||
<li><code>ProgramXyz</code> 與 <code>MachineCoordinate</code> 並陳:原始 NC 寫的是程式座標,pipeline 終點同時保留兩者,方便 UI / 報表選用。</li>
|
||
<li><code>EndPointProgramToMcTransform</code> 把 Program → MC 的成因鏈攤平為四段(Tilt、ToolHeight、CoordinateOffset、Pivot),每段附上來源變換矩陣 — 若 MC 結果不如預期,看這個陣列就知道是哪一段補正在作怪,不需重跑除錯器。</li>
|
||
<li>modal 狀態(<code>Unit</code> / <code>Positioning</code> / <code>PlaneSelect</code> / 等)即使這一行沒有顯式寫出,也會被前一節的 modal lookback 帶到此處,確保每個 block 的 JSON 都是自足的。</li>
|
||
</ul>
|
||
<h3 id="23-interface-based--消費者導向依賴">2.3 Interface-based — 消費者導向依賴</h3>
|
||
<p>舊系統的 <a class="xref" href="../api/Hi.Numerical.HardNcEnv.html">HardNcEnv</a> 是一個 God Object — 上百個欄位塞在一起,修改任何一個都可能波及無關的 syntax。新系統反過來:每個 syntax 自己宣告需要什麼介面,由 <code>NcDependencyList.OfType<T>()</code> 拉取:</p>
|
||
<pre><code class="lang-csharp">// 範例:G28 ReferenceReturnSyntax 需要 home 座標
|
||
var homeConfig = ncDependencyList.OfType<IHomeMcConfig>().FirstOrDefault();
|
||
</code></pre>
|
||
<p>依賴設定本身也是物件,只要實作對應介面即可注入。新增廠牌只需新增一個 <code>XxxParameterTable : </code> <a class="xref" href="../api/Hi.NcParsers.Dependencys.ControllerParameterTableBase.html">ControllerParameterTableBase</a>。</p>
|
||
<hr>
|
||
<h2 id="3-架構對照圖">3. 架構對照圖</h2>
|
||
<h3 id="31-舊架構hardnc">3.1 舊架構(HardNc)</h3>
|
||
<pre><code class="lang-mermaid">graph TD
|
||
A[NC raw lines] --> B[HardNcRunner]
|
||
B --> C[new HardNcLine ctor]
|
||
C --> D[HardNcEnv God Object<br/>~80 fields, 4 brands hard-coded]
|
||
C --> E[NcProc.GetActs]
|
||
D -.coupled.-> C
|
||
D -.coupled.-> E
|
||
E --> F[IAct stream]
|
||
|
||
style D fill:#fdd,stroke:#c33,color:#000
|
||
style C fill:#fdd,stroke:#c33,color:#000
|
||
</code></pre>
|
||
<p><strong>痛點:</strong></p>
|
||
<ul>
|
||
<li><a class="xref" href="../api/Hi.Numerical.HardNcLine.html">HardNcLine</a> 建構子 = 解析 + modal 累計 + MC 計算 + 補償,全部混在 3,000 行內。</li>
|
||
<li><a class="xref" href="../api/Hi.Numerical.HardNcEnv.html">HardNcEnv</a> 包含所有廠牌設定,CncBrand 切換時用 if/switch 在內部分流。</li>
|
||
<li>新增廠牌 / 自訂語法 = 修改 <a class="xref" href="../api/Hi.Numerical.HardNcLine.html">HardNcLine</a>、<a class="xref" href="../api/Hi.Numerical.HardNcEnv.html">HardNcEnv</a>、<a class="xref" href="../api/Hi.Numerical.NcProc.html">NcProc</a> 三處。</li>
|
||
<li><a class="xref" href="../api/Hi.Numerical.HardNcLine.html">HardNcLine</a> 同時是資料載體、解析狀態機、輸出來源 — 無法在管線中插入第三方步驟。</li>
|
||
</ul>
|
||
<h3 id="32-新架構softnc">3.2 新架構(SoftNc)</h3>
|
||
<pre><code class="lang-mermaid">graph TD
|
||
A[NC raw lines] --> SEG[ISegmenter]
|
||
SEG --> SENT[Sentence stream]
|
||
SENT --> INIT[INcInitializer<br/>HomeMc / Static]
|
||
INIT --> P[ParsingSyntaxs<br/>Layer 1]
|
||
P --> L1[LogicSyntaxs Layer 2<br/>ProgramXyz / McXyz / Motion]
|
||
L1 --> L2[LogicSyntaxs Layer 3<br/>McAbcCyclic / Cleanup]
|
||
L2 --> POST[PostSyntaxs<br/>Cache / Snapshot]
|
||
POST --> SEM[INcSemantic<br/>→ IAct]
|
||
SEM --> OUT[SourcedActEntry]
|
||
|
||
DEP[INcDependency List<br/>BrandTable / IsoCoord / ToolOffset / ...]
|
||
DEP -. injected .-> P
|
||
DEP -. injected .-> L1
|
||
DEP -. injected .-> L2
|
||
DEP -. injected .-> SEM
|
||
|
||
style P fill:#dfd,stroke:#393,color:#000
|
||
style L1 fill:#dfd,stroke:#393,color:#000
|
||
style L2 fill:#dfd,stroke:#393,color:#000
|
||
style POST fill:#dfd,stroke:#393,color:#000
|
||
style SEM fill:#dfd,stroke:#393,color:#000
|
||
</code></pre>
|
||
<p>每一層的「步驟個數、順序、實作類別」都由 XML 決定。新增 G code = 新增一個 syntax 並在 XML 中插入;汰除舊 G code = 從 XML 拿掉那一行。</p>
|
||
<hr>
|
||
<h2 id="4-元件對照表">4. 元件對照表</h2>
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>角色</th>
|
||
<th>HardNc</th>
|
||
<th>SoftNc</th>
|
||
<th>進度</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>主 Runner</td>
|
||
<td><a class="xref" href="../api/Hi.Numerical.FilePlayers.HardNcRunner.html">HardNcRunner</a>(約 165 行)</td>
|
||
<td><a class="xref" href="../api/Hi.NcParsers.SoftNcRunner.html">SoftNcRunner</a>(約 870 行,純編排)</td>
|
||
<td>已完成</td>
|
||
</tr>
|
||
<tr>
|
||
<td>設定容器</td>
|
||
<td><a class="xref" href="../api/Hi.Numerical.HardNcEnv.html">HardNcEnv</a>(約 571 行 God Object)</td>
|
||
<td><code>List<</code><a class="xref" href="../api/Hi.NcParsers.Dependencys.INcDependency.html">INcDependency</a><code>></code> 多介面</td>
|
||
<td>已完成</td>
|
||
</tr>
|
||
<tr>
|
||
<td>NC 行物件</td>
|
||
<td><a class="xref" href="../api/Hi.Numerical.HardNcLine.html">HardNcLine</a>(約 3,118 行)</td>
|
||
<td><a class="xref" href="../api/Hi.NcParsers.Sentence.html">Sentence</a> + <a class="xref" href="../api/Hi.NcParsers.Syntaxs.SyntaxPiece.html">SyntaxPiece</a>(<code>JsonObject</code>)</td>
|
||
<td>已完成</td>
|
||
</tr>
|
||
<tr>
|
||
<td>段落切分</td>
|
||
<td>寫死於 <code>HardNcRunner.BuildNcLinesByRawNcLines</code></td>
|
||
<td><a class="xref" href="../api/Hi.NcParsers.Segmenters.ISegmenter.html">ISegmenter</a>(3 種實作)</td>
|
||
<td>已完成</td>
|
||
</tr>
|
||
<tr>
|
||
<td>初始化</td>
|
||
<td><code>RefNcLineOnInit</code> 隱式</td>
|
||
<td><a class="xref" href="../api/Hi.NcParsers.Initializers.INcInitializer.html">INcInitializer</a> 顯式(2 種實作)</td>
|
||
<td>已完成</td>
|
||
</tr>
|
||
<tr>
|
||
<td>文字解析</td>
|
||
<td><a class="xref" href="../api/Hi.Numerical.HardNcLine.html">HardNcLine</a> 建構子內 regex</td>
|
||
<td><code>ParsingSyntaxs/</code>(約 15 種,寫入 <code>Parsing</code>)</td>
|
||
<td>已完成</td>
|
||
</tr>
|
||
<tr>
|
||
<td>Modal / 跨行邏輯</td>
|
||
<td><a class="xref" href="../api/Hi.Numerical.HardNcLine.html">HardNcLine</a> 內 <code>last:</code> 參考</td>
|
||
<td><code>LogicSyntaxs/</code>(約 36 種,跨節點 lookback)</td>
|
||
<td>已完成</td>
|
||
</tr>
|
||
<tr>
|
||
<td>廠牌專屬語法</td>
|
||
<td><code>if (CncBrand == ...)</code> 內聯</td>
|
||
<td><code>XxxSyntaxUtil.DefaultSyntaxList</code> 五份</td>
|
||
<td>ISO 共通已完成;廠牌特定進行中</td>
|
||
</tr>
|
||
<tr>
|
||
<td>Cycle 處理</td>
|
||
<td><code>HardNcLine.cs</code> 內函式群</td>
|
||
<td><a class="xref" href="../api/Hi.NcParsers.LogicSyntaxs.BoringCycleSyntax.html">BoringCycleSyntax</a> / <a class="xref" href="../api/Hi.NcParsers.LogicSyntaxs.DrillingCycleSyntax.html">DrillingCycleSyntax</a> / <a class="xref" href="../api/Hi.NcParsers.LogicSyntaxs.CannedCycleResolveSyntax.html">CannedCycleResolveSyntax</a> 等</td>
|
||
<td>已完成</td>
|
||
</tr>
|
||
<tr>
|
||
<td>座標系 / 偏移</td>
|
||
<td><code>HardNcEnv.IsoCoordinateTable</code> 等欄位</td>
|
||
<td><a class="xref" href="../api/Hi.NcParsers.Dependencys.Generic.IsoCoordinateTable.html">IsoCoordinateTable</a> / <code>HeidenhainDatumTable</code> / <a class="xref" href="../api/Hi.NcParsers.Dependencys.Generic.ToolOffsetTable.html">ToolOffsetTable</a> 介面</td>
|
||
<td>已完成</td>
|
||
</tr>
|
||
<tr>
|
||
<td>廠牌參數表</td>
|
||
<td><code>HardNcEnv.ConfigurationTable</code> 字典</td>
|
||
<td><a class="xref" href="../api/Hi.NcParsers.Dependencys.Fanuc.FanucParameterTable.html">FanucParameterTable</a> / <a class="xref" href="../api/Hi.NcParsers.Dependencys.Syntec.SyntecParameterTable.html">SyntecParameterTable</a> / <a class="xref" href="../api/Hi.NcParsers.Dependencys.Siemens.SiemensMachineDataTable.html">SiemensMachineDataTable</a> / <a class="xref" href="../api/Hi.NcParsers.Dependencys.Heidenhain.HeidenhainParameterTable.html">HeidenhainParameterTable</a>(繼承 <a class="xref" href="../api/Hi.NcParsers.Dependencys.ControllerParameterTableBase.html">ControllerParameterTableBase</a>)</td>
|
||
<td>已完成</td>
|
||
</tr>
|
||
<tr>
|
||
<td>行程界限</td>
|
||
<td><code>HardNcEnv.CheckStrokeLimit</code></td>
|
||
<td><a class="xref" href="../api/Hi.NcParsers.Dependencys.IStrokeLimitConfig.html">IStrokeLimitConfig</a> + <a class="xref" href="../api/Hi.NcParsers.Semantics.StrokeLimitCheckSemantic.html">StrokeLimitCheckSemantic</a></td>
|
||
<td>已完成</td>
|
||
</tr>
|
||
<tr>
|
||
<td>動作輸出</td>
|
||
<td><a class="xref" href="../api/Hi.Numerical.NcProc.html">NcProc</a>.<code>GetActs</code></td>
|
||
<td><a class="xref" href="../api/Hi.NcParsers.Semantics.INcSemantic.html">INcSemantic</a>.<code>Resolve</code>(12 種)</td>
|
||
<td>已完成</td>
|
||
</tr>
|
||
<tr>
|
||
<td>診斷</td>
|
||
<td><code>sessionProgress.ReportError</code> 字串</td>
|
||
<td><a class="xref" href="../api/Hi.NcParsers.NcDiagnosticProgress.html">NcDiagnosticProgress</a> 結構化(severity / category / ID / sentence)</td>
|
||
<td>已完成</td>
|
||
</tr>
|
||
<tr>
|
||
<td>Cs Script</td>
|
||
<td><code>HardNcUtil.GetSimCsScript</code> 字串切割</td>
|
||
<td><a class="xref" href="../api/Hi.NcParsers.ParsingSyntaxs.CsScriptSyntax.html">CsScriptSyntax</a> + <a class="xref" href="../api/Hi.NcParsers.Semantics.CsScriptBeginSemantic.html">CsScriptBeginSemantic</a> / <a class="xref" href="../api/Hi.NcParsers.Semantics.CsScriptEndSemantic.html">CsScriptEndSemantic</a></td>
|
||
<td>已完成</td>
|
||
</tr>
|
||
<tr>
|
||
<td>子程式 / <code>CALL</code></td>
|
||
<td><a class="xref" href="../api/Hi.Numerical.HardNcLine.html">HardNcLine</a> 內部分支處理</td>
|
||
<td><a class="xref" href="../api/Hi.NcParsers.Syntaxs.IExpandingNcSyntax.html">IExpandingNcSyntax</a> 介面已備好,待建構</td>
|
||
<td>待建構</td>
|
||
</tr>
|
||
<tr>
|
||
<td>數學 / 邏輯函式</td>
|
||
<td><a class="xref" href="../api/Hi.Numerical.HardNcLine.html">HardNcLine</a> 內 <code>IsoNC_Proc</code> P/Invoke</td>
|
||
<td>待建構</td>
|
||
<td>待建構</td>
|
||
</tr>
|
||
<tr>
|
||
<td>NcOpt 模組</td>
|
||
<td>綁 <a class="xref" href="../api/Hi.Numerical.HardNcLine.html">HardNcLine</a> / <a class="xref" href="../api/Hi.Numerical.HardNcEnv.html">HardNcEnv</a></td>
|
||
<td>待建構</td>
|
||
<td>待建構</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<hr>
|
||
<h2 id="5-進度狀態">5. 進度狀態</h2>
|
||
<h3 id="51-已完成--主路徑全綠">5.1 已完成 — 主路徑全綠</h3>
|
||
<p>ISO 共通部分皆已就緒:三層 <a class="xref" href="../api/Hi.NcParsers.Syntaxs.INcSyntax.html">INcSyntax</a> 架構、<a class="xref" href="../api/Hi.NcParsers.Semantics.INcSemantic.html">INcSemantic</a> 動作輸出、<a class="xref" href="../api/Hi.NcParsers.Dependencys.INcDependency.html">INcDependency</a>
|
||
注入、廠牌參數表、ISO Logic Syntax、Motion + Compound Motion + Spindle 語義、
|
||
Canned Cycle G73–G89、Group-09 Cycle modal 狀態管理、G41/G42 Radius Compensation、
|
||
G68/G68.2/G69 傾斜、G43.4 RTCP、G53/G53.1、Mc ABC 旋轉軸最短路徑、ProgramXyz 追蹤、
|
||
ISO Coordinate Table 字串 key 遷移、Block Skip 多層管控、Unit / ProgramStop /
|
||
Coolant Mist、G28 / Comment / CncBrand / 版本 / CsScript、Cache Syntax(modal
|
||
lookback O(N·Pace))、結構化 <a class="xref" href="../api/Hi.NcParsers.NcDiagnosticProgress.html">NcDiagnosticProgress</a> 診斷、<a class="xref" href="../api/Hi.MachiningProcs.LocalProjectService.html">LocalProjectService</a> / <a class="xref" href="../api/Hi.MachiningProcs.MachiningProject.html">MachiningProject</a> 整合,以及
|
||
<a class="xref" href="../api/Hi.MachiningProcs.SessionShell.html">SessionShell</a> Session Events。</p>
|
||
<h3 id="52-仍未動工">5.2 仍未動工</h3>
|
||
<h4 id="521-各廠牌特定語法尚未深入盤點">5.2.1 各廠牌特定語法尚未深入盤點</h4>
|
||
<p>ISO 共通部分接近完成;但每個廠牌都有大量自有語法尚未動工,下表僅是樣本:</p>
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>廠牌</th>
|
||
<th>待動工樣本</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>Fanuc</td>
|
||
<td>Custom Macro B 細節、<code>G10</code> Programmable Data Setting、<code>G50</code> 主軸限制、<code>G31</code> Skip、Polar 完整支援</td>
|
||
</tr>
|
||
<tr>
|
||
<td>Siemens</td>
|
||
<td><code>TRAORI</code> / <code>TRAFOOF</code>、<code>CYCLE800</code> 傾斜、<code>MSG</code> / <code>STOPRE</code>、Frame 體系(<code>TRANS</code> / <code>ROT</code> / <code>SCALE</code> / <code>MIRROR</code>)、GUD/PUD 變數、<code>SETAL</code> 警報</td>
|
||
</tr>
|
||
<tr>
|
||
<td>Syntec</td>
|
||
<td>自訂 G 巨集、Pr 系列參數對應、雙頭 / 雙刀塔語法</td>
|
||
</tr>
|
||
<tr>
|
||
<td>Mazak</td>
|
||
<td>Mazatrol 對話式區段、MAZATROL ↔ EIA/ISO 切換、Mazak 特有 G/M 號碼差異</td>
|
||
</tr>
|
||
<tr>
|
||
<td>Heidenhain</td>
|
||
<td><code>FK</code> Free Contour、<code>SL</code> Cycle、<code>PATTERN DEF</code>、<code>TCH PROBE</code> 量測循環、<code>TOOL DEF</code> / <code>TOOL CALL</code> 進階欄位、<code>PLANE</code> 完整 7 種模式</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p>架構上不需改 pipeline;新增廠牌語法 = 新增 <a class="xref" href="../api/Hi.NcParsers.Syntaxs.INcSyntax.html">INcSyntax</a> 實作 + 註冊 + 加入該廠牌
|
||
<code>XxxSyntaxUtil.DefaultSyntaxList</code>。但實作數量大,需依客戶優先序逐項展開。</p>
|
||
<h4 id="522-程式呼叫--subprogram--macro-call">5.2.2 程式呼叫 — subprogram / macro call</h4>
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>對象</th>
|
||
<th>描述</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>ISO <code>M98 P_ L_</code> / <code>M99</code></td>
|
||
<td>Fanuc / Syntec / Mazak 子程式呼叫與返回</td>
|
||
</tr>
|
||
<tr>
|
||
<td>Heidenhain <code>LBL <n></code> / <code>CALL LBL <n> REPn</code></td>
|
||
<td>標籤定義與重複呼叫</td>
|
||
</tr>
|
||
<tr>
|
||
<td>Heidenhain <code>PGM CALL "<file>"</code></td>
|
||
<td>外部檔案呼叫</td>
|
||
</tr>
|
||
<tr>
|
||
<td>Siemens <code><name></code> 子程式</td>
|
||
<td>自訂子程式名稱呼叫</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p><a class="xref" href="../api/Hi.NcParsers.Syntaxs.IExpandingNcSyntax.html">IExpandingNcSyntax</a>.<code>Expand()</code> 介面正是為此設計 — 允許一個 <a class="xref" href="../api/Hi.NcParsers.Syntaxs.SyntaxPiece.html">SyntaxPiece</a> 在管線中被展開為多個。已有 <a class="xref" href="../api/Hi.NcParsers.ParsingSyntaxs.Heidenhain.HeidenhainCallSyntax.html">HeidenhainCallSyntax</a>、<a class="xref" href="../api/Hi.NcParsers.ParsingSyntaxs.Heidenhain.HeidenhainLblSyntax.html">HeidenhainLblSyntax</a> 在 ParsingSyntax 層解析出 <code>Parsing.CALL</code> / <code>Parsing.LBL</code> 結構但尚未連到 expander。</p>
|
||
<h4 id="523-數學--邏輯函式macro--control-flow">5.2.3 數學 / 邏輯函式(macro / control flow)</h4>
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>對象</th>
|
||
<th>描述</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>Fanuc Custom Macro B</td>
|
||
<td><code>#100=...</code>、<code>IF [...] GOTO n</code>、<code>WHILE [...] DO n / END n</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td>Heidenhain Q-Parameter</td>
|
||
<td><code>Q1 = Q2 + Q3</code>、<code>FN0</code> ~ <code>FN26</code>、<code>IF Q1 EQU 0 GOTO LBL</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td>Siemens R-parameter / GUD</td>
|
||
<td><code>R1 = R2 * SIN(R3)</code>、<code>IF / GOTOB / GOTOF</code></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p><a class="xref" href="../api/Hi.NcParsers.ParsingSyntaxs.Heidenhain.HeidenhainFnAssignmentSyntax.html">HeidenhainFnAssignmentSyntax</a> 與 <a class="xref" href="../api/Hi.NcParsers.ParsingSyntaxs.NamedVarAssignmentSyntax.html">NamedVarAssignmentSyntax</a> 已能將指派寫入 JSON;但 expression evaluator、條件跳轉、迴圈展開尚未實作。</p>
|
||
<h4 id="524-ncopt-模組重寫">5.2.4 NcOpt 模組重寫</h4>
|
||
<p>目前 <code>Hi.NcOpt</code>(<a class="xref" href="../api/Hi.NcOpt.NcOptProc.html">NcOptProc</a>、<a class="xref" href="../api/Hi.NcOpt.NcOptOption.html">NcOptOption</a>)仍綁定舊系統:透過 <a class="xref" href="../api/Hi.Numerical.HardNcLine.html">HardNcLine</a> 鏈結串列做最佳化(feedrate、深度切分、加速度限制等)。此模組尚未深入規劃,仍可能有未知工作量需釐清。</p>
|
||
<hr>
|
||
<h2 id="6-客戶可重組性reconfigurable展示">6. 客戶可重組性(Reconfigurable)展示</h2>
|
||
<p>新系統下,下列三類客製化全部 <strong>不需重編譯</strong>:</p>
|
||
<h3 id="61-切換廠牌內建-5-組-preset">6.1 切換廠牌(內建 5 組 preset)</h3>
|
||
<pre><code class="lang-csharp">var runner = SoftNcRunner.HeidenhainNcRunner;
|
||
runner.ConfigureByMachiningChain(machine.Chain);
|
||
</code></pre>
|
||
<p>亦可由 XML 載入由專案反序列化挑選。詳見 <a class="xref" href="../api/Hi.NcParsers.SoftNcRunner.html">SoftNcRunner</a>。</p>
|
||
<h3 id="62-客製某廠牌特定語法不影響其他廠牌">6.2 客製某廠牌特定語法(不影響其他廠牌)</h3>
|
||
<p>例如某客戶 Fanuc 機台用了非標準 <code>M168</code> 進行夾具控制:</p>
|
||
<ol>
|
||
<li>新增一個 <code>MyClampMSyntax : </code> <a class="xref" href="../api/Hi.NcParsers.Syntaxs.ISituNcSyntax.html">ISituNcSyntax</a> 類別。</li>
|
||
<li>在客戶專案的 <a class="xref" href="../api/Hi.NcParsers.SoftNcRunner.html">SoftNcRunner</a> XML 中插入一行 <code><MyClampMSyntax/></code>。</li>
|
||
<li>不需改動 HiAPIs 任何原始檔。</li>
|
||
</ol>
|
||
<h3 id="63-跨廠牌共用機構配置">6.3 跨廠牌共用機構配置</h3>
|
||
<p><a class="xref" href="../api/Hi.NcParsers.SoftNcRunner.html#Hi_NcParsers_SoftNcRunner_ConfigureByMachiningChain_">ConfigureByMachiningChain</a> 把機台軸序、旋轉軸 / 線性軸區分、<a class="xref" href="../api/Hi.NcParsers.Dependencys.SystemWired.NcKinematicsDependency.html">NcKinematicsDependency</a> 的注入交由 <code>IMachiningChain</code> 驅動 — 5 軸機、4 軸機、雙轉台都共用同一條程式路徑。</p>
|
||
<hr>
|
||
<h2 id="7-過渡相容性">7. 過渡相容性</h2>
|
||
<p>為了不破壞既有客戶專案:</p>
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>機制</th>
|
||
<th>位置</th>
|
||
<th>用途</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td><a class="xref" href="../api/Hi.NcParsers.SoftNcRunner.html#Hi_NcParsers_SoftNcRunner_FromLegacyNcEnvXml_">FromLegacyNcEnvXml</a></td>
|
||
<td><a class="xref" href="../api/Hi.NcParsers.SoftNcRunner.html">SoftNcRunner</a> 內 <code>Legacy HardNcEnv XML support</code> 區段</td>
|
||
<td>讀舊 <a class="xref" href="../api/Hi.Numerical.HardNcEnv.html">HardNcEnv</a> XML 自動建構 <a class="xref" href="../api/Hi.NcParsers.SoftNcRunner.html">SoftNcRunner</a></td>
|
||
</tr>
|
||
<tr>
|
||
<td><a class="xref" href="../api/Hi.Common.XmlUtils.XFactory.html">XFactory</a>.<code>Regs.Add("NcEnv", ...)</code></td>
|
||
<td><a class="xref" href="../api/Hi.Numerical.HardNcEnv.html">HardNcEnv</a> 靜態建構子</td>
|
||
<td>舊 XML key <code>NcEnv</code> 也能載入</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>ApplyLegacyVersionPatches</code></td>
|
||
<td><a class="xref" href="../api/Hi.NcParsers.SoftNcRunner.html">SoftNcRunner</a></td>
|
||
<td>依 <a class="xref" href="../api/Hi.Common.XmlUtils.ProjectApiVersion.html">ProjectApiVersion</a> 補上後續版本新增的 syntax/semantic(3.1.163 起 4 道補丁)</td>
|
||
</tr>
|
||
<tr>
|
||
<td><a class="xref" href="../api/Hi.MachiningProcs.SessionShell.html#Hi_MachiningProcs_SessionShell_EnableSoftNcRunner">EnableSoftNcRunner</a></td>
|
||
<td><a class="xref" href="../api/Hi.MachiningProcs.SessionShell.html">SessionShell</a></td>
|
||
<td>客戶可在 script 中切換新舊 runner 比對結果</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
</article>
|
||
|
||
<div class="contribution d-print-none">
|
||
</div>
|
||
|
||
<div class="next-article d-print-none border-top" id="nextArticle"></div>
|
||
|
||
</div>
|
||
|
||
<div class="affix">
|
||
<nav id="affix"></nav>
|
||
</div>
|
||
</main>
|
||
|
||
<div class="container-xxl search-results" id="search-results"></div>
|
||
|
||
<footer class="border-top text-secondary">
|
||
<div class="container-xxl">
|
||
<div class="flex-fill">
|
||
<span> Copyright © 2025 <a href='https://superhightech.com.tw'>Tech Coordinate</a>. All rights reserved. <a href='https://superhightech.com.tw'>超級高科技股份有限公司</a> © 2025 版權所有 </span>
|
||
</div>
|
||
</div>
|
||
</footer>
|
||
</body>
|
||
</html>
|