コード例 #1
0
        private async Task ProcessTempUpdateAsync(double targetTemp)
        {
            logger.LogWarning($"Ajusting temp from {CurrentTemperature} to {targetTemp}");
            // gradually increase current temp to target temp
            double step = (targetTemp - CurrentTemperature) / 10d;

            for (int i = 9; i >= 0; i--)
            {
                CurrentTemperature = targetTemp - step * (double)i;
                await tempSensor.SendTemperatureTelemetryValueAsync(CurrentTemperature);

                await tempSensor.ReportCurrentTemperatureAsync(CurrentTemperature);

                await Task.Delay(1000);
            }
            logger.LogWarning($"Adjustment complete");
        }