private async Task TurnOnKettle()
        {
            await powerSwitch.SwitchOnAsync();

            await heatingElement.SwitchOnAsync();

            await powerLamp.SwitchOnAsync();
        }
示例#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();
            }
        }