Example #1
0
        public async Task <IActionResult> GetSecondaryDataAsync()
        {
            var temperatureSensor   = new TemperatureSensor(_temperatureStorage);
            var pressureSensor      = new PressureSensor(_pressureStorage);
            var humiditySensor      = new HumiditySensor(_humidityStorage);
            var windDirectionSensor = new WindDirectionSensor(_windStorage);
            var windSpeedSensor     = new WindSpeedSensor(_windStorage);
            var windChill           = new WindChill(temperatureSensor, windSpeedSensor);
            var dewPoint            = new DewPoint(temperatureSensor, humiditySensor);
            var timeSpan            = new TimeSpan(3, 0, 0);

            var result = new SecondaryDataDTO()
            {
                WindChill              = (int)windChill.CalculateWindChill(),
                DewPoint               = (int)dewPoint.CalculateDewPoint(),
                MaximalTemperature     = (int)temperatureSensor.HighValue().Value,
                MinimalTemperature     = (int)temperatureSensor.LowValue().Value,
                MaximalHumidity        = (int)humiditySensor.HighValue().Value,
                MinimalHumidity        = (int)humiditySensor.LowValue().Value,
                MinimalPressure        = (int)pressureSensor.LowValue().Value,
                MaximalPressure        = (int)pressureSensor.HighValue().Value,
                MinimalTemperatureTime = temperatureSensor.TimeOfLowValue().TimeOfDay.Add(timeSpan).ToString().Substring(0, 5),
                MaximalTemperatureTime = temperatureSensor.TimeOfHighValue().TimeOfDay.Add(timeSpan).ToString().Substring(0, 5),
                MinimalHumidityTime    = humiditySensor.TimeOfLowValue().TimeOfDay.Add(timeSpan).ToString().Substring(0, 5),
                MaximalHumidityTime    = humiditySensor.TimeOfHighValue().TimeOfDay.Add(timeSpan).ToString().Substring(0, 5),
                MinimalPressureTime    = pressureSensor.TimeOfLowValue().TimeOfDay.Add(timeSpan).ToString().Substring(0, 5),
                MaximalPressureTime    = pressureSensor.TimeOfHighValue().TimeOfDay.Add(timeSpan).ToString().Substring(0, 5),
            };

            return(Ok(result));
        }