forked from amkovkov/GranuSightSoftware2
feat: command line arguments parsing
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
using System.CommandLine;
|
||||
|
||||
using GSS2.Core;
|
||||
using GSS2.Core.Hardware;
|
||||
using GSS2.Core.Logging;
|
||||
|
||||
using Microsoft.Extensions.Logging.Console;
|
||||
|
||||
using ConsoleFormatter = GSS2.Core.Logging.ConsoleFormatter;
|
||||
|
||||
namespace GSS2.Test;
|
||||
|
||||
public partial class Program
|
||||
{
|
||||
private class CameraTuningWorker : BackgroundService
|
||||
{
|
||||
private readonly ILogger<CameraTuningWorker> _logger;
|
||||
private readonly IHostApplicationBuilder _applicationLifetime;
|
||||
private readonly CameraService _cameraService;
|
||||
private readonly IlluminatorService _illuminatorService;
|
||||
|
||||
public CameraTuningWorker(ILogger<CameraTuningWorker> logger, IHostApplicationBuilder applicationLifetime, CameraService cameraService, IlluminatorService illuminatorService)
|
||||
{
|
||||
_applicationLifetime = applicationLifetime;
|
||||
_logger = logger;
|
||||
_cameraService = cameraService;
|
||||
_illuminatorService = illuminatorService;
|
||||
_logger.LogInformation("Initialized");
|
||||
}
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
_logger.LogInformation("Running camera fine tuning");
|
||||
}
|
||||
}
|
||||
private static void CameraTuning(ParseResult parseResult)
|
||||
{
|
||||
var builder = Host.CreateApplicationBuilder();
|
||||
|
||||
builder.Logging.ClearProviders();
|
||||
builder.Logging.AddConsole(options => options.FormatterName = nameof(ConsoleFormatter));
|
||||
builder.Logging.AddConsoleFormatter<ConsoleFormatter, ConsoleFormatterOptions>();
|
||||
builder.Logging.AddProvider(new FileLoggerProvider("full.log", true));
|
||||
builder.Logging.AddProvider(new FileLoggerProvider("last_run.log", false));
|
||||
builder.Services.AddSingleton<LibCameraLogSink>();
|
||||
|
||||
builder.Services.AddIlluminatorService("Hardware:Illuminator");
|
||||
builder.Services.AddCameraService("Hardware:Camera", true);
|
||||
|
||||
builder.Services.AddHostedService<CameraTuningWorker>();
|
||||
|
||||
var host = builder.Build();
|
||||
host.Services.GetRequiredService<LibCameraLogSink>();
|
||||
|
||||
host.Run();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user