| | 1 | | namespace WebApi.Services; |
| | 2 | |
|
| | 3 | | public class IOTControlService : IIOTControlService |
| | 4 | | { |
| | 5 | |
|
| | 6 | | public bool ShouldWindowOpen(double currentTemperature, double desiredTemperature, double currentHumidity, double de |
| 4 | 7 | | { |
| 4 | 8 | | bool shouldOpenForTemperature = currentTemperature > desiredTemperature; |
| 4 | 9 | | bool shouldOpenForHumidity = currentHumidity > desiredHumidity; |
| 4 | 10 | | bool shouldOpenForCo2 = currentCo2 > desiredCo2; |
| | 11 | |
|
| | 12 | | // Open the window if any of the conditions are met |
| 4 | 13 | | return shouldOpenForTemperature || shouldOpenForHumidity || shouldOpenForCo2; |
| 4 | 14 | | } |
| | 15 | |
|
| | 16 | | public bool AreDesiredValuesReached(double currentTemp, double desiredTemp, double currentHumidity, double desiredHu |
| 2 | 17 | | { |
| 2 | 18 | | bool temperatureReached = currentTemp <= desiredTemp; |
| 2 | 19 | | bool humidityReached = currentHumidity <= desiredHumidity; |
| 2 | 20 | | bool co2Reached = currentCo2 <= desiredCo2; |
| | 21 | |
|
| | 22 | | // All desired values need to be reached |
| 2 | 23 | | return temperatureReached && humidityReached && co2Reached; |
| 2 | 24 | | } |
| | 25 | | } |