Exemplo n.º 1
0
 protected Device(Network network, DeviceType type = null)
 {
     Network               = network;
     Location              = new Location();
     Type                  = type ?? DeviceType.Unknown;
     Name                  = null;
     IsConnected           = null;
     CurrentStateGenerator = new CurrentStateGenerator();
 }
Exemplo n.º 2
0
        public void UpdateCurrentAction()
        {
            var newCurrentAction = CurrentStateGenerator.Generate(BinarySwitch.Power, PowerSensor.Value);

            if (newCurrentAction != CurrentAction)
            {
                CurrentAction = newCurrentAction;

                var @event = DeviceEvent.CurrentActionChanged(this, null);
                AddEvent(@event);
            }
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
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));
        }