示例#1
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                Ds18b20Dto ds18b20Dto = new(_sensorService.GetSensorData());
                _logger.LogInformation($"Interior Temperature: {ds18b20Dto.Celsius}C");
                await _temperatureReadingService.AddReadingAsync(ds18b20Dto);

                await Task.Delay(TimeSpan.FromMinutes(5), stoppingToken);
            }
        }
示例#2
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                NwsLatestObservationDto observationDto = await _nwsClient.GetLatestWeatherObservationAsync();

                _logger.LogInformation($"Exterior Temperature: {observationDto.Properties.Temperature.Value}C");
                await _temperatureReadingService.AddReadingAsync(observationDto);

                await Task.Delay(TimeSpan.FromMinutes(30), stoppingToken);
            }
        }