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,38 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace Lab505.Sim;
public class OpcUaHostedService : IHostedService
{
private readonly OpcUaSimulationServer _server;
private readonly ILogger<OpcUaHostedService> _logger;
public OpcUaHostedService(
OpcUaSimulationServer server,
ILogger<OpcUaHostedService> logger)
{
_server = server;
_logger = logger;
}
public async Task StartAsync(CancellationToken cancellationToken)
{
_logger.LogInformation("Starting OPC UA Simulation Server on port 4840");
try
{
await _server.StartAsync();
_logger.LogInformation("OPC UA Simulation Server started on port 4840");
}
catch (Exception ex)
{
_logger.LogWarning("OPC UA Simulation Server failed to start (port 4840 may already be in use): {Message}", ex.Message);
}
}
public async Task StopAsync(CancellationToken cancellationToken)
{
_logger.LogInformation("Stopping OPC UA Simulation Server");
await _server.StopAsync();
}
}