using System.Drawing; using GSS2.Core.Analysis.AmineContent.Database; using GSS2.Core.Hardware; namespace GSS2.Test; public class Worker( ILogger logger, IHostApplicationLifetime applicationLifetime, AmineContentCalibrationContext amineCalibrationContext, AmineContentResultsContext amineResultsContext, LightsService lightsService, IlluminatorService illuminatorService, CameraService cameraService ) : BackgroundService { private readonly ILogger _logger = logger; private readonly IHostApplicationLifetime _applicationLifetime = applicationLifetime; private readonly AmineContentCalibrationContext _amineCalibrationContext = amineCalibrationContext; private readonly AmineContentResultsContext _amineResultsContext = amineResultsContext; private readonly LightsService _lightsService = lightsService; private readonly IlluminatorService _illuminatorService = illuminatorService; private readonly CameraService _cameraService = cameraService; protected override async Task ExecuteAsync(CancellationToken cancellationToken) { await _cameraService.InitializeAsync(cancellationToken); _ = _lightsService.Run(cancellationToken); _ = _lightsService.SnowfallAsync(0.3, 1, Color.Aqua, cancellationToken); _illuminatorService.SetIntensity(0.5, 0, 0); _illuminatorService.TurnOn(); await Task.Delay(1000); var img = await _cameraService.CaptureImage(cancellationToken); img?.SaveImage("IMAGE.png"); await Task.Delay(1000); _illuminatorService.TurnOff(); await _lightsService.DisconnectAsync(cancellationToken); applicationLifetime.StopApplication(); } }