Controller Page Web Implementation
This document describes the web implementation of the Controller Page in the HiNC-2025-webservice project.
Overview
The Controller Page web implementation consists of:
- Backend API controller (
ControllerController.cs) - Frontend HTML, JavaScript, and CSS files
- Integration with the rendering canvas and toolbar components
Backend Implementation
ControllerController.cs
Located at Controller/ControllerController.cs, this API controller provides endpoints for managing CNC controller settings:
Endpoints
GET /api/controller/cnc-brand- Gets the current CNC brandPUT /api/controller/cnc-brand- Updates the CNC brandGET /api/controller/machine-config- Gets machine configurationPUT /api/controller/machine-config- Updates machine configurationGET /api/controller/general-config- Gets general configuration settingsPUT /api/controller/general-config- Updates general configurationGET /api/controller/iso-coordinate-table- Gets the ISO coordinate tablePUT /api/controller/iso-coordinate-table/{index}- Updates an ISO coordinate entryGET /api/controller/heidenhain-datum-preset-table- Gets the Heidenhain datum preset tablePUT /api/controller/heidenhain-datum-preset-table/{index}- Updates a Heidenhain datum preset entryGET /api/controller/heidenhain-datum-shift-table- Gets the Heidenhain datum shift tablePUT /api/controller/heidenhain-datum-shift-table/{index}- Updates a Heidenhain datum shift entryGET /api/controller/milling-tool-offset-table- Gets the milling tool offset tablePUT /api/controller/milling-tool-offset-table- Updates the milling tool offset tableGET /api/controller/ideal-offset-dependent- Gets the ideal offset dependent settingPUT /api/controller/ideal-offset-dependent- Updates the ideal offset dependent settingPOST /api/controller/set-ideal-offset-from-toolhouse- Sets ideal offset based on tool housePOST /api/controller/initialize-display- Initializes the display engine for rendering
Frontend Implementation
HTML Structure
The main HTML file (wwwroot/controller/controller-panel.html) contains:
- Management panel with tabs for different configuration sections
- Viewer panel with rendering canvas for 3D visualization
- Responsive layout with resizable panels
JavaScript Components
The frontend uses Vue.js framework with ES modules for component-based architecture.
controller-panel.js
Main Vue.js component that orchestrates the controller page:
- Imports and registers all sub-components (tabs, toolbars, rendering canvas)
- Manages global state (CNC brand, rendering connection)
- Handles tab switching and dynamic component loading
- Initializes display engine and rendering connections
Key features:
- Component-based architecture using Vue.js
- Dynamic tab components loaded from separate files
- Brand-specific UI updates (showing/hiding Heidenhain tabs)
- Integration with rendering canvas and toolbars
Tab Components
Each configuration tab is implemented as a separate Vue.js component:
coordinate-table-tab.js- ISO coordinate table managementdatum-preset-tab.js- Heidenhain datum preset table (brand-specific)datum-shift-tab.js- Heidenhain datum shift table (brand-specific)offset-table-tab.js- Tool offset table with ideal offset settingsmachine-tab.js- Machine configuration with axis limits (degrees for rotary axes)brand-tab.js- CNC brand selectionconfig-tab.js- General configuration settings
controller-extended-toolbar.js
Vue.js component for the extended toolbar that provides:
- Rendering flags dropdown menu (similar to WPF's RenderingFlagSubmenu)
- Controller-specific rendering options (Machine, Coordinates, ISO, Datum, etc.)
- Brand-aware rendering flags (Heidenhain-specific options)
- Integration with display engine for real-time updates
CSS Styling
Two CSS files provide styling:
controller-panel.css- Main panel layout and component styles- Two-column responsive layout using flexbox
- Tab navigation and content styling
- Form controls with special handling for checkboxes
- Overrides global styles for proper checkbox display
controller-extended-toolbar.css- Toolbar-specific styles- Dropdown menu styling
- Button and icon styling
- Consistent with player toolbar design
Integration Points
With Main Application
The controller page is integrated into the main application through:
- Navigation menu in
index.html - Route handling in
main.js - Iframe embedding for isolated functionality
With Project Service
The controller utilizes the IProjectService to:
- Access the current MachiningProject
- Retrieve and update NcEnv settings
- Save changes to the project
With Rendering Engine
The controller page integrates with:
- DispEngine for 3D visualization
- MachiningProjectDisplayee for rendering project data
- Custom rendering flags for controller-specific visualizations
Key Differences from WPF Implementation
- Asynchronous Operations: All data operations are asynchronous using fetch API
- Component Architecture: Vue.js components instead of WPF UserControls
- Web-based Rendering: Uses WebGL-based rendering canvas instead of WPF controls
- Responsive Design: Two-column layout with CSS flexbox for better screen utilization
- Unit Conversion: Frontend handles degree/radian conversion for rotary axes
- Granular API: Split NcEnv into multiple focused endpoints instead of single large DTO
- Toolbar Integration: Reuses rendering flag patterns from player section
Implementation Details
Data Transfer Objects (DTOs)
The backend uses several DTOs to simplify complex object serialization:
IsoCoordinateTableEntry- For ISO coordinate table entriesDatumTableEntry- For Heidenhain datum tablesMachineConfigDto- For machine configuration settingsGeneralConfigDto- For general configuration settings
Unit Handling
- Backend stores rotary axis values in radians (following HiAPI conventions)
- Frontend displays and accepts input in degrees for user-friendliness
- Conversion happens in the Vue.js components (
radToDeganddegToRadfunctions)
Rendering Flag Management
The controller uses specific rendering flags for visualization:
- Flag indices follow the
RenderingFlagenum structure - Controller-specific flags include: Coordinate, HeidenhainDatumPreset, HeidenhainDatumShift, Stock, AxisLimits
- Flags are synchronized between frontend state and display engine
Future Enhancements
- Implement ObjectManagementMenuButton component for file management
- Add undo/redo functionality
- Implement keyboard shortcuts
- Add client-side validation for numeric inputs
- Implement batch updates for better performance
- Add tooltips for configuration options