initial commit

This commit is contained in:
robotics_x1
2026-10-12 15:24:08 +07:00
commit 55228b3772
367 changed files with 162893 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace Lab505.Sim;
/// <summary>
/// Hosted Service để chạy VDA Mock Server ở background
/// </summary>
public class VdaSimulationServer : IHostedService
{
private readonly VdaSimulationHostedService _server;
private readonly ILogger<VdaSimulationServer> _logger;
public VdaSimulationServer(
VdaSimulationHostedService server,
ILogger<VdaSimulationServer> logger)
{
_server = server ?? throw new ArgumentNullException(nameof(server));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
public Task StartAsync(CancellationToken cancellationToken)
{
try
{
_logger.LogInformation("Starting VDA Simulation Hosted Service");
_server.Start();
_logger.LogInformation("VDA Simulation Hosted Service started successfully");
return Task.CompletedTask;
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to start VDA Simulation Hosted Service");
throw;
}
}
public Task StopAsync(CancellationToken cancellationToken)
{
try
{
_logger.LogInformation("Stopping VDA Simulation Hosted Service");
_server.Stop();
_logger.LogInformation("VDA Simulation Hosted Service stopped successfully");
return Task.CompletedTask;
}
catch (Exception ex)
{
_logger.LogError(ex, "Error stopping VDA Simulation Hosted Service");
return Task.CompletedTask;
}
}
}