From 8736bad3e7c67b0310b1d0710fedcd636bc49cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=C4=83ng=20Nguy=E1=BB=85n?= Date: Thu, 6 Nov 2025 14:14:10 +0700 Subject: [PATCH] update --- .../Pages/Components/Config/RobotConfig.razor | 109 ++-- .../Components/Config/RobotPLCConfig.razor | 78 ++- .../Components/Config/RobotSafetyConfig.razor | 116 ++-- .../Config/RobotSimulationConfig.razor | 4 +- .../Config/RobotVDA5050Config.razor | 16 +- .../Pages/RobotConfigManager.razor.cs | 2 + RobotApp.Common.Shares/Dtos/RobotConfigDto.cs | 6 + .../Dtos/RobotPlcConfigDto.cs | 8 +- .../Dtos/RobotSafetyConfigDto.cs | 11 +- .../Dtos/RobotVDA5050ConfigDto.cs | 5 +- RobotApp.VDA5050/VDA5050Setting.cs | 5 +- .../Controllers/RobotConfigsController.cs | 8 +- ...20251106025457_UpdateVDA5050St.Designer.cs | 582 ++++++++++++++++++ .../20251106025457_UpdateVDA5050St.cs | 29 + .../ApplicationDbContextModelSnapshot.cs | 5 + RobotApp/Data/RobotVDA5050Config.cs | 4 + RobotApp/Program.cs | 2 + RobotApp/RobotApp.csproj | 2 + RobotApp/Services/MQTTClient.cs | 13 +- RobotApp/Services/Robot/RobotBattery.cs | 8 +- RobotApp/Services/Robot/RobotConfiguration.cs | 1 + RobotApp/Services/Robot/RobotConnection.cs | 4 +- RobotApp/Services/Robot/RobotFactsheet.cs | 4 +- .../Services/Robot/RobotOrderController.cs | 17 +- RobotApp/Services/Robot/RobotStates.cs | 12 +- RobotApp/Services/Robot/RobotVisualization.cs | 2 + RobotApp/nlog.config | 24 + RobotApp/robot.db | Bin 167936 -> 167936 bytes 28 files changed, 931 insertions(+), 146 deletions(-) create mode 100644 RobotApp/Data/Migrations/20251106025457_UpdateVDA5050St.Designer.cs create mode 100644 RobotApp/Data/Migrations/20251106025457_UpdateVDA5050St.cs create mode 100644 RobotApp/nlog.config diff --git a/RobotApp.Client/Pages/Components/Config/RobotConfig.razor b/RobotApp.Client/Pages/Components/Config/RobotConfig.razor index fabfda2..24aca8e 100644 --- a/RobotApp.Client/Pages/Components/Config/RobotConfig.razor +++ b/RobotApp.Client/Pages/Components/Config/RobotConfig.razor @@ -1,44 +1,64 @@ - - - -
- - - @foreach (var t in NavigationTypes) - { - - } - -
+@implements IDisposable -
-
- - -
-
- - -
-
+
+ + -
-
- - +
+ + + @foreach (var t in NavigationTypes) + { + + } + +
-
- - + +
+
+ + + +
+
+ + + +
-
-
- - -
+
+
+ + + +
+
+ + + +
+
+ +
+ + + +
+ +
+
+ @if (Model.CreatedAt != default || Model.UpdatedAt != default) + { +
+ Created: @Model.CreatedAt.ToString("dd/MM/yyyy HH:mm:ss") + Updated: @Model.UpdatedAt.ToString("dd/MM/yyyy HH:mm:ss") +
+ } +
+
- @code { [Parameter] @@ -47,17 +67,26 @@ [Parameter] public EventCallback ModelChanged { get; set; } - private RobotConfigDto Config = new(); + private EditContext? EditContext; private IEnumerable NavigationTypes => Enum.GetValues(typeof(NavigationType)).Cast(); protected override void OnParametersSet() { - Config = Model ?? new(); + if (EditContext is null || !EditContext.Model!.Equals(Model)) + { + if (EditContext is not null) EditContext.OnFieldChanged -= EditContext_OnFieldChanged; + EditContext = new EditContext(Model); + EditContext.OnFieldChanged += EditContext_OnFieldChanged; + } } - private async Task OnSubmit() + private void EditContext_OnFieldChanged(object? sender, FieldChangedEventArgs e) { - Model = Config; - await ModelChanged.InvokeAsync(Model); + _ = ModelChanged.InvokeAsync(Model); + } + + public void Dispose() + { + if (EditContext is not null) EditContext.OnFieldChanged -= EditContext_OnFieldChanged; } } diff --git a/RobotApp.Client/Pages/Components/Config/RobotPLCConfig.razor b/RobotApp.Client/Pages/Components/Config/RobotPLCConfig.razor index ad80fbe..bf4fa6d 100644 --- a/RobotApp.Client/Pages/Components/Config/RobotPLCConfig.razor +++ b/RobotApp.Client/Pages/Components/Config/RobotPLCConfig.razor @@ -1,32 +1,47 @@ -@using RobotApp.Common.Shares.Dtos +@implements IDisposable +
+ + - - - -
-
- - +
+
+ + + +
+
+ + + +
-
- - + +
+
+ + + +
-
-
-
- - +
+ + +
-
-
- - + +
+
+ @if (Model.CreatedAt != default || Model.UpdatedAt != default) + { +
+ Created: @Model.CreatedAt.ToString("dd/MM/yyyy HH:mm:ss") + Updated: @Model.UpdatedAt.ToString("dd/MM/yyyy HH:mm:ss") +
+ }
- - +
@code { [Parameter] @@ -35,16 +50,25 @@ [Parameter] public EventCallback ModelChanged { get; set; } - private RobotPlcConfigDto Local = new(); + private EditContext? EditContext; protected override void OnParametersSet() { - Local = Model is not null ? Model with { } : new RobotPlcConfigDto(); + if (EditContext is null || !EditContext.Model!.Equals(Model)) + { + if (EditContext is not null) EditContext.OnFieldChanged -= EditContext_OnFieldChanged; + EditContext = new EditContext(Model); + EditContext.OnFieldChanged += EditContext_OnFieldChanged; + } } - private async Task OnSubmit() + private void EditContext_OnFieldChanged(object? sender, FieldChangedEventArgs e) { - Model = Local; - await ModelChanged.InvokeAsync(Model); + _ = ModelChanged.InvokeAsync(Model); + } + + public void Dispose() + { + if (EditContext is not null) EditContext.OnFieldChanged -= EditContext_OnFieldChanged; } } \ No newline at end of file diff --git a/RobotApp.Client/Pages/Components/Config/RobotSafetyConfig.razor b/RobotApp.Client/Pages/Components/Config/RobotSafetyConfig.razor index bf8424e..8aacb26 100644 --- a/RobotApp.Client/Pages/Components/Config/RobotSafetyConfig.razor +++ b/RobotApp.Client/Pages/Components/Config/RobotSafetyConfig.razor @@ -1,50 +1,70 @@ - - - -
-
- - +@implements IDisposable +
+ + +
+
+ + + +
+
+ + + +
-
- - -
-
-
-
- - +
+
+ + + +
+
+ + + +
-
- - + +
+
+ + + +
+
+ + + +
-
-
-
- - +
+ + +
-
- - + +
+ + +
+ +
+
+ @if (Model.CreatedAt != default || Model.UpdatedAt != default) + { +
+ Created: @Model.CreatedAt.ToString("dd/MM/yyyy HH:mm:ss") + Updated: @Model.UpdatedAt.ToString("dd/MM/yyyy HH:mm:ss") +
+ }
+
-
- - -
- -
- - -
- - @code { [Parameter] @@ -53,17 +73,25 @@ [Parameter] public EventCallback ModelChanged { get; set; } - private RobotSafetyConfigDto Local = new(); + private EditContext? EditContext; protected override void OnParametersSet() { - // Work on a shallow copy (record) so parent instance isn't mutated until submit - Local = Model is not null ? Model with { } : new RobotSafetyConfigDto(); + if (EditContext is null || !EditContext.Model!.Equals(Model)) + { + if (EditContext is not null) EditContext.OnFieldChanged -= EditContext_OnFieldChanged; + EditContext = new EditContext(Model); + EditContext.OnFieldChanged += EditContext_OnFieldChanged; + } } - private async Task OnSubmit() + private void EditContext_OnFieldChanged(object? sender, FieldChangedEventArgs e) { - Model = Local; - await ModelChanged.InvokeAsync(Model); + _ = ModelChanged.InvokeAsync(Model); + } + + public void Dispose() + { + if (EditContext is not null) EditContext.OnFieldChanged -= EditContext_OnFieldChanged; } } diff --git a/RobotApp.Client/Pages/Components/Config/RobotSimulationConfig.razor b/RobotApp.Client/Pages/Components/Config/RobotSimulationConfig.razor index b455f3d..f6ca067 100644 --- a/RobotApp.Client/Pages/Components/Config/RobotSimulationConfig.razor +++ b/RobotApp.Client/Pages/Components/Config/RobotSimulationConfig.razor @@ -1,6 +1,4 @@ -@using RobotApp.Common.Shares.Dtos - -@implements IDisposable +@implements IDisposable
diff --git a/RobotApp.Client/Pages/Components/Config/RobotVDA5050Config.razor b/RobotApp.Client/Pages/Components/Config/RobotVDA5050Config.razor index 2a61e9b..7b08872 100644 --- a/RobotApp.Client/Pages/Components/Config/RobotVDA5050Config.razor +++ b/RobotApp.Client/Pages/Components/Config/RobotVDA5050Config.razor @@ -1,14 +1,20 @@ @implements IDisposable -
-
- - - +
+
+ + + +
+
+ + + +
diff --git a/RobotApp.Client/Pages/RobotConfigManager.razor.cs b/RobotApp.Client/Pages/RobotConfigManager.razor.cs index 83d9b72..45637ba 100644 --- a/RobotApp.Client/Pages/RobotConfigManager.razor.cs +++ b/RobotApp.Client/Pages/RobotConfigManager.razor.cs @@ -201,6 +201,7 @@ public partial class RobotConfigManager template.VDA5050Password, template.VDA5050Manufacturer, template.VDA5050Version, + template.VDA5050TopicPrefix, template.VDA5050PublishRepeat, template.VDA5050EnablePassword, template.VDA5050EnableTls @@ -373,6 +374,7 @@ public partial class RobotConfigManager SelectedVda.VDA5050Password, SelectedVda.VDA5050Manufacturer, SelectedVda.VDA5050Version, + SelectedVda.VDA5050TopicPrefix, SelectedVda.VDA5050PublishRepeat, SelectedVda.VDA5050EnablePassword, SelectedVda.VDA5050EnableTls, diff --git a/RobotApp.Common.Shares/Dtos/RobotConfigDto.cs b/RobotApp.Common.Shares/Dtos/RobotConfigDto.cs index 0b0acdf..8d5fc4e 100644 --- a/RobotApp.Common.Shares/Dtos/RobotConfigDto.cs +++ b/RobotApp.Common.Shares/Dtos/RobotConfigDto.cs @@ -1,4 +1,5 @@ using RobotApp.Common.Shares.Enums; +using System.ComponentModel.DataAnnotations; namespace RobotApp.Common.Shares.Dtos; @@ -8,13 +9,18 @@ public record RobotConfigDto { public Guid Id { get; set; } public NavigationType NavigationType { get; set; } + [Range(0.1, 10, ErrorMessage = "Value must be from 0.1 to 10")] public double RadiusWheel { get; set; } + [Range(0.1, 10, ErrorMessage = "Value must be from 0.1 to 10")] public double Width { get; set; } + [Range(0.1, 10, ErrorMessage = "Value must be from 0.1 to 10")] public double Length { get; set; } + [Range(0.1, 10, ErrorMessage = "Value must be from 0.1 to 10")] public double Height { get; set; } public DateTime CreatedAt { get; set; } public DateTime UpdatedAt { get; set; } public bool IsActive { get; set; } + [Required] public string ConfigName { get; set; } public string Description { get; set; } } diff --git a/RobotApp.Common.Shares/Dtos/RobotPlcConfigDto.cs b/RobotApp.Common.Shares/Dtos/RobotPlcConfigDto.cs index ec6e03a..7cc50e1 100644 --- a/RobotApp.Common.Shares/Dtos/RobotPlcConfigDto.cs +++ b/RobotApp.Common.Shares/Dtos/RobotPlcConfigDto.cs @@ -1,16 +1,22 @@ -namespace RobotApp.Common.Shares.Dtos; +using System.ComponentModel.DataAnnotations; + +namespace RobotApp.Common.Shares.Dtos; #nullable disable public record RobotPlcConfigDto { public Guid Id { get; set; } + [Required] public string PLCAddress { get; set; } + [Range(1, 65535, ErrorMessage = "Value must be from 1 to 65535")] public int PLCPort { get; set; } + [Range(1, 65535, ErrorMessage = "Value must be from 1 to 65535")] public int PLCUnitId { get; set; } public DateTime CreatedAt { get; set; } public DateTime UpdatedAt { get; set; } public bool IsActive { get; set; } + [Required] public string ConfigName { get; set; } public string Description { get; set; } } diff --git a/RobotApp.Common.Shares/Dtos/RobotSafetyConfigDto.cs b/RobotApp.Common.Shares/Dtos/RobotSafetyConfigDto.cs index 9fc964a..4e93faa 100644 --- a/RobotApp.Common.Shares/Dtos/RobotSafetyConfigDto.cs +++ b/RobotApp.Common.Shares/Dtos/RobotSafetyConfigDto.cs @@ -1,4 +1,6 @@ -namespace RobotApp.Common.Shares.Dtos; +using System.ComponentModel.DataAnnotations; + +namespace RobotApp.Common.Shares.Dtos; #nullable disable @@ -6,15 +8,22 @@ public record RobotSafetyConfigDto { public Guid Id { get; set; } public double SafetySpeedVerySlow { get; set; } + [Range(0, 10, ErrorMessage = "Value must be from 0 to 10")] public double SafetySpeedSlow { get; set; } + [Range(0, 10, ErrorMessage = "Value must be from 0 to 10")] public double SafetySpeedNormal { get; set; } + [Range(0, 10, ErrorMessage = "Value must be from 0 to 10")] public double SafetySpeedMedium { get; set; } + [Range(0, 10, ErrorMessage = "Value must be from 0 to 10")] public double SafetySpeedOptimal { get; set; } + [Range(0, 10, ErrorMessage = "Value must be from 0 to 10")] public double SafetySpeedFast { get; set; } + [Range(0, 10, ErrorMessage = "Value must be from 0 to 10")] public double SafetySpeedVeryFast { get; set; } public DateTime CreatedAt { get; set; } public DateTime UpdatedAt { get; set; } public bool IsActive { get; set; } + [Required] public string ConfigName { get; set; } public string Description { get; set; } } diff --git a/RobotApp.Common.Shares/Dtos/RobotVDA5050ConfigDto.cs b/RobotApp.Common.Shares/Dtos/RobotVDA5050ConfigDto.cs index dcb7d59..b0719a4 100644 --- a/RobotApp.Common.Shares/Dtos/RobotVDA5050ConfigDto.cs +++ b/RobotApp.Common.Shares/Dtos/RobotVDA5050ConfigDto.cs @@ -14,11 +14,11 @@ public record RobotVDA5050ConfigDto [Required] [Range(1, 65535, ErrorMessage = "Value must be from 1 to 65535")] public int VDA5050Port { get; set; } - [Required] public string VDA5050UserName { get; set; } public string VDA5050Password { get; set; } public string VDA5050Manufacturer { get; set; } public string VDA5050Version { get; set; } + public string VDA5050TopicPrefix { get; set; } [Range(1, 65535, ErrorMessage = "Value must be from 1 to 65535")] public int VDA5050PublishRepeat { get; set; } public bool VDA5050EnablePassword { get; set; } @@ -29,6 +29,7 @@ public record RobotVDA5050ConfigDto public DateTime CreatedAt { get; set; } public DateTime UpdatedAt { get; set; } public bool IsActive { get; set; } + [Required] public string ConfigName { get; set; } public string Description { get; set; } } @@ -42,6 +43,7 @@ public record UpdateRobotVDA5050ConfigDto public string VDA5050Password { get; set; } public string VDA5050Manufacturer { get; set; } public string VDA5050Version { get; set; } + public string VDA5050TopicPrefix { get; set; } public int VDA5050PublishRepeat { get; set; } public bool VDA5050EnablePassword { get; set; } public bool VDA5050EnableTls { get; set; } @@ -60,6 +62,7 @@ public record CreateRobotVDA5050ConfigDto public string VDA5050Password { get; set; } public string VDA5050Manufacturer { get; set; } public string VDA5050Version { get; set; } + public string VDA5050TopicPrefix { get; set; } public int VDA5050PublishRepeat { get; set; } public bool VDA5050EnablePassword { get; set; } public bool VDA5050EnableTls { get; set; } diff --git a/RobotApp.VDA5050/VDA5050Setting.cs b/RobotApp.VDA5050/VDA5050Setting.cs index f450c7c..e867757 100644 --- a/RobotApp.VDA5050/VDA5050Setting.cs +++ b/RobotApp.VDA5050/VDA5050Setting.cs @@ -1,6 +1,4 @@ -using System.ComponentModel.DataAnnotations.Schema; - -namespace RobotApp.VDA5050; +namespace RobotApp.VDA5050; public class VDA5050Setting @@ -17,4 +15,5 @@ public class VDA5050Setting public string? CAFile { get; set; } public string? CerFile { get; set; } public string? KeyFile { get; set; } + public string? TopicPrefix { get; set; } } diff --git a/RobotApp/Controllers/RobotConfigsController.cs b/RobotApp/Controllers/RobotConfigsController.cs index fd95fd2..c3394ba 100644 --- a/RobotApp/Controllers/RobotConfigsController.cs +++ b/RobotApp/Controllers/RobotConfigsController.cs @@ -186,6 +186,7 @@ public class RobotConfigsController(Services.Logger Logg VDA5050Password = config.VDA5050Password, VDA5050Manufacturer = config.VDA5050Manufacturer, VDA5050Version = config.VDA5050Version, + VDA5050TopicPrefix = config.VDA5050TopicPrefix, VDA5050PublishRepeat = config.VDA5050PublishRepeat, VDA5050EnablePassword = config.VDA5050EnablePassword, VDA5050EnableTls = config.VDA5050EnableTls, @@ -220,10 +221,11 @@ public class RobotConfigsController(Services.Logger Logg config.SerialNumber = updateDto.SerialNumber ?? config.SerialNumber; config.VDA5050HostServer = updateDto.VDA5050HostServer ?? config.VDA5050HostServer; config.VDA5050Port = updateDto.VDA5050Port; - config.VDA5050UserName = updateDto.VDA5050UserName ?? config.VDA5050UserName; - config.VDA5050Password = updateDto.VDA5050Password ?? config.VDA5050Password; + config.VDA5050UserName = updateDto.VDA5050UserName; + config.VDA5050Password = updateDto.VDA5050Password; config.VDA5050Manufacturer = updateDto.VDA5050Manufacturer ?? config.VDA5050Manufacturer; config.VDA5050Version = updateDto.VDA5050Version ?? config.VDA5050Version; + config.VDA5050TopicPrefix = updateDto.VDA5050TopicPrefix; config.VDA5050PublishRepeat = updateDto.VDA5050PublishRepeat; config.VDA5050EnablePassword = updateDto.VDA5050EnablePassword; config.VDA5050EnableTls = updateDto.VDA5050EnableTls; @@ -264,6 +266,7 @@ public class RobotConfigsController(Services.Logger Logg VDA5050Password = createDto.VDA5050Password, VDA5050Manufacturer = createDto.VDA5050Manufacturer, VDA5050Version = createDto.VDA5050Version, + VDA5050TopicPrefix = createDto.VDA5050TopicPrefix, VDA5050PublishRepeat = createDto.VDA5050PublishRepeat, VDA5050EnablePassword = createDto.VDA5050EnablePassword, VDA5050EnableTls = createDto.VDA5050EnableTls, @@ -292,6 +295,7 @@ public class RobotConfigsController(Services.Logger Logg VDA5050Password = config.VDA5050Password, VDA5050Manufacturer = config.VDA5050Manufacturer, VDA5050Version = config.VDA5050Version, + VDA5050TopicPrefix = config.VDA5050TopicPrefix, VDA5050PublishRepeat = config.VDA5050PublishRepeat, VDA5050EnablePassword = config.VDA5050EnablePassword, VDA5050EnableTls = config.VDA5050EnableTls, diff --git a/RobotApp/Data/Migrations/20251106025457_UpdateVDA5050St.Designer.cs b/RobotApp/Data/Migrations/20251106025457_UpdateVDA5050St.Designer.cs new file mode 100644 index 0000000..aa834e1 --- /dev/null +++ b/RobotApp/Data/Migrations/20251106025457_UpdateVDA5050St.Designer.cs @@ -0,0 +1,582 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using RobotApp.Data; + +#nullable disable + +namespace RobotApp.Data.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20251106025457_UpdateVDA5050St")] + partial class UpdateVDA5050St + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "9.0.9"); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasColumnType("TEXT"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("TEXT"); + + b.Property("ProviderKey") + .HasColumnType("TEXT"); + + b.Property("ProviderDisplayName") + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("RoleId") + .HasColumnType("TEXT"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("LoginProvider") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Value") + .HasColumnType("TEXT"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("RobotApp.Data.ApplicationRole", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("RobotApp.Data.ApplicationUser", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("AccessFailedCount") + .HasColumnType("INTEGER"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("EmailConfirmed") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnabled") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnd") + .HasColumnType("TEXT"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("PasswordHash") + .HasColumnType("TEXT"); + + b.Property("PhoneNumber") + .HasColumnType("TEXT"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("INTEGER"); + + b.Property("SecurityStamp") + .HasColumnType("TEXT"); + + b.Property("TwoFactorEnabled") + .HasColumnType("INTEGER"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("RobotApp.Data.RobotConfig", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Id"); + + b.Property("ConfigName") + .HasMaxLength(100) + .HasColumnType("nvarchar(64)") + .HasColumnName("ConfigName"); + + b.Property("CreatedAt") + .HasColumnType("datetime2") + .HasColumnName("CreatedAt"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("ntext") + .HasColumnName("Description"); + + b.Property("Height") + .HasColumnType("float") + .HasColumnName("Height"); + + b.Property("IsActive") + .HasColumnType("bit") + .HasColumnName("IsActive"); + + b.Property("Length") + .HasColumnType("float") + .HasColumnName("Length"); + + b.Property("NavigationType") + .HasColumnType("int") + .HasColumnName("NavigationType"); + + b.Property("RadiusWheel") + .HasColumnType("float") + .HasColumnName("RadiusWheel"); + + b.Property("UpdatedAt") + .HasColumnType("datetime2") + .HasColumnName("UpdatedAt"); + + b.Property("Width") + .HasColumnType("float") + .HasColumnName("Width"); + + b.HasKey("Id"); + + b.ToTable("RobotConfig"); + }); + + modelBuilder.Entity("RobotApp.Data.RobotPlcConfig", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Id"); + + b.Property("ConfigName") + .HasMaxLength(100) + .HasColumnType("nvarchar(64)") + .HasColumnName("ConfigName"); + + b.Property("CreatedAt") + .HasColumnType("datetime2") + .HasColumnName("CreatedAt"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("ntext") + .HasColumnName("Description"); + + b.Property("IsActive") + .HasColumnType("bit") + .HasColumnName("IsActive"); + + b.Property("PLCAddress") + .HasMaxLength(50) + .HasColumnType("nvarchar(64)") + .HasColumnName("PLCAddress"); + + b.Property("PLCPort") + .HasColumnType("int") + .HasColumnName("PLCPort"); + + b.Property("PLCUnitId") + .HasColumnType("tinyint") + .HasColumnName("PLCUnitId"); + + b.Property("UpdatedAt") + .HasColumnType("datetime2") + .HasColumnName("UpdatedAt"); + + b.HasKey("Id"); + + b.ToTable("RobotPlcConfig"); + }); + + modelBuilder.Entity("RobotApp.Data.RobotSafetyConfig", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Id"); + + b.Property("ConfigName") + .HasMaxLength(100) + .HasColumnType("nvarchar(64)") + .HasColumnName("ConfigName"); + + b.Property("CreatedAt") + .HasColumnType("datetime2") + .HasColumnName("CreatedAt"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("ntext") + .HasColumnName("Description"); + + b.Property("IsActive") + .HasColumnType("bit") + .HasColumnName("IsActive"); + + b.Property("SafetySpeedFast") + .HasColumnType("float") + .HasColumnName("SafetySpeedFast"); + + b.Property("SafetySpeedMedium") + .HasColumnType("float") + .HasColumnName("SafetySpeedMedium"); + + b.Property("SafetySpeedNormal") + .HasColumnType("float") + .HasColumnName("SafetySpeedNormal"); + + b.Property("SafetySpeedOptimal") + .HasColumnType("float") + .HasColumnName("SafetySpeedOptimal"); + + b.Property("SafetySpeedSlow") + .HasColumnType("float") + .HasColumnName("SafetySpeedSlow"); + + b.Property("SafetySpeedVeryFast") + .HasColumnType("float") + .HasColumnName("SafetySpeedVeryFast"); + + b.Property("SafetySpeedVerySlow") + .HasColumnType("float") + .HasColumnName("SafetySpeedVerySlow"); + + b.Property("UpdatedAt") + .HasColumnType("datetime2") + .HasColumnName("UpdatedAt"); + + b.HasKey("Id"); + + b.ToTable("RobotSafetyConfig"); + }); + + modelBuilder.Entity("RobotApp.Data.RobotSimulationConfig", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Id"); + + b.Property("ConfigName") + .HasMaxLength(100) + .HasColumnType("nvarchar(64)") + .HasColumnName("ConfigName"); + + b.Property("CreatedAt") + .HasColumnType("datetime2") + .HasColumnName("CreatedAt"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("ntext") + .HasColumnName("Description"); + + b.Property("EnableSimulation") + .HasColumnType("bit") + .HasColumnName("EnableSimulation"); + + b.Property("IsActive") + .HasColumnType("bit") + .HasColumnName("IsActive"); + + b.Property("SimulationAcceleration") + .HasColumnType("float") + .HasColumnName("SimulationAcceleration"); + + b.Property("SimulationDeceleration") + .HasColumnType("float") + .HasColumnName("SimulationDeceleration"); + + b.Property("SimulationMaxAngularVelocity") + .HasColumnType("float") + .HasColumnName("SimulationMaxAngularVelocity"); + + b.Property("SimulationMaxVelocity") + .HasColumnType("float") + .HasColumnName("SimulationMaxVelocity"); + + b.Property("UpdatedAt") + .HasColumnType("datetime2") + .HasColumnName("UpdatedAt"); + + b.HasKey("Id"); + + b.ToTable("RobotSimulationConfig"); + }); + + modelBuilder.Entity("RobotApp.Data.RobotVDA5050Config", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Id"); + + b.Property("ConfigName") + .HasMaxLength(100) + .HasColumnType("nvarchar(64)") + .HasColumnName("ConfigName"); + + b.Property("CreatedAt") + .HasColumnType("datetime2") + .HasColumnName("CreatedAt"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("ntext") + .HasColumnName("Description"); + + b.Property("IsActive") + .HasColumnType("bit") + .HasColumnName("IsActive"); + + b.Property("SerialNumber") + .HasMaxLength(50) + .HasColumnType("nvarchar(64)") + .HasColumnName("SerialNumber"); + + b.Property("UpdatedAt") + .HasColumnType("datetime2") + .HasColumnName("UpdatedAt"); + + b.Property("VDA5050CA") + .HasColumnType("nvarchar(64)") + .HasColumnName("VDA5050_CA"); + + b.Property("VDA5050Cer") + .HasColumnType("nvarchar(64)") + .HasColumnName("VDA5050_Cer"); + + b.Property("VDA5050EnablePassword") + .HasColumnType("bit") + .HasColumnName("VDA5050_EnablePassword"); + + b.Property("VDA5050EnableTls") + .HasColumnType("bit") + .HasColumnName("VDA5050_EnableTls"); + + b.Property("VDA5050HostServer") + .HasMaxLength(100) + .HasColumnType("nvarchar(64)") + .HasColumnName("VDA5050_HostServer"); + + b.Property("VDA5050Key") + .HasColumnType("nvarchar(64)") + .HasColumnName("VDA5050_Key"); + + b.Property("VDA5050Manufacturer") + .HasMaxLength(50) + .HasColumnType("nvarchar(64)") + .HasColumnName("VDA5050_Manufacturer"); + + b.Property("VDA5050Password") + .HasMaxLength(50) + .HasColumnType("nvarchar(64)") + .HasColumnName("VDA5050_Password"); + + b.Property("VDA5050Port") + .HasColumnType("int") + .HasColumnName("VDA5050_Port"); + + b.Property("VDA5050PublishRepeat") + .HasColumnType("int") + .HasColumnName("VDA5050_PublishRepeat"); + + b.Property("VDA5050TopicPrefix") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)") + .HasColumnName("VDA5050_TopicPrefix"); + + b.Property("VDA5050UserName") + .HasMaxLength(50) + .HasColumnType("nvarchar(64)") + .HasColumnName("VDA5050_UserName"); + + b.Property("VDA5050Version") + .HasMaxLength(20) + .HasColumnType("nvarchar(64)") + .HasColumnName("VDA5050_Version"); + + b.HasKey("Id"); + + b.ToTable("RobotVDA5050Config"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("RobotApp.Data.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("RobotApp.Data.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("RobotApp.Data.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("RobotApp.Data.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RobotApp.Data.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("RobotApp.Data.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/RobotApp/Data/Migrations/20251106025457_UpdateVDA5050St.cs b/RobotApp/Data/Migrations/20251106025457_UpdateVDA5050St.cs new file mode 100644 index 0000000..6d8d20b --- /dev/null +++ b/RobotApp/Data/Migrations/20251106025457_UpdateVDA5050St.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace RobotApp.Data.Migrations +{ + /// + public partial class UpdateVDA5050St : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "VDA5050_TopicPrefix", + table: "RobotVDA5050Config", + type: "nvarchar(64)", + maxLength: 64, + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "VDA5050_TopicPrefix", + table: "RobotVDA5050Config"); + } + } +} diff --git a/RobotApp/Data/Migrations/ApplicationDbContextModelSnapshot.cs b/RobotApp/Data/Migrations/ApplicationDbContextModelSnapshot.cs index 39e24f0..7616c0d 100644 --- a/RobotApp/Data/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/RobotApp/Data/Migrations/ApplicationDbContextModelSnapshot.cs @@ -503,6 +503,11 @@ namespace RobotApp.Migrations .HasColumnType("int") .HasColumnName("VDA5050_PublishRepeat"); + b.Property("VDA5050TopicPrefix") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)") + .HasColumnName("VDA5050_TopicPrefix"); + b.Property("VDA5050UserName") .HasMaxLength(50) .HasColumnType("nvarchar(64)") diff --git a/RobotApp/Data/RobotVDA5050Config.cs b/RobotApp/Data/RobotVDA5050Config.cs index 7cf649b..7d58931 100644 --- a/RobotApp/Data/RobotVDA5050Config.cs +++ b/RobotApp/Data/RobotVDA5050Config.cs @@ -42,6 +42,10 @@ public class RobotVDA5050Config [MaxLength(20)] public string VDA5050Version { get; set; } + [Column("VDA5050_TopicPrefix", TypeName = "nvarchar(64)")] + [MaxLength(64)] + public string VDA5050TopicPrefix { get; set; } + [Column("VDA5050_PublishRepeat", TypeName = "int")] public int VDA5050PublishRepeat { get; set; } diff --git a/RobotApp/Program.cs b/RobotApp/Program.cs index a7e797a..9657231 100644 --- a/RobotApp/Program.cs +++ b/RobotApp/Program.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using MudBlazor.Services; +using NLog.Web; using RobotApp.Components; using RobotApp.Components.Account; using RobotApp.Data; @@ -9,6 +10,7 @@ using RobotApp.Services; using RobotApp.Services.Robot.Simulation; var builder = WebApplication.CreateBuilder(args); +builder.Host.UseNLog(); // Add services to the container. builder.Services.AddRazorComponents() diff --git a/RobotApp/RobotApp.csproj b/RobotApp/RobotApp.csproj index e73f004..59b0445 100644 --- a/RobotApp/RobotApp.csproj +++ b/RobotApp/RobotApp.csproj @@ -33,6 +33,8 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/RobotApp/Services/MQTTClient.cs b/RobotApp/Services/MQTTClient.cs index 8671407..2c05b67 100644 --- a/RobotApp/Services/MQTTClient.cs +++ b/RobotApp/Services/MQTTClient.cs @@ -24,6 +24,9 @@ public class MQTTClient : IAsyncDisposable public event Action? InstanceActionsChanged; public bool IsConnected => !IsDisposed && MqttClient is not null && MqttClient.IsConnected; + private string OrderTopic => $"{VDA5050Setting.TopicPrefix}/{ClientId}/{VDA5050Topic.ORDER.ToTopicString()}"; + private string InstanceActionsTopic => $"{VDA5050Setting.TopicPrefix}/{ClientId}/{VDA5050Topic.INSTANTACTIONS.ToTopicString()}"; + public MQTTClient(string clientId, VDA5050Setting setting, Logger logger) { VDA5050Setting = setting; @@ -38,8 +41,8 @@ public class MQTTClient : IAsyncDisposable .WithCleanSession(true) .Build(); MqttClientSubscribeOptions = MqttClientFactory.CreateSubscribeOptionsBuilder() - .WithTopicFilter(f => f.WithTopic(VDA5050Topic.ORDER.ToTopicString())) - .WithTopicFilter(f => f.WithTopic(VDA5050Topic.INSTANTACTIONS.ToTopicString())) + .WithTopicFilter(f => f.WithTopic(OrderTopic)) + .WithTopicFilter(f => f.WithTopic(InstanceActionsTopic)) .Build(); } @@ -238,10 +241,10 @@ public class MQTTClient : IAsyncDisposable if (IsDisposed) return Task.CompletedTask; var stringData = Encoding.UTF8.GetString(args.ApplicationMessage.Payload); - VDA5050Topic topic = EnumExtensions.ToTopic(args.ApplicationMessage.Topic); + //VDA5050Topic topic = EnumExtensions.ToTopic(args.ApplicationMessage.Topic); - if (topic == VDA5050Topic.ORDER) OrderChanged?.Invoke(stringData); - else if (topic == VDA5050Topic.INSTANTACTIONS) InstanceActionsChanged?.Invoke(stringData); + if (args.ApplicationMessage.Topic == OrderTopic) OrderChanged?.Invoke(stringData); + else if (args.ApplicationMessage.Topic == InstanceActionsTopic) InstanceActionsChanged?.Invoke(stringData); } catch (Exception ex) { diff --git a/RobotApp/Services/Robot/RobotBattery.cs b/RobotApp/Services/Robot/RobotBattery.cs index c7c092b..4652d28 100644 --- a/RobotApp/Services/Robot/RobotBattery.cs +++ b/RobotApp/Services/Robot/RobotBattery.cs @@ -6,13 +6,13 @@ public class RobotBattery(RobotConfiguration RobotConfiguration) : IBattery { public bool IsReady { get; private set; } = RobotConfiguration.IsSimulation; - public double Voltage { get; private set; } + public double Voltage { get; private set; } = RobotConfiguration.IsSimulation ? 24 : 0; public double Current { get; private set; } - public double SOC { get; private set; } + public double SOC { get; private set; } = RobotConfiguration.IsSimulation ? 100 : 0; - public double SOH { get; private set; } + public double SOH { get; private set; } = RobotConfiguration.IsSimulation ? 100 : 0; public BatteryStatus Status { get; private set; } @@ -22,7 +22,7 @@ public class RobotBattery(RobotConfiguration RobotConfiguration) : IBattery public double Temperature { get; private set; } - public double RemainingCapacity { get; private set; } + public double RemainingCapacity { get; private set; } public double RemainingEnergy { get; private set; } diff --git a/RobotApp/Services/Robot/RobotConfiguration.cs b/RobotApp/Services/Robot/RobotConfiguration.cs index 8aeb486..ea027c9 100644 --- a/RobotApp/Services/Robot/RobotConfiguration.cs +++ b/RobotApp/Services/Robot/RobotConfiguration.cs @@ -46,6 +46,7 @@ public class RobotConfiguration(IServiceProvider ServiceProvider, Logger(data, JsonOptionExtends.Read); if (msg is null || string.IsNullOrEmpty(msg.SerialNumber) || msg.SerialNumber != RobotConfiguration.SerialNumber) return; OrderUpdated?.Invoke(msg); @@ -36,6 +37,7 @@ public class RobotConnection(RobotConfiguration RobotConfiguration, { try { + Logger.Debug($"Nhận InstanceActions: {data}"); var msg = JsonSerializer.Deserialize(data, JsonOptionExtends.Read); if (msg is null || string.IsNullOrEmpty(msg.SerialNumber) || msg.SerialNumber != RobotConfiguration.SerialNumber) return; ActionUpdated?.Invoke(msg); @@ -48,7 +50,7 @@ public class RobotConnection(RobotConfiguration RobotConfiguration, public async Task Publish(string topic, string data) { - if (MqttClient is not null && MqttClient.IsConnected) return await MqttClient.PublishAsync(topic, data); + if (MqttClient is not null && MqttClient.IsConnected) return await MqttClient.PublishAsync($"{VDA5050Setting.TopicPrefix}/{RobotConfiguration.SerialNumber}/{topic}", data); return new(false, "Chưa có kết nối tới broker"); } diff --git a/RobotApp/Services/Robot/RobotFactsheet.cs b/RobotApp/Services/Robot/RobotFactsheet.cs index 0e4aa44..c5e4eab 100644 --- a/RobotApp/Services/Robot/RobotFactsheet.cs +++ b/RobotApp/Services/Robot/RobotFactsheet.cs @@ -42,6 +42,8 @@ public class RobotFactsheet(RobotConnection RobotConnection, RobotConfiguration FactSheetMsg factSheet = new() { SerialNumber = RobotConfiguration.SerialNumber, + Manufacturer = RobotConfiguration.VDA5050Setting.Manufacturer, + Version = RobotConfiguration.VDA5050Setting.Version, ProtocolFeatures = new() { AgvActions = [..AgvActions.Values], @@ -59,7 +61,7 @@ public class RobotFactsheet(RobotConnection RobotConnection, RobotConfiguration if (RobotConnection.IsConnected) break; await Task.Delay(1000); } - await PubFactsheet(); + //await PubFactsheet(); } public readonly static AgvAction StartPause = new() diff --git a/RobotApp/Services/Robot/RobotOrderController.cs b/RobotApp/Services/Robot/RobotOrderController.cs index 7702f5a..b3adfc3 100644 --- a/RobotApp/Services/Robot/RobotOrderController.cs +++ b/RobotApp/Services/Robot/RobotOrderController.cs @@ -1,12 +1,14 @@ using RobotApp.Common.Shares.Enums; using RobotApp.Interfaces; using RobotApp.Services.Exceptions; +using RobotApp.Services.Robot.Actions; using RobotApp.Services.State; using RobotApp.VDA5050.InstantAction; using RobotApp.VDA5050.Order; using RobotApp.VDA5050.State; using System.Collections.Concurrent; using System.Data; +using System.Threading.Tasks; using Action = RobotApp.VDA5050.InstantAction.Action; namespace RobotApp.Services.Robot; @@ -154,6 +156,8 @@ public class RobotOrderController(INavigation NavigationManager, if (NavigationManager.State != NavigationState.Idle) throw new OrderException(RobotErrors.Error1012(NavigationManager.State)); OrderActions.Clear(); + LastNode = null; + for (int i = 0; i < order.Nodes.Length; i++) { if (order.Nodes[i].Actions is not null && order.Nodes[i].Actions.Length > 0) @@ -184,11 +188,11 @@ public class RobotOrderController(INavigation NavigationManager, if (i < order.Nodes.Length - 1 && order.Edges[i].SequenceId != i) throw new OrderException(RobotErrors.Error1011(order.Edges[i].EdgeId, order.Edges[i].SequenceId, i)); if (order.Nodes[i].Released) CurrentBaseNode = order.Nodes[i]; } - ActionManager.ClearInstantActions(); - SafetyManager.OnSafetySpeedChanged += OnSafetySpeedChanged; + ActionManager.ClearInstantActions(); if (OrderActions.Count > 0) ActionManager.AddOrderActions([.. OrderActions.Values.SelectMany(a => a)]); + NavigationManager.Move(order.Nodes, order.Edges); NavigationManager.OnNavigationFinished += NavigationFinished; OrderId = order.OrderId; @@ -267,7 +271,8 @@ public class RobotOrderController(INavigation NavigationManager, if (ActionHard is not null) { var robotAction = ActionManager[ActionHard.ActionId]; - if (robotAction is null || (robotAction is not null && robotAction.IsCompleted)) + if (robotAction is null) return; + if (robotAction is not null && robotAction.IsCompleted) { NavigationManager.Resume(); ActionHard = null; @@ -282,6 +287,12 @@ public class RobotOrderController(INavigation NavigationManager, { if (ActionWaitingRunning.TryDequeue(out Action? action) && action is not null) { + var robotAction = ActionManager[action.ActionId]; + if (robotAction is null) + { + ActionWaitingRunning.Enqueue(action); + return; + } ActionManager.StartOrderAction(action.ActionId); ActionHard = action.BlockingType == BlockingType.HARD.ToString() ? action : null; } diff --git a/RobotApp/Services/Robot/RobotStates.cs b/RobotApp/Services/Robot/RobotStates.cs index 4b4192e..05017d7 100644 --- a/RobotApp/Services/Robot/RobotStates.cs +++ b/RobotApp/Services/Robot/RobotStates.cs @@ -20,7 +20,7 @@ public class RobotStates(RobotConfiguration RobotConfiguration, ILocalization LocalizationManager, IBattery BatteryManager, ILoad LoadManager, - IDriver DriverManager) : BackgroundService + INavigation NavigationManager) : BackgroundService { private uint HeaderId = 0; @@ -41,6 +41,8 @@ public class RobotStates(RobotConfiguration RobotConfiguration, return new StateMsg { HeaderId = HeaderId++, + Manufacturer = RobotConfiguration.VDA5050Setting.Manufacturer, + Version = RobotConfiguration.VDA5050Setting.Version, SerialNumber = RobotConfiguration.SerialNumber, Maps = [], OrderId = OrderManager.OrderId, @@ -72,16 +74,16 @@ public class RobotStates(RobotConfiguration RobotConfiguration, { Charging = BatteryManager.IsCharging, BatteryHealth = BatteryManager.SOH, - Reach = BatteryManager.RemainingCapacity, + Reach = 0, BatteryVoltage = BatteryManager.Voltage, BatteryCharge = BatteryManager.SOC, }, Loads = LoadManager.Load, Velocity = new() { - Vx = DriverManager.LinearVelocity, - Vy = 0, - Omega = DriverManager.AngularVelocity, + Vx = NavigationManager.VelocityX, + Vy = NavigationManager.VelocityY, + Omega = NavigationManager.Omega, }, SafetyState = new() { diff --git a/RobotApp/Services/Robot/RobotVisualization.cs b/RobotApp/Services/Robot/RobotVisualization.cs index 1f958ac..03f7c31 100644 --- a/RobotApp/Services/Robot/RobotVisualization.cs +++ b/RobotApp/Services/Robot/RobotVisualization.cs @@ -16,6 +16,8 @@ public class RobotVisualization(ILocalization Localization, INavigation Navigati return new VisualizationMsg() { HeaderId = HeaderId++, + Manufacturer = RobotConfiguration.VDA5050Setting.Manufacturer, + Version = RobotConfiguration.VDA5050Setting.Version, SerialNumber = RobotConfiguration.SerialNumber, MapId = Localization.CurrentActiveMap, MapDescription = string.Empty, diff --git a/RobotApp/nlog.config b/RobotApp/nlog.config new file mode 100644 index 0000000..77328fe --- /dev/null +++ b/RobotApp/nlog.config @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/RobotApp/robot.db b/RobotApp/robot.db index 627e3b5e8e44c132cce50ce5c544b07212327e07..b198f6405c22e45af6b6963bfee2cdb42da99b90 100644 GIT binary patch delta 296 zcmZozz}2vTYl5_31p@@F0s@z(6iipUr&`$goEz^1OH9_{rvO!EBS-?wfUL( z9stcb!KbXm?8%7V7>;IU`|Zs3jLeKug$(?Se1G{W`M7!8xmR%)a~|dFV0U2q%1}66 z!GST5tDVJ!UEI)+vDbL}5(ma$W-%QFC8%@aL-GqUlLLxU(=scjCpt3ZN9Ik$|%In&&