Initial commit

This commit is contained in:
2026-07-03 16:31:37 +07:00
commit 899c7c637d
1939 changed files with 641750 additions and 0 deletions

View File

@@ -0,0 +1,87 @@
using System.Text.Json.Serialization;
using Microsoft.AspNetCore.SignalR;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using RobotNet10.NavigationTune.Data;
using RobotNet10.NavigationTune.Execution;
using RobotNet10.NavigationTune.Interfaces;
using RobotNet10.NavigationTune.Services;
using RobotNet10.NavigationTune.Shared.Interfaces;
namespace RobotNet10.NavigationTune.Extensions;
/// <summary>
/// Extension methods for service registration
/// </summary>
public static class ServiceCollectionExtensions
{
/// <summary>
/// Add Navigation Tuning services
/// </summary>
public static IServiceCollection AddNavigationTuning(
this IServiceCollection services,
Action<DbContextOptionsBuilder> dbContextOptions)
{
services.AddDbContext<TuningDbContext>(dbContextOptions);
// Repositories
services.AddScoped<ITestRepository, TestRepository>();
services.AddScoped<IScenarioRepository, ScenarioRepository>();
// Services
services.AddScoped<IParameterManager, ParameterManager>();
services.AddScoped<IMetricsCalculator, MetricsCalculator>();
services.AddScoped<ITuningAdvisor, TuningAdvisor>();
// Execution
services.AddScoped<ITestExecutor, TestExecutor>();
services.AddScoped<ITuningNavigation, TuningNavigation>();
// Singleton: so Stop/EMC Stop (different HTTP request) can cancel the running test
services.AddSingleton<IRunningTestCancellationRegistry, RunningTestCancellationRegistry>();
// Orchestrator
services.AddScoped<ITuningOrchestrator, TuningOrchestrator>();
// SignalR Hub: allow NaN/Infinity in JSON so telemetry/metrics with non-finite floats do not abort the connection
services.AddSignalR()
.AddJsonProtocol(options =>
{
options.PayloadSerializerOptions.NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals;
});
return services;
}
/// <summary>
/// Add Navigation Tuning with real robot dependencies
/// </summary>
public static IServiceCollection AddNavigationTuningWithRobot(
this IServiceCollection services,
Action<DbContextOptionsBuilder> dbContextOptions)
{
// Add base services
services.AddNavigationTuning(dbContextOptions);
// Note: Adapters for real robot should be registered in the application layer
// that has access to RobotApp.Interfaces.ILocalization and IVelocityController
// Example:
// services.AddScoped<ILocalizationProvider>(sp =>
// {
// var localization = sp.GetRequiredService<RobotNet10.RobotApp.Interfaces.ILocalization>();
// return new LocalizationAdapter(
// () => localization.X,
// () => localization.Y,
// () => localization.Theta
// );
// });
return services;
}
/// <summary>
/// Map SignalR hubs
/// Note: This should be called in the application's Program.cs or Startup.cs
/// Example: app.MapHub<TuningHub>("/tuninghub");
/// </summary>
}