Esempio n. 1
0
        public void SetPower(BinarySwitchPower power)
        {
            var binaryState = TranslatePowerToBinaryState(power);

            _client.SetBinaryState(new SetBinaryState
            {
                BinaryState = binaryState
            });
        }
Esempio n. 2
0
        public void SetPower(BinarySwitchPower power)
        {
            var binaryState = TranslatePowerToBinaryState(power);

            _client.SetBinaryState(new SetBinaryState
            {
                BinaryState = binaryState
            });
        }
Esempio n. 3
0
        public void SetPower(BinarySwitchPower power)
        {
            switch (power)
            {
            case BinarySwitchPower.On:
                _device.DoCommand("PowerOn");
                break;

            case BinarySwitchPower.Off:
                _device.DoCommand("PowerOff");
                break;
            }
        }
Esempio n. 4
0
        public void SetPower(BinarySwitchPower power)
        {
            switch (power)
            {
                case BinarySwitchPower.On:
                    _device.DoDeviceOperation(_device.BackingObject.PowerOn);
                    break;

                case BinarySwitchPower.Off:
                    _device.DoDeviceOperation(_device.BackingObject.PowerOff);
                    break;
            }
        }
Esempio n. 5
0
        public void SetPower(BinarySwitchPower power)
        {
            switch (power)
            {
            case BinarySwitchPower.On:
                _dataEntry.SetValue(true);
                break;

            case BinarySwitchPower.Off:
                _dataEntry.SetValue(false);
                break;
            }
        }
Esempio n. 6
0
        public void SetPower(BinarySwitchPower power)
        {
            switch (power)
            {
                case BinarySwitchPower.On:
                    _dataEntry.SetValue(true);
                    break;

                case BinarySwitchPower.Off:
                    _dataEntry.SetValue(false);
                    break;
            }
        }
Esempio n. 7
0
        public void SetPower(BinarySwitchPower power)
        {
            switch (power)
            {
            case BinarySwitchPower.On:
                _device.DoDeviceOperation(_device.BackingObject.PowerOn);
                break;

            case BinarySwitchPower.Off:
                _device.DoDeviceOperation(_device.BackingObject.PowerOff);
                break;
            }
        }
Esempio n. 8
0
        public void SetPower(BinarySwitchPower power)
        {
            switch (power)
            {
                case BinarySwitchPower.On:
                    _device.DoCommand("PowerOn");
                    break;

                case BinarySwitchPower.Off:
                    _device.DoCommand("PowerOff");
                    break;
            }
        }
Esempio n. 9
0
        private static string TranslatePowerToBinaryState(BinarySwitchPower power)
        {
            switch (power)
            {
                case BinarySwitchPower.Off:
                    return "0";

                case BinarySwitchPower.On:
                    return "1";

                default:
                    throw new ArgumentException("invalid BinarySwitchPower value \"" + power + "\"", "power");
            }
        }
Esempio n. 10
0
        private static string TranslatePowerToBinaryState(BinarySwitchPower power)
        {
            switch (power)
            {
            case BinarySwitchPower.Off:
                return("0");

            case BinarySwitchPower.On:
                return("1");

            default:
                throw new ArgumentException("invalid BinarySwitchPower value \"" + power + "\"", "power");
            }
        }
Esempio n. 11
0
        public string Generate(BinarySwitchPower? power, IPower value)
        {
            if (power != BinarySwitchPower.On || value == null)
            {
                return null;
            }

            foreach (var step in _steps)
            {
                //TODO: add comparison to IPower interface
                if (value.Value <= step.Item1.Value)
                {
                    return step.Item2;
                }
            }

            return null;
        }
Esempio n. 12
0
        public void Works(string steps, BinarySwitchPower? binaryPower, double wattsPower, string expected)
        {
            var generator = new CurrentStateGenerator();

            if (!string.IsNullOrEmpty(steps))
            {
                foreach (var step in steps.Split(';').Select(x => x.Split(',')))
                {
                    var stepValue = double.Parse(step[0]);
                    var stepName = step[1];
                    generator.AddStep(new WattsPower(stepValue), stepName);
                }
            }

            var actual = generator.Generate(binaryPower, new WattsPower(wattsPower));

            Assert.That(actual, Is.EqualTo(expected));
        }
Esempio n. 13
0
        public static LightCommand CreateCommand(BinarySwitchPower power)
        {
            var result = new LightCommand();

            switch (power)
            {
            case BinarySwitchPower.On:
                result.On         = true;
                result.Brightness = byte.MaxValue;
                break;

            case BinarySwitchPower.Off:
                result.On         = false;
                result.Brightness = byte.MinValue;
                break;

            default:
                throw new Exception();
            }

            return(result);
        }
Esempio n. 14
0
        public static LightCommand CreateCommand(BinarySwitchPower power)
        {
            var result = new LightCommand();

            switch (power)
            {
                case BinarySwitchPower.On:
                    result.On = true;
                    result.Brightness = byte.MaxValue;
                    break;

                case BinarySwitchPower.Off:
                    result.On = false;
                    result.Brightness = byte.MinValue;
                    break;

                default:
                    throw new Exception();
            }

            return result;
        }
Esempio n. 15
0
        public void SetPower(BinarySwitchPower power)
        {
            var command = Helpers.CreateCommand(power);

            _light.SendCommand(command);
        }
 public ReadOnlyBinarySwitchSwitchState(BinarySwitchPower? power)
 {
     Power = power;
 }
Esempio n. 17
0
        public void SetPower(BinarySwitchPower power)
        {
            var command = Helpers.CreateCommand(power);

            _light.SendCommand(command);
        }