forked from amkovkov/GranuSightSoftware2
31 lines
1.1 KiB
C#
31 lines
1.1 KiB
C#
using System.Drawing;
|
|
using GSS2.Core.Analysis.AmineContent.Database;
|
|
using GSS2.Core.Hardware;
|
|
|
|
namespace GSS2.Test;
|
|
|
|
public class Worker(
|
|
ILogger<Worker> logger,
|
|
AmineContentCalibrationContext calibrationContext,
|
|
LightsService lightsService,
|
|
TemperatureHumidityService temperatureHumidity
|
|
) : BackgroundService
|
|
{
|
|
private readonly ILogger<Worker> _logger = logger;
|
|
private readonly AmineContentCalibrationContext _calibrationContext = calibrationContext;
|
|
private readonly LightsService _lightsService = lightsService;
|
|
private readonly TemperatureHumidityService _temperatureHumidity = temperatureHumidity;
|
|
|
|
protected override async Task ExecuteAsync(CancellationToken cancellationToken)
|
|
{
|
|
_ = _lightsService.Run(cancellationToken);
|
|
await _lightsService.SnowfallAsync(0.3, 1, Color.Aqua, cancellationToken);
|
|
while (!cancellationToken.IsCancellationRequested)
|
|
{
|
|
var (temperature, humidity) = await _temperatureHumidity.MeasureAsync();
|
|
_logger.LogInformation("Temperature: {}, RelativeHumidity: {}", temperature, humidity);
|
|
await Task.Delay(5000);
|
|
}
|
|
}
|
|
}
|