240 lines
18 KiB
HTML
240 lines
18 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Controller Page Web Implementation | HiAPI-C# 2025 </title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta name="title" content="Controller Page Web Implementation | 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="">
|
|
<h1 id="controller-page-web-implementation">Controller Page Web Implementation</h1>
|
|
|
|
<p>This document describes the Quasar-based web implementation of the Controller Page in the <code>HiNC-2025-webservice</code> project.</p>
|
|
<h2 id="overview">Overview</h2>
|
|
<p>The Controller Page is built on the Quasar CLI SPA that lives under <code>HiNC-2025-webservice/wwwroot-src/</code>.</p>
|
|
<p>Top-level structure:</p>
|
|
<ul>
|
|
<li>Backend API controller: <code>Controller/ControllerController.cs</code> (extended; see Endpoints).</li>
|
|
<li>Frontend Vue 3 / TypeScript <code><script setup></code> components: <code>wwwroot-src/src/pages/ControllerPage.vue</code> + seven sibling components under <code>wwwroot-src/src/components/controller/</code>.</li>
|
|
<li>Typed API wrapper: <code>wwwroot-src/src/api/controller.ts</code>.</li>
|
|
<li>Shared infrastructure reused unchanged: <code>ObjectManagementMenuButton</code>, <code>RenderingCanvas</code>, <code>RenderingCanvasToolBar</code>, <code>NumericInput</code>, <code>useCleanupHub</code>, <code>projectStore</code>.</li>
|
|
</ul>
|
|
<h2 id="backend-implementation">Backend Implementation</h2>
|
|
<h3 id="endpoints">Endpoints</h3>
|
|
<p>All endpoints live under <code>Controller/ControllerController.cs</code> (route prefix <code>api/Controller</code>). Endpoints introduced in the 2026-04-19 rebuild are marked <strong>new</strong>.</p>
|
|
<ul>
|
|
<li><strong>Initialize</strong>
|
|
<ul>
|
|
<li><code>POST /api/Controller/initialize</code> - <strong>new</strong>. Registers the project's <a class="xref" href="../../api/Hi.Numerical.HardNcEnv.html">HardNcEnv</a> under a fresh IndexService key so the <code>ObjectManagementMenuButton</code> can target it. Returns <code>{ ncEnvKey, cncBrand }</code>.</li>
|
|
</ul>
|
|
</li>
|
|
<li><strong>Brand</strong>
|
|
<ul>
|
|
<li><code>GET/PUT /api/Controller/cnc-brand</code> - read / write <a class="xref" href="../../api/Hi.Numerical.HardNcEnv.html#Hi_Numerical_HardNcEnv_CncBrand">CncBrand</a>.</li>
|
|
<li><code>GET/PUT /api/Controller/heidenhain-master-axis-char</code> - <strong>new</strong>. Exposes <a class="xref" href="../../api/Hi.Numerical.HardNcEnv.html#Hi_Numerical_HardNcEnv_HeidenhainMasterAxisChar">HeidenhainMasterAxisChar</a> as a single-character string (<code>A</code>, <code>B</code>, or <code>C</code>).</li>
|
|
</ul>
|
|
</li>
|
|
<li><strong>ISO coordinate table</strong> (string keys: <code>G54</code>, ..., <code>G59.9</code>)
|
|
<ul>
|
|
<li><code>GET /api/Controller/iso-coordinate-table</code></li>
|
|
<li><code>PUT /api/Controller/iso-coordinate-table/{index}</code></li>
|
|
<li><code>POST /api/Controller/iso-coordinate-table/{index}/set-to-program-zero</code></li>
|
|
<li><code>POST /api/Controller/iso-coordinate-table/{index}/set-to-machine-zero</code></li>
|
|
<li><code>PUT /api/Controller/iso-coordinate-selection</code> - updates <a class="xref" href="../../api/Hi.Numerical.IsoCoordinateEntryDisplayee.html">IsoCoordinateEntryDisplayee</a>.</li>
|
|
</ul>
|
|
</li>
|
|
<li><strong>Heidenhain datum preset / shift</strong>
|
|
<ul>
|
|
<li><code>GET/PUT /api/Controller/heidenhain-datum-preset-table</code> and <code>/{index}</code></li>
|
|
<li><code>POST /api/Controller/heidenhain-datum-preset-table/{index}/reset</code> - <strong>new</strong>. Resets the entry to zero (matches WPF <code>DatumPresetTablePanel.SetDatumPosition_Click</code>).</li>
|
|
<li><code>GET/PUT /api/Controller/heidenhain-datum-shift-table</code> and <code>/{index}</code></li>
|
|
<li><code>POST /api/Controller/heidenhain-datum-shift-table/{index}/reset</code> - <strong>new</strong>.</li>
|
|
</ul>
|
|
</li>
|
|
<li><strong>Milling tool offset table</strong> (<a class="xref" href="../../api/Hi.Numerical.MillingToolOffsetTable.html">MillingToolOffsetTable</a>)
|
|
<ul>
|
|
<li><code>GET /api/Controller/milling-tool-offset-table</code> - returns <code>Dictionary<int, MillingToolOffsetTableRow></code>.</li>
|
|
<li><code>PUT /api/Controller/milling-tool-offset-table</code> - whole-table replacement (legacy batch API, still supported).</li>
|
|
<li><code>PUT /api/Controller/milling-tool-offset-table/{toolId:int}</code> - <strong>new</strong>. Row-level PUT.</li>
|
|
<li><code>POST /api/Controller/milling-tool-offset-table</code> - <strong>new</strong>. Adds a default-valued row and returns the new tool ID.</li>
|
|
<li><code>DELETE /api/Controller/milling-tool-offset-table/{toolId:int}</code> - <strong>new</strong>.</li>
|
|
<li><code>POST /api/Controller/milling-tool-offset-table/{toolId:int}/rename</code> - <strong>new</strong>. Body: <code>int newToolId</code>. Rejects duplicate keys.</li>
|
|
<li><code>POST /api/Controller/set-ideal-offset-from-toolhouse</code> - recomputes the offset table from the current <code>MachiningToolHouse</code>.</li>
|
|
<li><code>GET/PUT /api/Controller/ideal-offset-dependent</code> - <code>IsIdealOffsetDependentOnToolHouse</code> toggle.</li>
|
|
</ul>
|
|
</li>
|
|
<li><strong>Machine (strokes, speeds, rapid feed)</strong>
|
|
<ul>
|
|
<li><code>GET/PUT /api/Controller/rapid-feedrate</code></li>
|
|
<li><code>GET/PUT /api/Controller/tooling-time</code></li>
|
|
<li><code>GET/PUT /api/Controller/stroke-limit-xyz</code> - <code>double[6]</code> in mm.</li>
|
|
<li><code>GET/PUT /api/Controller/stroke-limit-abc</code> - <code>double[6]</code> in radians.</li>
|
|
<li><code>GET/PUT /api/Controller/max-rotary-speed-abc</code> - <code>double[3]</code> in rad/s.</li>
|
|
</ul>
|
|
</li>
|
|
<li><strong>Config</strong>
|
|
<ul>
|
|
<li><code>GET/PUT /api/Controller/shortest-rotary</code> - <a class="xref" href="../../api/Hi.Numerical.HardNcEnv.html#Hi_Numerical_HardNcEnv_EnableShortestRotary">EnableShortestRotary</a>.</li>
|
|
</ul>
|
|
</li>
|
|
<li><strong>Display</strong>
|
|
<ul>
|
|
<li><code>POST /api/Controller/initialize-display/{connectionId}</code> - binds the shared <a class="xref" href="../../api/Hi.MachiningProcs.MachiningProjectDisplayee.html">MachiningProjectDisplayee</a> to the rendering engine keyed by <code>connectionId</code>. The Controller page and Player page share this displayee, so <code>Display Options ▾</code> toggles via the rendering-flags API propagate to both viewers.</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<h2 id="frontend-implementation">Frontend Implementation</h2>
|
|
<h3 id="pagescontrollerpagevue"><code>pages/ControllerPage.vue</code></h3>
|
|
<ul>
|
|
<li>Two-pane <code><q-splitter></code>. Left: management tabs. Right: rendering viewer.</li>
|
|
<li>Head line: <code>ObjectManagementMenuButton</code> + “Controller” title + status badge; binds to <code>HardNcEnv</code> via the <code>initialize</code> endpoint.</li>
|
|
<li>Tabs: a <code><q-tabs></code> row with seven tabs. Datum Preset and Datum Shift are gated behind <code>isHeidenhain</code> (<code>cncBrand === CncBrand.Heidenhain</code>), mirroring the WPF <code>UpdateBrandSpecificTabs()</code> behaviour.</li>
|
|
<li>Viewer: <code>RenderingCanvasToolBar</code> (View dropdown) + <code>ControllerExtendedToolBar</code> (Display Options dropdown) + <code>RenderingCanvas</code>.</li>
|
|
</ul>
|
|
<h3 id="srcapicontrollerts"><code>src/api/controller.ts</code></h3>
|
|
<p>Full-feature typed wrapper. Retains the <code>CncBrand</code> / <code>getCncBrand</code> exports used by <code>PlayerExtendedToolBar.vue</code> so the Player page stays compatible. Adds <code>initializeController</code>, row-level offset-table helpers, master-axis char read/write, and the two new datum reset helpers.</p>
|
|
<h3 id="per-tab-components-srccomponentscontroller">Per-tab components (<code>src/components/controller/</code>)</h3>
|
|
<ul>
|
|
<li><code>CoordinateTableTab.vue</code> - string-keyed ISO coordinate editor (<code>G54</code>, ..., <code>G59.9</code>). P0 / M0 action buttons. Row-click → <code>iso-coordinate-selection</code> so the selected coordinate is highlighted in the viewer.</li>
|
|
<li><code>DatumPresetTab.vue</code> - Heidenhain-only. Q339 int key. Reset-to-zero action. “Show on Display” icon toggles <code>RenderingFlag.HeidenhainCoordinate</code>.</li>
|
|
<li><code>DatumShiftTab.vue</code> - Heidenhain-only. D int key. Same structure as DatumPresetTab.</li>
|
|
<li><code>OffsetTableTab.vue</code> - <a class="xref" href="../../api/Hi.Numerical.MillingToolOffsetTable.html">MillingToolOffsetTable</a> editor. When <code>isIdealOffsetDependentOnToolHouse</code> is on, tool IDs are read-only and a “Refresh from Tool House” button appears. When off, each tool ID is inline-editable via the shared <code>NumericInput</code>, and an Add button creates new rows.</li>
|
|
<li><code>MachineTab.vue</code> - Rapid Feedrate (mm/min) + Tooling Time (sec) + Linear Stroke (mm) + Rotary Stroke (deg) + Max Rotary Speed (rpm). Client-side unit conversion (rad ↔ deg, rad/s ↔ rpm) in the <code>onStrokeAbcChange</code> / <code>onMaxRotaryChange</code> handlers. Uses <code>NumericInput</code> so the backend's <code>±Infinity</code> default stroke limits display literally.</li>
|
|
<li><code>BrandTab.vue</code> - <code><q-select></code> with Fanuc / Heidenhain / Mazak / Siemens / Syntec. When Heidenhain, exposes a Master-axis character <code><q-select></code> with options A / B / C. Emits <code>@brand-changed</code> to the parent.</li>
|
|
<li><code>ConfigTab.vue</code> - “Enable Shortest Rotary Path” toggle + info banner.</li>
|
|
</ul>
|
|
<h3 id="controllerextendedtoolbarvue"><code>ControllerExtendedToolBar.vue</code></h3>
|
|
<p>Thin <code>Display Options ▾</code> wrapper around the shared <code>/api/rendering-flags</code> endpoints, grouped into Solid / Coordinate / Display Aids (the same structure as <code>PlayerExtendedToolBar.vue</code>). The Heidenhain Coordinate row is visible only when the current brand is Heidenhain. Mirrors the win-desktop <code>ControllerExtendedRenderingCanvasToolBar.xaml</code> which is itself a <code>RenderingFlagSubmenu</code> wrapper.</p>
|
|
<h2 id="integration-points">Integration Points</h2>
|
|
<ul>
|
|
<li><strong>Shared displayee with Player</strong>: <code>initialize-display/{connectionId}</code> attaches <code>ProjectDisplayeeService.MachiningProjectDisplayee</code>, so flag toggles on the Controller page's extended toolbar also update the Player viewer.</li>
|
|
<li><strong>Project reload</strong>: the page is hosted under <code>MainLayout.vue</code>'s <code><keep-alive :key="projectEpoch"></code> wrapper, so it remounts automatically on project open / reload (no explicit project-watch boilerplate in <code>ControllerPage.vue</code>).</li>
|
|
<li><strong>Cleanup hub</strong>: <code>initialize</code> returns a fresh NcEnv key each time; the page registers it with <code>useCleanupHub</code> so it is dropped on unmount to prevent IndexService leaks.</li>
|
|
</ul>
|
|
<h2 id="notable-design-decisions">Notable design decisions</h2>
|
|
<ul>
|
|
<li><strong>Row-level tool-offset CRUD</strong> replaces the older “PUT whole table” pattern. Backed by the four endpoints <code>PUT /{toolId}</code> (update one row), <code>POST</code> (add a default-valued row), <code>DELETE /{toolId}</code> (remove one row), and <code>POST /{toolId}/rename</code> (change the tool ID of an existing row).</li>
|
|
<li><strong>Infinity round-trip</strong>: <code>Program.cs</code> enables <code>JsonNumberHandling.AllowNamedFloatingPointLiterals</code>, and the shared <code>NumericInput.vue</code> already parses / formats <code>Infinity</code>, <code>-Infinity</code>, and <code>NaN</code> strings. Default <code>StrokeLimitXyz_mm</code> of <code>[-Inf, +Inf, ...]</code> is therefore displayed and editable without any special handling in <code>MachineTab.vue</code>.</li>
|
|
<li><strong>IsoCoordinateTable string keys</strong>: the table is a <code>Dictionary<string, Vec3d></code> with human-readable G-code keys (<code>"G54"</code>, <code>"G59.2"</code>). The frontend consumes this directly - no <code>IndexDisplay</code> computed property is required. See <code>iso-coordinate-table-string-key.md</code> in the Second Brain.</li>
|
|
<li><strong>Heidenhain-conditional tab visibility</strong> is driven by a single <code>cncBrand: CncBrandValue | null</code> state on the page. <code>BrandTab</code> emits <code>@brand-changed</code>; <code>ObjectManagementMenuButton</code> reloads trigger a full <code>initialize</code> refetch. Switching away from Heidenhain while one of those tabs is active falls back to Coordinate Table.</li>
|
|
</ul>
|
|
<h2 id="key-differences-from-wpf-implementation">Key Differences from WPF Implementation</h2>
|
|
<ol>
|
|
<li><strong>Dependency-free SPA</strong>: served by the same ASP.NET Core host that provides the REST API; no embedded WPF or web-view bridge.</li>
|
|
<li><strong>Component architecture</strong>: Vue 3 <code><script setup></code> + Quasar <code><q-tabs></code> / <code><q-splitter></code> / <code><q-markup-table></code> / <code><q-select></code> instead of WPF <code>UserControl</code> + <code>TabControl</code> + <code>DataGrid</code>.</li>
|
|
<li><strong>Shared displayee</strong>: the Quasar implementation binds <code>MachiningProjectDisplayee</code> once (via <code>initialize-display</code>) and lets the rendering-flags API drive toggles, rather than each WPF tab owning per-tab <code>ShowXxx</code> bool bindings.</li>
|
|
<li><strong>Granular endpoints</strong>: both the legacy and Quasar implementations split NcEnv into per-property endpoints, but the Quasar implementation additionally introduces row-level CRUD for the tool offset table.</li>
|
|
<li><strong>Unit conversion</strong>: handled in the per-tab component (rad ↔ deg, rad/s ↔ rpm), same as the legacy draft.</li>
|
|
</ol>
|
|
<h2 id="future-enhancements">Future Enhancements</h2>
|
|
<ul>
|
|
<li>Undo / redo coordination with <code>HardNcEnv</code>'s change-tracking.</li>
|
|
<li>Batch updates (debounced “commit all deltas” for high-frequency sliders).</li>
|
|
<li>Keyboard shortcuts (Arrow keys for row navigation, <code>Enter</code> to commit, <code>Esc</code> to revert inline edits).</li>
|
|
<li>Additional per-row tooltips explaining each column.</li>
|
|
</ul>
|
|
|
|
</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>
|