private async Task TurnOffKettle()
        {
            await powerSwitch.SwitchOffAsync();

            await heatingElement.SwitchOffAsync();

            await powerLamp.SwitchOffAsync();
        }
Esempio n. 2
0
        //power switch toggle
        public async Task TogglePowerSwitch(bool?switchMode = null)
        {
            //4. The power switch is a toggle switch
            //   and must be switched off by the controller
            //   in any case where the controller decides to turn off the kettle.
            var switchOn = switchMode ?? !_powerSwitch.IsOn;

            //6.The kettle controller should not attempt to heat if there is no water ...
            if (switchOn && !_powerSwitch.IsOn && _waterSensor.CurrentValue)
            {
                if (!_isComponentsInitialized)
                {
                    InitializeComponents();
                }
                await _powerSwitch.SwitchOnAsync();
            }

            if (!switchOn && _powerSwitch.IsOn)
            {
                await _powerSwitch.SwitchOffAsync();
            }
        }