public void Regulate(double minTemp, double maxTemp) { while (true) { while (_thermometer.Read() > minTemp) { FakeUtils.Wait(1); } _heater.Engage(); while (_thermometer.Read() < maxTemp) { FakeUtils.Wait(1); } _heater.Disengage(); } }
public Regulate(IThermometer thermometer, IHeater heater, double minTemp, double maxTemp) { Thermometer = thermometer; Heater = heater; MinTemp = minTemp; MaxTemp = maxTemp; for (; ;) { while (Thermometer.Read() > MinTemp) { Wait(); } Heater.Engage(); TemperatureDirection = TemperatureDirection.Rising; while (Thermometer.Read() < MaxTemp) { Wait(); } Heater.Disengage(); TemperatureDirection = TemperatureDirection.Falling; } }