Esempio n. 1
0
        public static AdjustPowerLevelCommand Create(double delta)
        {
            var command = new AdjustPowerLevelCommand
            {
                Delta = delta
            };

            return(command);
        }
Esempio n. 2
0
        public override Task RunTask(int taskId)
        {
            Command cmd = null;

            switch (taskId)
            {
            case 0:
                cmd = new TurnOnCommand();
                break;

            case 1:
                cmd = new TurnOffCommand();

                break;

            case 2:
                cmd = new TurnOnCommand();

                ConsoleEx.WriteTitleLine("State Time:");
                var time = ConsoleEx.ReadNumber();
                cmd.SetProperty(MessageProperties.StateTime, time);

                break;

            case 3:
                ConsoleEx.WriteTitleLine("Enter dimmer level [0-100]:");
                var level = ConsoleEx.ReadNumber();
                cmd = new SetPowerLevelCommand();
                ((SetPowerLevelCommand)cmd).PowerLevel = level;
                break;

            case 4:
                ConsoleEx.WriteTitleLine("Adjust Power Level [0-100]:");
                var delta = ConsoleEx.ReadNumber();
                cmd = new AdjustPowerLevelCommand();
                ((AdjustPowerLevelCommand)cmd).Delta = delta;
                break;
            }

            MessageBroker.Send(cmd, Uid);

            return(Task.CompletedTask);
        }
Esempio n. 3
0
        protected async Task Handle(AdjustPowerLevelCommand powerLevel)
        {
            if (!_PowerLevel.HasValue)
            {
                return;
            }

            var destinationLevel = _PowerLevel.Value + powerLevel.Delta;

            if (destinationLevel > 100)
            {
                destinationLevel = 100.0;
            }
            else if (destinationLevel < 0)
            {
                destinationLevel = 0;
            }

            await ControlDimmer(destinationLevel);
        }
Esempio n. 4
0
 protected Task HandleState(AdjustPowerLevelCommand command)
 {
     return(Task.CompletedTask);
 }