From 7fcc742c1ba962af1d84aaa2975e50f19297db81 Mon Sep 17 00:00:00 2001 From: jkpete <1031139173@qq.com> Date: Sun, 14 Dec 2025 09:45:45 +0800 Subject: [PATCH] add track pages --- Components/Layout/NavMenu.razor | 13 +- Components/Pages/Control.razor | 365 ++++++++++++++++++++++++++ Components/Pages/Home.razor | 81 +++++- Components/Pages/ParamSetting.razor | 386 ++++++++++++++++++++++++++++ Program.cs | 13 +- Properties/launchSettings.json | 2 +- wwwroot/favicon.png | Bin 1148 -> 1154 bytes 7 files changed, 851 insertions(+), 9 deletions(-) create mode 100644 Components/Pages/Control.razor create mode 100644 Components/Pages/ParamSetting.razor diff --git a/Components/Layout/NavMenu.razor b/Components/Layout/NavMenu.razor index 91b07fe..234a450 100644 --- a/Components/Layout/NavMenu.razor +++ b/Components/Layout/NavMenu.razor @@ -1,6 +1,6 @@  @@ -10,7 +10,7 @@ diff --git a/Components/Pages/Control.razor b/Components/Pages/Control.razor new file mode 100644 index 0000000..6776c80 --- /dev/null +++ b/Components/Pages/Control.razor @@ -0,0 +1,365 @@ +@page "/control" +@using Pages +@using System.Numerics +@using EGFramework +@implements IEGFramework +@rendermode InteractiveServer + +空轨控制 + +

空轨控制

+ +
+
+

当前位置: @dataActionStatus.Position / 25

+

旋转角度: @dataActionStatus.Rotate°

+

当前定位点: @(currentLocationName ?? "无")

+
+ +
+

位置控制

+
+
+ @foreach (var marker in locationMarkers) + { +
+
+ } +
+ + @dataActionStatus.Position +
+ +
+ + + + + + + +
+ + + + +
+ +
+

快速定位

+
+ @foreach (var location in locationMarkers) + { + + } +
+
+ +
+

颜色显示

+
+ RGB: @((int)(CurrentColor.X * 255)), @((int)(CurrentColor.Y * 255)), @((int)(CurrentColor.Z * 255)) + HSV: @((int)(CurrentHSV.X)), @((int)(CurrentHSV.Y)), @((int)(CurrentHSV.Z)) + +
+
+ +
+

靶机控制

+ +
+ + @if (isMoving) + { +
+
+ 移动中... +
+

空轨移动中,请等待...

+
+ } +
+ +@code { + private DataActionStatus dataActionStatus = new DataActionStatus { Position = 0, Rotate = 0 }; + private bool isMoving = false; + private bool isTargetActive = false; + private bool isTargetOperationInProgress = false; + private int targetPosition; + private string? currentLocationName; + private Vector3 CurrentColor = new Vector3(0.5f, 0.5f, 0.5f); // 默认灰色 + private Vector3 CurrentHSV = new Vector3(); + + public ModelTrackControl ModelTrackControl { set; get; } + + // 定义定位点字典 + private Dictionary locationMarkers = new Dictionary + { + { 0, new Vector3(0.3f, 0.8f, 0.12f) }, // 浅绿 - 起点 + { 7, new Vector3(0.1f, 0.5f, 0.2f) }, // 深绿色 - 中间点1 + { 10, new Vector3(0.0f, 0.5f, 1.0f) }, // 蓝色 - 中间点2 + { 15, new Vector3(0.5f, 0.2f, 0.75f) }, // 紫色 - 中间点3 + { 25, new Vector3(0.8f, 0.2f, 0.5f) } // 洋红色 - 终点 + }; + + protected override void OnInitialized() + { + UpdateCurrentLocationName(); + ModelTrackControl = this.GetModule(); + } + + private void OnPositionSliderInput(ChangeEventArgs e) + { + if (int.TryParse(e.Value?.ToString(), out int value)) + { + // 寻找最近的定位点 + var nearestLocation = locationMarkers.Keys + .OrderBy(x => Math.Abs(x - value)) + .First(); + + targetPosition = nearestLocation; + UpdateCurrentLocationName(targetPosition); + } + } + + + private async Task StartScanColor(){ + if(ModelTrackControl.IsScanning) return; + ModelTrackControl.StartScanColor(); + StateHasChanged(); + while(ModelTrackControl.IsScanning){ + // 更新颜色显示 + UpdateCurrentColor(); + + StateHasChanged(); + await Task.Delay(50); + } + } + + private async Task MoveToPosition() + { + if (isMoving) return; + + isMoving = true; + StateHasChanged(); + + // 模拟移动过程 + int steps = Math.Abs(targetPosition - dataActionStatus.Position); + int direction = targetPosition > dataActionStatus.Position ? 1 : -1; + + while(ModelTrackControl.MoveStatus != StatusTrack.Stop) + { + if(targetPosition!=dataActionStatus.Position){ + dataActionStatus.Position += direction; + } + + // 更新颜色显示 + UpdateCurrentColor(); + + StateHasChanged(); + await Task.Delay(50); + } + + UpdateCurrentLocationName(); + isMoving = false; + } + + private async Task MoveToLocation(int position) + { + targetPosition = position; + this.ModelTrackControl.MoveToPosition(position); + await MoveToPosition(); + } + + private async Task ToggleTarget() + { + if (isTargetOperationInProgress) return; + + isTargetOperationInProgress = true; + StateHasChanged(); + + + + isTargetActive = !isTargetActive; + if(isTargetActive){ + this.ModelTrackControl.StartTarget(); + }else{ + this.ModelTrackControl.RevertTarget(); + } + // 模拟靶机操作延迟 + await Task.Delay(2000); + + dataActionStatus.Rotate = isTargetActive ? 90 : 0; + + isTargetOperationInProgress = false; + StateHasChanged(); + } + + private string GetMarkerColor(Vector3 colorVector) + { + // 将Vector3转换为CSS颜色值 + return $"rgb({(int)(colorVector.X * 255)}, {(int)(colorVector.Y * 255)}, {(int)(colorVector.Z * 255)})"; + } + + private string GetColorValue(Vector3 colorVector) + { + // 将Vector3转换为CSS颜色值 + return $"rgb({(int)(colorVector.X * 255)}, {(int)(colorVector.Y * 255)}, {(int)(colorVector.Z * 255)})"; + } + + private string GetLocationName(int position) + { + return locationMarkers.ContainsKey(position) ? + $"定位点 {position}" : + position.ToString(); + } + + private void UpdateCurrentLocationName(int? position = null) + { + int pos = position ?? dataActionStatus.Position; + currentLocationName = locationMarkers.ContainsKey(pos) ? + $"定位点 {pos}" : + null; + } + + private void UpdateCurrentColor() + { + // 根据传感器检测到的颜色进行更新 + CurrentColor = this.ModelTrackControl.GetColor(); + CurrentHSV = this.ModelTrackControl.GetColorHSV(); + } +} + + \ No newline at end of file diff --git a/Components/Pages/Home.razor b/Components/Pages/Home.razor index 9001e0b..e1cdc45 100644 --- a/Components/Pages/Home.razor +++ b/Components/Pages/Home.razor @@ -1,7 +1,82 @@ @page "/" -Home +博裕空轨管理平台 -

Hello, world!

+
+
+
+
+

欢迎使用

+

博裕空轨设备管理系统

+

高效、精准的空轨设备控制与监控解决方案

+
+
+
-Welcome to your new app. +
+
+
+
+

系统功能简介

+
+
+

博裕空轨设备管理系统是一款先进的自动化控制解决方案,专为工业空轨设备设计。系统提供精确的位置控制、靶机角度调节、运动参数配置和实时状态监控功能。

+ +
+
+
位置控制功能
+

系统可以精确控制空轨设备前进和后退到指定位置,实现毫米级精确定位,满足各种工业场景的定位需求。

+
+
+
靶机测转功能
+

空轨下方的靶机可以进行0-90度的精确测转,用户可通过系统界面直观地设置和监控靶机角度。

+
+
+
运动参数配置
+

系统提供完善的运动参数配置功能,包括速度、加速度、减速度等参数设置,用户可根据实际需求灵活调整。

+
+
+
色标传感器监控
+

实时查看空轨当前色标传感器的颜色状态,系统提供直观的颜色显示和状态提示功能。

+
+
+
+
+
+
+ +
+
+
+
立即开始使用系统
+

请使用右侧导航菜单访问各个功能模块,或联系山东博裕获取相关帮助。

+
+
+
+
+ + diff --git a/Components/Pages/ParamSetting.razor b/Components/Pages/ParamSetting.razor new file mode 100644 index 0000000..10e5615 --- /dev/null +++ b/Components/Pages/ParamSetting.razor @@ -0,0 +1,386 @@ +@page "/paramSetting" +@using EGFramework +@using Pages +@using System.Numerics +@implements IEGFramework +@rendermode InteractiveServer + +参数设置 +

参数设置

+ + + + + +
+ +

基本设置

+ +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+

颜色映射设置

+ +
+ + @foreach (var color in DataSettings.ColorMapping) + { +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ } +
+ + +
+ + +
+
+ +

动作状态

+ +
+ + + +
+ +
+ + + +
+ +
+ + +
+
+
+ +@code { + private DataSetting DataSettings { get; set; } + private DataActionStatus DataActionStatus { get; set; } + public int newColorKey { set; get; } + private EditContext? EditContext; + + protected override void OnInitialized() + { + // 这里应该从数据存储加载设置 + LoadSettings(); + EditContext = new EditContext(DataSettings); + } + + private void LoadSettings() + { + // 模拟加载设置数据 + DataSettings = this.GetModule().Setting; + DataActionStatus = this.GetModule().Status; + } + + private void HandleValidSubmit() + { + // 这里应该保存设置到数据存储 + this.GetModule().Save(DataSettings); + Console.WriteLine("设置已保存"); + // 显示成功消息或导航到其他页面 + } + + private void ResetToDefaults() + { + DataSettings = this.GetModule().CreateDefault(); + EditContext = new EditContext(DataSettings); + } + + private void AddColorMapping() + { + if (!DataSettings.ColorMapping.ContainsKey(newColorKey)) + { + DataSettings.ColorMapping[newColorKey] = new Vector3(0, 0, 0); + StateHasChanged(); + } + } + + private void RemoveColorMapping(int key) + { + if (DataSettings.ColorMapping.ContainsKey(key)) + { + DataSettings.ColorMapping.Remove(key); + StateHasChanged(); + } + } +} + + \ No newline at end of file diff --git a/Program.cs b/Program.cs index bd92a0f..d6821d1 100644 --- a/Program.cs +++ b/Program.cs @@ -1,4 +1,10 @@ using TargetService.Components; +using EGFramework; + +EGBlazorController MainApp = new EGBlazorController(); +MainApp.Init(); +MainApp.Start(); + var builder = WebApplication.CreateBuilder(args); @@ -12,12 +18,17 @@ var app = builder.Build(); if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Error", createScopeForErrors: true); + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. + app.UseHsts(); } +app.UseHttpsRedirection(); + app.UseStaticFiles(); app.UseAntiforgery(); app.MapRazorComponents() .AddInteractiveServerRenderMode(); -app.Run(); +app.Run("http://0.0.0.0:6556"); + diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json index 1534944..b9545c6 100644 --- a/Properties/launchSettings.json +++ b/Properties/launchSettings.json @@ -13,7 +13,7 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, - "applicationUrl": "http://localhost:5257", + "applicationUrl": "http://localhost:6556", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/wwwroot/favicon.png b/wwwroot/favicon.png index 8422b59695935d180d11d5dbe99653e711097819..41ac9b8fb764ccafd88788ca810b23b411a4fab2 100644 GIT binary patch delta 1134 zcmV-!1d;pv2!aWaBYyx1a7bBm000ie000ie0hKEb8vphX9~y z^xE&%;d`)2riPXkI!~aBk}sUYNasIkz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